전투 구현 반영
This commit is contained in:
+20
-52
@@ -35,7 +35,8 @@ function processWar_NG(
|
||||
$defender = $city;
|
||||
|
||||
if($city->getRawNation()['rice'] <= 0 && $city->getRaw()['supply'] == 1){
|
||||
$attacker->setOppose(null);
|
||||
$attacker->setOppose($defender);
|
||||
$defender->setOppose($attacker);
|
||||
$attacker->addTrain(1);
|
||||
$attacker->addWin();
|
||||
$conquerCity = true;
|
||||
@@ -80,21 +81,25 @@ function processWar_NG(
|
||||
$defender->applyBattleBeginSkillAndItem();
|
||||
}
|
||||
|
||||
$attacker->computeWarPower();
|
||||
$defender->computeWarPower();
|
||||
$attacker->beginPhase();
|
||||
$defender->beginPhase();
|
||||
|
||||
$attacker->checkPreActiveSkill();
|
||||
$defender->checkPreActiveSkill();
|
||||
|
||||
$attacker->checkActiveSkill();
|
||||
$defender->checkActiveSkill();
|
||||
//NOTE: 마법은 checkActiveSkill, checkPostActiveSkill 내에서 반영
|
||||
|
||||
$attacker->checkPostActiveSkill();
|
||||
$defender->checkPostActiveSkill();
|
||||
//NOTE: 반계류 등의 스킬을 post에서 반영
|
||||
|
||||
$attacker->applyActiveSkill();
|
||||
$defender->applyActiveSkill();
|
||||
|
||||
$deadDefender = $attacker->tryAttackInPhase();
|
||||
$deadAttacker = $defender->tryAttackInPhase();
|
||||
//NOTE: 마법은 tryAttackInPhase 내에서 반영
|
||||
$deadDefender = $attacker->calcDamage();
|
||||
$deadAttacker = $defender->calcDamage();
|
||||
|
||||
$attackerHP = $attacker->getHP();
|
||||
$defenderHP = $defender->getHP();
|
||||
@@ -189,10 +194,18 @@ function processWar_NG(
|
||||
|
||||
}
|
||||
|
||||
//TODO: 전투 종료
|
||||
$attacker->finishBattle();
|
||||
$defender->finishBattle();
|
||||
|
||||
if($defender instanceof WarUnitCity){
|
||||
$newConflict = $defender->addConflict();
|
||||
if($newConflict){
|
||||
$nationName = $attacker->getRawNation()['name'];
|
||||
$josaYi = JosaUtil::pick($nationName, '이');
|
||||
$logger->pushGlobalHistoryLog("<M><b>【분쟁】</b></><D><b>{$nationName}</b></>{$josaYi} <G><b>{$defender->getName()}</b></> 공략에 가담하여 분쟁이 발생하고 있습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
($getNextDefender)($defender, false);
|
||||
//NOTE: 공격자의 applyDB는 함수 호출자가 실행
|
||||
|
||||
@@ -204,51 +217,6 @@ function processWar_NG(
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// 표준 공 / 수 반환 수치는 약 0이 되게 (100~550)
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
function addConflict($city, $nationID, $mykillnum) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
$nationlist = [];
|
||||
$killnum = [0];
|
||||
|
||||
list($year, $month) = $gameStor->getValuesAsArray(['year', 'month']);
|
||||
|
||||
$conflict = Json::decode($city['conflict']);
|
||||
|
||||
if(!$conflict || $city['def'] == 0){ // 선타, 막타 보너스
|
||||
$mykillnum *= 1.05;
|
||||
}
|
||||
|
||||
if (!$conflict) {
|
||||
$conflict[$nationID] = $mykillnum;
|
||||
}
|
||||
else if(key_exists($nationID, $conflict)){
|
||||
$conflict[$nationID] += $mykillnum;
|
||||
arsort($conflict);
|
||||
}
|
||||
else{
|
||||
$conflict[$nationID] = $mykillnum;
|
||||
arsort($conflict);
|
||||
|
||||
$nation = getNationStaticInfo($nationID);
|
||||
$josaYi = JosaUtil::pick($nation['name'], '이');
|
||||
pushWorldHistory(["<C>●</>{$year}년 {$month}월:<M><b>【분쟁】</b></><D><b>{$nation['name']}</b></>{$josaYi} <G><b>{$city['name']}</b></> 공략에 가담하여 분쟁이 발생하고 있습니다."]);
|
||||
}
|
||||
|
||||
$rawConflict = Json::encode($conflict);
|
||||
$city['conflict'] = $rawConflict;
|
||||
|
||||
$db->update('city', [
|
||||
'conflict'=>$rawConflict
|
||||
], 'city=%i',$city['city']);
|
||||
|
||||
return $city;
|
||||
}
|
||||
|
||||
function DeleteConflict($nation) {
|
||||
$db = DB::db();
|
||||
|
||||
|
||||
+43
-6
@@ -24,6 +24,8 @@ class WarUnit{
|
||||
protected $warPower;
|
||||
protected $warPowerMultiply = 1.0;
|
||||
|
||||
protected $activatedSkill = [];
|
||||
|
||||
private function __construct(){
|
||||
}
|
||||
|
||||
@@ -99,6 +101,10 @@ class WarUnit{
|
||||
$this->oppose = $oppose;
|
||||
}
|
||||
|
||||
function getOppose():?WarUnit{
|
||||
return $this->oppose;
|
||||
}
|
||||
|
||||
function getWarPower(){
|
||||
return $this->warPower * $this->warPowerMultiply;
|
||||
}
|
||||
@@ -124,9 +130,11 @@ class WarUnit{
|
||||
$warPower = GameConst::$armperphase + $myAtt - $opDef;
|
||||
$opposeWarPowerMultiply = 1.0;
|
||||
|
||||
if($warPower <= 0){
|
||||
//FIXME: 0으로 잡을때 90~100이면, 1은 너무 억울하지 않나?
|
||||
$warPower = rand(90, 100);
|
||||
if($warPower < 100){
|
||||
//최소 전투력 50 보장
|
||||
$warPower = max(0, $warPower);
|
||||
$warPower = ($warPower + 100) / 2;
|
||||
$warPower = rand($warPower, 100);
|
||||
}
|
||||
|
||||
$warPower *= CharAtmos(
|
||||
@@ -139,8 +147,20 @@ class WarUnit{
|
||||
$oppose->getCharacter()
|
||||
);
|
||||
|
||||
$genDexAtt = getGenDex($this->getRaw(), $this->getCrewType()->id);
|
||||
$oppDexDef = getGenDex($oppose->getRaw(), $this->getCrewType()->id);
|
||||
if($this instanceof WarUnitGeneral){
|
||||
$genDexAtt = getGenDex($this->getRaw(), $this->getCrewType()->id);
|
||||
}
|
||||
else{
|
||||
$genDexAtt = ($this->cityRate - 60) * 7200;
|
||||
}
|
||||
|
||||
if($this instanceof WarUnitGeneral){
|
||||
$oppDexDef = getGenDex($oppose->getRaw(), $this->getCrewType()->id);
|
||||
}
|
||||
else{
|
||||
$oppDexDef = ($this->cityRate - 60) * 7200;
|
||||
}
|
||||
|
||||
$warPower *= getDexLog($genDexAtt, $oppDexDef);
|
||||
|
||||
$warPower *= $this->getCrewType()->getAttackCoef($oppose->getCrewType());
|
||||
@@ -189,6 +209,11 @@ class WarUnit{
|
||||
return false;
|
||||
}
|
||||
|
||||
function beginPhase():void{
|
||||
$this->activatedSkill = [];
|
||||
$this->computeWarPower();
|
||||
}
|
||||
|
||||
function checkBattleBeginSkill():bool{
|
||||
return false;
|
||||
}
|
||||
@@ -201,6 +226,18 @@ class WarUnit{
|
||||
return false;
|
||||
}
|
||||
|
||||
function hasActivatedSkill(string $skillName):bool{
|
||||
return $this->activatedSkill[$skillName] ?? false;
|
||||
}
|
||||
|
||||
function deactivateSkill(string $skillName):bool{
|
||||
$this->activatedSkill[$skillName] = false;
|
||||
}
|
||||
|
||||
function checkPreActiveSkill():bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkActiveSkill():bool{
|
||||
return false;
|
||||
}
|
||||
@@ -227,7 +264,7 @@ class WarUnit{
|
||||
throw new NotInheritedMethodException();
|
||||
}
|
||||
|
||||
function tryAttackInPhase():int{
|
||||
function calcDamage():int{
|
||||
return $this->getWarPower();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,22 @@ class WarUnitCity extends WarUnit{
|
||||
protected $trainAtmos;
|
||||
|
||||
protected $rice = 0;
|
||||
public $cityRate;
|
||||
|
||||
protected $updatedVar = [];
|
||||
|
||||
function __construct($raw, $rawNation, $year, $month){
|
||||
protected $year;
|
||||
protected $month;
|
||||
|
||||
function __construct($raw, $rawNation, $year, $month, $cityRate){
|
||||
$this->raw = $raw;
|
||||
$this->rawNation = $rawNation;
|
||||
|
||||
$this->year = $year;
|
||||
$this->month = $month;
|
||||
|
||||
$this->isAttacker = false;
|
||||
$this->cityRate = $cityRate;
|
||||
|
||||
$this->logger = new ActionLogger(0, $raw['nation'], $year, $month);
|
||||
$this->crewType = GameUnitConst::byID($raw['crewtype']);
|
||||
@@ -39,7 +47,7 @@ class WarUnitCity extends WarUnit{
|
||||
return $this->raw['name'];
|
||||
}
|
||||
|
||||
function tryAttackInPhase():int{
|
||||
function calcDamage():int{
|
||||
$warPower = $this->getWarPower();
|
||||
$warPower *= Util::randRange(0.9, 1.1);
|
||||
}
|
||||
@@ -89,6 +97,37 @@ class WarUnitCity extends WarUnit{
|
||||
$this->updatedVar['secu'] = true;
|
||||
}
|
||||
|
||||
function addConflict():bool{
|
||||
$conflict = Json::decode($this->raw['conflict']);
|
||||
$opposeNation = $this->getOppose()->getRawNation();
|
||||
|
||||
$nationID = $opposeNation['nation'];
|
||||
$newConflict = false;
|
||||
|
||||
$dead = $this->dead;
|
||||
|
||||
if(!$conflict || $this->getHP() == 0){ // 선타, 막타 보너스
|
||||
$dead *= 1.05;
|
||||
}
|
||||
|
||||
if(!$conflict){
|
||||
$conflict = [$nationID => $dead];
|
||||
}
|
||||
else if(key_exists($nationID, $conflict)){
|
||||
$conflict[$nationID] += $dead;
|
||||
arsort($conflict);
|
||||
}
|
||||
else{
|
||||
$conflict[$nationID] = $dead;
|
||||
arsort($conflict);
|
||||
$newConflict = true;
|
||||
}
|
||||
|
||||
$this->raw['conflict'] = Json::encode($conflict);
|
||||
$this->updatedVar['conflict'] = true;
|
||||
|
||||
return $newConflict;
|
||||
}
|
||||
|
||||
|
||||
function applyDB($db):bool{
|
||||
|
||||
@@ -355,7 +355,11 @@ class WarUnitGeneral extends WarUnit{
|
||||
$this->dead += $damage;
|
||||
$this->raw['crew'] -= $damage;
|
||||
|
||||
|
||||
$addDex = $damage;
|
||||
if(!$this->isAttacker){
|
||||
$addDex *= 0.9;
|
||||
}
|
||||
$this->addDex($this->oppose->getCrewType(), $addDex);
|
||||
|
||||
return $this->raw['crew'];
|
||||
}
|
||||
@@ -375,14 +379,18 @@ class WarUnitGeneral extends WarUnit{
|
||||
$rice = min($this->raw['rice'], $rice);
|
||||
$this->raw['rice'] -= $rice;
|
||||
$this->updatedVar['rice'] = true;
|
||||
//TODO: 죽인 만큼 숙련도 변경
|
||||
//TODO: 죽인 만큼 쌀 소모
|
||||
|
||||
$addDex = $damage;
|
||||
if(!$this->isAttacker){
|
||||
$addDex *= 0.9;
|
||||
}
|
||||
$this->addDex($this->oppose->getCrewType(), $addDex);
|
||||
|
||||
$this->killed += $damage;
|
||||
return $this->killed;
|
||||
}
|
||||
|
||||
function tryAttackInPhase():int{
|
||||
function calcDamage():int{
|
||||
//TODO
|
||||
return 0;
|
||||
}
|
||||
@@ -416,9 +424,45 @@ class WarUnitGeneral extends WarUnit{
|
||||
return true;
|
||||
}
|
||||
|
||||
function finishBattle(){
|
||||
//TODO: 전투 종료 처리. 경험치 등
|
||||
///checkAbility의 method 버전
|
||||
function checkStatChange():bool{
|
||||
//FIXME: 장기적으로는 General 클래스가 별도로 있어야 함
|
||||
$logger = $this->getLogger();
|
||||
$limit = GameConst::$upgradeLimit;
|
||||
|
||||
$table = [
|
||||
['통솔', 'leader'],
|
||||
['무력', 'power'],
|
||||
['지력', 'intel'],
|
||||
];
|
||||
|
||||
$result = false;
|
||||
|
||||
foreach($table as [$statNickName, $statName]){
|
||||
$statExpName = $statName.'2';
|
||||
|
||||
if($this->raw[$statExpName] < 0){
|
||||
$logger->pushGeneralActionLog("<R>{$statNickName}</>이 <C>1</> 떨어졌습니다!", ActionLogger::PLAIN);
|
||||
$this->raw[$statExpName] += $limit;
|
||||
$this->updatedVar[$statExpName] = true;
|
||||
$this->raw[$statName] -= 1;
|
||||
$this->updatedVar[$statName] = true;
|
||||
$result = true;
|
||||
}
|
||||
else if($this->raw[$statExpName] >= $limit){
|
||||
$logger->pushGeneralActionLog("<R>{$statNickName}</>이 <C>1</> 올랐습니다!", ActionLogger::PLAIN);
|
||||
$this->raw[$statExpName] -= $limit;
|
||||
$this->updatedVar[$statExpName] = true;
|
||||
$this->raw[$statName] += 1;
|
||||
$this->updatedVar[$statName] = true;
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function finishBattle(){
|
||||
if($this->isAttacker){
|
||||
$this->raw['recwar'] = $this->raw['turntime'];
|
||||
}
|
||||
@@ -436,6 +480,8 @@ class WarUnitGeneral extends WarUnit{
|
||||
Util::setRound($this->raw['rice']);
|
||||
Util::setRound($this->raw['experience']);
|
||||
Util::setRound($this->raw['dedication']);
|
||||
|
||||
$this->checkStatChange();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user