diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 5555af3d..c4aae7f8 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -565,7 +565,9 @@ function updateNationState() $nation['level'] = $nationlevel; $updateVals = [ - 'level' => $nationlevel + 'level' => $nationlevel, + 'gold'=>$db->sqleval('gold + %i', $nationlevel*1000), + 'rice'=>$db->sqleval('rice + %i', $nationlevel*1000), ]; switch ($nationlevel) { @@ -708,7 +710,8 @@ function updateNationState() 'troop' => $npcID ], 'no=%i', $npcID); - //TODO: 5턴간 집합턴 입력 + $cmd = buildGeneralCommandClass('che_집합', General::createGeneralObjFromDB($npcID), $admin); + _setGeneralCommand($cmd, iterator_to_array(Util::range(GameConst::$maxTurn))); $assemblerCnt += 1; $gameStor->assembler_id = $lastAssemblerID; } diff --git a/hwe/sammo/Command/General/che_인재탐색.php b/hwe/sammo/Command/General/che_인재탐색.php index 8909fb46..c8f6e519 100644 --- a/hwe/sammo/Command/General/che_인재탐색.php +++ b/hwe/sammo/Command/General/che_인재탐색.php @@ -182,7 +182,6 @@ class che_인재탐색 extends Command\GeneralCommand $totalStat = GameConst::$defaultStatNPCTotal; $minStat = GameConst::$defaultStatNPCMin; $mainStat = GameConst::$defaultStatNPCMax - Util::randRangeInt(0, GameConst::$defaultStatNPCMin); - //TODO: defaultStatNPCTotal, defaultStatNPCMin 추가 $otherStat = $minStat + Util::randRangeInt(0, Util::toInt(GameConst::$defaultStatNPCMin/2)); $subStat = $totalStat - $mainStat - $otherStat; if ($subStat < $minStat) { @@ -235,12 +234,13 @@ class che_인재탐색 extends Command\GeneralCommand $birthYear = $env['year'] - $age; $deathYear = $env['year'] + Util::randRangeInt(10, 50); + $cityID = Util::choiceRandom(array_keys(\sammo\CityConst::all())); $newNPC = new \sammo\Scenario\NPC( Util::randRangeInt(1, 150), \sammo\getRandGenName(), null, $scoutNation, - $general->getCityID(), + $cityID, $leadership, $strength, $intel, diff --git a/hwe/sammo/Command/Nation/che_의병모집.php b/hwe/sammo/Command/Nation/che_의병모집.php index 20a7a6c2..b334fba7 100644 --- a/hwe/sammo/Command/Nation/che_의병모집.php +++ b/hwe/sammo/Command/Nation/che_의병모집.php @@ -216,7 +216,7 @@ class che_의병모집 extends Command\NationCommand ); $newNPC->killturn = Util::randRangeInt(64, 70); $newNPC->npc = 4; - $newNPC->setMoney(100, 100); + $newNPC->setMoney(1000, 1000); $newNPC->setExpDed($avgGen['exp'], $avgGen['ded']); $newNPC->setDex( $dexVal[0], diff --git a/hwe/sammo/Event/Action/CreateManyNPC.php b/hwe/sammo/Event/Action/CreateManyNPC.php index 433d8fe4..47d7aeea 100644 --- a/hwe/sammo/Event/Action/CreateManyNPC.php +++ b/hwe/sammo/Event/Action/CreateManyNPC.php @@ -6,20 +6,19 @@ use \sammo\Util; class CreateManyNPC extends \sammo\Event\Action{ protected $npcCount; protected $avgGen; - public function __construct($npcCount = 200){ + public function __construct($npcCount = 10){ $this->npcCount = $npcCount; } protected function generateNPC($env){ - $pickTypeList = ['무'=>6, '지'=>6, '무지'=>3]; + $pickTypeList = ['무'=>1, '지'=>1]; - $pickType = Util::choiceRandomUsingWeightPair($pickTypeList); + $pickType = Util::choiceRandomUsingWeight($pickTypeList); - $totalStat = GameConst::$defaultStatNPCMax * 2 + 10; - $minStat = 10; - $mainStat = GameConst::$defaultStatNPCMax - Util::randRangeInt(0, 10); - //TODO: defaultStatNPCTotal, defaultStatNPCMin 추가 - $otherStat = $minStat + Util::randRangeInt(0, 5); + $totalStat = GameConst::$defaultStatNPCTotal; + $minStat = GameConst::$defaultStatNPCMin; + $mainStat = GameConst::$defaultStatNPCMax - Util::randRangeInt(0, GameConst::$defaultStatNPCMin); + $otherStat = $minStat + Util::randRangeInt(0, Util::toInt(GameConst::$defaultStatNPCMin/2)); $subStat = $totalStat - $mainStat - $otherStat; if ($subStat < $minStat) { $subStat = $otherStat; @@ -50,7 +49,10 @@ class CreateManyNPC extends \sammo\Event\Action{ $strength = Util::round($strength); $intel = Util::round($intel); - $age = $env['year'] - 20; + $age = Util::randRangeInt(20, 25); + $birthYear = $env['year'] - $age; + $deathYear = $env['year'] + Util::randRangeInt(10, 50); + $cityID = Util::choiceRandom(array_keys(\sammo\CityConst::all())); $newNPC = new \sammo\Scenario\NPC( Util::randRangeInt(1, 150), @@ -62,16 +64,17 @@ class CreateManyNPC extends \sammo\Event\Action{ $strength, $intel, 0, - $age, - $env['year'] + Util::randRangeInt(10, 50), + $birthYear, + $deathYear, null, null ); - $newNPC->npc = 6; - $newNPC->setMoney(100, 100); + $newNPC->npc = 3; + $newNPC->setMoney(1000, 1000); + $newNPC->setExpDed(0, 0); $newNPC->setSpecYear( - Util::round((GameConst::$retirementYear - $age)/12) + $age, - Util::round((GameConst::$retirementYear - $age)/3) + $age + Util::round((GameConst::$retirementYear - $age) / 12) + $age, + Util::round((GameConst::$retirementYear - $age) / 3) + $age ); $newNPC->build($env); @@ -93,12 +96,12 @@ class CreateManyNPC extends \sammo\Event\Action{ if($genCnt == 1){ $npcName = $result[0][0]; $josaRa = \sammo\JosaUtil::pick($npcName, '라'); - $logger->pushGlobalActionLog("운영자가 $npcName{$josaRa}는 장수를 생성하였습니다."); + $logger->pushGlobalActionLog("$npcName{$josaRa}는 장수가 등장하였습니다."); } else{ - $logger->pushGlobalActionLog("운영자가 장수 {$genCnt}명을 생성하였습니다."); + $logger->pushGlobalActionLog("장수 {$genCnt}명이 등장하였습니다."); } - $logger->pushGlobalHistoryLog("운영자가 장수 {$genCnt}명을 생성했습니다.", \sammo\ActionLogger::NOTICE_YEAR_MONTH); + $logger->pushGlobalHistoryLog("장수 {$genCnt}명이 등장했습니다.", \sammo\ActionLogger::NOTICE_YEAR_MONTH); $logger->flush(); return [__CLASS__, $result]; diff --git a/hwe/sammo/Event/Condition/Date.php b/hwe/sammo/Event/Condition/Date.php index d34261d3..5f6b0630 100644 --- a/hwe/sammo/Event/Condition/Date.php +++ b/hwe/sammo/Event/Condition/Date.php @@ -18,7 +18,7 @@ class Date extends \sammo\Event\Condition{ //TODO:구현 - public function __construct(string $cmp, int $year, int $month){ + public function __construct(string $cmp, ?int $year, ?int $month){ //Cmp('==', '!=', '<=', '>=', '<', '>'), Year, Month(Optional) if(!array_key_exists($cmp, self::AVAILABLE_CMP)){ throw new \InvalidArgumentException('올바르지 않은 비교연산자입니다'); diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index fdf381c8..af7da571 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -3358,7 +3358,7 @@ class GeneralAI return $result; } - if($npcType == 2 && $nationID == 0){ + if(($npcType == 2 || $npcType == 3) && $nationID == 0){ $result = $this->do거병(); if($result !== null){ $result->reason='do거병'; diff --git a/hwe/sammo/TurnExecutionHelper.php b/hwe/sammo/TurnExecutionHelper.php index 04c92544..b6532979 100644 --- a/hwe/sammo/TurnExecutionHelper.php +++ b/hwe/sammo/TurnExecutionHelper.php @@ -376,16 +376,6 @@ class TurnExecutionHelper turnDate($nextTurn); - // 이벤트 핸들러 동작 - foreach (DB::db()->query('SELECT * from event') as $rawEvent) { - $eventID = $rawEvent['id']; - $cond = Json::decode($rawEvent['condition']); - $action = Json::decode($rawEvent['action']); - $event = new Event\EventHandler($cond, $action); - - $event->tryRunEvent(['currentEventID'=>$eventID] + $gameStor->getAll(true)); - } - $logger = new ActionLogger(0, 0, $gameStor->year, $gameStor->month, false); // 분기계산. 장수들 턴보다 먼저 있다면 먼저처리 @@ -414,6 +404,16 @@ class TurnExecutionHelper disaster(); } + // 이벤트 핸들러 동작 + foreach (DB::db()->query('SELECT * from event') as $rawEvent) { + $eventID = $rawEvent['id']; + $cond = Json::decode($rawEvent['condition']); + $action = Json::decode($rawEvent['action']); + $event = new Event\EventHandler($cond, $action); + + $event->tryRunEvent(['currentEventID'=>$eventID] + $gameStor->getAll(true)); + } + postUpdateMonthly(); // 다음달로 넘김 diff --git a/hwe/scenario/scenario_2.json b/hwe/scenario/scenario_2.json index 0d97777d..f1ce5c16 100644 --- a/hwe/scenario/scenario_2.json +++ b/hwe/scenario/scenario_2.json @@ -12,5 +12,12 @@ "expandCityWallIncreaseAmount": 1600, "defaultMaxGeneral":300, "joinRuinedNPCProp":0 - } + }, + "events":[ + [ + ["Date", "==", null, 12], + ["CreateManyNPC", 10], + ["DeleteEvent"] + ] + ] } \ No newline at end of file