1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-14 21:15:58 +00:00

Game: Move debug logic out of Game

This commit is contained in:
John 2021-11-14 23:50:23 -06:00
parent 518e8fa5c4
commit 36cc6896b1
2 changed files with 12 additions and 18 deletions

View File

@ -1,18 +1,8 @@
extends Node
class ShipData:
var Coor: Vector2
var Length: int
var Orientation: bool #vertical is true, (Trueship = vertical) (Falseship = horizontal)
var light_theme = load("res://light_theme.tres")
var dark_theme = load("res://dark_theme.tres")
# Preloaded assets, to be used later
# TODO: Move Setup into the Player. It's just here, for now, so that it can be tested and the game doesn't appear broken
onready var Setup = preload("res://scenes/Game/Setup.tscn")
# TODO: Move Fire into the Player. See above.
onready var Fire = preload("res://scenes/Game/Fire.tscn")
# Path to Player class, for instantiating new Players in code
onready var Player = preload("res://scenes/Game/Player.tscn")
@ -33,11 +23,7 @@ var is_multiplayer = false
# Called when the node enters the scene tree for the first time.
func _ready():
# TODO: Move Setup into the Player.
var setup = Setup.instance()
setup.connect("game_ready", self, "game_setup")
add_child(setup)
get_node("ConfirmationDialog").get_ok().text = "Yes"
get_node("ConfirmationDialog").get_cancel().text = "No"
get_node("ConfirmationDialog").get_ok().rect_min_size.x = 100
@ -50,8 +36,6 @@ func _ready():
# TODO: Move Setup into the Player.
func game_setup(_ships):
print_debug("Congrats! Setup complete.")
# TODO: Move Fire into the Player.
add_child(Fire.instance())
# Member functions:
# game_start: starts the game

View File

@ -3,6 +3,12 @@ extends Node
# Path to Board class, for instantiating new Boards in code
var Board = "res://script/game/Gameplay/Board.gd"
# Preloaded assets, to be used later
# TODO: Move Setup into the Player. It's just here, for now, so that it can be tested and the game doesn't appear broken
onready var Setup = preload("res://scenes/Game/Setup.tscn")
# TODO: Move Fire into the Player. See above.
onready var Fire = preload("res://scenes/Game/Fire.tscn")
# Player ID of this player
var pid
# board (an instance of the Board class)
@ -10,7 +16,9 @@ onready var board = Board.new()
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
var setup = Setup.instance()
setup.connect("game_ready", self, "game_setup")
add_child(setup)
# Member functions:
# hit: Called when opponent fires on us.
@ -40,6 +48,8 @@ func set_up(ships):
# Initiates the player's turn, and blocks until the player selects a location to fire upon
# returns: fire = [player id, target coordinates]
func turnStart():
# TODO: Yielf until Fire return
add_child(Fire.instance())
var player_id = 0
var target = Vector2(0,0)
return [player_id, target]