From 4341341a07a493eeef7f0307d84ddc277ef493e0 Mon Sep 17 00:00:00 2001 From: hided62 Date: Sun, 26 Jul 2026 23:30:25 +0000 Subject: [PATCH] compare: run optional general turn lifecycle --- hwe/compare/turn_command_trace.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/hwe/compare/turn_command_trace.php b/hwe/compare/turn_command_trace.php index 377f97d6..4ceef57c 100644 --- a/hwe/compare/turn_command_trace.php +++ b/hwe/compare/turn_command_trace.php @@ -523,14 +523,34 @@ function comparisonRunTurnCommand(array $request): array $actorGeneralId = $request['actorGeneralId'] ?? null; $action = $request['action'] ?? null; $args = $request['args'] ?? null; + $includeLifecycle = $request['includeLifecycle'] ?? false; if (!is_int($actorGeneralId) || $actorGeneralId < 1) { throw new \InvalidArgumentException('actorGeneralId must be a positive integer'); } if (!is_string($action) || $action === '') { throw new \InvalidArgumentException('action must be a non-empty string'); } + if (!is_bool($includeLifecycle)) { + throw new \InvalidArgumentException('includeLifecycle must be a boolean'); + } + if ($includeLifecycle && $kind !== 'general') { + throw new \InvalidArgumentException('includeLifecycle currently supports general commands only'); + } comparisonApplyTurnFixtureSetup($request['setup'] ?? null); + if ($includeLifecycle) { + DB::db()->insertUpdate('general_turn', [ + 'general_id' => $actorGeneralId, + 'turn_idx' => 0, + 'action' => $action, + 'arg' => Json::encode($args), + 'brief' => $action, + ], [ + 'action' => $action, + 'arg' => Json::encode($args), + 'brief' => $action, + ]); + } $snapshotRequest = ['observe' => $request['observe'] ?? []]; $before = comparisonTurnStateSnapshot($snapshotRequest); $db = DB::db(); @@ -610,6 +630,16 @@ function comparisonRunTurnCommand(array $request): array $nationStor->setValue($lastNationTurnKey, $resultTurn->toRaw()); } + if ($includeLifecycle) { + pullGeneralCommand($general->getID()); + $general->increaseVarWithLimit( + 'myset', + GameConst::$incDefSettingChange, + null, + GameConst::$maxDefSettingChange, + ); + $turn->updateTurnTime(); + } $general->getLogger()->flush(); $turn->applyDB(); unset($turn);