Files
aetherbound-guild/runtime/tests/p10_1/first_crossing_fixture.gd
T

85 lines
3.0 KiB
GDScript

class_name P101FirstCrossingFixture
extends RefCounted
const P100Market = preload("res://p10_0/market_service.gd")
const State = preload("res://p10_1/region_run_state.gd")
const RegionService = preload("res://p10_1/region_market_service.gd")
func prepared_snapshot(route_index: int) -> Dictionary:
var service = prepared_service(route_index)
return service.state.snapshot() if service != null else {}
func prepared_service(route_index: int):
if route_index < 0 or route_index > 2:
return null
var service = market_with_healer()
if service == null:
return null
var offers: Array = Array(service.state.current_run.market_board.recruit_offers).duplicate(true)
var healers: Array = offers.filter(func(offer): return offer.profession_id == "PF-B07")
var partners: Array = offers.filter(func(offer): return offer.profession_id != "PF-B07")
if healers.is_empty() or partners.is_empty():
return null
var healer: Dictionary = healers[0]
var partner: Dictionary = partners[0]
for offer in [partner, healer]:
var hire: Dictionary = service.hire(
"battle-hire-%s" % offer.source_offer_id,
service.state.revision,
String(offer.source_offer_id),
int(offer.list_price)
)
if not hire.ok:
return null
var guardrails: Array = service.state.current_run.market_board.equipment_offers.filter(func(offer): return offer.catalog_id == "EQ-046")
if guardrails.is_empty():
return null
var guardrail: Dictionary = guardrails[0]
var bought: Dictionary = service.buy_equipment(
"battle-buy-guardrail",
service.state.revision,
String(guardrail.offer_id),
int(guardrail.list_price)
)
if not bought.ok:
return null
var equipped: Dictionary = service.equip(
"battle-equip-guardrail",
service.state.revision,
String(healer.recruit_id),
String(bought.receipt.instance_id)
)
if not equipped.ok:
return null
var route: Dictionary = service.state.current_run.market_board.battle_offers[route_index]
var prepared: Dictionary = service.commit_route(
"battle-route-%d" % route_index,
service.state.revision,
String(route.offer_id),
String(service.state.current_run.market_board.board_hash)
)
return service if prepared.ok else null
func market_with_healer():
for seed_index in range(1, 129):
var root_seed := ("p10.1-healer-fixture-%d" % seed_index).sha256_text().substr(0, 32)
var p100 := P100Market.new({}, root_seed, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
var raw: Dictionary = p100.state.snapshot()
raw.guild_profile.persistent_renown = 32
raw.guild_profile.contract_clear_ids = ["CLEAR-RG01-C01", "CLEAR-RG01-C02"]
raw.guild_profile.unlocked_region_ids = ["RG-01", "RG-02"]
if not p100.restore_snapshot(raw):
continue
var state := State.new()
if not state.initialize_from_p100(p100.state.snapshot()):
continue
var service = RegionService.new(state.snapshot())
if not service.begin_region_run("battle-entry", 0, "standard").ok:
continue
if service.state.current_run.market_board.recruit_offers.any(func(offer): return offer.profession_id == "PF-B07"):
return service
return null