/*! * \fn void GameStd::shootPlayer(int playerNb) * \brief tire sur le joueur de numero passe en parametre et realise les actions consequentes * \param int playerNb le joueur sur lequel le tir a ete fait * \return */ void GameStd::shootPlayer(int playerNb){ SpaceshipFactory* factory = new SpaceshipFactoryStd(); Spaceship* s = players[playerNb]->getSpaceship(); //si Battlecruiser, l'artefact revient au shooter if (s->hasArtefact() && s->getType()==BattlecruiserType) players[currentPlayer]->getSpaceship()->takeArtefact(); //creation du nouveau vaisseau Spaceship* newSpaceship = factory->createNextSpaceship(s); //si Mothership, retour a la base if (newSpaceship->getType() == MothershipType){ GameBuilder* builder = new GameBuilderStd(); builder->setPosShip(newSpaceship,players[playerNb]->getColor(), getMapLongueur(), getMapHauteur()); delete builder; std::cout<<"remplacement par mothership"<<std::endl; } delete factory; players[playerNb]->replaceSpaceship(newSpaceship); std::cout << "Spaceship du joueur "<<playerNb<<"remplace"<<std::endl; }
void SpaceshipValidator::validate(const Spaceship & s) { string errors; if (s.getName().size() < 3) errors += string("The spaceship name cannot be less than 2 characters!\n"); if (!isupper(s.getCaptain()[0])) errors += string("The captain's name must start with a capital letter!\n"); if (s.getType().size() < 3) errors += string("The spaceship type cannot be less than 2 characters!\n"); if (errors.size() > 0) throw ValidationException(errors); /*if (errors.size() > 0) throw ValidationExceptionInherited(errors);*/ }