#include "Game.hpp" //==================== Constructor and Destructor ==================== //Constructor Game::Game() : Grid(), m_nbMove(0), m_score(0){ } //Destructor Game::~Game(){ } //==================== Helpers ==================== //Swipe action bool Game::swipe(kbdh::Direction direction){ bool moveDone; switch(direction){ case kbdh::Left: moveDone=swipeLeft(); break; case kbdh::Right: moveDone=swipeRight(); break; case kbdh::Up: moveDone=swipeUp(); break; case kbdh::Down: moveDone=swipeDown(); break; } if(moveDone){ m_score+=m_lastMoveScore; m_nbMove++; this->popRandomNumber(); } return moveDone; } //Cout the grid void Game::coutGrid(){ std::cout << this->description(); } //Return true if the game is lost. False else. //bool Game::isOver(){ //return m_grid.isOver(); //} //Pop a random number on the grid void Game::popRandomNumber(){ std::tuple coord(Grid::getRandomEmptyCellCoord()); int percent=rand() % 100; int number; if(percent <= 10){ number=4; } else{ number=2; } Grid::setCell(coord, number); } //==================== Getters and Setter ==================== //Retrieve the Score int Game::getScore(){ return m_score; } //Retrieve the number of moves int Game::getNbMove(){ return m_nbMove; } //std::vector > Game::getGrid(){ //return m_grid.getGrid(); //} //int Game::maxStrLenInGrid(){ //return m_grid.maxStrLenInGrid(); //}