1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| #ifndef GAME_HPP
#define GAME_HPP
#include "DummyClass.hpp"
#include "Clock.hpp"
#include "NoClock.hpp"
#include <iostream>
template <typename GameBoard,typename GameRules, class ClockType>
class Game : public DummyClass
{
private:
GameBoard m_board;
GameRules m_rules;
ClockType m_clocks[GameRules::NB_PLAYERS];
int moves;
public:
Game()
{
moves = 0;
}
bool checkMove()
{
m_rules.check(m_board);
}
void play()
{
while(moves < 50)
{
int color = getCurrentColorTurn();
std::cout << "Moves : " << moves << " Color : " << color << std::endl;
m_clocks[color].start();
// GetTime
m_clocks[color].stop();
moves++;
}
}
// Ici, j'essaie de faire une fonction, qui existe que lorsque ClockType == NoClock
// Et une autre, lorsque ClockType == Clock
/*
template <GameBoard,GameRules, class NoClock>
void setClockTime(unsigned int time)
{
}
*/
/*
// template <typename GameBoard,typename GameRules>
void setClockTime<GameBoard,typename GameRules, NoClock>(unsigned int time)
{
for ( unsigned int i = 0 ; i < GameRules::NB_PLAYERS ; i++ )
{
m_clocks[i].setTotalTime(time);
}
}
*/
int getCurrentColorTurn()const
{
return (moves % GameRules::NB_PLAYERS);
}
}; |
Partager