1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-15 05:25:57 +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 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 light_theme = load("res://light_theme.tres")
var dark_theme = load("res://dark_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 # Path to Player class, for instantiating new Players in code
onready var Player = preload("res://scenes/Game/Player.tscn") 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. # Called when the node enters the scene tree for the first time.
func _ready(): 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_ok().text = "Yes"
get_node("ConfirmationDialog").get_cancel().text = "No" get_node("ConfirmationDialog").get_cancel().text = "No"
get_node("ConfirmationDialog").get_ok().rect_min_size.x = 100 get_node("ConfirmationDialog").get_ok().rect_min_size.x = 100
@ -50,8 +36,6 @@ func _ready():
# TODO: Move Setup into the Player. # TODO: Move Setup into the Player.
func game_setup(_ships): func game_setup(_ships):
print_debug("Congrats! Setup complete.") print_debug("Congrats! Setup complete.")
# TODO: Move Fire into the Player.
add_child(Fire.instance())
# Member functions: # Member functions:
# game_start: starts the game # game_start: starts the game

View File

@ -3,6 +3,12 @@ extends Node
# Path to Board class, for instantiating new Boards in code # Path to Board class, for instantiating new Boards in code
var Board = "res://script/game/Gameplay/Board.gd" 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 # Player ID of this player
var pid var pid
# board (an instance of the Board class) # 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. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. var setup = Setup.instance()
setup.connect("game_ready", self, "game_setup")
add_child(setup)
# Member functions: # Member functions:
# hit: Called when opponent fires on us. # 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 # Initiates the player's turn, and blocks until the player selects a location to fire upon
# returns: fire = [player id, target coordinates] # returns: fire = [player id, target coordinates]
func turnStart(): func turnStart():
# TODO: Yielf until Fire return
add_child(Fire.instance())
var player_id = 0 var player_id = 0
var target = Vector2(0,0) var target = Vector2(0,0)
return [player_id, target] return [player_id, target]