Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // Isaac Bum Simulator
- //
- // Created by Hayden Lueck on 2014-11-06.
- // Copyright (c) 2014 Hayden Lueck. All rights reserved.
- //
- #include <iostream>
- #include <string>
- #include <vector>
- class Isaac{
- public:
- int getPennies() const{
- return pennies;
- }
- void removePenny(){
- pennies--;
- }
- void addToInventory(const std::string & item){
- this->item = item;
- }
- void printInventory() const{
- std::cout << "Inventory:\n-------------------------\n" << item << std::endl << std::endl;
- }
- void changeTrinket(const std::string & trk){
- trinket = trk;
- }
- void printTrinket() const{
- std::cout << "Held trinket: " << trinket << std::endl;
- std::cout << std::endl;
- }
- void addToConsumables(const std::string & cnsm){
- consumables.push_back(cnsm);
- }
- void printConsumables() const{
- std::cout << "Consumables gained:\n-------------------------\n";
- for(int i = 0; i < consumables.size(); i++){
- std::cout << "Item " << i + 1 << ": " << consumables[i] << std::endl;
- }
- std::cout << std::endl;
- }
- private:
- int pennies = 15;
- std::string item = "none";
- std::string trinket = "none";
- std::vector<std::string> consumables;
- };
- class bumGuy{
- public:
- void bum(Isaac & eyeSack)
- {
- std::string item, trinket, consumable;
- char confirm;
- do
- {
- std::cout << "You have " << eyeSack.getPennies() << " pennies." << std::endl
- << "Input 0 to give a penny, or any other character to quit: ";
- std::cin >> confirm;
- if(confirm == '0')
- {
- eyeSack.removePenny();
- int x = rand()%20;
- if(x >= 13){
- if(x == 19){
- item = items();
- std::cout << "You got " << item << "!";
- eyeSack.addToInventory(item);
- break;
- }
- else if(x <= 16){
- consumable = consumables();
- std::cout << "You got a " << consumable << "!";
- eyeSack.addToConsumables(consumable);
- }
- else{
- trinket = trinkets();
- std::cout << "You got " << trinket << "!";
- eyeSack.changeTrinket(trinket);
- }
- }
- else{
- std::cout << "You got nothing :(";
- }
- std::cout << std::endl;
- if(eyeSack.getPennies() == 0){
- std::cout << "You're out of pennies!" << std::endl;
- break;
- }
- }
- }while(confirm == '0');
- }
- std::string consumables()
- {
- consumableList = {
- "heart",
- "bomb",
- "key",
- "soul heart" };
- int x = rand() % MAX_CONSUMABLES;
- if(x >= 0 && x < MAX_CONSUMABLES)
- {
- return consumableList[x];
- }
- else
- {
- return "error";
- }
- }
- std::string items(){
- itemList = {
- "Lemon Mishap",
- "The Bible",
- "My Little Unicorn",
- "The D20",
- "Bucket of Lard" };
- int x = rand() % MAX_ITEMS;
- if(x >= 0 && x < MAX_ITEMS)
- {
- return itemList[x];
- }
- else
- {
- return "error";
- }
- }
- std::string trinkets()
- {
- trinketList = {
- "Ace of Spades",
- "Counterfeit Penny",
- "Fish Head",
- "Liberty Cap",
- "A Missing Page" };
- int x = rand() % MAX_TRINKETS;
- if(x >= 0 && x < MAX_TRINKETS)
- {
- return trinketList[x];
- }
- else
- {
- return "error";
- }
- }
- private:
- const int MAX_TRINKETS = 5, MAX_ITEMS = 5, MAX_CONSUMABLES = 4;
- std::vector<std::string> trinketList, itemList, consumableList;
- };
- int main() {
- srand(int(time(0)));
- Isaac eyeSack;
- bumGuy bum;
- bum.bum(eyeSack);
- std::cout << std::endl;
- eyeSack.printInventory();
- eyeSack.printConsumables();
- eyeSack.printTrinket();
- return 0;
- }
Add Comment
Please, Sign In to add comment