diff --git a/godot_ship/script/game/Gameplay/Board.gd b/godot_ship/script/game/Gameplay/Board.gd new file mode 100644 index 0000000..90dc099 --- /dev/null +++ b/godot_ship/script/game/Gameplay/Board.gd @@ -0,0 +1,27 @@ +extends Node + +var bottomBoard # Player board +var topBoard # Opponent board +var ships # list of Ships +var shipCount # number of 'active' (un-sunk) ships + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + +func getState(): + pass + +func placeShip(): + pass + +func getBottomBoard(): + pass + +func getShipCount(): + pass diff --git a/godot_ship/script/game/Gameplay/Game.gd b/godot_ship/script/game/Gameplay/Game.gd new file mode 100644 index 0000000..5289713 --- /dev/null +++ b/godot_ship/script/game/Gameplay/Game.gd @@ -0,0 +1,25 @@ +extends Node + +var players # = player1, player2, ... +var turnCount = 0 +var wasHit = false +var isMultiplayer = false + +# Called when the node enters the scene tree for the first time. +func _ready(): + gameStart() + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + +func gameStart(): + pass + +func victoryScreen(): + pass + +func displayTurn(): + pass diff --git a/godot_ship/script/game/Gameplay/Player.gd b/godot_ship/script/game/Gameplay/Player.gd new file mode 100644 index 0000000..ddaa32c --- /dev/null +++ b/godot_ship/script/game/Gameplay/Player.gd @@ -0,0 +1,51 @@ +extends Node + +var pid +var board + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + +# hit: Called when opponent fires on us. +# Update internal state, and return bool hit/miss +func hit(): + pass + +# placeShip: called when ships are placed. +# forwards Ship locations to the Board, so that it may construct a ship +# ship: a list of ship properties {possition, orientation, size} +func placeShips(_ship): + pass + +# setUp: set up the board given the placed ship locations +# translates the ship positions in the Setup UI to board-space, then places each ship +# ships: a list of lists of ship properties {{position, orientation, size}, ...} +func setUp(_ships): + pass + +# turnStart: start player's turn +# Initiates the player's turn, and blocks until the player selects a location to fire upon +# returns: fire {player, coordinates} +func turnStart(): + pass + +# getBoard: returns the player's board +# returns: board +func getBoard(): + return board + +# forfeit: ends game for player +# Sinks all ships +func forfeit(): + pass + +# getShipCount: get the number of ships the player has left alive +func getShipCount(): + pass + diff --git a/godot_ship/script/game/Gameplay/Ship.gd b/godot_ship/script/game/Gameplay/Ship.gd new file mode 100644 index 0000000..d8799b8 --- /dev/null +++ b/godot_ship/script/game/Gameplay/Ship.gd @@ -0,0 +1,40 @@ +extends Node + +# This is the rendered element of a "ship", auto-generated when + +var size = 0 # Size of ship in units +var position # Coordinates of ship's center. Ship extends [-(size-1 >> 1), (size/2 >> 1)] +var sunk = false +var orientation = false + +# index into ship sprite table +var texture = 0 + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + +func getSize(): + return size + +func getPosition(): + return position + +func getOrientation(): + return orientation + +func getSunk(): + return sunk + +func setSunk(): + sunk = true + +func makeShip(in_position, in_size, in_orientation): + position = in_position + size = in_size + orientation = in_orientation