本文整理汇总了C++中Human::SetLuck方法的典型用法代码示例。如果您正苦于以下问题:C++ Human::SetLuck方法的具体用法?C++ Human::SetLuck怎么用?C++ Human::SetLuck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Human
的用法示例。
在下文中一共展示了Human::SetLuck方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Combat
/*******************************************************************************************************
* COMBAT - called when a physical challenge is actioned
*******************************************************************************************************/
void Combat(Human & HumanObj, Enemy * EnemyObj)
{
// enemy variables
const char * enemyName = EnemyObj->GetName();
int enemyHealth = EnemyObj->GetHealth();
int enemyStrength = EnemyObj->GetStrength();
int enemyLuck = EnemyObj->GetLuck();
// conditional block to determine outcome of confrontations
if (HumanObj.GetStrength() >= enemyStrength && HumanObj.GetLuck() >= enemyLuck)
{
// wins hands down
if (BestOfThree())
{
std::cout << "^^ You are a formidable foe, you fight " << enemyName << " and win easily \n You feast on the still beating heart of your foe...\n You gain health and strength. \n";
HumanObj.SetHealth(HumanObj.GetHealth() + 10);
HumanObj.SetStrength(HumanObj.GetStrength() + 2);
HumanStats(HumanObj);
}
else
{
std::cout << "^^ You are a formidable foe, you fight " << enemyName << " and win easily \n However, you took a hit that is but a flesh wound...\n Your health is tarnished but a bit. \n";
HumanObj.SetHealth(HumanObj.GetHealth() - 5);
HumanStats(HumanObj);
}
Pause();
}
else if (HumanObj.GetHealth() >= enemyHealth && HumanObj.GetLuck() >= enemyLuck)
{
// player gets lucky takes a few but wins
if (BestOfThree())
{
std::cout << "^^ Your enemy is your equal, you fight " << enemyName << " and get lucky \n You feast on the still beating heart of your foe...\n You gain health and luck. \n";
HumanObj.SetHealth(HumanObj.GetHealth() + 10);
HumanObj.SetLuck(HumanObj.GetLuck() + 2);
HumanStats(HumanObj);
}
else
{
std::cout << "^^ Your enemy is your equal, you fight " << enemyName << " and get lucky \n However, you took a hit that is but a flesh wound...\n Your health is tarnished but a bit. \n";
HumanObj.SetHealth(HumanObj.GetHealth() - 5);
HumanObj.SetLuck(HumanObj.GetLuck() + 2);
HumanStats(HumanObj);
}
Pause();
}
else if (HumanObj.GetHealth() < enemyHealth && HumanObj.GetLuck() >= enemyLuck)
{
// player gets lucky
if (BestOfThree())
{
std::cout << "^^ Your enemy is healthier than you, you fight " << enemyName << " and get lucky \n You feast on the still beating heart of your foe...\n You gain health and luck. \n";
HumanObj.SetHealth(HumanObj.GetHealth() + 10);
HumanObj.SetLuck(HumanObj.GetLuck() + 2);
HumanStats(HumanObj);
}
else
{
std::cout << "^^ Your enemy is healthier than you, you fight " << enemyName << " and get lucky \n However, you took a hit that is but a flesh wound...\n Your health is tarnished but a bit. \n";
HumanObj.SetHealth(HumanObj.GetHealth() - 5);
HumanObj.SetLuck(HumanObj.GetLuck() + 2);
HumanStats(HumanObj);
}
Pause();
}
else
{
// player loses takes some damage
std::cout << "^^ Your enemy is stronger, healthier and luckier than you.\n You fight " << enemyName << " and you lose and flee... \n You took several big hits...\n Your health, strength are drained and you lost a lucky charm. \n";
HumanObj.SetHealth(HumanObj.GetHealth() - 20);
HumanObj.SetStrength(HumanObj.GetStrength() - 2);
HumanObj.SetLuck(HumanObj.GetLuck() - 2);
HumanStats(HumanObj);
Pause();
}
}
示例2: ApplyChallenge
/*******************************************************************************************************
* APPLY CHALLENGE - for the users chosen path, action the challenge for that direction
*******************************************************************************************************/
void ApplyChallenge(Challenge * ChallengePtr, Human & HumanObj, Enemy *Enemies[])
{
//metal challenge variables
bool incorrect = true;
int count = 0;
const int userInputLimit = 25;
char userInput[userInputLimit] = {};
StringOO userAnswer;
StringOO actualAnswer;
// points
int points = ChallengePtr->GetDifficulty() + HumanObj.GetLocation();
// if the challenge is of type FLEE
if (ChallengePtr->GetType() == "flee")
{
std::cout << ">> To proceed in this direction we shall find out first if you can... \n";
std::cout << ChallengePtr->GetDescription() << std::endl;
Pause();
if (BestOfThree())
{
std::cout << "+> Turns out yes, yes you can...you're free to pass! \n";
HumanStats(HumanObj);
}
else
{
std::cout << "-> Nope, you can't as it turns out... \n Someone had to come in and save you from yourself...\n and further embarrassment...\n Your fumbling has cost you health, strength, luck and intelligence." << std::endl;
HumanObj.SetHealth(HumanObj.GetHealth() - points);
HumanObj.SetStrength(HumanObj.GetStrength() - 2);
HumanObj.SetLuck(HumanObj.GetLuck() - 2);
HumanObj.SetIntelligence(HumanObj.GetIntelligence() - 1);
HumanStats(HumanObj);
}
Pause();
}
// if the challenge is of type MENTAL
else if (ChallengePtr->GetType() == "mental")
{
actualAnswer = ChallengePtr->GetAnswer();
std::cout << ">> To proceed in this direction you must answer a question correctly... \n";
std::cout << ChallengePtr->GetQuestion() << std::endl;
while (incorrect)
{
std::cout << std::endl << "+ ";
std::cin.getline(userInput, userInputLimit);
userAnswer = userInput;
if (userAnswer.StringCompare(actualAnswer) && count == 0)
{
std::cout << "\n+> Correct, please pass GO...Umm? but there is no $200 for you to collect... \n At least you have your health ;-)" << std::endl;
Pause();
HumanStats(HumanObj);
incorrect = false;
}
else if (userAnswer.StringCompare(actualAnswer) && count > 0)
{
std::cout << "-> Really? " << count << " guesses! Stop drinking the Coolade!, don't pass GO...! \n";
points += count;
std::cout << " And give me " << points << " points of your best health and " << count << " of your intelligences... \n " << std::endl;
Pause();
HumanObj.SetHealth(HumanObj.GetHealth() - points);
HumanObj.SetIntelligence(HumanObj.GetIntelligence() - count);
HumanStats(HumanObj);
incorrect = false;
}
else if (!userAnswer.StringCompare(actualAnswer) && count != 4)
{
std::cout << "\n NOPE!! Try again...\n";
count++;
}
else
{
std::this_thread::sleep_for(std::chrono::seconds(1));
std::cout << "\n-> STOP!!... <- \n I think thats enough don't you?! \n";
points += count;
std::cout << " For that you can give me...\n - " << points << " points of your best health and...\n - " << count << " of your intelligences... \n " << std::endl;
Pause();
HumanObj.SetHealth(HumanObj.GetHealth() - points);
HumanObj.SetIntelligence(HumanObj.GetIntelligence() - count);
HumanStats(HumanObj);
incorrect = false;
}
}
}
// if the challenge is of type PHYSICAL
else if (ChallengePtr->GetType() == "physical")
{
std::cout << ChallengePtr->GetDescription() << std::endl;
Pause();
Combat(HumanObj, Enemies[ChallengePtr->GetEnemy()]);
}
// if the challenge has no type
else
{
std::cout << " AND...\n" << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(3));
std::cout << " ...NOTHING HAPPENED!! \n" << std::endl;
std::cout << " Get out of Gaol Free or Just Visiting, either way your free to pass!! \n" << std::endl;
Pause();
//.........这里部分代码省略.........