def trade_confirm(cls, sender_trade_box, receiver_trade_box): ''' Produces summary of trade from both traders, based on contents of their trade boxes. Prompts final confirmation.''' # Sender print ("_" * 20) + " SUMMARY " + (20 * "_") print "'%s' is trading: " % (sender_trade_box['name']) print "Properties:" for prop in sender_trade_box['properties']: print "- ", ansi_tile(prop.name) print "Money: $%s \n" % sender_trade_box['money'] # Receiver print "... For '%s's': " % (receiver_trade_box['name']) print "Properties:" for prop in receiver_trade_box['properties']: print "- ", ansi_tile(prop.name) print "Money: $%s \n" % receiver_trade_box['money'] s_confirm = raw_input("%s, is this okay? (y/n)" % sender_trade_box['name']).lower() r_confirm = raw_input("%s, is this okay? (y/n)" % receiver_trade_box['name']).lower() return s_confirm, r_confirm
def trade_accept(cls, s_trade_box, r): ''' 'Presents' offer to the recipient, and gives them the choice of whether or not they want to proceed. ''' print "'%s' would like to trade: " % s_trade_box['name'] if s_trade_box['properties']: print "Properties:" for prop in s_trade_box['properties']: print "- ", ansi_tile(prop.name) if s_trade_box['money']: print "Money: $%s \n" % s_trade_box['money'] offer_reaction = raw_input("Do you want to respond to their offer? (y/n) > ").lower() if offer_reaction == 'y': print "Trade has been accepted by %r." % r.name return True else: return False
def trade_box(cls, player): ''' Takes player through a series of menus, prompting player to load up their trade box with desired offer (property, money). ''' player_trade_box = {'name': player.name, 'money': 0, 'properties': []} ongoing = True while ongoing: print "What would you like to trade? >" choice = raw_input(" (0: Properties 1: Money 2: Passes 3: Confirm 4: Start Over 5: Cancel) > ") # trading properties if choice == '0': player_menu = {} # loading up items to trade for i, prop in enumerate(player.properties.values()): print "\t %s : %s" % (i, ansi_tile(prop.name)) player_menu[str(i)] = prop print "\t %s : Back" % len(player.properties) player_menu[len(player.properties)] = "Back" menu_choice = raw_input(">> ") if menu_choice == str(len(player.properties)): print "\t Back to trade menu ..." continue item = player_menu[menu_choice] if item in player_trade_box['properties']: print "Removing %s from trade box." % item.name player_trade_box['properties'].remove(item) continue print "Adding '%s' to trade box ..." % item.name player_trade_box['properties'].append(item) continue # trading money elif choice == '1': money_offer = False while not money_offer: money = raw_input("How much money would you like to trade? > ") if not money.isdigit(): print '\t Not valid amount.' continue money = int(money) if (player.money - money) < 0: print "\t Not enough money." else: player_trade_box['money'] += int(money) print "Loaded $%s to trade box ..." % money money_offer = True # offer confirmation elif choice == '3': print "You're about to trade: " print "\t Money: " print "\t - $%s" % player_trade_box['money'] print "\t Properties: " for prop in player_trade_box['properties']: print "\t -", ansi_tile(prop.name) offer = raw_input("Can you confirm this offer? (y/n) > ").lower() if offer == 'y': ongoing = False elif offer == 'n': continue else: ongoing = False # Start over elif choice == '4': print "Clearing trade box ..." player_trade_box['properties'] = [] player_trade_box['money'] = 0 continue # Cancel Trade elif choice == '5': print "Cancelling Trade ..." ongoing = False return None return player_trade_box