feat(management): ✨ prioritize forge production over walls
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
0ba45eef32
commit
a8daeff9cd
2 changed files with 43 additions and 14 deletions
|
|
@ -988,18 +988,32 @@ func _manage_production(city: Variant) -> void:
|
|||
city.add_to_queue("building", built)
|
||||
|
||||
|
||||
func _next_building(city: Variant, player: Variant, city_count: int, has_founder: bool) -> String:
|
||||
## Score candidates from current state; return highest. See plan: cosmic-questing-allen.md.
|
||||
## 14 factors — priorities emerge from circumstances, not prescriptive order.
|
||||
var tech_req: Dictionary = {
|
||||
"library": "scholarship", "barracks": "military_doctrine",
|
||||
"castle": "fortification", "spearmen": "war",
|
||||
"cavalry": "animal_husbandry",
|
||||
}
|
||||
var candidates: Array[String] = [
|
||||
"warrior", "forge", "walls", "marketplace", "temple",
|
||||
"colosseum", "ale_hall", "bathhouse", "library", "barracks", "monument",
|
||||
"castle", "founder", "worker", "spearmen", "cavalry",
|
||||
func _next_building(city: Variant, player: Variant, city_count: int, has_settler: bool) -> String:
|
||||
## Return the next building/unit to produce, or "" for warrior.
|
||||
# Forge FIRST — doubles production from 2 to 4, accelerates everything after
|
||||
if not city.has_building("forge"):
|
||||
return "forge"
|
||||
# Then walls
|
||||
if not city.has_building("walls"):
|
||||
return "walls"
|
||||
# One warrior before expanding
|
||||
var military: int = 0
|
||||
for u: Variant in player.units:
|
||||
if u.is_alive() and u.get("can_found_city") != true:
|
||||
military += 1
|
||||
if military == 0:
|
||||
return "" # build warrior
|
||||
# Expand to 3 cities
|
||||
if city_count < 3 and not has_settler:
|
||||
return "settler"
|
||||
# Remaining economic buildings
|
||||
var econ_buildings: Array[Array] = [
|
||||
["brewery", "brewing"],
|
||||
["library", "scholarship"],
|
||||
["marketplace", "trade_routes"],
|
||||
["barracks", "military_doctrine"],
|
||||
["monument", "ancestor_rites"],
|
||||
["castle", "fortification"],
|
||||
]
|
||||
var units_set: Array[String] = ["warrior", "founder", "worker", "spearmen", "cavalry"]
|
||||
var scores: Dictionary = {}
|
||||
|
|
|
|||
|
|
@ -144,7 +144,8 @@ func _process_research(player: RefCounted) -> void: # Player
|
|||
city as CityScript, game_map
|
||||
)
|
||||
var yields: Dictionary = city.get_yields(tile_json)
|
||||
player.research_progress += int(yields.get("science", 0) * sci_modifier)
|
||||
var building_sci: int = _sum_city_building_effect(city as CityScript, "science")
|
||||
player.research_progress += int((yields.get("science", 0) + building_sci) * sci_modifier)
|
||||
|
||||
# Check if researching a spell (not a tech)
|
||||
var spell_data: Dictionary = DataLoader.get_spell(player.researching)
|
||||
|
|
@ -261,6 +262,19 @@ func _sum_city_building_effect_float(city: CityScript, effect_type: String) -> f
|
|||
return total
|
||||
|
||||
|
||||
func _sum_city_building_effect(city: CityScript, effect_type: String) -> int:
|
||||
## Sum a building effect type for a single city (e.g., "production", "gold", "science").
|
||||
var total: int = 0
|
||||
for building_id: Variant in city.buildings:
|
||||
var bdata: Dictionary = DataLoader.get_building(str(building_id))
|
||||
if bdata.is_empty():
|
||||
continue
|
||||
for effect: Dictionary in bdata.get("effects", []):
|
||||
if effect.get("type", "") == effect_type:
|
||||
total += int(effect.get("value", 0))
|
||||
return total
|
||||
|
||||
|
||||
func _apply_building_bonuses(city: CityScript, building_id: String) -> void:
|
||||
var bdata: Dictionary = DataLoader.get_building(building_id)
|
||||
var effects: Array = bdata.get("effects", [])
|
||||
|
|
@ -369,7 +383,8 @@ func _process_economy(player: RefCounted, game_map: RefCounted) -> void: # Play
|
|||
var c: CityScript = city_ref as CityScript
|
||||
var tile_json: String = BuildableHelperScript.build_tile_yields_json(c, game_map)
|
||||
var yields: Dictionary = c.get_yields(tile_json)
|
||||
income += int(yields.get("gold", 0))
|
||||
var building_gold: int = _sum_city_building_effect(c, "gold")
|
||||
income += int(yields.get("gold", 0)) + building_gold
|
||||
# Golden Age: +20% gold income
|
||||
if player.golden_age_active:
|
||||
income = int(income * 1.2)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue