diff options
author | Joursoir <chat@joursoir.net> | 2021-02-17 17:45:28 +0000 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2021-02-17 17:45:28 +0000 |
commit | 87d7320f84926c4d10734c773ecf3cf4eb47ddc4 (patch) | |
tree | b840169cebb266e1ad7c99f3d3a850e832422517 /GameField.hpp | |
download | lp-gomoku-87d7320f84926c4d10734c773ecf3cf4eb47ddc4.tar.gz lp-gomoku-87d7320f84926c4d10734c773ecf3cf4eb47ddc4.tar.bz2 lp-gomoku-87d7320f84926c4d10734c773ecf3cf4eb47ddc4.zip |
init project: create game field
Diffstat (limited to 'GameField.hpp')
-rw-r--r-- | GameField.hpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/GameField.hpp b/GameField.hpp new file mode 100644 index 0000000..1d2af31 --- /dev/null +++ b/GameField.hpp @@ -0,0 +1,37 @@ +#ifndef LPG_GAMEFIELD_H +#define LPG_GAMEFIELD_H + +enum states { + G_EMPTY = 0, + G_NONE, + G_DRAW, + G_XPLAYER = 10, + G_OPLAYER = -10 +}; + +class GameField { + // optional: + int field[3][3]; + int free; + int win_length; + + // non-optional: + int state; + int who_move; +public: + GameField() : field{0}, free(9), win_length(3), state(G_NONE), + who_move(G_XPLAYER) { } + ~GameField() { } + int GetState() { return state; } + + bool CanMove(int x, int y); + void Move(int x, int y); + +private: + void UpdateState(); + int ScanRows(); + int ScanCols(); + int ScanDiags(); +}; + +#endif /* LPG_GAMEFIELD_H */ |