Player* GameHandler::createPlayer (PlayerInfo info, const int id) { GamePlayer fieldPlayer = (id == 0) ? GAME_PLAYER_A : GAME_PLAYER_B; info.player = fieldPlayer; switch (info.type) { case HUMAN_PLAYER: { HumanPlayer* res = new HumanPlayer(info); for (GraphicsTile* tile: this->backgroundTiles) QObject::connect(tile, SIGNAL(makeMove(const Move&)), res, SLOT(setMove(const Move&))); for (GraphicsMovableTile* tile: this->pawns) if (engine::getPlayerFor(this->game.getFieldAt(tile->getPos())) == fieldPlayer) QObject::connect(tile, SIGNAL(makeMove(const Move&)), res, SLOT(setMove(const Move&))); return res; break; } case AI_PLAYER: { AIPlayer* res = new AIPlayer(info); QObject::connect(res, SIGNAL(crashed()), this, SLOT(botCrashed())); return res; break; } default: return NULL; } return NULL; }
void Mammut::crash() { if (m_isCrashed) return; Sound sound(Sound::kImpact); emit crashed(); m_isCrashed = true; }