농지개간, 상업투자 구현, General 클래스로 checkStatChange 이동, uniqueItemEx 추가(및 재구현)
This commit is contained in:
@@ -5,5 +5,7 @@ use \sammo\Util;
|
||||
use \sammo\JosaUtil;
|
||||
|
||||
class che_농지개간 extends che_상업투자{
|
||||
|
||||
static $cityKey = 'agri';
|
||||
static $actionKey = '농업';
|
||||
static $actionName = '농지 개간';
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace sammo\Command;
|
||||
|
||||
use \sammo\{
|
||||
Util, JosaUtil,
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
getGeneralIntel,
|
||||
@@ -13,6 +13,7 @@ use \sammo\{
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use function sammo\CriticalScore;
|
||||
use function sammo\uniqueItemEx;
|
||||
|
||||
|
||||
class che_상업투자 extends BaseCommand{
|
||||
@@ -47,6 +48,8 @@ class che_상업투자 extends BaseCommand{
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$trust = Util::valueFit($this->city['trust'], 50);
|
||||
@@ -94,12 +97,24 @@ class che_상업투자 extends BaseCommand{
|
||||
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
|
||||
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
|
||||
|
||||
//TODO: 내정량 상승시 초과 가능?
|
||||
//NOTE: 내정량 상승시 초과 가능?
|
||||
$cityUpdated = [
|
||||
static::$cityKey => Util::valueFit(
|
||||
$this->city[static::$cityKey] + $score,
|
||||
0,
|
||||
$this->city[static::$cityKey.'2']
|
||||
)
|
||||
];
|
||||
|
||||
$general->increaseVarWithLimit('gold', -$this->reqGold, 0);
|
||||
$general->increaseVar('experience', $exp);
|
||||
$general->increaseVar('dedication', $ded);
|
||||
$general->increaseVar('intel2', 1);
|
||||
$general->updateVar('resturn', 'SUCCESS');
|
||||
$general->applyDB($db);
|
||||
|
||||
|
||||
//TODO:uniqueItemEx에 해당하는 함수 추가
|
||||
$this->checkStatChange();
|
||||
uniqueItemEx($general->getVar('no'), $logger);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,6 +48,12 @@ class General implements iActionTrigger{
|
||||
$nationTypeClass = getNationTypeClass($staticNation['type']);
|
||||
$this->nationType = new $nationTypeClass;
|
||||
$this->levelObj = new TriggerGeneralLevel($this->raw, $city);
|
||||
|
||||
$specialDomesticClass = getGeneralSpecialDomesticClass($raw['special']);
|
||||
$this->specialDomesticObj = new $specialDomesticClass;
|
||||
|
||||
//TODO: $specialWarClass 설정
|
||||
|
||||
$personalityClass = getPersonalityClass($raw['personal']);
|
||||
$this->personalityObj = new $personalityClass;
|
||||
}
|
||||
@@ -148,6 +154,38 @@ class General implements iActionTrigger{
|
||||
return $db->affectedRows() > 0;
|
||||
}
|
||||
|
||||
function checkStatChange():bool{
|
||||
$logger = $this->getLogger();
|
||||
$limit = GameConst::$upgradeLimit;
|
||||
|
||||
$table = [
|
||||
['통솔', 'leader'],
|
||||
['무력', 'power'],
|
||||
['지력', 'intel'],
|
||||
];
|
||||
|
||||
$result = false;
|
||||
|
||||
foreach($table as [$statNickName, $statName]){
|
||||
$statExpName = $statName.'2';
|
||||
|
||||
if($this->getVar($statExpName) < 0){
|
||||
$logger->pushGeneralActionLog("<R>{$statNickName}</>이 <C>1</> 떨어졌습니다!", ActionLogger::PLAIN);
|
||||
$this->increaseVar($statExpName, $limit);
|
||||
$this->increaseVar($statName, -1);
|
||||
$result = true;
|
||||
}
|
||||
else if($this->getVar($statExpName) >= $limit){
|
||||
$logger->pushGeneralActionLog("<R>{$statNickName}</>이 <C>1</> 올랐습니다!", ActionLogger::PLAIN);
|
||||
$this->increaseVar($statExpName, -$limit);
|
||||
$this->increaseVar($statName, 1);
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function onPreTurnExecute(General $general, ?array $nation):array{
|
||||
$chain = [];
|
||||
if($this->nationType){
|
||||
|
||||
Reference in New Issue
Block a user