349 lines
12 KiB
GDScript
349 lines
12 KiB
GDScript
class_name FG4Contract1Fixture
|
|
extends RefCounted
|
|
|
|
const FG3Fixture = preload("res://tests/fg3/contract1_fixture.gd")
|
|
const FG3Battle = preload("res://fg3/contract2_battle_service.gd")
|
|
const FG3Execution = preload("res://fg3/contract2_execution_service.gd")
|
|
const SaveV10 = preload("res://fg3/save_v10_service.gd")
|
|
const SaveV11 = preload("res://fg4/save_v11_service.gd")
|
|
const Battle = preload("res://fg4/contract1_battle_service.gd")
|
|
const Contract = preload("res://fg4/contract1_service.gd")
|
|
const Contract2Activation = preload("res://fg4/contract2_activation_service.gd")
|
|
const Contract2Battle = preload("res://fg4/contract2_battle_service.gd")
|
|
const Contract2 = preload("res://fg4/contract2_service.gd")
|
|
const RG04Activation = preload("res://fg4/rg04_activation_service.gd")
|
|
const RG04Battle = preload("res://fg4/rg04_contract1_battle_service.gd")
|
|
const RG04Contract1 = preload("res://fg4/rg04_contract1_service.gd")
|
|
const RG04Contract2Activation = preload("res://fg4/rg04_contract2_activation_service.gd")
|
|
const RG04Contract2Battle = preload("res://fg4/rg04_contract2_battle_service.gd")
|
|
const RG04Contract2 = preload("res://fg4/rg04_contract2_service.gd")
|
|
|
|
|
|
func fg3_region_closed_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := FG3Execution.new(FG3Fixture.new().contract2_boss_muster_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
var prepared := service.commit_boss_plan(
|
|
"fg4-fixture-fg3-boss-prepare",
|
|
service.state.revision,
|
|
String(service.state.current_run.boss_muster.muster_hash),
|
|
"interrupt_pulse_family"
|
|
)
|
|
if not prepared.ok:
|
|
return {}
|
|
var battle := FG3Battle.new(service.state.snapshot()).run_to_terminal("interrupt_pulse_family")
|
|
if not battle.ok or String(battle.snapshot.outcome) != "victory":
|
|
return {}
|
|
var settled := service.settle_boss(
|
|
"fg4-fixture-fg3-boss-settle",
|
|
service.state.revision,
|
|
battle.snapshot
|
|
)
|
|
if not settled.ok:
|
|
return {}
|
|
var closed := service.close_region(
|
|
"fg4-fixture-fg3-close",
|
|
service.state.revision,
|
|
String(service.state.current_run.pending_boss_result.close_id)
|
|
)
|
|
return service.state.snapshot() if closed.ok else {}
|
|
|
|
|
|
func encoded_v10(sequence: int = 100, artifact_id: String = "AR-011") -> Dictionary:
|
|
return SaveV10.new().encode_snapshot(fg3_region_closed_snapshot(artifact_id), sequence)
|
|
|
|
|
|
func migrated_v11(sequence: int = 100, artifact_id: String = "AR-011") -> Dictionary:
|
|
var encoded := encoded_v10(sequence, artifact_id)
|
|
if not bool(encoded.get("ok", false)):
|
|
return {}
|
|
return SaveV11.new().migrate_v10_text(String(encoded.text), sequence)
|
|
|
|
|
|
func market_1_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var migrated := migrated_v11(100, artifact_id)
|
|
return migrated.snapshot if bool(migrated.get("ok", false)) else {}
|
|
|
|
|
|
func boss_muster_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := Contract.new(market_1_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
for market_index in range(1, 13):
|
|
var route: Dictionary = service.state.current_run.market_board.battle_offers[0]
|
|
var prepared := service.commit_route(
|
|
"fg4-fixture-%02d-prepare" % market_index,
|
|
service.state.revision,
|
|
String(route.offer_id),
|
|
String(service.state.current_run.market_board.board_hash)
|
|
)
|
|
if not prepared.ok:
|
|
return {}
|
|
var plan_id := String(Battle.PRIMARY_PLAN[market_index])
|
|
var battle := Battle.new(service.state.snapshot()).run_to_terminal(plan_id)
|
|
if not battle.ok or String(battle.snapshot.outcome) != "victory":
|
|
return {}
|
|
var settled := service.settle_route(
|
|
"fg4-fixture-%02d-settle" % market_index,
|
|
service.state.revision,
|
|
battle.snapshot
|
|
)
|
|
if not settled.ok:
|
|
return {}
|
|
return service.state.snapshot()
|
|
|
|
|
|
func contract2_handoff_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := Contract.new(boss_muster_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
var prepared := service.commit_boss_plan(
|
|
"fg4-fixture-boss-prepare",
|
|
service.state.revision,
|
|
String(service.state.current_run.boss_muster.muster_hash),
|
|
"vent_and_brace"
|
|
)
|
|
if not prepared.ok:
|
|
return {}
|
|
var battle := Battle.new(service.state.snapshot()).run_to_terminal("vent_and_brace")
|
|
if not battle.ok or String(battle.snapshot.outcome) != "victory":
|
|
return {}
|
|
var settled := service.settle_boss(
|
|
"fg4-fixture-boss-settle",
|
|
service.state.revision,
|
|
battle.snapshot
|
|
)
|
|
if not settled.ok:
|
|
return {}
|
|
var closed := service.close_contract(
|
|
"fg4-fixture-contract-close",
|
|
service.state.revision,
|
|
String(service.state.current_run.pending_boss_result.close_id)
|
|
)
|
|
return service.state.snapshot() if closed.ok else {}
|
|
|
|
|
|
func contract2_market_1_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := Contract2Activation.new(contract2_handoff_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
var activated := service.activate_contract(
|
|
"fg4-fixture-contract2-activate",
|
|
service.state.revision,
|
|
String(service.state.current_run.market_board.handoff_hash)
|
|
)
|
|
return service.state.snapshot() if activated.ok else {}
|
|
|
|
|
|
func contract2_boss_muster_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := Contract2.new(contract2_market_1_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
for market_index in range(1, 13):
|
|
var route: Dictionary = service.state.current_run.market_board.battle_offers[0]
|
|
var prepared := service.commit_contract2_route(
|
|
"fg4-fixture-contract2-%02d-prepare" % market_index,
|
|
service.state.revision,
|
|
String(route.offer_id),
|
|
String(service.state.current_run.market_board.board_hash)
|
|
)
|
|
if not prepared.ok:
|
|
return {}
|
|
var plan_id := String(Contract2Battle.PRIMARY_PLAN[market_index])
|
|
var battle := Contract2Battle.new(service.state.snapshot()).run_to_terminal(plan_id)
|
|
if not battle.ok or String(battle.snapshot.outcome) != "victory":
|
|
return {}
|
|
var settled := service.settle_contract2_route(
|
|
"fg4-fixture-contract2-%02d-settle" % market_index,
|
|
service.state.revision,
|
|
battle.snapshot
|
|
)
|
|
if not settled.ok:
|
|
return {}
|
|
return service.state.snapshot()
|
|
|
|
|
|
func region_result_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := Contract2.new(contract2_boss_muster_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
var prepared := service.commit_contract2_boss_plan(
|
|
"fg4-fixture-contract2-boss-prepare",
|
|
service.state.revision,
|
|
String(service.state.current_run.boss_muster.muster_hash),
|
|
"vary_tags"
|
|
)
|
|
if not prepared.ok:
|
|
return {}
|
|
var battle := Contract2Battle.new(service.state.snapshot()).run_to_terminal("vary_tags")
|
|
if not battle.ok or String(battle.snapshot.outcome) != "victory":
|
|
return {}
|
|
var settled := service.settle_contract2_boss(
|
|
"fg4-fixture-contract2-boss-settle",
|
|
service.state.revision,
|
|
battle.snapshot
|
|
)
|
|
return service.state.snapshot() if settled.ok else {}
|
|
|
|
|
|
func region_closed_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := Contract2.new(region_result_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
var closed := service.close_region(
|
|
"fg4-fixture-rg03-close",
|
|
service.state.revision,
|
|
String(service.state.current_run.pending_boss_result.close_id)
|
|
)
|
|
return service.state.snapshot() if closed.ok else {}
|
|
|
|
|
|
func rg04_market_1_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := RG04Activation.new(region_closed_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
var activated := service.activate_region(
|
|
"fg4-fixture-rg04-activate",
|
|
service.state.revision,
|
|
String(service.state.current_run.market_board.result_hash)
|
|
)
|
|
return service.state.snapshot() if activated.ok else {}
|
|
|
|
|
|
func rg04_boss_muster_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := RG04Contract1.new(rg04_market_1_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
for market_index in range(1, 13):
|
|
var route: Dictionary = service.state.current_run.market_board.battle_offers[0]
|
|
var prepared := service.commit_route(
|
|
"fg4-fixture-rg04-%02d-prepare" % market_index,
|
|
service.state.revision,
|
|
String(route.offer_id),
|
|
String(service.state.current_run.market_board.board_hash)
|
|
)
|
|
if not prepared.ok:
|
|
return {}
|
|
var plan_id := String(RG04Battle.PRIMARY_PLAN[market_index])
|
|
var battle := RG04Battle.new(service.state.snapshot()).run_to_terminal(plan_id)
|
|
if not battle.ok or String(battle.snapshot.outcome) != "victory":
|
|
return {}
|
|
var settled := service.settle_route(
|
|
"fg4-fixture-rg04-%02d-settle" % market_index,
|
|
service.state.revision,
|
|
battle.snapshot
|
|
)
|
|
if not settled.ok:
|
|
return {}
|
|
return service.state.snapshot()
|
|
|
|
|
|
func rg04_contract_result_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := RG04Contract1.new(rg04_boss_muster_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
var prepared := service.commit_boss_plan(
|
|
"fg4-fixture-rg04-boss-prepare",
|
|
service.state.revision,
|
|
String(service.state.current_run.boss_muster.muster_hash),
|
|
"steer_action_count"
|
|
)
|
|
if not prepared.ok:
|
|
return {}
|
|
var battle := RG04Battle.new(service.state.snapshot()).run_to_terminal("steer_action_count")
|
|
if not battle.ok or String(battle.snapshot.outcome) != "victory":
|
|
return {}
|
|
var settled := service.settle_boss(
|
|
"fg4-fixture-rg04-boss-settle",
|
|
service.state.revision,
|
|
battle.snapshot
|
|
)
|
|
return service.state.snapshot() if settled.ok else {}
|
|
|
|
|
|
func rg04_contract2_handoff_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := RG04Contract1.new(rg04_contract_result_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
var closed := service.close_contract(
|
|
"fg4-fixture-rg04-contract-close",
|
|
service.state.revision,
|
|
String(service.state.current_run.pending_boss_result.close_id)
|
|
)
|
|
return service.state.snapshot() if closed.ok else {}
|
|
|
|
|
|
func rg04_contract2_market_1_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := RG04Contract2Activation.new(rg04_contract2_handoff_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
var activated := service.activate_contract(
|
|
"fg4-fixture-rg04-contract2-activate",
|
|
service.state.revision,
|
|
String(service.state.current_run.market_board.handoff_hash)
|
|
)
|
|
return service.state.snapshot() if activated.ok else {}
|
|
|
|
|
|
func rg04_contract2_boss_muster_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := RG04Contract2.new(rg04_contract2_market_1_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
for market_index in range(1, 13):
|
|
var route: Dictionary = service.state.current_run.market_board.battle_offers[0]
|
|
var prepared := service.commit_route(
|
|
"fg4-fixture-rg04-contract2-%02d-prepare" % market_index,
|
|
service.state.revision,
|
|
String(route.offer_id),
|
|
String(service.state.current_run.market_board.board_hash)
|
|
)
|
|
if not prepared.ok:
|
|
return {}
|
|
var plan_id := String(RG04Contract2Battle.PRIMARY_PLAN[market_index])
|
|
var battle := RG04Contract2Battle.new(service.state.snapshot()).run_to_terminal(plan_id)
|
|
if not battle.ok or String(battle.snapshot.outcome) != "victory":
|
|
return {}
|
|
var settled := service.settle_route(
|
|
"fg4-fixture-rg04-contract2-%02d-settle" % market_index,
|
|
service.state.revision,
|
|
battle.snapshot
|
|
)
|
|
if not settled.ok:
|
|
return {}
|
|
return service.state.snapshot()
|
|
|
|
|
|
func rg04_region_result_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := RG04Contract2.new(rg04_contract2_boss_muster_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
var prepared := service.commit_boss_plan(
|
|
"fg4-fixture-rg04-contract2-boss-prepare",
|
|
service.state.revision,
|
|
String(service.state.current_run.boss_muster.muster_hash),
|
|
"safe_rule_seed"
|
|
)
|
|
if not prepared.ok:
|
|
return {}
|
|
var battle := RG04Contract2Battle.new(service.state.snapshot()).run_to_terminal("safe_rule_seed")
|
|
if not battle.ok or String(battle.snapshot.outcome) != "victory":
|
|
return {}
|
|
var settled := service.settle_boss(
|
|
"fg4-fixture-rg04-contract2-boss-settle",
|
|
service.state.revision,
|
|
battle.snapshot
|
|
)
|
|
return service.state.snapshot() if settled.ok else {}
|
|
|
|
|
|
func rg04_region_closed_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := RG04Contract2.new(rg04_region_result_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
var closed := service.close_region(
|
|
"fg4-fixture-rg04-close",
|
|
service.state.revision,
|
|
String(service.state.current_run.pending_boss_result.close_id)
|
|
)
|
|
return service.state.snapshot() if closed.ok else {}
|