175 lines
6.1 KiB
GDScript
175 lines
6.1 KiB
GDScript
class_name FG3Contract1Fixture
|
|
extends RefCounted
|
|
|
|
const P103Battle = preload("res://p10_3/deep_channels_battle_service.gd")
|
|
const P103Fixture = preload("res://tests/p10_3/deep_channels_fixture.gd")
|
|
const P103Growth = preload("res://p10_3/growth_service.gd")
|
|
const P103Preparation = preload("res://p10_3/deep_channels_preparation_service.gd")
|
|
const P103Resolution = preload("res://p10_3/deep_channels_resolution_service.gd")
|
|
const SaveV9 = preload("res://p10_3/save_v9_service.gd")
|
|
const SaveV10 = preload("res://fg3/save_v10_service.gd")
|
|
const FG3Battle = preload("res://fg3/contract1_battle_service.gd")
|
|
const FG3Contract = preload("res://fg3/contract1_service.gd")
|
|
const FG3Contract2 = preload("res://fg3/contract2_service.gd")
|
|
const FG3Contract2Battle = preload("res://fg3/contract2_battle_service.gd")
|
|
const FG3Contract2Execution = preload("res://fg3/contract2_execution_service.gd")
|
|
|
|
|
|
func p103_market_8_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var snapshot_value := P103Fixture.new().market_7_snapshot(true)
|
|
if snapshot_value.is_empty():
|
|
return {}
|
|
var growth := P103Growth.new(snapshot_value)
|
|
var selected := growth.select_artifact(
|
|
"fg3-fixture-artifact-%s" % artifact_id,
|
|
growth.state.revision,
|
|
String(growth.state.current_run.artifact_draft.draft_hash),
|
|
artifact_id
|
|
)
|
|
if not selected.ok:
|
|
return {}
|
|
var preparation := P103Preparation.new(growth.state.snapshot())
|
|
var route: Dictionary = preparation.state.current_run.market_board.battle_offers[0]
|
|
var prepared := preparation.commit_route(
|
|
"fg3-fixture-market7-route",
|
|
preparation.state.revision,
|
|
String(route.offer_id),
|
|
String(preparation.state.current_run.market_board.board_hash)
|
|
)
|
|
if not prepared.ok:
|
|
return {}
|
|
var plan_id := String(P103Battle.PREFERRED_PLAN[String(route.route_id)])
|
|
var battle := P103Battle.new(preparation.state.snapshot()).run_to_terminal(plan_id)
|
|
if not battle.ok or String(battle.snapshot.outcome) != "victory":
|
|
return {}
|
|
var resolution := P103Resolution.new(preparation.state.snapshot())
|
|
var settled := resolution.settle(
|
|
"fg3-fixture-market7-settle",
|
|
resolution.state.revision,
|
|
battle.snapshot
|
|
)
|
|
if not settled.ok or String(resolution.state.current_run.phase) != "market_8":
|
|
return {}
|
|
return resolution.state.snapshot()
|
|
|
|
|
|
func encoded_v9(sequence: int = 60, artifact_id: String = "AR-011") -> Dictionary:
|
|
return SaveV9.new().encode_snapshot(p103_market_8_snapshot(artifact_id), sequence)
|
|
|
|
|
|
func migrated_v10(sequence: int = 60, artifact_id: String = "AR-011") -> Dictionary:
|
|
var encoded := encoded_v9(sequence, artifact_id)
|
|
if not encoded.ok:
|
|
return {}
|
|
return SaveV10.new().migrate_v9_text(String(encoded.text), sequence)
|
|
|
|
|
|
func fg3_market_8_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var migrated := migrated_v10(60, artifact_id)
|
|
return migrated.snapshot if bool(migrated.get("ok", false)) else {}
|
|
|
|
|
|
func boss_muster_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := FG3Contract.new(fg3_market_8_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
for round_index in [8, 9, 10, 11, 12]:
|
|
var route: Dictionary = service.state.current_run.market_board.battle_offers[0]
|
|
var prepared := service.commit_route(
|
|
"fg3-fixture-round-%d-prepare" % round_index,
|
|
service.state.revision,
|
|
String(route.offer_id),
|
|
String(service.state.current_run.market_board.board_hash)
|
|
)
|
|
if not prepared.ok:
|
|
return {}
|
|
var battle := FG3Battle.new(service.state.snapshot()).run_to_terminal(
|
|
String(FG3Battle.PREFERRED_PLAN[String(route.route_id)])
|
|
)
|
|
if not battle.ok or String(battle.snapshot.outcome) != "victory":
|
|
return {}
|
|
var settled := service.settle_route(
|
|
"fg3-fixture-round-%d-settle" % round_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 := FG3Contract.new(boss_muster_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
var muster_hash := String(service.state.current_run.boss_muster.muster_hash)
|
|
var prepared := service.commit_boss_plan(
|
|
"fg3-fixture-boss-prepare",
|
|
service.state.revision,
|
|
muster_hash,
|
|
"follow_index_clear_eggs"
|
|
)
|
|
if not prepared.ok:
|
|
return {}
|
|
var battle := FG3Battle.new(service.state.snapshot()).run_to_terminal(
|
|
"follow_index_clear_eggs"
|
|
)
|
|
if not battle.ok or String(battle.snapshot.outcome) != "victory":
|
|
return {}
|
|
var settled := service.settle_boss(
|
|
"fg3-fixture-boss-settle",
|
|
service.state.revision,
|
|
battle.snapshot
|
|
)
|
|
if not settled.ok:
|
|
return {}
|
|
var closed := service.close_contract(
|
|
"fg3-fixture-contract1-close",
|
|
service.state.revision,
|
|
String(service.state.current_run.pending_boss_result.close_id)
|
|
)
|
|
if not closed.ok:
|
|
return {}
|
|
return service.state.snapshot()
|
|
|
|
|
|
func contract2_market_1_snapshot(artifact_id: String = "AR-011") -> Dictionary:
|
|
var service := FG3Contract2.new(contract2_handoff_snapshot(artifact_id))
|
|
if not service.valid:
|
|
return {}
|
|
var activated := service.activate_contract(
|
|
"fg3-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 := FG3Contract2Execution.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_route(
|
|
"fg3-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 battle := FG3Contract2Battle.new(service.state.snapshot()).run_to_terminal(
|
|
String(FG3Contract2Battle.PRIMARY_PLAN[market_index])
|
|
)
|
|
if not battle.ok or String(battle.snapshot.outcome) != "victory":
|
|
return {}
|
|
var settled := service.settle_route(
|
|
"fg3-fixture-contract2-%02d-settle" % market_index,
|
|
service.state.revision,
|
|
battle.snapshot
|
|
)
|
|
if not settled.ok:
|
|
return {}
|
|
return service.state.snapshot()
|