diff options
Diffstat (limited to 'src/Model/Game.cpp')
| -rw-r--r-- | src/Model/Game.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/Model/Game.cpp b/src/Model/Game.cpp index 284d82b..5781f54 100644 --- a/src/Model/Game.cpp +++ b/src/Model/Game.cpp @@ -4,7 +4,7 @@ //==================== Constructor and Destructor ==================== //Constructor -Game::Game() : m_grid(), m_score(0), m_nbMove(0){ +Game::Game() : Grid(), m_stats(){ } //Destructor @@ -21,22 +21,22 @@ bool Game::swipe(kbdh::Direction direction){ switch(direction){ case kbdh::Left: - moveDone=m_grid.swipeLeft(); + moveDone=swipeLeft(); break; case kbdh::Right: - moveDone=m_grid.swipeRight(); + moveDone=swipeRight(); break; case kbdh::Up: - moveDone=m_grid.swipeUp(); + moveDone=swipeUp(); break; case kbdh::Down: - moveDone=m_grid.swipeDown(); + moveDone=swipeDown(); break; } if(moveDone){ - m_score+=m_grid.getLastMoveScore(); - m_nbMove++; + m_stats.incScore(m_lastMoveScore); + m_stats.incnbMove(); this->popRandomNumber(); } @@ -46,17 +46,17 @@ bool Game::swipe(kbdh::Direction direction){ //Cout the grid void Game::coutGrid(){ - std::cout << m_grid.description(); + std::cout << this->description(); } //Return true if the game is lost. False else. -bool Game::isOver(){ - return m_grid.isOver(); -} +//bool Game::isOver(){ + //return m_grid.isOver(); +//} //Pop a random number on the grid void Game::popRandomNumber(){ - std::tuple<int, int> coord(m_grid.getRandomEmptyCellCoord()); + std::tuple<int, int> coord(Grid::getRandomEmptyCellCoord()); int percent=rand() % 100; @@ -70,16 +70,21 @@ void Game::popRandomNumber(){ } - m_grid.setCell(coord, number); + Grid::setCell(coord, number); } //==================== Getters and Setter ==================== //Retrieve the Score -int Game::getScore(){ - return m_score; +Stats Game::getStats(){ + return m_stats; } -//Retrieve the number of moves -int Game::getNbMove(){ - return m_nbMove; -} + +//std::vector<std::vector<int> > Game::getGrid(){ + //return m_grid.getGrid(); +//} + + +//int Game::maxStrLenInGrid(){ + //return m_grid.maxStrLenInGrid(); +//} |
