전투 구현 반영

This commit is contained in:
2018-08-20 03:14:56 +09:00
parent 1e01f2a749
commit ae8ccfe3a1
4 changed files with 204 additions and 22 deletions
+7 -7
View File
@@ -18,8 +18,6 @@ function processWar_NG(
$attackerNationUpdate = []; $attackerNationUpdate = [];
$defenderNationUpdate = []; $defenderNationUpdate = [];
$maxPhase = $attacker->getMaxPhase();
$defender = ($getNextDefender)(null, true); $defender = ($getNextDefender)(null, true);
$conquerCity = false; $conquerCity = false;
@@ -31,7 +29,7 @@ function processWar_NG(
$battleBegin = false; $battleBegin = false;
for($currPhase = 0; $currPhase < $maxPhase; $currPhase+=1){ for($currPhase = 0; $currPhase < $attacker->getMaxPhase(); $currPhase+=1){
$battleBegin = true; $battleBegin = true;
if($defender === null){ if($defender === null){
$defender = $city; $defender = $city;
@@ -103,8 +101,12 @@ function processWar_NG(
$defender->checkPostActiveSkill(); $defender->checkPostActiveSkill();
//NOTE: 반계류 등의 스킬을 post에서 반영 //NOTE: 반계류 등의 스킬을 post에서 반영
$attacker->applyActiveSkill(); $activeSkillIterator = new AppendIterator();
$defender->applyActiveSkill(); $activeSkillIterator->append($attacker->applyActiveSkill());
$activeSkillIterator->append($defender->applyActiveSkill());
foreach($activeSkillIterator as $b){
//doNothing
}
$deadDefender = $attacker->calcDamage(); $deadDefender = $attacker->calcDamage();
$deadAttacker = $defender->calcDamage(); $deadAttacker = $defender->calcDamage();
@@ -120,13 +122,11 @@ function processWar_NG(
//수비자가 더 병력 부족 //수비자가 더 병력 부족
$deadAttacker /= $deadDefenderRatio; $deadAttacker /= $deadDefenderRatio;
$deadDefender = $defenderHP; $deadDefender = $defenderHP;
break;
} }
else{ else{
//공격자가 더 병력 부족 //공격자가 더 병력 부족
$deadDefender /= $deadAttackerRatio; $deadDefender /= $deadAttackerRatio;
$deadAttacker = $attackerHP; $deadAttacker = $attackerHP;
break;
} }
} }
+5 -2
View File
@@ -193,6 +193,10 @@ class WarUnit{
$this->warPowerMultiply = $multiply; $this->warPowerMultiply = $multiply;
} }
function multiplyWarPowerMultiply($multiply){
$this->warPowerMultiply *= $multiply;
}
function computeWarPower(){ function computeWarPower(){
$oppose = $this->oppose; $oppose = $this->oppose;
@@ -334,8 +338,7 @@ class WarUnit{
return false; return false;
} }
function applyActiveSkill():bool{ function applyActiveSkill(){
return false;
} }
function getHP():int{ function getHP():int{
+186 -13
View File
@@ -4,6 +4,8 @@ namespace sammo;
class WarUnitGeneral extends WarUnit{ class WarUnitGeneral extends WarUnit{
protected $rawCity; protected $rawCity;
protected $bonusPhase = 0;
function __construct($raw, $rawCity, $rawNation, $isAttacker, $year, $month){ function __construct($raw, $rawCity, $rawNation, $isAttacker, $year, $month){
setLeadershipBonus($raw, $rawNation['level']); setLeadershipBonus($raw, $rawNation['level']);
@@ -81,7 +83,7 @@ class WarUnitGeneral extends WarUnit{
if($this->getSpecialWar() == 60){ if($this->getSpecialWar() == 60){
$phase += 1; $phase += 1;
} }
return $phase; return $phase + $bonusPhase;
} }
function addTrain(int $train){ function addTrain(int $train){
@@ -509,7 +511,7 @@ class WarUnitGeneral extends WarUnit{
!$this->hasActivatedSkill('특수') && !$this->hasActivatedSkill('특수') &&
Util::randBool($this->getComputedCriticalRatio()) Util::randBool($this->getComputedCriticalRatio())
){ ){
$this->activateSkill('특수', '필살'); $this->activateSkill('특수', '필살시도', '필살');
$activated = true; $activated = true;
} }
@@ -593,12 +595,27 @@ class WarUnitGeneral extends WarUnit{
if( if(
$specialWar == 74 && $specialWar == 74 &&
$oppose->hasActivatedSkill('회피') && $oppose->hasActivatedSkill('회피')
Util::randBool(0.5)
){ ){
$oppose->deactivateSkill('회피'); if($this->isAttacker){
$this->activateSkill('격노'); if(Util::randBool(1/3)){
$activated = true; $this->activateSkill('진노', '격노');
$oppose->deactivateSkill('회피');
$activated = true;
}
else if(Util::randBool(1/4)){
$this->activateSkill('격노');
$oppose->deactivateSkill('회피');
$activated = true;
}
}
else{
if(Util::randBool(1/2)){
$this->activateSkill('격노');
$oppose->deactivateSkill('회피');
$activated = true;
}
}
} }
if( if(
@@ -632,22 +649,178 @@ class WarUnitGeneral extends WarUnit{
$activated = true; $activated = true;
} }
if(
$specialWar == 42 &&
$this->hasActivatedSkill('계략')
){
$this->warPowerMultiply *= 1.3;
}
if(
$specialWar == 43 &&
$this->hasActivatedSkill('계략')
){
$this->warPowerMultiply *= 1.5;
}
return $activated; return $activated;
} }
function applyActiveSkill():bool{ function applyActiveSkill(){
$oppose = $this->getOppose(); $oppose = $this->getOppose();
$crewType = $this->getCrewType();
$specialWar = $this->getSpecialWar();
$thisLogger = $this->getLogger();
$opposeLogger = $oppose->getLogger();
if($this->hasActivatedSkill('저지')){ if($this->hasActivatedSkill('저지')){
$this->setWarPowerMultiply(0); $this->setWarPowerMultiply(0);
$oppose->setWarPowerMultiply(0); $oppose->setWarPowerMultiply(0);
$this->getLogger()->pushGeneralBattleDetailLog('상대를 <C>저지</>했다!</>'); $thisLogger->pushGeneralBattleDetailLog('상대를 <C>저지</>했다!</>');
$oppose->getLogger()->pushGeneralBattleDetailLog('저지</>당했다!</>'); $opposeLogger->pushGeneralBattleDetailLog('저지</>당했다!</>');
//저지는 특수함. //저지는 특수함.
return true; return;
} }
return false; yield true;
//계략 세트
if($this->hasActivatedSkill('계략')){
$table = [
'위보'=>1.2,
'매복'=>1.4,
'반목'=>1.6,
'화계'=>1.8,
'혼란'=>2.0
];
if($specialWar == 45){
$table['반목'] *= 2;
}
foreach($table as $skillKey => $skillMultiply){
if($this->hasActivatedSkill($skillKey)){
$josaUl = \sammo\JosaUtil::pick($skillKey, '을');
$thisLogger->pushGeneralBattleDetailLog("<D>{$skillKey}</>{$josaUl} <C>성공</>했다!");
$opposeLogger->pushGeneralBattleDetailLog("<D>{$skillKey}</>에 당했다!");
$this->multiplyWarPowerMultiply($skillMultiply);
break;
}
}
}
yield true;
//반계 세트
if($this->hasActivatedSkill('반계')){
$table = [
'위보'=>1.2,
'매복'=>1.4,
'반목'=>1.6,
'화계'=>1.8,
'혼란'=>2.0
];
foreach($table as $skillKey => $skillMultiply){
if($oppose->hasActivatedSkill($skillKey)){
$josaUl = \sammo\JosaUtil::pick($skillKey, '을');
$thisLogger->pushGeneralBattleDetailLog("<C>●</><C>반계</>로 상대의 <D>{$skillKey}</>{$josaUl} 되돌렸다!");
$opposeLogger->pushGeneralBattleDetailLog("<D>{$skillKey}</>{$josaUl} <R>역으로</> 당했다!");
$this->multiplyWarPowerMultiply($skillMultiply);
break;
}
}
}
yield true;
//계략 실패 세트
if($this->hasActivatedSkill('계략실패')){
$table = [
'위보'=>1.1,
'매복'=>1.2,
'반목'=>1.3,
'화계'=>1.4,
'혼란'=>1.5
];
foreach($table as $skillKey => $skillMultiply){
if($this->hasActivatedSkill($skillKey)){
$josaUl = \sammo\JosaUtil::pick($skillKey, '을');
$thisLogger->pushGeneralBattleDetailLog("<D>{$skillKey}</>{$josaUl} <C>실패</>했다!");
$opposeLogger->pushGeneralBattleDetailLog("<D>{$skillKey}</>{$josaUl} 간파했다!");
$this->multiplyWarPowerMultiply($skillMultiply);
$oppose->multiplyWarPowerMultiply(1/$skillMultiply);
break;
}
}
}
yield true;
if($this->hasActivatedSkill('치료')){
$thisLogger->pushGeneralBattleDetailLog("<C>치료</>했다!</>");
$oppose->multiplyWarPowerMultiply(1/1.5);
}
yield true;
if($this->hasActivatedSkill('필살')){
$thisLogger->pushGeneralBattleDetailLog('<C>필살</>공격!</>');
$opposeLogger->pushGeneralBattleDetailLog('상대의 <R>필살</>공격!</>');
$this->multiplyWarPowerMultiply($this->criticalDamage());
}
yield true;
if($this->hasActivatedSkill('회피')){
$thisLogger->pushGeneralBattleDetailLog('회피</>했다!</>');
$opposeLogger->pushGeneralBattleDetailLog('상대가 <R>회피</>했다!</>"');
$this->multiplyWarPowerMultiply(0.2);
}
yield true;
if($this->hasActivatedSkill('진노')){
if($oppose->hasActivatedSkill('필살')){
$thisLogger->pushGeneralBattleDetailLog('상대의 필살 공격에 <C>진노</>했다!</>');
$opposeLogger->pushGeneralBattleDetailLog('필살 공격에 상대가 <R>진노</>했다!</>');
}
else if($oppose->hasActivatedSkill('회피시도')){
$thisLogger->pushGeneralBattleDetailLog('상대의 회피 시도에 <C>진노</>했다!</>');
$opposeLogger->pushGeneralBattleDetailLog('회피 시도에 상대가 <R>진노</>했다!</>');
}
$this->bonusPhase += 1;
$this->multiplyWarPowerMultiply($this->criticalDamage());
}
else if($this->hasActivatedSkill('격노')){
if($oppose->hasActivatedSkill('필살')){
$thisLogger->pushGeneralBattleDetailLog('상대의 필살 공격에 <C>격노</>했다!</>');
$opposeLogger->pushGeneralBattleDetailLog('필살 공격에 상대가 <R>격노</>했다!</>');
}
else if($oppose->hasActivatedSkill('회피시도')){
$thisLogger->pushGeneralBattleDetailLog('상대의 회피 시도에 <C>격노</>했다!</>');
$opposeLogger->pushGeneralBattleDetailLog('회피 시도에 상대가 <R>격노</>했다!</>');
}
$this->multiplyWarPowerMultiply($this->criticalDamage());
}
yield true;
if($this->hasActivatedSkill('위압')){
$thisLogger->pushGeneralBattleDetailLog('상대에게 <C>위압</>을 줬다!</>');
$opposeLogger->pushGeneralBattleDetailLog('상대에게 <R>위압</>받았다!</>');
$oppose->setWarPowerMultiply(0);
}
yield true;
} }
function tryWound():bool{ function tryWound():bool{
+6
View File
@@ -0,0 +1,6 @@
<?php
namespace sammo;
class MustNotBeReachedException extends \LogicException
{}