Initial commit
This commit is contained in:
commit
4f4397b3e1
48 changed files with 2002 additions and 0 deletions
38
NimGame/game/nimgame/NimGame.h
Normal file
38
NimGame/game/nimgame/NimGame.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//
|
||||
// Created by JoachimWagner on 10.03.2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "../AbstractGame.h"
|
||||
#include "../../io/Writer.h"
|
||||
#include "../player/Player.h"
|
||||
|
||||
namespace atlas::game::nimgame {
|
||||
|
||||
class NimGame: public AbstractGame<int, int> {
|
||||
|
||||
|
||||
public:
|
||||
explicit NimGame(io::Writer &writer) : AbstractGame(writer) {
|
||||
setBoard(23);
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
auto updateBoard()-> void override{ setBoard(getBoard()- getTurn());}
|
||||
|
||||
auto isGameOver()->bool override{ // Operation
|
||||
return getBoard() < 1 || getPlayers().empty();
|
||||
}
|
||||
|
||||
[[nodiscard]] auto isTurnValid() const -> bool override { return getTurn() >= 1 && getTurn() <= 3; }
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue