전투 엔진 버그 3차 수정
This commit is contained in:
+10
-5
@@ -37,15 +37,20 @@ function processWar(array $rawAttacker, array $rawDefenderCity){
|
||||
|
||||
$city = new WarUnitCity($rawDefenderCity, $rawAttackerNation, $year, $month, $cityRate);
|
||||
|
||||
$defenderList = $db->query('SELECT no,name,turntime,personal,special2,crew,crewtype,atmos,train,intel,intel2,book,power,power2,weap,injury,leader,leader2,horse,item,explevel,level,rice,dex0,dex10,dex20,dex30,dex40,warnum,killnum,deathnum,killcrew,deathcrew,recwar FROM general WHERE city=%i AND nation=%i AND nation!=0 and crew > 0 and rice>(crew/100) and ((train>=60 and atmos>=60 and mode=1) or (train>=80 and atmos>=80 and mode=2))', $city->getVar('nation'), $city->getVar('city'));
|
||||
$defenderList = $db->query('SELECT no,name,nation,turntime,personal,special2,crew,crewtype,atmos,train,intel,intel2,book,power,power2,weap,injury,leader,leader2,horse,item,explevel,level,rice,dex0,dex10,dex20,dex30,dex40,warnum,killnum,deathnum,killcrew,deathcrew,recwar FROM general WHERE nation=%i AND city=%i AND nation!=0 and crew > 0 and rice>(crew/100) and ((train>=60 and atmos>=60 and mode=1) or (train>=80 and atmos>=80 and mode=2))', $city->getVar('nation'), $city->getVar('city'));
|
||||
|
||||
if(!$defenderList){
|
||||
$defenderList = [];
|
||||
}
|
||||
|
||||
usort($defenderList, function($lhs, $rhs){
|
||||
return -(extractBattleOrder($lhs) <=> extractBattleOrder($rhs));
|
||||
});
|
||||
|
||||
$iterDefender = new \ArrayIterator($defenderList);
|
||||
$iterDefender->rewind();
|
||||
|
||||
$getNextDefender = function(?WarUnit $prevDefender, bool $reqNext) use ($iterDefender, $db) {
|
||||
$getNextDefender = function(?WarUnit $prevDefender, bool $reqNext) use ($iterDefender, $rawDefenderCity, $rawDefenderNation, $year, $month, $db) {
|
||||
if($prevDefender !== null){
|
||||
$prevDefender->applyDB($db);
|
||||
}
|
||||
@@ -58,7 +63,7 @@ function processWar(array $rawAttacker, array $rawDefenderCity){
|
||||
return null;
|
||||
}
|
||||
|
||||
$retVal = $iterDefender->current();
|
||||
$retVal = new WarUnitGeneral($iterDefender->current(), $rawDefenderCity, $rawDefenderNation, false, $year, $month);
|
||||
$iterDefender->next();
|
||||
return $retVal;
|
||||
};
|
||||
@@ -278,8 +283,8 @@ function processWar_NG(
|
||||
$defenderHP = $defender->getHP();
|
||||
|
||||
if($deadAttacker > $attackerHP || $deadDefender > $defenderHP){
|
||||
$deadAttackerRatio = $deadAttacker / $attackerHP;
|
||||
$deadDefenderRatio = $deadDefender / $defenderHP;
|
||||
$deadAttackerRatio = $deadAttacker / max(1, $attackerHP);
|
||||
$deadDefenderRatio = $deadDefender / max(1, $defenderHP);
|
||||
|
||||
if($deadDefenderRatio > $deadAttackerRatio){
|
||||
//수비자가 더 병력 부족
|
||||
|
||||
@@ -257,14 +257,14 @@ class ActionLogger{
|
||||
'crewtype' => $me->getCrewTypeShortName(),
|
||||
'name' => $me->getName(),
|
||||
'remain_crew' => $me->getHP(),
|
||||
'killed_crew' => $me->getDead()
|
||||
'killed_crew' => -$me->getDeadCurrentBattle()
|
||||
];
|
||||
|
||||
$render_oppose = [
|
||||
'crewtype' => $oppose->getCrewTypeShortName(),
|
||||
'name' => $oppose->getName(),
|
||||
'remain_crew' => $oppose->getHP(),
|
||||
'killed_crew' => $oppose->getDead()
|
||||
'killed_crew' => -$oppose->getDeadCurrentBattle()
|
||||
];
|
||||
|
||||
if(!$me->isAttacker()){
|
||||
|
||||
@@ -8,7 +8,9 @@ class WarUnit{
|
||||
protected $logger;
|
||||
protected $crewType;
|
||||
|
||||
protected $killedCurr = 0;
|
||||
protected $killed = 0;
|
||||
protected $deadCurr = 0;
|
||||
protected $dead = 0;
|
||||
|
||||
protected $isAttacker = false;
|
||||
@@ -145,6 +147,14 @@ class WarUnit{
|
||||
return $this->dead;
|
||||
}
|
||||
|
||||
function getKilledCurrentBattle():int{
|
||||
return $this->killedCurr;
|
||||
}
|
||||
|
||||
function getDeadCurrentBattle():int{
|
||||
return $this->deadCurr;
|
||||
}
|
||||
|
||||
function getSpecialDomestic():int{
|
||||
return 0;
|
||||
}
|
||||
@@ -171,6 +181,8 @@ class WarUnit{
|
||||
|
||||
function setOppose(?WarUnit $oppose){
|
||||
$this->oppose = $oppose;
|
||||
$this->killedCurr = 0;
|
||||
$this->deadCurr = 0;
|
||||
$this->activatedSkill = [];
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ class WarUnitCity extends WarUnit{
|
||||
|
||||
function increaseKilled(int $damage):int{
|
||||
$this->killed += $damage;
|
||||
$this->killedCurr += $damage;
|
||||
return $this->killed;
|
||||
}
|
||||
|
||||
@@ -61,6 +62,7 @@ class WarUnitCity extends WarUnit{
|
||||
function decreaseHP(int $damage):int{
|
||||
$damage = min($damage, $this->hp);
|
||||
$this->dead += $damage;
|
||||
$this->deadCurr += $damage;
|
||||
$this->hp -= $damage;
|
||||
$this->increaseVarWithLimit('wall', -$damage/20, 0);
|
||||
|
||||
@@ -89,7 +91,7 @@ class WarUnitCity extends WarUnit{
|
||||
return;
|
||||
}
|
||||
$this->isFinished = true;
|
||||
|
||||
|
||||
$this->updateVar('def', Util::round($this->getHP() / 10));
|
||||
$this->updateVar('wall', Util::round($this->getVar('wall')));
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
}
|
||||
|
||||
function setOppose(?WarUnit $oppose){
|
||||
$this->oppose = $oppose;
|
||||
parent::setOppose($oppose);
|
||||
$this->increaseVar('warnum', 1);
|
||||
|
||||
if($this->isAttacker){
|
||||
@@ -67,8 +67,6 @@ class WarUnitGeneral extends WarUnit{
|
||||
else if($oppose !== null){
|
||||
$this->updateVar('recwar', $oppose->getVar('turntime'));
|
||||
}
|
||||
|
||||
$this->activatedSkill = [];
|
||||
}
|
||||
|
||||
function getSpecialWar():int{
|
||||
@@ -361,7 +359,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
if (
|
||||
$specialWar == 70 &&
|
||||
$this->oppose instanceof WarUnitGeneral &&
|
||||
!$this->hasActivateSkill('저격') &&
|
||||
!$this->hasActivatedSkill('저격') &&
|
||||
Util::randBool(1/3)
|
||||
) {
|
||||
$this->activateSkill('저격');
|
||||
@@ -386,7 +384,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
if(
|
||||
$item == 2 &&
|
||||
$this->oppose instanceof WarUnitGeneral &&
|
||||
!$this->hasActivateSkill('저격') &&
|
||||
!$this->hasActivatedSkill('저격') &&
|
||||
Util::randBool(1/5)
|
||||
){
|
||||
$itemActivated = true;
|
||||
@@ -455,6 +453,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
$damage = min($damage, $this->getVar('crew'));
|
||||
|
||||
$this->dead += $damage;
|
||||
$this->deadCurr += $damage;
|
||||
$this->increaseVar('crew', -$damage);
|
||||
|
||||
$addDex = $damage;
|
||||
@@ -487,6 +486,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
$this->addDex($this->getCrewType(), $addDex);
|
||||
|
||||
$this->killed += $damage;
|
||||
$this->killedCurr += $damage;
|
||||
return $this->killed;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user