feat: 게임 시작 후, 거병/건국 기간, 출병 제한 기간을 안내

This commit is contained in:
2022-05-11 02:22:40 +09:00
parent 5bc31c91fa
commit f100998800
4 changed files with 43 additions and 8 deletions
@@ -7,7 +7,7 @@ use sammo\ActionLogger;
class NoticeToHistoryLog extends \sammo\Event\Action
{
public function __construct(private string $msg)
public function __construct(private string $msg, private int $type = ActionLogger::YEAR_MONTH)
{
}
@@ -17,7 +17,7 @@ class NoticeToHistoryLog extends \sammo\Event\Action
throw new RuntimeException('year, month가 없음');
}
$logger = new ActionLogger(0, 0, $env['year'], $env['month']);
$logger->pushGlobalHistoryLog($this->msg);
$logger->pushGlobalHistoryLog($this->msg, $this->type);
$logger->flush();
}
}
+33
View File
@@ -399,4 +399,37 @@ class GameConstBase
public static $npcBanMessageProb = 0.01;
public static $npcSeizureMessageProb = 0.01;
public static $npcMessageFreqByDay = 4;
public static $defaultInitialEvents = [
[
true,
["NoticeToHistoryLog", "<S>2년간 거병 및 건국이 가능합니다.</>", ActionLogger::EVENT_YEAR_MONTH]
]
];
public static $defaultEvents = [
[
"month", 2000,
["DateRelative", "==", 1, 1],
["NoticeToHistoryLog", "<S>2년 뒤 출병 제한이 풀립니다.</>", ActionLogger::EVENT_YEAR_MONTH],
["DeleteEvent"]
],
[
"month", 2000,
["DateRelative", "==", 2, 1],
["NoticeToHistoryLog", "<S>1년 뒤 출병 제한이 풀립니다.</>", ActionLogger::EVENT_YEAR_MONTH],
["DeleteEvent"]
],
[
"month", 2000,
["DateRelative", "==", 2, 7],
["NoticeToHistoryLog", "<S>6개월 뒤 출병 제한이 풀립니다. 병력을 준비해주세요.</>", ActionLogger::EVENT_YEAR_MONTH],
["DeleteEvent"]
],
[
"month", 2000,
["DateRelative", "==", 3, 1],
["NoticeToHistoryLog", "<S>출병 제한이 풀렸습니다.</>", ActionLogger::EVENT_YEAR_MONTH],
["DeleteEvent"]
],
];
}
+4
View File
@@ -186,6 +186,10 @@ class ResetHelper{
$seasonIdx = $clearResult['seasonIdx'];
$scenarioObj = new Scenario($scenario, true);
if(class_exists('\\sammo\GameConst', false)){
trigger_error("이미 GameConst가 호출되어있습니다", E_USER_NOTICE);
}
$scenarioObj->buildConf();
$scenarioObj->initFull();
+4 -6
View File
@@ -207,7 +207,7 @@ class Scenario{
$cond = $rawEvent[0];
$action = array_slice($rawEvent, 1);
return new \sammo\Event\EventHandler($cond, $action);
}, Util::array_get($data['initialEvents'], []));
}, array_merge(GameConst::$defaultInitialEvents, Util::array_get($data['initialEvents'], [])));
$this->events = array_map(function($rawEvent){
//event는 여기서 풀지 않는다. 평가만 한다.
@@ -230,7 +230,7 @@ class Scenario{
'cond' => $cond,
'action' => $action
];
}, Util::array_get($data['events'], []));
}, array_merge(GameConst::$defaultEvents, Util::array_get($data['events'], [])));
}
public function getGameConf(){
@@ -546,6 +546,8 @@ class Scenario{
$this->buildDiplomacy($env);
pushGlobalHistoryLog($this->history, $env['year'], $env['month']);
foreach($this->initialEvents as $event){
$event->tryRunEvent($env);
}
@@ -563,10 +565,6 @@ class Scenario{
$db->insert('event', $events);
}
pushGlobalHistoryLog($this->history, $env['year'], $env['month']);
refreshNationStaticInfo();
foreach(getAllNationStaticInfo() as $nation){
SetNationFront($nation['nation']);