3.4 KiB
3.4 KiB
Legacy Economy and Monthly Updates
This document summarizes the legacy economic pipeline: monthly income,
maintenance, population growth, city supply recalculation, and nation level
updates. References include legacy/hwe/func_time_event.php,
legacy/hwe/sammo/Event/Action/*, and legacy/hwe/sammo/TurnExecutionHelper.php.
Entry Points
TurnExecutionHelper::executeAllCommand()- Calls
runEventHandler(PRE_MONTH)→preUpdateMonthly()→turnDate()→runEventHandler(MONTH)→postUpdateMonthly().
- Calls
- Event actions under
legacy/hwe/sammo/Event/Action/execute concrete economic updates.
Monthly Income (ProcessIncome)
Event/Action/ProcessIncome distributes gold and rice on schedule:
- Collects all nations and cities, groups generals per nation.
- Computes income using:
getGoldIncome()/getRiceIncome()fromfunc_time_event.php.getWallIncome()for rice from walls (same file).
- Applies nation tax rate (
rate_tmp) and salary ratio (bill). - Pays generals by
dedicationviagetBill(). - Updates
nation_env.prev_income_{gold|rice}and logs to history.
Key dependencies:
GameConst::$basegold,GameConst::$basericefor minimum reserves.GameConst::$resourceActionAmountGuidefor action amounts.iAction::onCalcNationalIncome()for nation-type modifiers.
Semiannual Maintenance (ProcessSemiAnnual)
Event/Action/ProcessSemiAnnual applies upkeep and growth:
- City stats decay by 1% (agri/comm/secu/def/wall).
- Population growth via
popIncrease():- Uses tax rate (
rate_tmp) and security. - Nation type can adjust via
onCalcNationalIncome('pop', ...).
- Uses tax rate (
- General and nation resources decay (1–5% bands based on thresholds).
War Income and Casualties (ProcessWarIncome)
Event/Action/ProcessWarIncome:
- Converts
city.deadinto national gold income (supply-based war income). - Returns 20% of
deadto population (pop += dead * 0.2), then clearsdead.
City Supply and Isolation (UpdateCitySupply)
Event/Action/UpdateCitySupply:
- BFS from each nation capital through
CityConstpaths to marksupply = 1. - Unsupplied cities (
supply = 0) receive 10% stat/pop loss monthly. - Generals in unsupplied cities lose 5% crew/train/atmos.
- Cities with
trust < 30become neutral (nation = 0), and officers are reset.
Nation Level Updates (UpdateNationLevel)
Event/Action/UpdateNationLevel:
- Nation level increases based on number of level≥4 cities.
- On level-up:
- Grants gold/rice bonus.
- Logs global and national history.
- Initializes
nation_turnrows for new chief levels. - Runs a unique-item lottery (deterministic RNG tagged
nationLevelUp).
City Trade Rates (RandomizeCityTradeRate)
- Once per month, adjusts
city.tradewith deterministic RNG:- Probability depends on city level.
- Trade rate ranges 95–105 when triggered.
RNG Notes
Economic events using RNG seed with UniqueConst::$hiddenSeed and a
feature-specific tag:
RandomizeCityTradeRate:hiddenSeed + 'randomizeCityTradeRate' + year + monthUpdateNationLevel:hiddenSeed + 'nationLevelUp' + year + month + nationID
Open Questions / Follow-ups
preUpdateMonthly(),postUpdateMonthly(), andturnDate()live inlegacy/hwe/func_time_event.phpandlegacy/hwe/func.php; their full side effects should be expanded alongside this document.