Add gas bomber skill-shot vessel
This commit is contained in:
parent
d0a9f5b971
commit
1d9afcbc2e
28 changed files with 882 additions and 85 deletions
|
|
@ -17,12 +17,19 @@ func _ready() -> void:
|
|||
GameState.fleet_cargo = 24
|
||||
GameState.fleet_gas_cargo = 12
|
||||
GameState.unlocked = ["shipyards", "logistics", "freight"]
|
||||
GameState.vessel_levels["unlock_gas_bomber"] = 1
|
||||
var main: Node = load("res://Main.tscn").instantiate()
|
||||
add_child(main)
|
||||
main.get_node("BackgroundLayer").visible = false
|
||||
main.get_node("Fleet").visible = false
|
||||
main.get_node("AsteroidField").visible = false
|
||||
main.get_node("PlanetField").visible = false
|
||||
main.get_node("BuildingField").visible = false
|
||||
main.get_node("EnemySpawner").set_process(false)
|
||||
main.get_node("BuildingField").place(GameState.BUILDING_SHIP_CRAFTER, Vector2(400.0, 0.0))
|
||||
var crafter_id: int = int(GameState.buildings[-1].id)
|
||||
GameState.deposit_to_building(crafter_id, 42)
|
||||
GameState.find_building(crafter_id).gas_stock = 18
|
||||
GameState.deposit_resource_to_building(crafter_id, GameState.RESOURCE_GAS, 18)
|
||||
var bc: Node = main.get_node("BuildController")
|
||||
bc.craft_building_id = crafter_id
|
||||
# The shared header (#24) is the thing worth eyeballing here, so give it
|
||||
|
|
|
|||
38
tests/_gas_bomb_aim_preview.gd
Normal file
38
tests/_gas_bomb_aim_preview.gd
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
GameState.buildings.clear()
|
||||
GameState.extractors.clear()
|
||||
GameState.transporters.clear()
|
||||
GameState.vessel_levels["unlock_gas_bomber"] = 1
|
||||
var main: Node = load("res://Main.tscn").instantiate()
|
||||
add_child(main)
|
||||
main.get_node("BackgroundLayer").visible = false
|
||||
main.get_node("AsteroidField").visible = false
|
||||
main.get_node("PlanetField").visible = false
|
||||
main.get_node("BuildingField").visible = false
|
||||
main.get_node("EnemySpawner").set_process(false)
|
||||
main.get_node("AsteroidField").set_process(false)
|
||||
var fleet: Node = main.get_node("Fleet")
|
||||
fleet.spawn_ships(3, Vector2.ZERO, PackedStringArray([
|
||||
GameState.VESSEL_INTERCEPTOR, GameState.VESSEL_SHIELD,
|
||||
GameState.VESSEL_GAS_BOMBER]))
|
||||
var skill: GasBombController = main.get_node("GasBombController")
|
||||
skill._process(0.0)
|
||||
main.get_node("Camera2D").zoom = Vector2(1.8, 1.8)
|
||||
var button: Control = main.get_node("UI/GasBombButton")
|
||||
var press := InputEventScreenTouch.new()
|
||||
press.index = 9
|
||||
press.position = button.global_position + button.size * 0.5
|
||||
press.pressed = true
|
||||
skill.handle_touch(press)
|
||||
var drag := InputEventScreenDrag.new()
|
||||
drag.index = 9
|
||||
drag.position = press.position + Vector2(-245, -235)
|
||||
skill.handle_drag(drag)
|
||||
for offset in [Vector2(-65, 0), Vector2(45, -45), Vector2(55, 65)]:
|
||||
var enemy: Node = load("res://Enemy.tscn").instantiate()
|
||||
enemy.position = skill.aim_target + offset
|
||||
enemy.speed = 0.0
|
||||
main.add_child(enemy)
|
||||
1
tests/_gas_bomb_aim_preview.gd.uid
Normal file
1
tests/_gas_bomb_aim_preview.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dcokscjlrguje
|
||||
6
tests/_gas_bomb_aim_preview.tscn
Normal file
6
tests/_gas_bomb_aim_preview.tscn
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://tests/_gas_bomb_aim_preview.gd" id="1"]
|
||||
|
||||
[node name="GasBombAimPreview" type="Node2D"]
|
||||
script = ExtResource("1")
|
||||
|
|
@ -11,13 +11,19 @@ func _ready() -> void:
|
|||
GameState.stored_vessels = [
|
||||
GameState.VESSEL_INTERCEPTOR,
|
||||
GameState.VESSEL_SHIELD, GameState.VESSEL_SHIELD,
|
||||
GameState.VESSEL_GAS_BOMBER,
|
||||
]
|
||||
var main: Node = load("res://Main.tscn").instantiate()
|
||||
add_child(main)
|
||||
main.get_node("BackgroundLayer").visible = false
|
||||
main.get_node("AsteroidField").visible = false
|
||||
main.get_node("PlanetField").visible = false
|
||||
main.get_node("BuildingField").visible = false
|
||||
main.get_node("AsteroidField").set_process(false)
|
||||
main.get_node("EnemySpawner").set_process(false)
|
||||
main.get_node("Fleet").spawn_ships(3, Vector2.ZERO, PackedStringArray([
|
||||
GameState.VESSEL_INTERCEPTOR, GameState.VESSEL_INTERCEPTOR,
|
||||
GameState.VESSEL_SHIELD,
|
||||
GameState.VESSEL_GAS_BOMBER,
|
||||
]))
|
||||
main.get_node("BuildController")._on_hangar_pressed()
|
||||
|
|
|
|||
|
|
@ -16,19 +16,22 @@ func _ready() -> void:
|
|||
GameState.unlocked = ["shipyards", "vessel_science"]
|
||||
var main: Node = load("res://Main.tscn").instantiate()
|
||||
add_child(main)
|
||||
main.get_node("BackgroundLayer").visible = false
|
||||
main.get_node("Fleet").visible = false
|
||||
main.get_node("AsteroidField").visible = false
|
||||
main.get_node("PlanetField").visible = false
|
||||
main.get_node("BuildingField").visible = false
|
||||
main.get_node("EnemySpawner").set_process(false)
|
||||
main.get_node("BuildingField").place(GameState.BUILDING_SHIP_LAB, Vector2(400.0, 0.0))
|
||||
var lab_id: int = int(GameState.buildings[-1].id)
|
||||
GameState.deposit_to_building(lab_id, 18)
|
||||
GameState.fleet_cargo = 12
|
||||
GameState.fleet_gas_cargo = 8
|
||||
# A level already bought, so the list shows both a researched and an
|
||||
# unresearched line rather than a uniform page of zeroes.
|
||||
GameState.vessel_levels["int_damage"] = 1
|
||||
var bc: Node = main.get_node("BuildController")
|
||||
# The shared header (#24) hides its HERE column when it has no building,
|
||||
# so bind it the way opening the panel from the building does.
|
||||
for bar in bc.resource_bars:
|
||||
bar.building_id = lab_id
|
||||
main.get_node("UI/LabMenu").visible = true
|
||||
bc.lab_vessel = GameState.VESSEL_INTERCEPTOR
|
||||
bc.lab_vessel = GameState.VESSEL_GAS_BOMBER
|
||||
bc._refresh_lab()
|
||||
|
|
|
|||
151
tests/test_gas_bomber.gd
Normal file
151
tests/test_gas_bomber.gd
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
extends SceneTree
|
||||
|
||||
var game_state: Node
|
||||
var main: Node
|
||||
var fleet: Node
|
||||
var skill: GasBombController
|
||||
var inside_enemies: Array = []
|
||||
var outside_enemy: Node
|
||||
var stage := 0
|
||||
var elapsed := 0.0
|
||||
var original_zoom := 2.5
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
game_state = root.get_node("GameState")
|
||||
game_state.buildings.clear()
|
||||
game_state.extractors.clear()
|
||||
game_state.transporters.clear()
|
||||
game_state.stored_vessels.clear()
|
||||
game_state.vessel_deliveries.clear()
|
||||
game_state.reset_progression()
|
||||
game_state.rocks = 0
|
||||
game_state.gas = 0
|
||||
game_state.fleet_cargo = 0
|
||||
game_state.fleet_gas_cargo = 0
|
||||
game_state.build_time_scale = 0.01
|
||||
|
||||
# Research is gas-only: any amount of ore and 29 gas must still leave it
|
||||
# waiting, then the thirtieth unit starts and completes the unlock.
|
||||
var lab_id: int = game_state.add_building(GameState.BUILDING_SHIP_LAB, Vector2.ZERO)
|
||||
if not game_state.queue_lab_research(lab_id, "unlock_gas_bomber"):
|
||||
_fail_now("could not queue Gas Bomber research")
|
||||
return
|
||||
game_state.deposit_resource_to_building(lab_id, GameState.RESOURCE_ORE, 200)
|
||||
game_state.deposit_resource_to_building(lab_id, GameState.RESOURCE_GAS, 29)
|
||||
game_state._advance_lab_research(10.0)
|
||||
if game_state.outstanding_resource_cost(lab_id, GameState.RESOURCE_GAS) != 1 \
|
||||
or game_state.outstanding_resource_cost(lab_id, GameState.RESOURCE_ORE) != 0:
|
||||
_fail_now("research shortfall was not tracked as gas")
|
||||
return
|
||||
if game_state.vessel_is_unlocked(GameState.VESSEL_GAS_BOMBER):
|
||||
_fail_now("Gas Bomber unlocked without its full gas cost")
|
||||
return
|
||||
game_state.deposit_resource_to_building(lab_id, GameState.RESOURCE_GAS, 1)
|
||||
game_state._advance_lab_research(10.0)
|
||||
if not game_state.vessel_is_unlocked(GameState.VESSEL_GAS_BOMBER):
|
||||
_fail_now("30 gas did not unlock the Gas Bomber")
|
||||
return
|
||||
|
||||
# Crafting requires both resources and preserves the vessel type.
|
||||
var crafter_id: int = game_state.add_building(GameState.BUILDING_SHIP_CRAFTER, Vector2.ZERO)
|
||||
if not game_state.queue_order(crafter_id, GameState.VESSEL_GAS_BOMBER):
|
||||
_fail_now("unlocked Gas Bomber could not be queued")
|
||||
return
|
||||
game_state.deposit_resource_to_building(crafter_id, GameState.RESOURCE_ORE, 10)
|
||||
game_state.deposit_resource_to_building(crafter_id, GameState.RESOURCE_GAS, 7)
|
||||
game_state._advance_production(10.0)
|
||||
if game_state.outstanding_resource_cost(crafter_id, GameState.RESOURCE_GAS) != 1 \
|
||||
or game_state.outstanding_resource_cost(crafter_id, GameState.RESOURCE_ORE) != 0:
|
||||
_fail_now("crafting shortfall was not tracked as gas")
|
||||
return
|
||||
if not game_state.order_list(crafter_id).is_empty() \
|
||||
and bool(game_state.order_list(crafter_id)[0].started):
|
||||
_fail_now("Gas Bomber started with insufficient gas")
|
||||
return
|
||||
game_state.deposit_resource_to_building(crafter_id, GameState.RESOURCE_GAS, 1)
|
||||
game_state._advance_production(10.0)
|
||||
if game_state.stored_vessels != [GameState.VESSEL_GAS_BOMBER]:
|
||||
_fail_now("crafting did not produce a typed Gas Bomber")
|
||||
return
|
||||
|
||||
main = load("res://Main.tscn").instantiate()
|
||||
root.add_child(main)
|
||||
fleet = main.get_node("Fleet")
|
||||
skill = main.get_node("GasBombController")
|
||||
|
||||
|
||||
func _process(delta: float) -> bool:
|
||||
elapsed += delta
|
||||
match stage:
|
||||
0:
|
||||
if elapsed < 0.2:
|
||||
return false
|
||||
main.get_node("EnemySpawner").set_process(false)
|
||||
main.get_node("AsteroidField").set_process(false)
|
||||
if main.get_node("UI/GasBombButton").visible:
|
||||
return _fail_now("bomb control appeared without a Gas Bomber")
|
||||
fleet.spawn_ships(2, Vector2.ZERO, PackedStringArray([
|
||||
GameState.VESSEL_INTERCEPTOR, GameState.VESSEL_GAS_BOMBER]))
|
||||
main.get_node("Camera2D").zoom = Vector2(original_zoom, original_zoom)
|
||||
skill._process(0.0)
|
||||
if not main.get_node("UI/GasBombButton").visible:
|
||||
return _fail_now("fleet Gas Bomber did not reveal the bomb control")
|
||||
|
||||
var press := InputEventScreenTouch.new()
|
||||
press.index = 7
|
||||
var bomb_button: Control = main.get_node("UI/GasBombButton")
|
||||
press.position = bomb_button.global_position + bomb_button.size * 0.5
|
||||
press.pressed = true
|
||||
main._handle_touch(press)
|
||||
if not skill.aiming:
|
||||
return _fail_now("bomb control did not begin aiming")
|
||||
var drag := InputEventScreenDrag.new()
|
||||
drag.index = 7
|
||||
drag.position = Vector2(350, 700)
|
||||
main._handle_drag(drag)
|
||||
if main.get_node("Camera2D").zoom.x >= original_zoom:
|
||||
return _fail_now("long aim did not zoom out")
|
||||
|
||||
for offset in [Vector2(-60, 0), Vector2(70, 35)]:
|
||||
var enemy: Node = load("res://Enemy.tscn").instantiate()
|
||||
enemy.position = skill.aim_target + offset
|
||||
enemy.speed = 0.0
|
||||
main.add_child(enemy)
|
||||
inside_enemies.append(enemy)
|
||||
outside_enemy = load("res://Enemy.tscn").instantiate()
|
||||
outside_enemy.position = skill.aim_target + Vector2(GasBombController.AOE_RADIUS + 80.0, 0)
|
||||
outside_enemy.speed = 0.0
|
||||
main.add_child(outside_enemy)
|
||||
|
||||
var release := InputEventScreenTouch.new()
|
||||
release.index = 7
|
||||
release.position = drag.position
|
||||
release.pressed = false
|
||||
main._handle_touch(release)
|
||||
if not skill.projectile_active:
|
||||
return _fail_now("release did not throw a gas bomb")
|
||||
elapsed = 0.0
|
||||
stage = 1
|
||||
1:
|
||||
if elapsed < 2.5:
|
||||
return false
|
||||
if skill.last_hit_count != 2:
|
||||
return _fail_now("AOE hit %d enemies instead of 2" % skill.last_hit_count)
|
||||
for enemy in inside_enemies:
|
||||
if is_instance_valid(enemy):
|
||||
return _fail_now("an enemy inside the AOE survived")
|
||||
if not is_instance_valid(outside_enemy) or outside_enemy.hp != outside_enemy.max_hp:
|
||||
return _fail_now("the AOE damaged an enemy outside its radius")
|
||||
if absf(main.get_node("Camera2D").zoom.x - original_zoom) > 0.03:
|
||||
return _fail_now("camera did not restore its pre-aim zoom")
|
||||
print("TEST_GAS_BOMBER: PASS")
|
||||
quit(0)
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _fail_now(message: String) -> bool:
|
||||
print("TEST_GAS_BOMBER: FAIL (%s)" % message)
|
||||
quit(1)
|
||||
return true
|
||||
1
tests/test_gas_bomber.gd.uid
Normal file
1
tests/test_gas_bomber.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c3vtwrwjpmcbm
|
||||
42
tests/test_multi_resource_supply.gd
Normal file
42
tests/test_multi_resource_supply.gd
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
extends SceneTree
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
var state: Node = root.get_node("GameState")
|
||||
state.buildings.clear()
|
||||
state.extractors.clear()
|
||||
state.transporters.clear()
|
||||
state.stored_vessels.clear()
|
||||
state.reset_progression()
|
||||
state.rocks = 0
|
||||
state.gas = 30
|
||||
state.build_time_scale = 0.01
|
||||
|
||||
state.add_building(GameState.BUILDING_MOTHERSHIP, Vector2.ZERO)
|
||||
state.add_building(GameState.BUILDING_TRANSPORT_HUB, Vector2.ZERO)
|
||||
var lab_id: int = state.add_building(GameState.BUILDING_SHIP_LAB, Vector2(120, 0))
|
||||
if not state.queue_lab_research(lab_id, "unlock_gas_bomber"):
|
||||
_fail("could not queue gas research")
|
||||
return
|
||||
if state.outstanding_resource_cost(lab_id, GameState.RESOURCE_GAS) != 30:
|
||||
_fail("lab did not request 30 gas")
|
||||
return
|
||||
|
||||
# Large steps make each physical leg complete in one call; multiple calls
|
||||
# still exercise dispatch -> bank pickup -> lab delivery -> hub return.
|
||||
for i in range(12):
|
||||
state._advance_transporters(10.0)
|
||||
state._advance_lab_research(10.0)
|
||||
if not state.vessel_is_unlocked(GameState.VESSEL_GAS_BOMBER):
|
||||
_fail("hub transporters did not deliver gas to research")
|
||||
return
|
||||
if state.gas != 0 or state.building_resource(lab_id, GameState.RESOURCE_GAS) != 0:
|
||||
_fail("gas was not consumed at the lab")
|
||||
return
|
||||
print("TEST_MULTI_RESOURCE_SUPPLY: PASS")
|
||||
quit(0)
|
||||
|
||||
|
||||
func _fail(message: String) -> void:
|
||||
print("TEST_MULTI_RESOURCE_SUPPLY: FAIL (%s)" % message)
|
||||
quit(1)
|
||||
1
tests/test_multi_resource_supply.gd.uid
Normal file
1
tests/test_multi_resource_supply.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d34djd8v1r1jd
|
||||
|
|
@ -23,7 +23,7 @@ func _process(delta: float) -> bool:
|
|||
return false
|
||||
var definitions: Array = VESSEL_DEFINITIONS.all()
|
||||
var fleet_definitions: Array = VESSEL_DEFINITIONS.fleet()
|
||||
if fleet_definitions.size() != 2 \
|
||||
if fleet_definitions.size() != 3 \
|
||||
or fleet_definitions.any(func(definition): return definition.has_capability("transport")):
|
||||
return _fail("logistics transporters leaked into the combat-fleet catalog")
|
||||
if ships.size() != definitions.size():
|
||||
|
|
@ -45,7 +45,13 @@ func _process(delta: float) -> bool:
|
|||
or definitions[1].hull_points.size() != 6
|
||||
or definitions[1].icon != IconButton.Icon.SHIELD_VESSEL):
|
||||
return _fail("shield vessel is not an unarmed hexagon")
|
||||
if ships[2].has_capability("weapon") or not ships[2].has_capability("transport"):
|
||||
var gas_index: int = VESSEL_DEFINITIONS.ORDER.find(GameState.VESSEL_GAS_BOMBER)
|
||||
if gas_index < 0 or ships[gas_index].has_capability("weapon") \
|
||||
or not ships[gas_index].definition.has_capability("gas_bomber"):
|
||||
return _fail("gas bomber is not an unarmed skill vessel")
|
||||
var transporter_index: int = VESSEL_DEFINITIONS.ORDER.find(GameState.VESSEL_TRANSPORTER)
|
||||
if ships[transporter_index].has_capability("weapon") \
|
||||
or not ships[transporter_index].has_capability("transport"):
|
||||
return _fail("transporter capabilities were composed incorrectly")
|
||||
print("TEST_VESSEL_COMPOSITION: PASS")
|
||||
quit(0)
|
||||
|
|
|
|||
Loading…
Reference in a new issue