Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
FarmingGame/shop_trade.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
53 lines (41 sloc)
1.31 KB
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
#include <iostream> | |
#include "shop.h" | |
#include "inventory.h" | |
#include "shop_trade.h" | |
void trade_items(Inventory& inventory) | |
{ | |
std::string user_choice; | |
std::cout << "What would you like to trade in from your inventory?" << std::endl; | |
inventory.inventory_out(); | |
std::cout << "\nInput the name of the item you would like to trade: "; | |
std::cin >> user_choice; | |
if (user_choice == "tomato" && inventory.tomatoes >= 1) | |
{ | |
inventory.tomatoes -= 1; | |
inventory.shovel += 1; | |
std::cout << "You have traded in 1 tomato for 1 shovel." << std::endl; | |
} | |
else if (user_choice == "cherry" && inventory.cherries >= 1) | |
{ | |
inventory.cherries -= 1; | |
inventory.fertiliser += 1; | |
std::cout << "You have traded in 1 cherry for 1 fertiliser." << std::endl; | |
} | |
else if (user_choice == "shovel" && inventory.shovel >= 1) | |
{ | |
inventory.shovel -= 1; | |
inventory.watering_can += 1; | |
std::cout << "You have traded in 1 shovel for a watering can." << std::endl; | |
} | |
else if (user_choice == "watering can" && inventory.watering_can >= 1) | |
{ | |
inventory.watering_can -= 1; | |
inventory.shovel += 1; | |
std::cout << "You have traded in 1 watering can for 1 shovel." << std:: endl; | |
} | |
else | |
{ | |
std::cout << "Sorry looks like you do not have this item in your inventory or it is unable to be traded in\n"; | |
} | |
} | |
//these are just some examples of trades |