버그 수정, 구조 변경

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