강행, 단련 추가
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
|
||||
|
||||
use function \sammo\{
|
||||
uniqueItemEx
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use sammo\CityConst;
|
||||
|
||||
|
||||
|
||||
class che_강행 extends Command\GeneralCommand{
|
||||
static protected $actionName = '강행';
|
||||
|
||||
protected function init(){
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
$this->setDestCity($this->arg['destCityID'], []);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
['NotSameCity'],
|
||||
['NearCity', 3],
|
||||
['ReqGeneralGold', $reqGold],
|
||||
['ReqGeneralRice', $reqRice],
|
||||
];
|
||||
}
|
||||
|
||||
protected function argTest():bool{
|
||||
if(!key_exists('destCityID', $this->arg)){
|
||||
return false;
|
||||
}
|
||||
if(!key_exists($this->arg['destCityID'], CityConst::all())){
|
||||
return false;
|
||||
}
|
||||
$this->arg = [
|
||||
'destCityID'=>$this->arg['destCityID']
|
||||
];
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
$env = $this->env;
|
||||
return [$env['develcost'] * 5, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$env = $this->env;
|
||||
|
||||
$general = $this->generalObj;
|
||||
$date = substr($general->getVar('turntime'),11,5);
|
||||
|
||||
$destCityName = $this->destCity['name'];
|
||||
$destCityID = $this->destCity['city'];
|
||||
$josaRo = JosaUtil::pick($destCityName, '로');
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>{$josaRo} 강행했습니다. <1>$date</>");
|
||||
|
||||
$exp = 100;
|
||||
|
||||
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
|
||||
$general->setVar('city', $destCityID);
|
||||
|
||||
if($general->getVar('level') == 12 && $this->nation['level'] == 0){
|
||||
$generalList = $db->queryFirstColumn('SELECT no, name, city, nation, level FROM general WHERE nation=%i AND no!=%i', $general->getNationID(), $general->getID());
|
||||
foreach($generalList as $targetRawGeneral){
|
||||
$targetGeneralID = $targetRawGeneral['no'];
|
||||
$targetGeneral = $this->getGeneralObjFromGeneralSource($targetGeneralID);
|
||||
if($targetGeneral === null){
|
||||
$targetGeneral = new General($targetRawGeneral, null, $env['year'], $env['month'], false);
|
||||
}
|
||||
$targetGeneral->setVar('city', $destCityID);
|
||||
$targetGeneral->getLogger()->pushGeneralActionLog("방랑군 세력이 <G><b>{$destCityName}</b></>{$josaRo} 강행했습니다.", ActionLogger::PLAIN);
|
||||
$targetGeneral = null;
|
||||
}
|
||||
}
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
||||
$general->increaseVar('experience', $exp);
|
||||
$general->increaseVar('leader2', 1);
|
||||
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
$general->applyDB($db);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
|
||||
|
||||
use function \sammo\{
|
||||
uniqueItemEx
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
|
||||
|
||||
|
||||
class che_단련 extends Command\GeneralCommand{
|
||||
static protected $actionName = '단련';
|
||||
|
||||
protected function init(){
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
['NoNeutral'],
|
||||
['ReqGeneralCrew'],
|
||||
//TODO:훈련이 너무 낮습니다?
|
||||
//TODO:사기가 너무 낮습니다?
|
||||
['ReqGeneralGold', $reqGold],
|
||||
['ReqGeneralRice', $reqRice],
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
protected function argTest():bool{
|
||||
$this->arg = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
$env = $this->env;
|
||||
return [$env['develcost'], $env['develcost']];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$general = $this->generalObj;
|
||||
$date = substr($general->getVar('turntime'),11,5);
|
||||
|
||||
[$pick, $multiplier] = Util::choiceRandomUsingWeightPair([
|
||||
[['success', 1], 0.34],
|
||||
[['normal', 2], 0.33],
|
||||
[['fail', 3], 0.33]
|
||||
]);
|
||||
|
||||
$score = Util::round($general->getVar('crew') * $general->getVar('train') * $general->getVar('atmos') / 20 / 10000);
|
||||
$score *= $multiplier;
|
||||
$scoreText = number_format($score, 0);
|
||||
|
||||
$armTypeText = GameUnitConst::allType()[$general->getCrewTypeObj()->armType];
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
if($pick == 'fail'){
|
||||
$logger->pushGeneralActionLog("단련이 <span class='ev_failed'>지지부진</span>하여 {$armTypeText} 숙련도가 <C>{$scoreText}</> 향상되었습니다. <1>$date</>");
|
||||
}
|
||||
else if($pick == 'success'){
|
||||
$logger->pushGeneralActionLog("단련이 <S>일취월장</>하여 {$armTypeText} 숙련도가 <C>{$scoreText}</> 향상되었습니다. <1>$date</>");
|
||||
}
|
||||
else{
|
||||
$logger->pushGeneralActionLog("{$armTypeText} 숙련도가 <C>{$scoreText}</> 향상되었습니다. <1>$date</>");
|
||||
}
|
||||
|
||||
$exp = $general->getVar('crew') / 400;
|
||||
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
|
||||
|
||||
$general->addDex($general->getCrewTypeObj(), $score, false);
|
||||
|
||||
$incStat = Util::choiceRandomUsingWeight([
|
||||
'leader2'=>$general->getLeadership(false, false, false, false),
|
||||
'power2'=>$general->getPower(false, false, false, false),
|
||||
'intel2'=>$general->getIntel(false, false, false, false)
|
||||
]);
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
||||
$general->increaseVarWithLimit('rice', -$reqRice, 0);
|
||||
$general->increaseVar('experience', $exp);
|
||||
$general->increaseVar($incStat, 1);
|
||||
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
$general->applyDB($db);
|
||||
|
||||
uniqueItemEx($general->getVar('no'), $logger);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -87,7 +87,7 @@ class che_사기진작 extends Command\GeneralCommand{
|
||||
$general->increaseVarWithLimit('atmos', $score, 0, GameConst::$maAtmosByCommand);
|
||||
$general->setVar('train', $sideEffect);
|
||||
|
||||
$general->addDex($general->getVar('crew')/100, $score, false);
|
||||
$general->addDex($general->getCrewTypeObj(), $score, false);
|
||||
|
||||
$general->increaseVar('experience', $exp);
|
||||
$general->increaseVar('dedication', $ded);
|
||||
@@ -95,7 +95,7 @@ class che_사기진작 extends Command\GeneralCommand{
|
||||
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
$general->applyDB($db);
|
||||
|
||||
|
||||
uniqueItemEx($general->getVar('no'), $logger);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class che_훈련 extends Command\GeneralCommand{
|
||||
$general->increaseVarWithLimit('train', $score, 0, GameConst::$maxTrainByCommand);
|
||||
$general->setVar('atmos', $sideEffect);
|
||||
|
||||
$general->addDex($general->getVar('crew')/100, $score, false);
|
||||
$general->addDex($general->getCrewTypeObj(), $score, false);
|
||||
|
||||
$general->increaseVar('experience', $exp);
|
||||
$general->increaseVar('dedication', $ded);
|
||||
@@ -92,7 +92,7 @@ class che_훈련 extends Command\GeneralCommand{
|
||||
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
$general->applyDB($db);
|
||||
|
||||
|
||||
uniqueItemEx($general->getVar('no'), $logger);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class ReqGeneralCrew extends Constraint{
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->reason = "병사들이 없습니다.";
|
||||
$this->reason = "병사가 모자랍니다.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user