Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from time import sleep
- import os
- import random
- def enter():
- input('Press Enter to Continue')
- def clear():
- os.system('clear')
- class Inventory:
- def __init__(self):
- self.items = {'Basic Rod': 0, 'Advanced Rod': 0, 'Ultimate Rod': 0,
- 'Coins': 50, 'Minnow': 0, 'Sardine': 0, 'Grouper': 0, 'Trout': 0,
- 'Salmon': 0, 'Boot': 0}
- self.values = {'Minnow': 10, 'Sardine': 15, 'Grouper': 20, 'Trout': 30,
- 'Salmon': 50, 'Boot': 5}
- def catch(self, fish):
- print('You caught a %s!' % fish)
- self.items[fish] += 1
- enter()
- def fishing(self):
- clear()
- while True:
- if self.items['Ultimate Rod'] > 0:
- rod = 3
- elif self.items['Advanced Rod'] > 0:
- rod = 2
- elif self.items['Basic Rod'] > 0:
- rod = 1
- else:
- print("You don't have a fishing pole.")
- enter()
- break
- # num = random.randint(2,7)
- catch_roll = random.randint(1, 10)
- print('You cast out your rod and wait')
- # for i in range(num):
- # sleep(1)
- # print('.')
- if rod == 1:
- if catch_roll < 2:
- self.catch('Boot')
- elif catch_roll >6:
- self.catch('Sardine')
- else:
- self.catch('Minnow')
- elif rod == 2:
- if catch_roll < 2:
- self.catch('Boot')
- elif catch_roll < 6:
- self.catch('Sardine')
- elif catch_roll < 9:
- self.catch('Grouper')
- else:
- self.catch('Trout')
- else:
- if catch_roll < 3:
- self.catch('Grouper')
- elif catch_roll >6:
- self.catch('Trout')
- else:
- self.catch('Salmon')
- break
- def add(self, fish):
- self.items[fish] += 1
- def sell(self):
- while True:
- clear()
- for k, v in self.items.items():
- if v > 0 and k not in ['Basic Rod', 'Advanced Rod',
- 'Ultimate Rod', 'Coins']:
- print('%s x %s = %s' % (k, v, (v * self.values[k])))
- print('1.Sell all\n2.Main Menu')
- menu = str(input('> '))
- if menu == '1':
- total = 0
- for k, v in self.items.items():
- if v > 0 and k not in ['Basic Rod', 'Advanced Rod',
- 'Ultimate Rod', 'Coins']:
- total += v * self.values[k]
- self.items[k] = 0
- self.items['Coins'] += total
- print('You gained %s Coins.' % total)
- enter()
- elif menu == '2':
- break
- else:
- continue
- def buy(self):
- while True:
- clear()
- print('--Store--\nYou have %s Coins' % self.items['Coins'])
- print('1.Basic Rod 50 Coins\n2.Advanced Rod 150 Coins')
- print('3.Ultimate Rod 300 Coins\n4.Main Menu')
- menu = str(input('> '))
- if menu == '1':
- self.purchase('Basic Rod', 1, 50)
- elif menu == '2':
- self.purchase('Advanced Rod', 1, 150)
- elif menu == '3':
- self.purchase('Ultimate Rod', 1, 300)
- elif menu == '4':
- break
- else:
- continue
- def purchase(self, item, amount, price):
- if self.items[item] > 0:
- print('You already own this item.')
- enter()
- elif self.items['Coins'] >= price:
- self.items[item] += amount
- self.items['Coins'] -= price
- print('Thank you for your purchase.')
- enter()
- else:
- print('You need %s more coins.' % (price - self.items['Coins']))
- enter()
- def display(self):
- clear()
- print('--Inventory--')
- for k, v in self.items.items():
- if v > 0:
- print('%s: %s' % (k, v))
- enter()
- items = Inventory()
- while True:
- clear()
- print('--Menu--\n1.Go Fishing\n2.Buy\n3.Sell\n4.Inventory\n5.Buy Boat')
- menu = str(input('> '))
- if menu == '1':
- items.fishing()
- elif menu == '2':
- items.buy()
- elif menu == '3':
- items.sell()
- elif menu == '4':
- items.display()
- elif menu == '5':
- if items.items['Coins'] > 600:
- clear()
- print('You win!')
- break
- else:
- clear()
- print('You need %s more coins.' % (600 - items.items['Coins']))
- enter()
- else:
- continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement