本文整理汇总了C++中PlayerInfo::BoardingShip方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerInfo::BoardingShip方法的具体用法?C++ PlayerInfo::BoardingShip怎么用?C++ PlayerInfo::BoardingShip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerInfo
的用法示例。
在下文中一共展示了PlayerInfo::BoardingShip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: Instantiate
//.........这里部分代码省略.........
// cargo name with something more specific.
if(!cargo.empty())
{
const Trade::Commodity *commodity = nullptr;
if(cargo == "random")
commodity = PickCommodity(*player.GetSystem(), *result.destination->GetSystem());
else
{
for(const Trade::Commodity &option : GameData::Commodities())
if(option.name == cargo)
{
commodity = &option;
break;
}
}
if(commodity)
result.cargo = commodity->items[Random::Int(commodity->items.size())];
else
result.cargo = cargo;
}
// Pick a random cargo amount, if requested.
if(cargoSize || cargoLimit)
{
if(cargoProb)
result.cargoSize = Random::Polya(cargoLimit, cargoProb) + cargoSize;
else if(cargoLimit > cargoSize)
result.cargoSize = cargoSize + Random::Int(cargoLimit - cargoSize + 1);
else
result.cargoSize = cargoSize;
}
// Pick a random passenger count, if requested.
if(passengers | passengerLimit)
{
if(passengerProb)
result.passengers = Random::Polya(passengerLimit, passengerProb) + passengers;
else if(passengerLimit > passengers)
result.passengers = passengers + Random::Int(passengerLimit - passengers + 1);
else
result.passengers = passengers;
}
result.illegalCargoFine = illegalCargoFine;
// How far is it to the destination?
DistanceMap distance(player.GetSystem());
int jumps = distance.Distance(result.destination->GetSystem());
int defaultPayment = (jumps + 1) * (150 * result.cargoSize + 1500 * result.passengers);
int defaultDeadline = doDefaultDeadline ? (2 * jumps) : 0;
// Set the deadline, if requested.
if(daysToDeadline || defaultDeadline)
{
result.hasDeadline = true;
result.deadline = player.GetDate() + (defaultDeadline + daysToDeadline);
}
// Copy the completion conditions. No need to copy the offer conditions,
// because they have already been checked.
result.toComplete = toComplete;
result.toFail = toFail;
// Generate the substitutions map.
map<string, string> subs;
subs["<commodity>"] = result.cargo;
subs["<tons>"] = to_string(result.cargoSize) + (result.cargoSize == 1 ? " ton" : " tons");
subs["<cargo>"] = subs["<tons>"] + " of " + subs["<commodity>"];
subs["<bunks>"] = to_string(result.passengers);
subs["<passengers>"] = (result.passengers == 1) ? "passenger" : "passengers";
subs["<fare>"] = (result.passengers == 1) ? "a passenger" : (subs["<bunks>"] + " passengers");
if(player.GetPlanet())
subs["<origin>"] = player.GetPlanet()->Name();
else if(player.BoardingShip())
subs["<origin>"] = player.BoardingShip()->Name();
subs["<planet>"] = result.destination ? result.destination->Name() : "";
subs["<system>"] = result.destination ? result.destination->GetSystem()->Name() : "";
subs["<destination>"] = subs["<planet>"] + " in the " + subs["<system>"] + " system";
subs["<date>"] = result.deadline.ToString();
subs["<day>"] = result.deadline.LongString();
// Instantiate the NPCs. This also fills in the "<npc>" substitution.
for(const NPC &npc : npcs)
result.npcs.push_back(npc.Instantiate(subs, player.GetSystem()));
// Instantiate the actions. The "complete" action is always first so that
// the "<payment>" substitution can be filled in.
for(const auto &it : actions)
result.actions[it.first] = it.second.Instantiate(subs, defaultPayment);
for(const auto &it : onEnter)
result.onEnter[it.first] = it.second.Instantiate(subs, defaultPayment);
// Perform substitution in the name and description.
result.displayName = Format::Replace(displayName, subs);
result.description = Format::Replace(description, subs);
result.clearance = Format::Replace(clearance, subs);
result.blocked = Format::Replace(blocked, subs);
result.clearanceFilter = clearanceFilter;
result.hasFullClearance = hasFullClearance;
result.hasFailed = false;
return result;
}
示例3: Instantiate
//.........这里部分代码省略.........
break;
}
}
if(commodity)
result.cargo = commodity->items[Random::Int(commodity->items.size())];
else
result.cargo = cargo;
}
// Pick a random cargo amount, if requested.
if(cargoSize || cargoLimit)
{
if(cargoProb)
result.cargoSize = Random::Polya(cargoLimit, cargoProb) + cargoSize;
else if(cargoLimit > cargoSize)
result.cargoSize = cargoSize + Random::Int(cargoLimit - cargoSize + 1);
else
result.cargoSize = cargoSize;
}
// Pick a random passenger count, if requested.
if(passengers | passengerLimit)
{
if(passengerProb)
result.passengers = Random::Polya(passengerLimit, passengerProb) + passengers;
else if(passengerLimit > passengers)
result.passengers = passengers + Random::Int(passengerLimit - passengers + 1);
else
result.passengers = passengers;
}
result.illegalCargoFine = illegalCargoFine;
// How far is it to the destination?
DistanceMap distance(player.GetSystem());
int jumps = distance.Distance(result.destination->GetSystem());
int payload = result.cargoSize + 10 * result.passengers;
// Set the deadline, if requested.
if(deadlineBase || deadlineMultiplier)
result.deadline = player.GetDate() + deadlineBase + deadlineMultiplier * jumps;
// Copy the conditions. The offer conditions must be copied too, because they
// may depend on a condition that other mission offers might change.
result.toOffer = toOffer;
result.toComplete = toComplete;
result.toFail = toFail;
// Generate the substitutions map.
map<string, string> subs;
subs["<commodity>"] = result.cargo;
subs["<tons>"] = to_string(result.cargoSize) + (result.cargoSize == 1 ? " ton" : " tons");
subs["<cargo>"] = subs["<tons>"] + " of " + subs["<commodity>"];
subs["<bunks>"] = to_string(result.passengers);
subs["<passengers>"] = (result.passengers == 1) ? "passenger" : "passengers";
subs["<fare>"] = (result.passengers == 1) ? "a passenger" : (subs["<bunks>"] + " passengers");
if(player.GetPlanet())
subs["<origin>"] = player.GetPlanet()->Name();
else if(player.BoardingShip())
subs["<origin>"] = player.BoardingShip()->Name();
subs["<planet>"] = result.destination ? result.destination->Name() : "";
subs["<system>"] = result.destination ? result.destination->GetSystem()->Name() : "";
subs["<destination>"] = subs["<planet>"] + " in the " + subs["<system>"] + " system";
subs["<date>"] = result.deadline.ToString();
subs["<day>"] = result.deadline.LongString();
if(!result.stopovers.empty())
{
string planets;
const Planet * const *last = &*--result.stopovers.end();
int count = 0;
// Iterate by reference to the pointers so we can check when we're at
// the very last one in the set.
for(const Planet * const &planet : result.stopovers)
{
if(count++)
planets += (&planet != last) ? ", " : (count > 2 ? ", and " : " and ");
planets += planet->Name() + " in the " + planet->GetSystem()->Name() + " system";
}
subs["<stopovers>"] = planets;
}
// Instantiate the NPCs. This also fills in the "<npc>" substitution.
for(const NPC &npc : npcs)
result.npcs.push_back(npc.Instantiate(subs, player.GetSystem()));
// Instantiate the actions. The "complete" action is always first so that
// the "<payment>" substitution can be filled in.
for(const auto &it : actions)
result.actions[it.first] = it.second.Instantiate(subs, jumps, payload);
for(const auto &it : onEnter)
result.onEnter[it.first] = it.second.Instantiate(subs, jumps, payload);
// Perform substitution in the name and description.
result.displayName = Format::Replace(displayName, subs);
result.description = Format::Replace(description, subs);
result.clearance = Format::Replace(clearance, subs);
result.blocked = Format::Replace(blocked, subs);
result.clearanceFilter = clearanceFilter;
result.hasFullClearance = hasFullClearance;
result.hasFailed = false;
return result;
}