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

Board: Return LOST state when hit and no ships remain.

This commit is contained in:
John 2021-11-24 02:53:05 -06:00
parent 1a3d770690
commit 66cac5247f

View File

@ -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