Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
261 additions
and
0 deletions.
There are no files selected for viewing
128
Encounters.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#include "Encounters.h" | ||
Encounters::Encounters(string Name, string Dialogue, string Luck, string Type, string NexDest, bool inTransit, bool Death, int Health, | ||
int Hunger, int HungerRate, int encounters) { | ||
NewName = Name; | ||
NewDialogue = Dialogue; | ||
NewLuck = Luck; | ||
NewType = Type; | ||
NewNexDest = NexDest; | ||
NewInTransit = inTransit; | ||
NewDeath = Death; | ||
NewHealth = Health; | ||
NewHunger = Hunger; | ||
NewHungerRate = HungerRate; | ||
NewEncounters = encounters; | ||
|
||
} | ||
|
||
Encounters::~Encounters() { | ||
} | ||
string Encounters::getName() const { | ||
return NewName; | ||
} | ||
string Encounters::getDialogue(string Type, string Luck) const { | ||
int dice_roll = rand() % 50 + 1; | ||
if (Type == "Hunger" && Luck == "Good") { | ||
ifstream inFile; | ||
inFile.open("Hunger.txt"); | ||
if (inFile.fail()) { | ||
NewDialogue == "Dialogue access failed"; | ||
return NewDialogue; | ||
} | ||
inFile.seekg(round(dice_roll), (round(dice_roll) + 10)); | ||
inFile.close(); | ||
} | ||
if (Type == "Hunger" && Luck == "Bad") { | ||
ifstream inFile; | ||
inFile.open("Hunger.txt"); | ||
if (inFile.fail()) { | ||
NewDialogue == "Dialogue access failed"; | ||
return NewDialogue; | ||
} | ||
inFile.seekg((round(dice_roll)+50), (round(dice_roll) + 60)); | ||
inFile.close(); | ||
} | ||
if (Type == "Health" && Luck == "Good") { | ||
ifstream inFile; | ||
inFile.open("Health.txt"); | ||
if (inFile.fail()) { | ||
NewDialogue == "Dialogue access failed"; | ||
return NewDialogue; | ||
} | ||
inFile.seekg(round(dice_roll), (round(dice_roll) + 10)); | ||
inFile.close(); | ||
} | ||
if (Type == "Health" && Luck == "Bad") { | ||
ifstream inFile; | ||
inFile.open("Hunger.txt"); | ||
if (inFile.fail()) { | ||
NewDialogue == "Dialogue access failed"; | ||
return NewDialogue; | ||
} | ||
inFile.seekg((round(dice_roll) + 50), (round(dice_roll) + 60)); | ||
inFile.close(); | ||
} | ||
if (Type == "Map") { | ||
ifstream inFile; | ||
inFile.open("Map.txt"); | ||
if (inFile.fail()) { | ||
NewDialogue == "Dialogue access failed"; | ||
return NewDialogue; | ||
} | ||
inFile.seekg((round(dice_roll)), (round(dice_roll) + 10)); | ||
inFile.close(); | ||
} | ||
} | ||
string Encounters::getHealth() const { | ||
return ("Your Health is: " + NewHealth); | ||
} | ||
string Encounters::getHunger() const { | ||
return ("Your Hunger is: " + NewHunger); | ||
} | ||
string Encounters::getLuck() const { | ||
int dice_roll = rand() % 10 + 1; | ||
if (dice_roll > 5) { | ||
string NewLuck = "Good"; | ||
} | ||
if (dice_roll < 5) { | ||
string NewLuck = "Bad"; | ||
} | ||
return NewLuck; | ||
} | ||
void Encounters::setType(string Type) { | ||
int dice_roll = rand() % 3 + 1; | ||
if (dice_roll == 1) { | ||
NewType = "Hunger"; | ||
} | ||
if (dice_roll == 2) { | ||
NewType = "Health"; | ||
} | ||
if (dice_roll == 3) { | ||
NewType = "Map"; | ||
} | ||
} | ||
void Encounters::setHealth(int Health) { | ||
NewHealth = Health - 10; | ||
} | ||
void Encounters::setNexDest(string NexDest) { | ||
NewNexDest = "Sercet Location"; | ||
} | ||
void Encounters::setInTransit(bool inTransit) { | ||
NewInTransit = inTransit; | ||
} | ||
void Encounters::setEncounters(int encounters) { | ||
NewEncounters = encounters + 1; | ||
} | ||
void Encounters::setDeath(int Health, int Hunger, bool Death) { | ||
if (Hunger == 100 or Health == 0) { | ||
NewDeath = true; | ||
} | ||
}void Encounters::setHungerRate(string Luck, int HungerRate) { | ||
if (Luck == "good") { | ||
NewHungerRate = HungerRate * 0.95; | ||
} | ||
if (Luck == "bad") { | ||
NewHungerRate = HungerRate * 1.5; | ||
} | ||
} | ||
|
53
Encounters.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
#include <iostream> | ||
#include <random> | ||
#include <cstdlib> | ||
#include <thread> | ||
#include <chrono> | ||
#include <string> | ||
#include <fstream> | ||
|
||
|
||
using namespace std; | ||
|
||
#ifndef Encounters_H | ||
#define Encounters_H | ||
|
||
class Encounters { | ||
public: | ||
|
||
Encounters(string, string, string, string, string, bool, bool, int, int, int, int); | ||
|
||
~Encounters(); | ||
|
||
string getName() const; | ||
string getDialogue(string, string) const; | ||
string getHealth() const; | ||
string getHunger() const; | ||
string getLuck() const; | ||
|
||
|
||
void setInTransit(bool); | ||
void setEncounters(int); | ||
void setDeath(int, int, bool); | ||
void setHungerRate(string, int); | ||
void setType(string); | ||
void setHealth(int); | ||
void setNexDest(string); | ||
|
||
|
||
private: | ||
string NewName; | ||
string NewDialogue; | ||
string NewLuck; | ||
string NewType; | ||
string NewNexDest; | ||
bool NewInTransit; | ||
bool NewDeath; | ||
int NewHealth; | ||
int NewHunger; | ||
int NewHungerRate; | ||
int NewEncounters; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
//Survival Simulation Module | ||
#include "Encounters.h" | ||
using namespace std; | ||
|
||
int main() { | ||
string Name = "Bob"; | ||
string Dialogue; | ||
string PreDest = "Get From Ami's Map Module"; | ||
string NexDest = "Get From Ami's Map Module"; | ||
string Luck; | ||
string Type; | ||
bool inTransit = false; | ||
bool Death = false; | ||
int Health = 100; | ||
int Hunger = 0; | ||
int hungerRate = 10; | ||
int encounters = 0; | ||
int pathway; | ||
int dice_roll = rand() % 4 + 1; | ||
int dice_roll2 = rand() % dice_roll + 1; | ||
|
||
cout << endl << "You start with Health: " << Health << " and Hunger: " << Hunger << "\n"; | ||
cout << endl << "As you leave " << PreDest << " You are presented with a road that seperates" << | ||
" into three paths which one will you choose? "; | ||
|
||
cin >> pathway; | ||
std::this_thread::sleep_for(std::chrono::seconds(10)); | ||
|
||
|
||
Encounters Encounter1(Name, Dialogue, Luck, Type, NexDest, inTransit, Death, Health, Hunger, hungerRate, encounters); | ||
|
||
Encounter1.setInTransit(true); | ||
cout << endl << Encounter1.getName() << " welcome to the road!" << endl; | ||
|
||
while (inTransit = true) { | ||
Encounter1.setDeath(Health, Hunger, Death); | ||
if (Death == true) | ||
{ | ||
cout << endl << "I'm sorry player " << NexDest << " Is to far" << "\n" << "Game Over!" << endl; | ||
abort(); | ||
} | ||
Encounter1.setEncounters(encounters); | ||
if (encounters >= 2) { | ||
cout << endl << "You've made it to " + NexDest << endl; | ||
inTransit = false; | ||
} | ||
Encounter1.setType(Type); | ||
if (Type == "Health") { | ||
if (Encounter1.getLuck() == "Good") { | ||
cout << endl << Encounter1.getDialogue << endl; | ||
Encounter1.setHealth; | ||
} | ||
else { | ||
cout << endl << Encounter1.getDialogue << endl; | ||
Encounter1.setHealth; | ||
} | ||
} | ||
if (Type == "Hunger") { | ||
if (Encounter1.getLuck() == "Good") { | ||
cout << endl << Encounter1.getDialogue << endl; | ||
Encounter1.setHungerRate; | ||
} | ||
else { | ||
cout << endl << Encounter1.getDialogue << endl; | ||
Encounter1.setHungerRate; | ||
} | ||
} | ||
if (Type == "Map") { | ||
if (Encounter1.getLuck() == "Good") { | ||
cout << endl << Encounter1.getDialogue << endl; | ||
Encounter1.setNexDest; | ||
} | ||
else { | ||
cout << endl << Encounter1.getDialogue << endl; | ||
Encounter1.setNexDest; | ||
} | ||
} | ||
|
||
} | ||
} |