def victory(s): """Won by chance, let's try again""" s = ui.victory(s) s.ui.end_text = """RANDOM VICTORY. This will not happen everytime. Try again and see for yourself.""" s.ui.story_text = """You got lucky : the red robot walked into the trap by chance.""" s.ui.obj_text = """Click on the "Retry" button""" s.ui.active["retry"] = True #g.BUTTONS["retry"][-1] = lambda: g._state(step_9) return s
def main(): ui.clear_screen() ui.print_mainmenu() implementation.init_deck() implementation.distr_cards(ui.player_count) global victory # Main part of game while not victory: # if the player is human: if ui.player_types[ui.current_player]: # HUMAN card_there = True before_asking = True while card_there: ui.clear_screen() ui.show_main_interface() # Saves detected quartets in a list. list can be empty quartets = implementation.filter_quartets(ui.current_player) # Prints the hand of the player in a nice layout print(ui.show_hand(implementation.player_hands[ui.current_player])) if not before_asking: # Only shown if the player got a card from another player print("Graaaaatz! You got the card you wanted!\n") if len(quartets) != 0: # displaying the dropped quartet # (it's already removed from implementation.player_hands) print("You dropped a quartet:") print(ui.show_hand(quartets)) ui.quartets_counter[ui.current_player] += 1 input("Press 'enter' to continue.\n") ui.clear_screen() ui.show_main_interface() print(ui.show_hand(implementation.player_hands[ui.current_player])) if [] in implementation.player_hands: # Detects end of game victory = True ui.victory() break # card_there gets True, when the player successfully # asked for a card card_there = ui.ask_for_cards() # Used earlier in an if-condition before_asking = False if victory: break print("\nYou did not get the card you asked for.") if len(implementation.deck) != 0: # Automaticly draws a card for the player if he failed to ask # for the right card and shows it to him print("But I got one from the deck for you:") print(ui.show_hand([implementation.draw_card(ui.current_player)])) input("Press 'enter' for next turn.\n") # switches the player if ui.current_player == ui.player_count - 1: ui.current_player = 0 ui.turn_counter += 1 else: ui.current_player += 1 else: # AI while ai.ask_for_card(ui.current_player): # Asking for cards part for the ai. # Ai asks for cards in the while condition implementation.filter_quartets(ui.current_player) if [] in implementation.player_hands: # tests for victory condition victory = True ui.victory() break if victory: break if len(implementation.deck) != 0: # AI draws a card if it failed to ask for the right card implementation.draw_card(ui.current_player) # switches the player if ui.current_player == ui.player_count - 1: ui.current_player = 0 ui.turn_counter += 1 else: ui.current_player += 1
variables.stash["Food"] -= 1 # Every 4 days player and all indentured servants accumulate gold if days % 4 == 0: variables.stash["Gold"] = variables.stash[ "Gold"] + 1 + variables.indentured_count # Advertising is good for 14 days and adds 20% to sale prices # Subtract 1 from the counter every day it's above 0 if variables.advertising_duration > 0: variables.advertising_duration -= 1 variables.advertising_boost = 1.2 else: variables.advertising_boost = 1 # Every 30 days one indentured servant retires if days % 30 == 0 and variables.indentured_count > 0: variables.indentured_count -= 1 print("An indentured servant has paid off his debt and retired.") # Every subsequent day has a random event if days > 1: ui.update_display(events.random_event()) # You win if you collect 1000 gold if variables.stash["Gold"] >= 1000: ui.victory(days) print(actions.action_menu(ui.get_action()))