feat: eslint 적용 및 관련 코드 일괄 수정
This commit is contained in:
@@ -16,32 +16,32 @@ based on `legacy/hwe/sammo/API/Global/ExecuteEngine.php`,
|
||||
## Global Turn Loop (`TurnExecutionHelper::executeAllCommand`)
|
||||
|
||||
1. **Time gate**
|
||||
- If `now < game_env.turntime`, return without executing.
|
||||
- If `now < game_env.turntime`, return without executing.
|
||||
2. **Locking**
|
||||
- `tryLock()` on `plock` row (`type='GAME'`).
|
||||
- If locked or `isunited` in `2|3`, return (frozen state).
|
||||
- `tryLock()` on `plock` row (`type='GAME'`).
|
||||
- If locked or `isunited` in `2|3`, return (frozen state).
|
||||
3. **Pre-turn maintenance**
|
||||
- Cache game env, `checkDelay()`, `updateOnline()`, `CheckOverhead()`.
|
||||
- Cache game env, `checkDelay()`, `updateOnline()`, `CheckOverhead()`.
|
||||
4. **Catch-up monthly loop**
|
||||
- Compute `prevTurn = cutTurn(turntime, turnterm)` and `nextTurn = addTurn(prevTurn)`.
|
||||
- While `nextTurn <= now`:
|
||||
- `executeGeneralCommandUntil(nextTurn, limitActionTime, year, month)`
|
||||
- `updateTraffic()`
|
||||
- Monthly pipeline:
|
||||
- `runEventHandler(PreMonth)`
|
||||
- `preUpdateMonthly()`
|
||||
- `turnDate(nextTurn)`
|
||||
- `checkStatistic()` (only if `month == 1`)
|
||||
- `runEventHandler(Month)`
|
||||
- `postUpdateMonthly($monthlyRng)`
|
||||
- Advance `prevTurn`, `nextTurn`, update `game_env.turntime`.
|
||||
- Compute `prevTurn = cutTurn(turntime, turnterm)` and `nextTurn = addTurn(prevTurn)`.
|
||||
- While `nextTurn <= now`:
|
||||
- `executeGeneralCommandUntil(nextTurn, limitActionTime, year, month)`
|
||||
- `updateTraffic()`
|
||||
- Monthly pipeline:
|
||||
- `runEventHandler(PreMonth)`
|
||||
- `preUpdateMonthly()`
|
||||
- `turnDate(nextTurn)`
|
||||
- `checkStatistic()` (only if `month == 1`)
|
||||
- `runEventHandler(Month)`
|
||||
- `postUpdateMonthly($monthlyRng)`
|
||||
- Advance `prevTurn`, `nextTurn`, update `game_env.turntime`.
|
||||
5. **Current partial month**
|
||||
- `turnDate(prevTurn)`
|
||||
- `executeGeneralCommandUntil(now, limitActionTime, year, month)`
|
||||
- `turnDate(prevTurn)`
|
||||
- `executeGeneralCommandUntil(now, limitActionTime, year, month)`
|
||||
6. **Post-turn maintenance**
|
||||
- `processTournament()`
|
||||
- `processAuction()`
|
||||
- Reset cache, `unlock()`.
|
||||
- `processTournament()`
|
||||
- `processAuction()`
|
||||
- Reset cache, `unlock()`.
|
||||
|
||||
`limitActionTime` is derived from `max_execution_time` (roughly 2/3 of the
|
||||
configured limit). If time runs out mid-loop, it returns early and keeps
|
||||
@@ -52,36 +52,36 @@ configured limit). If time runs out mid-loop, it returns early and keeps
|
||||
For each general with `turntime < targetDate` (ordered by `turntime, no`):
|
||||
|
||||
1. **Load state**
|
||||
- `General::createObjFromDB()` and `KVStorage` for `game_env`.
|
||||
- `General::createObjFromDB()` and `KVStorage` for `game_env`.
|
||||
2. **Nation command (if officer_level >= 5)**
|
||||
- Pull `nation_turn` row for `turn_idx = 0`.
|
||||
- Build `NationCommand` with `LastTurn` stored in `nation_env`.
|
||||
- Pull `nation_turn` row for `turn_idx = 0`.
|
||||
- Build `NationCommand` with `LastTurn` stored in `nation_env`.
|
||||
3. **AI/autorun**
|
||||
- NPCs (`npc >= 2`) or players past `autorun_limit` use `GeneralAI`.
|
||||
- AI can replace both nation and general commands.
|
||||
- NPCs (`npc >= 2`) or players past `autorun_limit` use `GeneralAI`.
|
||||
- AI can replace both nation and general commands.
|
||||
4. **Preprocess triggers**
|
||||
- RNG seed: `hiddenSeed + 'preprocess' + year + month + generalID`.
|
||||
- `preprocessCommand()` merges action triggers + `che_부상경감`, `che_병력군량소모`.
|
||||
- RNG seed: `hiddenSeed + 'preprocess' + year + month + generalID`.
|
||||
- `preprocessCommand()` merges action triggers + `che_부상경감`, `che_병력군량소모`.
|
||||
5. **Blocked users**
|
||||
- `processBlocked()` consumes `killturn` and logs if `block >= 2`.
|
||||
- `processBlocked()` consumes `killturn` and logs if `block >= 2`.
|
||||
6. **Execute nation command**
|
||||
- RNG seed: `hiddenSeed + 'nationCommand' + year + month + generalID + commandKey`.
|
||||
- `processNationCommand()` checks conditions, term stack, `run()`.
|
||||
- If `run()` fails and `getAlternativeCommand()` exists, it retries.
|
||||
- Updates `nation_env` with `LastTurn` result.
|
||||
- RNG seed: `hiddenSeed + 'nationCommand' + year + month + generalID + commandKey`.
|
||||
- `processNationCommand()` checks conditions, term stack, `run()`.
|
||||
- If `run()` fails and `getAlternativeCommand()` exists, it retries.
|
||||
- Updates `nation_env` with `LastTurn` result.
|
||||
7. **Execute general command**
|
||||
- Load from `general_turn` (`turn_idx = 0`), default to `휴식`.
|
||||
- RNG seed: `hiddenSeed + 'generalCommand' + year + month + generalID + commandKey`.
|
||||
- `processCommand()` checks conditions, term stack, `run()`.
|
||||
- Updates `killturn` based on NPC status, autorun, or `휴식`.
|
||||
- Load from `general_turn` (`turn_idx = 0`), default to `휴식`.
|
||||
- RNG seed: `hiddenSeed + 'generalCommand' + year + month + generalID + commandKey`.
|
||||
- `processCommand()` checks conditions, term stack, `run()`.
|
||||
- Updates `killturn` based on NPC status, autorun, or `휴식`.
|
||||
8. **Queue maintenance & turntime**
|
||||
- `pullNationCommand()` / `pullGeneralCommand()` advance queues.
|
||||
- `pullNationCommand()` / `pullGeneralCommand()` advance queues.
|
||||
- `updateTurnTime()` handles deletion/retirement and sets next `turntime`.
|
||||
- Persist via `General::applyDB()`.
|
||||
9. **LastTurn persistence**
|
||||
- General `LastTurn` lives in `general.last_turn` JSON.
|
||||
- Nation `LastTurn` is stored in `nation_env` under `turn_last_{officer_level}`.
|
||||
- `LastTurn.term` only advances when the same command + arg repeats across turns.
|
||||
- General `LastTurn` lives in `general.last_turn` JSON.
|
||||
- Nation `LastTurn` is stored in `nation_env` under `turn_last_{officer_level}`.
|
||||
- `LastTurn.term` only advances when the same command + arg repeats across turns.
|
||||
|
||||
## Command Semantics (BaseCommand)
|
||||
|
||||
@@ -97,8 +97,8 @@ For each general with `turntime < targetDate` (ordered by `turntime, no`):
|
||||
## Turntime & Lifecycle (`updateTurnTime`)
|
||||
|
||||
- **Inactivity**: if `killturn <= 0`:
|
||||
- NPC-owned characters can detach (owner -> NPC) if `deadyear` not reached.
|
||||
- Otherwise the general is deleted (`kill()`).
|
||||
- NPC-owned characters can detach (owner -> NPC) if `deadyear` not reached.
|
||||
- Otherwise the general is deleted (`kill()`).
|
||||
- **Retirement**: if `age >= retirementYear` and not NPC, `CheckHall()` and
|
||||
`rebirth()` are invoked.
|
||||
- **Scheduling**: next `turntime` is `addTurn(current, turnterm)` with
|
||||
|
||||
Reference in New Issue
Block a user