forked from devsam/core
농지 개간, 상업 투자를 외부 커맨드로 연결
This commit is contained in:
+11
-44
@@ -208,53 +208,20 @@ function process_1(array $rawGeneral, int $type){
|
||||
$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);
|
||||
$logger = $general->getLogger();
|
||||
|
||||
$nationTypeObj = $general->getNationTypeObj();
|
||||
$generalLevelObj = $general->getGeneralLevelObj();
|
||||
|
||||
$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;
|
||||
if($type == 1){
|
||||
$cmdObj = new Command\che_농지개간($general, $env);
|
||||
}
|
||||
else{
|
||||
$cmdObj = new Command\che_상업투자($general, $env);
|
||||
}
|
||||
|
||||
$trust = Util::valutFit($city['trust'], 50);
|
||||
|
||||
$score = getGeneralIntel($general, true, true, true, false);
|
||||
$score *= $trust / 100;
|
||||
$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);
|
||||
|
||||
|
||||
|
||||
if(!$cmdObj->isAvailable()){
|
||||
return;
|
||||
}
|
||||
$cmdObj->run();
|
||||
}
|
||||
|
||||
function process_1_old(&$general, $type) {
|
||||
|
||||
@@ -34,7 +34,7 @@ abstract class BaseCommand{
|
||||
|
||||
protected $logger;
|
||||
|
||||
public function __construct(General $generalObj, array $env, $arg){
|
||||
public function __construct(General $generalObj, array $env, $arg = null){
|
||||
$this->generalObj = $generalObj;
|
||||
$this->logger = $generalObj->getLogger();
|
||||
$this->env = $env;
|
||||
@@ -50,9 +50,13 @@ abstract class BaseCommand{
|
||||
return;
|
||||
}
|
||||
$this->city = $db->queryFirstRow('SELECT * FROM city WHERE city=%i', $this->generalObj->getVar('city'));
|
||||
$this->generalObj->setRawCity($this->city);
|
||||
return;
|
||||
}
|
||||
$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){
|
||||
|
||||
@@ -101,6 +101,10 @@ class General implements iActionTrigger{
|
||||
return $this->rawCity;
|
||||
}
|
||||
|
||||
function setRawCity(?array $city){
|
||||
$this->city = $city;
|
||||
}
|
||||
|
||||
function getCityID():int{
|
||||
return $this->raw['city'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user