本文整理汇总了C++中Monster::SetRace方法的典型用法代码示例。如果您正苦于以下问题:C++ Monster::SetRace方法的具体用法?C++ Monster::SetRace怎么用?C++ Monster::SetRace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monster
的用法示例。
在下文中一共展示了Monster::SetRace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandlePutMob_
//==============================================================================
void GameServer::HandlePutMob_(const QVariantMap& request, QVariantMap& response)
{
if (!testingStageActive_)
{
WriteResult_(response, EFEMPResult::BAD_ACTION);
return;
}
if (!request["x"].toFloat()
|| !request["y"].toFloat())
{
WriteResult_(response, EFEMPResult::BAD_PLACING);
return;
}
float x = request["x"].toFloat();
float y = request["y"].toFloat();
Monster* monster = CreateActor_<Monster>();
SetActorPosition_(monster, Vector2(x, y));
monster->SetDirection(EActorDirection::SOUTH);
if (IsPositionWrong(x, y, monster))
{
KillActor_(monster);
WriteResult_(response, EFEMPResult::BAD_PLACING);
return;
}
auto flags = request["flags"].toList();
for (auto flag: flags)
{
if (monster->possibleFlags.lastIndexOf(flag.toString()) == -1)
{
WriteResult_(response, EFEMPResult::BAD_FLAG);
return;
}
monster->Flags.push_back(flag.toString());
}
monster->SetRace(request["race"].toString());
if (monster->GetRace() == "NONE")
{
WriteResult_(response, EFEMPResult::BAD_RACE);
return;
}
auto stats = request["stats"].toMap();
for (auto s = stats.begin(); s != stats.end(); s++)
{
EStatConst stat = StringToStat[s.key()];
QVariant val = s.value();
monster->SetStat(stat, val.toFloat());
}
auto inventory = request["inventory"].toList();
for (auto elem: inventory)
{
Item* item = CreateActor_<Item>();
SetItemDescription(elem.toMap(), item);
item->SetOnTheGround(false);
monster->items.push_back(item);
actors_.erase(std::remove(actors_.begin(), actors_.end(), item)
, actors_.end()); //???
}
QStringList damage;
damage << request["dealtDamage"].toString().split("d");
if (damage.size() < 2
|| !damage[0].toInt()
|| !damage[1].toInt())
{
WriteResult_(response, EFEMPResult::BAD_DAMAGE);
return;
}
response["id"] = monster->GetId();
}