Skip to content

Commit

Permalink
Create a Board field to store Game state
Browse files Browse the repository at this point in the history
  • Loading branch information
cramaker committed May 17, 2023
1 parent 5be4772 commit 7aabfca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions game/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Game struct {
Columns int
Rows int
Players []string
Board [][]string
}

// Move is the column number where the player wants to drop the token
Expand Down
9 changes: 5 additions & 4 deletions internal/database/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ CREATE TABLE IF NOT EXISTS games (
state TEXT NOT NULL,
winner_id TEXT,
columns INTEGER DEFAULT 7,
rows INTEGER DEFAULT 6
);
rows INTEGER DEFAULT 6,
board TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS players (
id INTEGER PRIMARY KEY AUTOINCREMENT,
game_id INTEGER NOT NULL,
player_id TEXT NOT NULL,
FOREIGN KEY (game_id) REFERENCES games (id) ON DELETE CASCADE
);
);

CREATE TABLE IF NOT EXISTS moves (
id INTEGER PRIMARY KEY AUTOINCREMENT,
Expand All @@ -22,4 +23,4 @@ CREATE TABLE IF NOT EXISTS moves (
move_type TEXT NOT NULL,
"column" INTEGER,
FOREIGN KEY (game_id) REFERENCES games (id) ON DELETE CASCADE
);
);

0 comments on commit 7aabfca

Please sign in to comment.