전투 코드 반영

This commit is contained in:
2018-08-18 21:24:02 +09:00
parent 1f8fe35e25
commit 2a5af15aef
3 changed files with 44 additions and 11 deletions
+12 -2
View File
@@ -145,7 +145,12 @@ function processWar_NG(
$josaYi = JosaUtil::pick($attacker->getCrewTypeName(), '이'); $josaYi = JosaUtil::pick($attacker->getCrewTypeName(), '이');
$logger->pushGlobalActionLog("<Y>{$attacker->getName()}</>의 {$attacker->getCrewTypeName()}{$josaYi} 퇴각했습니다."); $logger->pushGlobalActionLog("<Y>{$attacker->getName()}</>의 {$attacker->getCrewTypeName()}{$josaYi} 퇴각했습니다.");
$attacker->getLogger()->pushGeneralActionLog("퇴각했습니다.", ActionLogger::PLAIN); if($noRice){
$attacker->getLogger()->pushGeneralActionLog("군량 부족으로 퇴각합니다.", ActionLogger::PLAIN);
}
else{
$attacker->getLogger()->pushGeneralActionLog("퇴각했습니다.", ActionLogger::PLAIN);
}
$defender->getLogger()->pushGeneralActionLog("<Y>{$attacker->getName()}</>의 {$attacker->getCrewTypeName()}{$josaYi} 퇴각했습니다.", ActionLogger::PLAIN); $defender->getLogger()->pushGeneralActionLog("<Y>{$attacker->getName()}</>의 {$attacker->getCrewTypeName()}{$josaYi} 퇴각했습니다.", ActionLogger::PLAIN);
break; break;
@@ -167,7 +172,12 @@ function processWar_NG(
$josaYi = JosaUtil::pick($defender->getCrewTypeName(), '이'); $josaYi = JosaUtil::pick($defender->getCrewTypeName(), '이');
$logger->pushGlobalActionLog("<Y>{$defender->getName()}</>의 {$defender->getCrewTypeName()}{$josaYi} 퇴각했습니다."); $logger->pushGlobalActionLog("<Y>{$defender->getName()}</>의 {$defender->getCrewTypeName()}{$josaYi} 퇴각했습니다.");
$attacker->getLogger()->pushGeneralActionLog("<Y>{$defender->getName()}</>의 {$defender->getCrewTypeName()}{$josaYi} 퇴각했습니다.", ActionLogger::PLAIN); $attacker->getLogger()->pushGeneralActionLog("<Y>{$defender->getName()}</>의 {$defender->getCrewTypeName()}{$josaYi} 퇴각했습니다.", ActionLogger::PLAIN);
$defender->getLogger()->pushGeneralActionLog("퇴각했습니다.", ActionLogger::PLAIN); if($noRice){
$defender->getLogger()->pushGeneralActionLog("군량 부족으로 퇴각합니다.", ActionLogger::PLAIN);
}
else{
$defender->getLogger()->pushGeneralActionLog("퇴각했습니다.", ActionLogger::PLAIN);
}
$defender->finishBattle(); $defender->finishBattle();
$defender = ($getNextDefender)($defender, true); $defender = ($getNextDefender)($defender, true);
+3 -5
View File
@@ -44,8 +44,6 @@ class WarUnitCity extends WarUnit{
$warPower *= Util::randRange(0.9, 1.1); $warPower *= Util::randRange(0.9, 1.1);
} }
function increaseKilled(int $damage):int{ function increaseKilled(int $damage):int{
$this->killed += $damage; $this->killed += $damage;
return $this->killed; return $this->killed;
@@ -59,7 +57,8 @@ class WarUnitCity extends WarUnit{
$damage = min($damage, $this->hp); $damage = min($damage, $this->hp);
$this->dead += $damage; $this->dead += $damage;
$this->hp -= $damage; $this->hp -= $damage;
$this->trainAtmos -= $damage / 2; $this->trainAtmos = max(0, $this->trainAtmos - $damage / 2);
return $this->hp;
} }
function continueWar(&$noRice):bool{ function continueWar(&$noRice):bool{
@@ -79,8 +78,7 @@ class WarUnitCity extends WarUnit{
$this->raw['wall'] = Util::round($this->trainAtmos / 10); $this->raw['wall'] = Util::round($this->trainAtmos / 10);
$this->updatedVar['wall'] = true; $this->updatedVar['wall'] = true;
$this->raw['dead'] += $this->dead; //NOTE: 전투로 인한 사망자는 여기서 처리하지 않음
$this->updatedVar['dead'] = true;
$decWealth = $this->dead / 10; $decWealth = $this->dead / 10;
$this->raw['agri'] = max(0, Util::round($this->raw['agri'] - $decWealth)); $this->raw['agri'] = max(0, Util::round($this->raw['agri'] - $decWealth));
+29 -4
View File
@@ -137,7 +137,6 @@ class WarUnitGeneral extends WarUnit{
$this->updatedVar['deathnum'] = true; $this->updatedVar['deathnum'] = true;
$this->addStatExp(1); $this->addStatExp(1);
//TODO: 1패 로그 추가
} }
@@ -324,13 +323,39 @@ class WarUnitGeneral extends WarUnit{
return $this->raw['crew']; return $this->raw['crew'];
} }
function addDex(GameUnitDetail $crewType, float $exp){
$armType = $crewType->armType;
if($armType == GameUnitConst::T_CASTLE){
$armType = GameUnitConst::T_SIEGE;
}
if($armType < 0){
return;
}
if($armType == GameUnitConst::T_WIZARD) {
$exp *= 0.9;
}
else if($armType == GameUnitConst::T_SIEGE) {
$exp *= 0.9;
}
$exp *= ($this->getComputedTrain() + $this->getComputeAtmos()) / 200;
$ntype = $armType*10;
$dexType = "dex{$ntype}";
$this->raw[$dexType] += $exp;
$this->updatedVar[$dexType] = true;
}
function decreaseHP(int $damage):int{ function decreaseHP(int $damage):int{
$damage = min($damage, $this->raw['crew']); $damage = min($damage, $this->raw['crew']);
$this->dead += $damage; $this->dead += $damage;
$this->raw['crew'] -= $damage; $this->raw['crew'] -= $damage;
//TODO: 죽은 만큼 숙련도 변경
return $this->raw['crew']; return $this->raw['crew'];
} }
@@ -367,7 +392,7 @@ class WarUnitGeneral extends WarUnit{
return false; return false;
} }
$wound = max(80, $this->raw['injury'] + rand(10, 80)); $wound = min(80, $this->raw['injury'] + Util::randRangeInt(10, 80));
if($wound < $this->raw['injury']){ if($wound < $this->raw['injury']){
return false; return false;
} }
@@ -384,7 +409,7 @@ class WarUnitGeneral extends WarUnit{
$noRice = false; $noRice = false;
return false; return false;
} }
if($this->raw['rice'] <= 0){ if($this->raw['rice'] <= $this->getHP() / 100){
$noRice = true; $noRice = true;
return false; return false;
} }