From 66cac5247f8c8a5b18ffd4bdecea0a22c269c9af Mon Sep 17 00:00:00 2001 From: John Breaux Date: Wed, 24 Nov 2021 02:53:05 -0600 Subject: [PATCH] Board: Return LOST state when hit and no ships remain. --- godot_ship/script/game/Gameplay/Board.gd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/godot_ship/script/game/Gameplay/Board.gd b/godot_ship/script/game/Gameplay/Board.gd index 894ad19..fd72f58 100644 --- a/godot_ship/script/game/Gameplay/Board.gd +++ b/godot_ship/script/game/Gameplay/Board.gd @@ -5,7 +5,7 @@ var Ship = preload("res://scenes/Game/Ship.tscn") # Consts and enums const NO_SHIP = -1 -enum {MISS = -1, READY = 0, HIT = 1, SUNK = 2} +enum {MISS = -1, READY = 0, HIT = 1, SUNK = 2, LOST = 3} var bottom_board:Array # Player board var top_board:Array # Opponent board @@ -49,6 +49,10 @@ func hit(pos): if res == SUNK: # remove it from the count ship_count -= 1 + # If no ships left, + if ship_count == 0: + # Game has been lost + res = LOST; return res # fire: Store the results of firing on an opponent