本文整理汇总了C++中PlayerInfo类的典型用法代码示例。如果您正苦于以下问题:C++ PlayerInfo类的具体用法?C++ PlayerInfo怎么用?C++ PlayerInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlayerInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DemandTribute
// Demand tribute, and get the planet's response.
string Planet::DemandTribute(PlayerInfo &player) const
{
if(player.GetCondition("tribute: " + name))
return "We are already paying you as much as we can afford.";
if(!tribute || defenseFleets.empty())
return "Please don't joke about that sort of thing.";
if(player.GetCondition("combat rating") < defenseThreshold)
return "You're not worthy of our time.";
// The player is scary enough for this planet to take notice. Check whether
// this is the first demand for tribute, or not.
if(!isDefending)
{
isDefending = true;
set<const Government *> toProvoke;
for(const auto &fleet : defenseFleets)
toProvoke.insert(fleet->GetGovernment());
for(const auto &gov : toProvoke)
gov->Offend(ShipEvent::PROVOKE);
// Terrorizing a planet is not taken lightly by it or its allies.
GetGovernment()->Offend(ShipEvent::ATROCITY);
return "Our defense fleet will make short work of you.";
}
// The player has already demanded tribute. Have they defeated the entire defense fleet?
bool isDefeated = (defenseDeployed == defenseFleets.size());
for(const shared_ptr<Ship> &ship : defenders)
if(!ship->IsDisabled() && !ship->IsYours())
{
isDefeated = false;
break;
}
if(!isDefeated)
return "We're not ready to surrender yet.";
player.Conditions()["tribute: " + name] = tribute;
GameData::GetPolitics().DominatePlanet(this);
return "We surrender. We will pay you " + Format::Credits(tribute) + " credits per day to leave us alone.";
}
示例2: if
MissionPanel::MissionPanel(PlayerInfo &player)
: MapPanel(player),
available(player.AvailableJobs()),
accepted(player.Missions()),
availableIt(player.AvailableJobs().begin()),
acceptedIt(player.AvailableJobs().empty() ? accepted.begin() : accepted.end())
{
while(acceptedIt != accepted.end() && !acceptedIt->IsVisible())
++acceptedIt;
wrap.SetWrapWidth(380);
wrap.SetFont(FontSet::Get(14));
wrap.SetAlignment(WrappedText::JUSTIFIED);
// Select the first available or accepted mission in the currently selected
// system, or along the travel plan.
if(!FindMissionForSystem(selectedSystem) && player.HasTravelPlan())
{
const auto &tp = player.TravelPlan();
for(auto it = tp.crbegin(); it != tp.crend(); ++it)
if(FindMissionForSystem(*it))
break;
}
// Auto select the destination system for the current mission.
if(availableIt != available.end())
selectedSystem = availableIt->Destination()->GetSystem();
else if(acceptedIt != accepted.end())
selectedSystem = acceptedIt->Destination()->GetSystem();
// Center the system slightly above the center of the screen because the
// lower panel is taking up more space than the upper one.
center = Point(0., -80.) - selectedSystem->Position();
}
示例3: Apply
void GameEvent::Apply(PlayerInfo &player)
{
for(const auto &it : GameData::Governments())
{
int rep = it.second.Reputation();
player.Conditions()["reputation: " + it.first] = rep;
}
conditionsToApply.Apply(player.Conditions());
player.AddChanges(changes);
for(const auto &it : GameData::Governments())
{
int rep = it.second.Reputation();
int newRep = player.Conditions()["reputation: " + it.first];
if(rep != newRep)
it.second.AddReputation(newRep - rep);
}
for(const System *system : systemsToUnvisit)
player.Unvisit(system);
}
示例4: player
BoardingPanel::BoardingPanel(PlayerInfo &player, const shared_ptr<Ship> &victim)
: player(player), you(player.FlagshipPtr()), victim(victim),
attackOdds(&*you, &*victim), defenseOdds(&*victim, &*you),
initialCrew(you->Crew())
{
SetInterruptible(false);
const System &system = *player.GetSystem();
for(const auto &it : victim->Cargo().Commodities())
plunder.emplace_back(it.first, it.second, system.Trade(it.first));
// You cannot plunder hand to hand weapons, because they are kept in the
// crew's quarters, not mounted on the exterior of the ship.
for(const auto &it : victim->Outfits())
if(!it.first->Get("unplunderable"))
plunder.emplace_back(it.first, it.second);
if(!victim->IsCapturable())
messages.emplace_back("This is not a ship that you can capture.");
sort(plunder.begin(), plunder.end());
}
示例5: HasSpace
bool Mission::HasSpace(const PlayerInfo &player) const
{
int extraCrew = 0;
if(player.Flagship())
extraCrew = player.Flagship()->Crew() - player.Flagship()->RequiredCrew();
return (cargoSize <= player.Cargo().Free() + player.Cargo().CommoditiesSize()
&& passengers <= player.Cargo().Bunks() + extraCrew);
}
示例6: MannedTurrets
static int MannedTurrets(IshipIGC* pshipParent)
{
// loop through all of the ships on that side and count the ones
// that are turrets of this.
int cMannedTurrets = 0;
const ShipListIGC* shipList = pshipParent->GetSide()->GetShips();
for (const ShipLinkIGC* lShip = shipList->first(); lShip; lShip = lShip->next())
{
IshipIGC* pship = lShip->data();
PlayerInfo* pplayer = (PlayerInfo*)pship->GetPrivateData();
if (pplayer->LastSeenState() == c_ssTurret)
{
PlayerInfo* pplayerParent = trekClient.FindPlayer(pplayer->LastSeenParent());
if (pplayerParent && pplayerParent->GetShip() == pshipParent)
cMannedTurrets++;
}
}
return cMannedTurrets;
}
示例7: CanBoard
static bool CanBoard(IshipIGC* pship)
{
PlayerInfo* pPlayer = (PlayerInfo*)pship->GetPrivateData();
if (pship != trekClient.GetShip()
&& pship->GetSide() == trekClient.GetSide()
&& pPlayer->LastSeenState() == c_ssDocked
&& pship->GetPilotType() >= c_ptPlayer)
{
HullID hid = pPlayer->LastSeenShipType();
assert (hid != NA);
IhullTypeIGC* pht = trekClient.m_pCoreIGC->GetHullType(hid);
assert (pht);
if ((trekClient.GetShip()->GetPilotType() == c_ptCheatPlayer) ||
(pht->GetMaxFixedWeapons() != pht->GetMaxWeapons()))
{
return true;
}
}
return false;
}
示例8: CanBeDone
// Check if this action can be completed right now. It cannot be completed
// if it takes away money or outfits that the player does not have.
bool MissionAction::CanBeDone(const PlayerInfo &player) const
{
if(player.Accounts().Credits() < -payment)
return false;
const Ship *flagship = player.Flagship();
for(const auto &it : gifts)
{
if(it.second >= 0)
continue;
// The outfit can be taken from the player's cargo or from the flagship.
int available = player.Cargo().Get(it.first);
for(const auto &ship : player.Ships())
available += ship->Cargo().Get(it.first);
if(flagship)
available += flagship->OutfitCount(it.first);
if(available < -it.second)
return false;
}
return true;
}
示例9: callFail
bool AllianceApplylistCommand::handleRecieve(cocos2d::CCDictionary *dict)
{
if (dict->valueForKey("cmd")->compare(AL_APPLY_LIST) != 0)
return false;
CCDictionary *params=_dict(dict->objectForKey("params"));
if (!params) {
return false;
}
const CCString *pStr = params->valueForKey("errorCode");
if (pStr->compare("")!=0) {
CCCommonUtils::flyText(_lang(pStr->getCString()));
callFail(NetResult::create());
}else{
map<std::string, PlayerInfo*>::iterator it;
AllianceManager::getInstance()->applyUserList.clear();
CCArray* arr = (CCArray*)params->objectForKey("list");
int num = arr->count();
for (int i=0; i<num; i++) {
CCDictionary* dicPlayer = (CCDictionary*)arr->objectAtIndex(i);
PlayerInfo* player = new PlayerInfo();
player->updateInfo(dicPlayer);
AllianceManager::getInstance()->applyUserList[player->uid] = player;
if(player->uid==GlobalData::shared()->playerInfo.uid){
if(dicPlayer->objectForKey("relinquishEndTime")){
GlobalData::shared()->playerInfo.relinquishEndTime = dicPlayer->valueForKey("relinquishEndTime")->doubleValue();
}
if(dicPlayer->objectForKey("officer")){
GlobalData::shared()->playerInfo.officer = dicPlayer->valueForKey("officer")->getCString();
}
}
}
callSuccess(NetResult::create(Error_OK, params));
}
return true;
}
示例10: player
Engine::Engine(PlayerInfo &player)
: player(player)
{
// Start the thread for doing calculations.
calcThread = thread(&Engine::ThreadEntryPoint, this);
if(!player.IsLoaded() || !player.GetSystem())
return;
// Preload any landscapes for this system.
for(const StellarObject &object : player.GetSystem()->Objects())
if(object.GetPlanet())
GameData::Preload(object.GetPlanet()->Landscape());
// Figure out what planet the player is landed on, if any.
const StellarObject *object = player.GetStellarObject();
if(object)
center = object->Position();
// Now we know the player's current position. Draw the planets.
draw[calcTickTock].SetCenter(center);
radar[calcTickTock].SetCenter(center);
for(const StellarObject &object : player.GetSystem()->Objects())
if(object.HasSprite())
{
draw[calcTickTock].Add(object);
double r = max(2., object.Radius() * .03 + .5);
radar[calcTickTock].Add(RadarType(object), object.Position(), r, r - 1.);
}
// Add all neighboring systems to the radar.
const Ship *flagship = player.Flagship();
const System *targetSystem = flagship ? flagship->GetTargetSystem() : nullptr;
const vector<const System *> &links = (flagship && flagship->Attributes().Get("jump drive")) ?
player.GetSystem()->Neighbors() : player.GetSystem()->Links();
for(const System *system : links)
radar[calcTickTock].AddPointer(
(system == targetSystem) ? Radar::SPECIAL : Radar::INACTIVE,
system->Position() - player.GetSystem()->Position());
}
示例11: CanOffer
// Check if it's possible to offer or complete this mission right now.
bool Mission::CanOffer(const PlayerInfo &player) const
{
if(location == BOARDING || location == ASSISTING)
{
if(!player.BoardingShip())
return false;
if(!sourceFilter.Matches(*player.BoardingShip()))
return false;
}
else
{
if(source && source != player.GetPlanet())
return false;
if(!sourceFilter.Matches(player.GetPlanet()))
return false;
}
if(!toOffer.Test(player.Conditions()))
return false;
if(!toFail.IsEmpty() && toFail.Test(player.Conditions()))
return false;
if(repeat)
{
auto cit = player.Conditions().find(name + ": offered");
if(cit != player.Conditions().end() && cit->second >= repeat)
return false;
}
auto it = actions.find(OFFER);
if(it != actions.end() && !it->second.CanBeDone(player))
return false;
it = actions.find(ACCEPT);
if(it != actions.end() && !it->second.CanBeDone(player))
return false;
it = actions.find(DECLINE);
if(it != actions.end() && !it->second.CanBeDone(player))
return false;
return true;
}
示例12: CanComplete
bool Mission::CanComplete(const PlayerInfo &player) const
{
if(player.GetPlanet() != destination || !waypoints.empty())
return false;
if(!toComplete.Test(player.Conditions()))
return false;
auto it = actions.find(COMPLETE);
if(it != actions.end() && !it->second.CanBeDone(player))
return false;
for(const NPC &npc : npcs)
if(!npc.HasSucceeded(player.GetSystem()))
return false;
// If any of the cargo for this mission is being carried by a ship that is
// not in this system, the mission cannot be completed right now.
for(const auto &ship : player.Ships())
if(ship->GetSystem() != player.GetSystem() && ship->Cargo().Get(this))
return false;
return true;
}
示例13: handle
void* handle(void* par) {
signal(SIGPIPE, SIG_IGN);
HandleThreadParameter* parameter = (HandleThreadParameter*) par;
int clientSocket = parameter->clientID;
Server* server = parameter->server;
std::vector<std::string> withBase = server->listFilesInDirectoryWithBase(
"sendFiles");
std::vector<std::string> withoutBase = server->listFilesInDirectory(
"sendFiles");
// Manda las imagenes y sonidos necesarios que se utilizaran.
server->sendFiles(withBase, withoutBase, clientSocket);
PlayerInfo* info = server->recieveNewPlayer(clientSocket);
if (!info){
Logs::logErrorMessage("No se ha recibido la informacion del jugador");
return NULL;
}
string playerName = info->getPlayer()->getName();
int result = server->isNameAbilivable(playerName);
server->sendAproval(clientSocket, result);
if (result != OK) {
playerName = server->getAbilivableName(playerName);
server->sendNewName(clientSocket, playerName);
info->setName(playerName);
info->getPlayer()->setName(playerName);
}
cont++;
info->getPlayer()->setTeam(cont%2 +1);
bool playing = true;
cout << playerName << " has conected and joined team: " << info->getPlayer()->getTeam() <<endl;
// Antes de agregarlo al juego creo el thread para chequear el estado en el que se encuentra.
TimerThreadParameter param = {server,clientSocket,playerName, &playing};
pthread_t timerThread;
server->addPlayerToGame(clientSocket, info);
pthread_create(&timerThread,NULL,timerChecker,(void*)¶m);
server->runMainLoop(clientSocket,playerName);
pthread_cancel(timerThread);
server->disconectPlayer(clientSocket,playerName);
close(clientSocket);
return NULL;
}
示例14: if
ShipInfoPanel::ShipInfoPanel(PlayerInfo &player, int index)
: player(player), shipIt(player.Ships().begin()), canEdit(player.GetPlanet())
{
SetInterruptible(false);
// If a valid ship index was given, show that ship.
if(static_cast<unsigned>(index) < player.Ships().size())
shipIt += index;
else if(player.Flagship())
{
// Find the player's flagship. It may not be first in the list, if the
// first item in the list cannot be a flagship.
while(shipIt != player.Ships().end() && shipIt->get() != player.Flagship())
++shipIt;
}
UpdateInfo();
}
示例15: Fine
// Check to see if the player has done anything they should be fined for.
string Politics::Fine(PlayerInfo &player, const Government *gov, int scan, const Ship *target, double security)
{
// Do nothing if you have already been fined today, or if you evade
// detection.
auto it = fined.find(gov);
if(it != fined.end() || Random::Real() > security || !gov->GetFineFraction())
return "";
string reason;
int64_t maxFine = 0;
for(const shared_ptr<Ship> &ship : player.Ships())
{
// Check if the ship evades being scanned due to interference plating.
if(Random::Real() > 1. / (1. + ship->Attributes().Get("scan interference")))
continue;
if(target && target != &*ship)
continue;
if(ship->GetSystem() != player.GetSystem())
continue;
if(!scan || (scan & ShipEvent::SCAN_CARGO))
{
int64_t fine = ship->Cargo().IllegalCargoFine();
if((fine > maxFine && maxFine >= 0) || fine < 0)
{
maxFine = fine;
reason = "carrying illegal cargo.";
}
}
if(!scan || (scan & ShipEvent::SCAN_OUTFITS))
{
for(const auto &it : ship->Outfits())
if(it.second)
{
int64_t fine = it.first->Get("illegal");
if((fine > maxFine && maxFine >= 0) || fine < 0)
{
maxFine = fine;
reason = "having illegal outfits installed on your ship.";
}
}
}
}
if(maxFine < 0)
{
gov->Offend(ShipEvent::ATROCITY);
if(!scan)
reason = "atrocity";
else
reason = "After scanning your ship, the " + gov->GetName()
+ " captain hails you with a grim expression on his face. He says, \"You are guilty of "
+ reason + " The penalty for your actions is death. Goodbye.\"";
}
else if(maxFine > 0)
{
// Scale the fine based on how lenient this government is.
maxFine = maxFine * gov->GetFineFraction() + .5;
reason = "The " + gov->GetName() + " fines you "
+ Format::Number(maxFine) + " credits for " + reason;
player.Accounts().AddFine(maxFine);
fined.insert(gov);
}
return reason;
}