농지 개간, 상업 투자를 외부 커맨드로 연결
This commit is contained in:
+11
-44
@@ -208,53 +208,20 @@ function process_1(array $rawGeneral, int $type){
|
|||||||
$actionName = '상업 투자';
|
$actionName = '상업 투자';
|
||||||
}
|
}
|
||||||
|
|
||||||
[$startYear, $year, $month, $develCost] = $gameStor->getValuesAsArray(['startyear', 'year', 'month', 'develcost']);
|
$env = $gameStor->getValues(['startyear', 'year', 'month', 'develcost']);
|
||||||
|
$general = new General($rawGeneral, null, $env['year'], $env['month']);
|
||||||
|
|
||||||
$general = new General($rawGeneral, $year, $month);
|
if($type == 1){
|
||||||
$logger = $general->getLogger();
|
$cmdObj = new Command\che_농지개간($general, $env);
|
||||||
|
}
|
||||||
$nationTypeObj = $general->getNationTypeObj();
|
else{
|
||||||
$generalLevelObj = $general->getGeneralLevelObj();
|
$cmdObj = new Command\che_상업투자($general, $env);
|
||||||
|
|
||||||
$reqGold = $nationTypeObj->onCalcDomestic($cityKey, 'cost', $develCost);
|
|
||||||
$reqGold = $generalLevelObj->onCalcDomestic($cityKey, 'cost', $develCost);
|
|
||||||
|
|
||||||
$city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general->getCityID());
|
|
||||||
|
|
||||||
$constraints = [
|
|
||||||
['NoNeutral'],
|
|
||||||
['NoWanderingNation'],
|
|
||||||
['OccupiedCity'],
|
|
||||||
['SuppliedCity'],
|
|
||||||
['ReqGeneralGold', $reqGold],
|
|
||||||
['RemainCityCapacity', [$cityKey, $actionName]]
|
|
||||||
];
|
|
||||||
$failReason = Constraint::testAll($constraints, [
|
|
||||||
'nation'=>$general->getStaticNation(),
|
|
||||||
'city'=>$city,
|
|
||||||
'general'=>$general->getRaw(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if($failReason !== null){
|
|
||||||
$logger->pushGeneralActionLog("{$failReason} {$sabotageName} 실패. <1>{$date}</>");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$trust = Util::valutFit($city['trust'], 50);
|
if(!$cmdObj->isAvailable()){
|
||||||
|
return;
|
||||||
$score = getGeneralIntel($general, true, true, true, false);
|
}
|
||||||
$score *= $trust / 100;
|
$cmdObj->run();
|
||||||
$score *= getDomesticExpLevelBonus($general['explevel']);
|
|
||||||
$score *= Util::randRange(0.8, 1.2);
|
|
||||||
$score = $nationTypeObj->onCalcDomestic($cityKey, 'score', $score);
|
|
||||||
$score = $generalLevelObj->onCalcDomestic($cityKey, 'score', $score);
|
|
||||||
|
|
||||||
['succ'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, 2);
|
|
||||||
$successRatio = $naionTypeObj->onCalcDomestic($cityKey, 'success', $successRatio);
|
|
||||||
$successRatio = $generalLevelObj->onCalcDomestic($cityKey, 'success', $successRatio);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function process_1_old(&$general, $type) {
|
function process_1_old(&$general, $type) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ abstract class BaseCommand{
|
|||||||
|
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
public function __construct(General $generalObj, array $env, $arg){
|
public function __construct(General $generalObj, array $env, $arg = null){
|
||||||
$this->generalObj = $generalObj;
|
$this->generalObj = $generalObj;
|
||||||
$this->logger = $generalObj->getLogger();
|
$this->logger = $generalObj->getLogger();
|
||||||
$this->env = $env;
|
$this->env = $env;
|
||||||
@@ -50,9 +50,13 @@ abstract class BaseCommand{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->city = $db->queryFirstRow('SELECT * FROM city WHERE city=%i', $this->generalObj->getVar('city'));
|
$this->city = $db->queryFirstRow('SELECT * FROM city WHERE city=%i', $this->generalObj->getVar('city'));
|
||||||
|
$this->generalObj->setRawCity($this->city);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->city = $db->queryFirstRow('SELECT %lb FROM city WHERE city=%i', $args, $this->generalObj->getVar('city'));
|
$this->city = $db->queryFirstRow('SELECT %lb FROM city WHERE city=%i', $args, $this->generalObj->getVar('city'));
|
||||||
|
if($this->generalObj->getRawCity() === null){
|
||||||
|
$this->generalObj->setRawCity($this->city);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setNation(?array $args = null){
|
protected function setNation(?array $args = null){
|
||||||
|
|||||||
@@ -101,6 +101,10 @@ class General implements iActionTrigger{
|
|||||||
return $this->rawCity;
|
return $this->rawCity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setRawCity(?array $city){
|
||||||
|
$this->city = $city;
|
||||||
|
}
|
||||||
|
|
||||||
function getCityID():int{
|
function getCityID():int{
|
||||||
return $this->raw['city'];
|
return $this->raw['city'];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user