버그 수정, 구조 변경

This commit is contained in:
2019-04-28 03:49:03 +09:00
parent ab47f40ee1
commit 99e6a2676b
52 changed files with 140 additions and 165 deletions
+4 -1
View File
@@ -24,5 +24,8 @@
"/nya":true,
"/pya":true,
"/twe":true,
},
},
"cSpell.words": [
"sammo"
],
}
+2 -6
View File
@@ -2,16 +2,12 @@
namespace sammo;
function processWar(array $rawAttacker, array $rawDefenderCity){
function processWar(General $attacker, array $rawNation, array $rawDefenderCity){
$db = DB::db();
$rawAttackerCity = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $rawAttacker['city']);
$attackerNationID = $rawAttacker['nation'];
$defenderNationID = $rawDefenderCity['nation'];
$rawAttackerNation = $db->queryFirstRow('SELECT nation,`level`,`name`,capital,gennum,tech,`type`,gold,rice FROM nation WHERE nation = %i', $attackerNationID);
if($defenderNationID == 0){
$rawDefenderNation = [
'nation'=>0,
@@ -32,7 +28,7 @@ function processWar(array $rawAttacker, array $rawDefenderCity){
$gameStor = KVStorage::getStorage($db, 'game_env');
[$startYear, $year, $month, $cityRate, $joinMode] = $gameStor->getValuesAsArray(['startyear', 'year', 'month', 'city_rate', 'join_mode']);
$attacker = new WarUnitGeneral($rawAttacker, $rawAttackerCity, $rawAttackerNation, true, $year, $month);
$attacker = new WarUnitGeneral($attacker, $rawNation, true, $year, $month);
$city = new WarUnitCity($rawDefenderCity, $rawDefenderNation, $year, $month, $cityRate);
+1 -1
View File
@@ -10,7 +10,7 @@ class che_대의 implements iAction{
static $name = '대의';
static $info = '명성 +10%, 훈련 -5';
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName == 'experience'){
return $value * 1.1;
}
+1 -1
View File
@@ -20,7 +20,7 @@ class che_안전 implements iAction{
return $value;
}
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName == 'bonusAtmos'){
return $value - 5;
}
+1 -1
View File
@@ -10,7 +10,7 @@ class che_왕좌 implements iAction{
static $name = '왕좌';
static $info = '명성 +10%, 사기 -5';
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName == 'experience'){
return $value * 1.1;
}
+1 -1
View File
@@ -20,7 +20,7 @@ class che_유지 implements iAction{
return $value;
}
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName == 'bonusTrain'){
return $value - 5;
}
+1 -1
View File
@@ -20,7 +20,7 @@ class che_은둔 implements iAction{
return $value;
}
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName == 'bonusAtmos'){
return $value - 5;
}
+1 -1
View File
@@ -20,7 +20,7 @@ class che_의협 implements iAction{
return $value;
}
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName == 'bonusAtmos'){
return $value + 5;
}
+1 -1
View File
@@ -20,7 +20,7 @@ class che_재간 implements iAction{
return $value;
}
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName == 'experience'){
return $value * 0.9;
}
+1 -1
View File
@@ -10,7 +10,7 @@ class che_정복 implements iAction{
static $name = '정복';
static $info = '명성 -10%, 사기 +5';
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName == 'experience'){
return $value * 0.9;
}
+1 -1
View File
@@ -20,7 +20,7 @@ class che_출세 implements iAction{
return $value;
}
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName == 'experience'){
return $value * 1.1;
}
+1 -1
View File
@@ -20,7 +20,7 @@ class che_패권 implements iAction{
return $value;
}
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName == 'bonusTrain'){
return $value + 5;
}
+1 -1
View File
@@ -10,7 +10,7 @@ class che_할거 implements iAction{
static $name = '할거';
static $info = '명성 -10%, 훈련 +5';
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName == 'experience'){
return $value * 0.9;
}
@@ -17,4 +17,11 @@ class che_돌격 implements iAction{
SpecialityConst::STAT_LEADERSHIP,
SpecialityConst::STAT_POWER
];
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName === 'initWarPhase'){
return $value += 1;
}
return $value;
}
}
@@ -17,4 +17,11 @@ class che_무쌍 implements iAction{
SpecialityConst::STAT_LEADERSHIP,
SpecialityConst::STAT_POWER
];
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName === 'warCriticalRatio' && $aux['isAttacker']??false){
return $value += 0.1;
}
return $value;
}
}
@@ -18,4 +18,11 @@ class che_필살 implements iAction{
SpecialityConst::STAT_POWER,
SpecialityConst::STAT_INTEL
];
public function onCalcStat(General $general, string $statName, $value, $aux=null){
if($statName === 'warCriticalRatio'){
return $value += 0.2;
}
return $value;
}
}
+1 -1
View File
@@ -104,7 +104,7 @@ class che_강행 extends Command\GeneralCommand{
$exp = 100;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$exp = $general->onCalcStat($general, 'experience', $exp);
$general->setVar('city', $destCityID);
if($general->getVar('level') == 12 && $this->nation['level'] == 0){
+2 -2
View File
@@ -157,8 +157,8 @@ class che_거병 extends Command\GeneralCommand{
$exp = 100;
$ded = 100;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$general->increaseVar('experience', $exp);
$general->increaseVar('dedication', $ded);
+2 -2
View File
@@ -143,8 +143,8 @@ class che_건국 extends Command\GeneralCommand{
$exp = 1000;
$ded = 1000;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$general->increaseVar('experience', $exp);
$general->increaseVar('dedication', $ded);
+1 -1
View File
@@ -107,7 +107,7 @@ class che_견문 extends Command\GeneralCommand{
$logger->pushGeneralActionLog("{$text} <1>$date</>");
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$exp = $general->onCalcStat($general, 'experience', $exp);
$general->increaseVar('experience', $exp);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
@@ -157,8 +157,8 @@ class che_군량매매 extends Command\GeneralCommand{
$exp = 30;
$ded = 50;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$incStat = Util::choiceRandomUsingWeight([
'leader2'=>$general->getLeadership(false, false, false, false),
+2 -2
View File
@@ -84,8 +84,8 @@ class che_귀환 extends Command\GeneralCommand{
$exp = 70;
$ded = 100;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$general->setVar('city', $cityID);
@@ -106,8 +106,8 @@ class che_기술연구 extends che_상업투자{
}
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
if(TechLimit($this->env['startyear'], $this->env['year'], $this->nation['tech'])){
$score /= 4;
+1 -1
View File
@@ -96,7 +96,7 @@ class che_단련 extends Command\GeneralCommand{
}
$exp = $general->getVar('crew') / 400;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$exp = $general->onCalcStat($general, 'experience', $exp);
$general->addDex($general->getCrewTypeObj(), $score, false);
+2 -2
View File
@@ -130,8 +130,8 @@ class che_등용 extends Command\GeneralCommand{
$exp = 100;
$ded = 200;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
[$reqGold, $reqRice] = $this->getCost();
@@ -236,7 +236,7 @@ class che_랜덤임관 extends Command\GeneralCommand{
$exp = 100;
}
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$exp = $general->onCalcStat($general, 'experience', $exp);
$general->setVar('nation', $destNationID);
$general->setVar('level', 1);
$general->setVar('belong', 1);
@@ -103,8 +103,8 @@ class che_물자조달 extends Command\GeneralCommand{
$exp = $score * 0.7 / 3;
$ded = $score * 1.0 / 3;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$incStat = Util::choiceRandomUsingWeight([
'leader2'=>$general->getLeadership(false, false, false, false),
@@ -83,8 +83,8 @@ class che_사기진작 extends Command\GeneralCommand{
$exp = 100;
$ded = 70;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$general->increaseVarWithLimit('atmos', $score, 0, GameConst::$maxAtmosByCommand);
$general->setVar('train', $sideEffect);
@@ -171,8 +171,8 @@ class che_상업투자 extends Command\GeneralCommand{
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
}
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
if(in_array($this->city['front'], [1, 3]) && $this->nation['capital'] != $this->city['city']){
$score *= static::$debuffFront;
@@ -70,8 +70,8 @@ class che_소집해제 extends Command\GeneralCommand{
$exp = 70;
$ded = 100;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$db->update('city', [
'pop'=>$db->sqleval('pop + %i', $crew)
+2 -2
View File
@@ -71,8 +71,8 @@ class che_요양 extends Command\GeneralCommand{
$exp = 10;
$ded = 7;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$general->setVar('injury', 0);
$general->increaseVar('experience', $exp);
+1 -1
View File
@@ -104,7 +104,7 @@ class che_이동 extends Command\GeneralCommand{
$exp = 50;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$exp = $general->onCalcStat($general, 'experience', $exp);
$general->setVar('city', $destCityID);
if($general->getVar('level') == 12 && $this->nation['level'] == 0){
@@ -107,8 +107,8 @@ class che_인재탐색 extends Command\GeneralCommand{
$exp = 100;
$ded = 70;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$general->increaseVarWithLimit('gold', -$reqGold, 0);
$general->increaseVarWithLimit('rice', -$reqRice, 0);
@@ -254,8 +254,8 @@ class che_인재탐색 extends Command\GeneralCommand{
$exp = 200;
$ded = 300;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$general->increaseVarWithLimit('gold', -$reqGold, 0);
$general->increaseVarWithLimit('rice', -$reqRice, 0);
+1 -1
View File
@@ -143,7 +143,7 @@ class che_임관 extends Command\GeneralCommand{
$exp = 100;
}
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$exp = $general->onCalcStat($general, 'experience', $exp);
$general->setVar('nation', $destNationID);
$general->setVar('level', 1);
$general->setVar('belong', 1);
@@ -168,7 +168,7 @@ class che_장비매매 extends Command\GeneralCommand{
}
$exp = 10;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$exp = $general->onCalcStat($general, 'experience', $exp);
$general->increaseVar('experience', $exp);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
@@ -113,8 +113,8 @@ class che_전투태세 extends Command\GeneralCommand{
$exp = 100 * 3;
$ded = 70 * 3;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$general->increaseVar('experience', $exp);
$general->increaseVar('dedication', $ded);
@@ -140,8 +140,8 @@ class che_정착장려 extends Command\GeneralCommand{
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
//NOTE: 내정량 상승시 초과 가능?
$cityUpdated = [
@@ -138,8 +138,8 @@ class che_주민선정 extends Command\GeneralCommand{
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
}
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
//NOTE: 내정량 상승시 초과 가능?
$cityUpdated = [
+2 -2
View File
@@ -135,8 +135,8 @@ class che_증여 extends Command\GeneralCommand{
$exp = 70;
$ded = 100;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$general->increaseVar('experience', $exp);
$general->increaseVar('dedication', $ded);
+2 -2
View File
@@ -97,8 +97,8 @@ class che_집합 extends Command\GeneralCommand{
$exp = 70;
$ded = 100;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$general->increaseVar('experience', $exp);
$general->increaseVar('dedication', $ded);
+2 -2
View File
@@ -179,8 +179,8 @@ class che_징병 extends Command\GeneralCommand{
$exp = Util::round($reqCrew / 100);
$ded = Util::round($reqCrew / 100);
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$general->addDex($general->getCrewTypeObj(), $reqCrew / 100, false);
+2 -2
View File
@@ -166,8 +166,8 @@ class che_첩보 extends Command\GeneralCommand{
$exp = Util::randRangeInt(1, 100);
$ded = Util::randRangeInt(1, 70);
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
[$reqGold, $reqRice] = $this->getCost();
$general->increaseVarWithLimit('gold', -$reqGold, 0);
+1 -1
View File
@@ -48,7 +48,7 @@ class che_출병 extends Command\GeneralCommand{
$this->setCity();
$this->setNation(['war', 'gennum', 'tech', 'gold', 'rice']);
$this->setDestCity($this->arg['destCityID'], ['city', 'name', 'nation']);
$this->setDestCity($this->arg['destCityID'], null);
[$reqGold, $reqRice] = $this->getCost();
$relYear = $this->env['year'] - $this->env['startyear'];
+2 -2
View File
@@ -116,8 +116,8 @@ class che_헌납 extends Command\GeneralCommand{
$exp = 70;
$ded = 100;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$general->increaseVar('experience', $exp);
$general->increaseVar('dedication', $ded);
+4 -4
View File
@@ -237,8 +237,8 @@ class che_화계 extends Command\GeneralCommand{
$exp = Util::randRangeInt(1, 100);
$ded = Util::randRangeInt(1, 70);
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
[$reqGold, $reqRice] = $this->getCost();
$general->increaseVarWithLimit('gold', -$reqGold, 0);
@@ -273,8 +273,8 @@ class che_화계 extends Command\GeneralCommand{
$exp = Util::randRangeInt(201, 300);
$ded = Util::randRangeInt(141, 210);
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
[$reqGold, $reqRice] = $this->getCost();
$general->increaseVarWithLimit('gold', -$reqGold, 0);
+2 -2
View File
@@ -79,8 +79,8 @@ class che_훈련 extends Command\GeneralCommand{
$exp = 100;
$ded = 70;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$exp = $general->onCalcStat($general, 'experience', $exp);
$ded = $general->onCalcStat($general, 'dedication', $ded);
$general->increaseVarWithLimit('train', $score, 0, GameConst::$maxTrainByCommand);
$general->setVar('atmos', $sideEffect);
+1 -5
View File
@@ -9,11 +9,7 @@ trait DefaultAction{
return $value;
}
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
return $value;
}
public function onCalcStat(General $general, string $stat, $value){
public function onCalcStat(General $general, string $statName, $value, $aux=null){
return $value;
}
+8 -8
View File
@@ -124,7 +124,7 @@ class GameUnitDetail{
return $def * $crew / 100;
}
public function getCriticalRatio(array $general){
public function getCriticalRatio(General $general){
if($this->armType == GameUnitConst::T_CASTLE){
//성벽은 필살을 사용하지 않는다.
return 0;
@@ -134,26 +134,26 @@ class GameUnitDetail{
// 지장 지력 : 65 5%, 70 8%, 75 10%, 80 13%
//충차장 통솔: 65 5%, 70 8%, 75 10%, 80 13%
if($this->armType == GameUnitConst::T_WIZARD){
$mainstat = getGeneralIntel($general, false, true, true, false);
$mainstat = $general->getIntel(false, true, true, false);
$coef = 0.4;
}
else if($this->armType == GameUnitConst::T_SIEGE){
$mainstat = getGeneralLeadership($general, false, true, true, false);
$mainstat = $general->getLeadership(false, true, true, false);
$coef = 0.4;
}
else if($this->armType == GameUnitConst::T_MISC){
$mainstat = getGeneralIntel($general, false, true, true, false) +
getGeneralLeadership($general, false, true, true, false) +
getGeneralPower($general, false, true, true, false);
$mainstat = $general->getIntel(false, true, true, false) +
$general->getLeadership(false, true, true, false) +
$general->getPower(false, true, true, false);
$mainstat /= 3;
$coef = 0.4;
}
else{
$mainstat = getGeneralPower($general, false, true, true, false);
$mainstat = $general->getPower(false, true, true, false);
$coef = 0.5;
}
$ratio = max($mainstat - 65, 0);
$ratio = Util::valueFit($mainstat - 65, 0);
$ratio *= $coef;
return min(50, $ratio) / 100;
+2 -7
View File
@@ -406,7 +406,7 @@ class General implements iAction{
return $value;
}
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
public function onCalcStat(General $general, string $statName, $value, $aux=null){
//xxx: $general?
foreach(array_merge([
$this->nationType,
@@ -419,16 +419,11 @@ class General implements iAction{
continue;
}
/** @var iAction $iObj */
$value = $iObj->onPreGeneralStatUpdate($this, $statName, $value);
$value = $iObj->onCalcStat($this, $statName, $value, $aux);
}
return $value;
}
public function onCalcStat(General $general, string $stat, $value){
//xxx: $general?
return $value;
}
public function onCalcStrategic(string $turnType, string $varType, $value){
foreach(array_merge([
$this->nationType,
+11 -12
View File
@@ -2,9 +2,8 @@
namespace sammo;
class WarUnit{
use LazyVarUpdater;
protected $raw = [];
protected $general;
protected $rawNation;
protected $logger;
@@ -31,7 +30,8 @@ class WarUnit{
protected $logActivatedSkill = [];
protected $isFinished = false;
private function __construct(){
private function __construct(General $general){
$this->general = $general;
}
protected function clearActivatedSkill(){
@@ -110,16 +110,12 @@ class WarUnit{
return $this->deadCurr;
}
function getSpecialDomestic():string{
return GameConst::$defaultSpecialDomestic;
function getGeneral():General{
return $this->general;
}
function getSpecialWar():string{
return 0;
}
function getItem():int{
return 0;
function getVar(string $key){
return $this->general->getVar($key);
}
function getMaxPhase():int{
@@ -241,7 +237,7 @@ class WarUnit{
}
function getComputedCriticalRatio():float{
return $this->getCrewType()->getCriticalRatio($this->getRaw());
return $this->getCrewType()->getCriticalRatio($this->general);
}
function getComputedAvoidRatio():float{
@@ -324,16 +320,19 @@ class WarUnit{
function getHP():int{
throw new NotInheritedMethodException();
return 0;
}
function decreaseHP(int $damage):int{
$this->dead += $damage;
throw new NotInheritedMethodException();
return 0;
}
function increaseKilled(int $damage):int{
$this->killed += $damage;
throw new NotInheritedMethodException();
return 0;
}
function calcDamage():int{
+22 -56
View File
@@ -2,26 +2,16 @@
namespace sammo;
class WarUnitGeneral extends WarUnit{
protected $rawCity;
protected $bonusPhase = 0;
function __construct($raw, $rawCity, $rawNation, $isAttacker, $year, $month){
setLeadershipBonus($raw, $rawNation['level']);
$this->raw = $raw;
$this->rawCity = $rawCity; //read-only
function __construct(General $general, array $rawNation, bool $isAttacker, int $year, int $month){
$this->general = $general;
$this->raw = $general->getRaw();
$this->rawNation = $rawNation; //read-only
$this->isAttacker = $isAttacker;
$this->logger = new ActionLogger(
$this->getVar('no'),
$this->getVar('nation'),
$year,
$month,
false
);
$this->crewType = GameUnitConst::byID($this->getVar('crewtype'));
$this->logger = $this->general->getLogger();
$this->crewType = $this->general->getCrewTypeObj();
$cityLevel = $this->getCityVar('level');
@@ -46,86 +36,62 @@ class WarUnitGeneral extends WarUnit{
}
function getName():string{
return $this->getVar('name');
return $this->general->getName();
}
function getCityVar(string $key){
return $this->rawCity[$key];
return $this->general->getRawCity()[$key];
}
function getSpecialDomestic():string{
return $this->getVar('special');
}
function setOppose(?WarUnit $oppose){
parent::setOppose($oppose);
$this->increaseVar('warnum', 1);
$general = $this->general;
$this->general->increaseVar('warnum', 1);
if($this->isAttacker){
$this->updateVar('recwar', $this->getVar('turntime'));
$general->updateVar('recwar', $general->getVar('turntime'));
}
else if($oppose !== null){
$this->updateVar('recwar', $oppose->getVar('turntime'));
$general->updateVar('recwar', $oppose->getVar('turntime'));
}
}
function getSpecialWar():int{
return $this->getVar('special2');
}
function getCharacter():int{
return $this->getVar('personal');
}
function getItem():int{
return $this->getVar('item');
}
function getMaxPhase():int{
$phase = $this->getCrewType()->speed;
if($this->getSpecialWar() == 60){
$phase += 1;
}
$phase = $this->general->onCalcStat($this->general, 'initWarPhase', $phase);
return $phase + $this->bonusPhase;
}
function addTrain(int $train){
$this->increaseVarWithLimit('train', $train, 0, GameConst::$maxTrainByWar);
$this->general->increaseVarWithLimit('train', $train, 0, GameConst::$maxTrainByWar);
}
function addAtmos(int $atmos){
$this->increaseVarWithLimit('atmos', $atmos, 0, GameConst::$maxAtmosByWar);
$this->general->increaseVarWithLimit('atmos', $atmos, 0, GameConst::$maxAtmosByWar);
}
function getComputedTrain(){
$train = $this->getVar('train');
$train = $this->general->getVar('train');
$train = $this->general->onCalcStat($this->general, 'bonusTrain', $train);
$train += $this->trainBonus;
return $train;
}
function getComputedAtmos(){
$atmos = $this->getVar('atmos');
$atmos = $this->general->getVar('atmos');
$atmos = $this->general->onCalcStat($this->general, 'bonusAtmos', $atmos);
$atmos += $this->atmosBonus;
return $atmos;
}
function getComputedCriticalRatio():float{
$critialRatio = $this->getCrewType()->getCriticalRatio($this->getRaw());
$general = $this->general;
$criticalRatio = $this->getCrewType()->getCriticalRatio($general);
$specialWar = $this->getSpecialWar();
$item = $this->getItem();
if($specialWar == 61){
if($this->isAttacker){
$critialRatio += 0.1;
}
}
else if($specialWar == 71){
$critialRatio += 0.2;
}
return $critialRatio;
$criticalRatio = $general->onCalcStat($general, 'warCriticalRatio', $criticalRatio, ['isAttacker'=>$this->isAttacker]);
return $criticalRatio;
}
function getComputedAvoidRatio():float{
+2 -3
View File
@@ -5,13 +5,12 @@ interface iAction{
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller;
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float;
public function onPreGeneralStatUpdate(General $general, string $statName, $value);
public function onCalcStat(General $general, string $stat, $value);
public function onCalcStat(General $general, string $statName, $value, $aux=null);
public function onCalcStrategic(string $turnType, string $varType, $value);
public function onCalcNationalIncome(string $type, int $amount):int;
public function getWarPowerMultiplier(WarUnit $unit):array;
public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller;
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller;
//NOTE: getBattleEndSkillTriggerList도 필요한가?
}