def riddle_lady(): """A riddle is given and the player must answer correctly to progress""" from player import inventory from items import item_ingredients global inventory if item_ingredients not in inventory: print("Are you ready to answer my riddle?") print( "'What's black when you buy it, red when you use it and white when you throw it away?'" ) ans = input('> ') if ans == "": return from gameparser import normalise_input ans2 = normalise_input(ans) if ans2[0] == "coal" or ans2[0] == "charcoal": print("CORRECT!") print("""\"I wanted to test you, to see if you were worthy. Here are some ingredients for a hangover cure. You'll definitely find this useful. They need to be mixed with water, so you'll need to find something else to contain it.\"\n""" ) from player import inventory from items import item_ingredients from conversations import conv_lady conv_lady[ "opening"] = """Leave me be now clerk. I've helped you more than I should.""" conv_lady["questions"] = ["But..."] conv_lady["responses"] = [ "(The lady turns away from you, she clearly doesn't want to talk)" ] inventory.append(item_ingredients) from game import print_inventory_items else: print("WRONG! Try again.")
def inter_decantcure(item_id,object_id): from player import inventory if (item_id == "boot" or item_id == "goblet") and (item_oldboot in inventory and item_hangover2 in inventory): print("You decant the contents of the goblet into the old boot") inventory.remove(item_hangover2) inventory.remove(item_oldboot) inventory.append(item_hangover) else: print("Nothing interesting happens")
def inter_watergoblet(item_id,object_id): from player import inventory if item_id == "ingredients" or item_id == "goblet": if item_watergoblet in inventory: inventory.remove(item_ingredients) inventory.remove(item_watergoblet) inventory.append(item_hangover2) print("You mix the ingredients in the wooden goblet full of water.") else: print("Nothing interesting happens.") else: print("Nothing interesting happens")
def inter_fountain(item_id,object_id): from player import inventory if item_id == "boot" and item_oldboot in inventory: inventory.remove(item_oldboot) inventory.append(item_waterboot) print("You fill the old boot up with water.") elif item_id == "goblet": inventory.remove(item_goblet) inventory.append(item_watergoblet) print("You fill the wooden goblet up with water.") else: print("Nothing interesting happens")
def inter_waterboot(item_id): from player import inventory if item_id == "ingredients" or item_id == "boot": if item_waterboot in inventory: inventory.remove(item_ingredients) inventory.remove(item_waterboot) inventory.append(item_hangover) print("You mix the ingredients in the old boot full of water.") else: print("Nothing interesting happens.") else: print("Nothing interesting happens")
def execute_take(item_id): """This function takes an item_id as an argument and moves this item from the list of items in the current room to the player's inventory. However, if there is no such item in the room, this function prints "You cannot take that." """ global current_room global inventory take = False for item in current_room["items"]: if item["id"] == item_id: inventory.append(item) current_room["items"].remove(item) take = True if take == False: print("You cannot take that.") pass
def riddle_lady(): """A riddle is given and the player must answer correctly to progress""" print("Are you ready to answer my riddle?") print( "'What's black when you buy it, red when you use it and white when you throw it away?'" ) ans = input('> ') from gameparser import normalise_input ans2 = normalise_input(ans) if ans2[0] == "coal" or ans2[0] == "charcoal": print("CORRECT!") print("""I wanted to test you, to see if you were worthy. Here are some ingredients for a hangover cure. You'll definitely find this useful. They need to be mixed with water, so you'll need to find something else to contain it.""" ) from player import inventory from items import item_ingredients inventory.append(item_ingredients) from game import print_inventory_items print_inventory_items(inventory) else: print("WRONG! Try again.")
def execute_take(item_id): """This function takes an item_id as an argument and moves this item from the list of items in the current room to the player's inventory. However, if there is no such item in the room, this function prints "You cannot take that." """ item_taken = False global inventory if len(inventory) > 3: print("You cannot carry more than four items.") elif len(inventory) <= 5: for ite in current_room["items"]: if item_id == ite["id"]: inventory.append(ite) current_room["items"].remove(ite) print("You have taken " + ite["name"] + ".") item_taken = True if item_taken == False: print("This doesn't make sense.") item_taken = False time.sleep(1) # 3
def dice_game(): """Plays a game of dice, using code from: https://code.sololearn.com/cjQ6V2Aj2rJk/#py by user PacketStorm, accessed 22/10/2018 """ def cee_lo_player(): combo = roll() win = [4, 5, 6] loss = [1, 2, 3] w = 9 l = 0 print("You rolled %s" % combo[0] + "-%s" % combo[1] + "-%s" % combo[2]) if combo == win: print("You rolled Cee-lo!") return w elif combo == loss: print("You rolled 123!") return l elif combo[0] == combo[1] == combo[2]: print("You rolled TRIP %s's!" % combo[0]) return combo[0] elif combo[0] == combo[1] or combo[1] == combo[2]: if combo[0] == combo[1]: print("You rolled a PAIR of %s's!" % combo[1]) print("Your number is %s!" % combo[2]) return combo[2] elif combo[1] == combo[2]: print("You rolled a PAIR of %s's!" % combo[1]) print("Your number is %s!" % combo[0]) return combo[0] else: return cee_lo_player() def cee_lo_Soldier(): combo = roll() win = [4, 5, 6] loss = [1, 2, 3] w = 9 l = 0 print("Soldier rolled %s" % combo[0] + "-%s" % combo[1] + "-%s" % combo[2]) if combo == win: print("Soldier rolled Cee-lo!") return w elif combo == loss: print("Soldier rolled 123!") return l elif combo[0] == combo[1] == combo[2]: print("Soldier rolled TRIP %s's!" % combo[0]) return combo[0] elif combo[0] == combo[1] or combo[1] == combo[2]: if combo[0] == combo[1]: print("Soldier rolled a PAIR of %s's!" % combo[1]) print("Soldier number is %s!" % combo[2]) return combo[2] elif combo[1] == combo[2]: print("Soldier rolled a PAIR of %s's!" % combo[1]) print("Soldier number is %s!" % combo[0]) return combo[0] else: return cee_lo_Soldier() def roll(): dice1 = random.randrange(1, 7, 1) dice2 = random.randrange(1, 7, 1) dice3 = random.randrange(1, 7, 1) combo = [dice1, dice2, dice3] return sorted(combo) print("Rollin' the dice...\n") player = cee_lo_player() print("") Soldier = cee_lo_Soldier() print("") print("You: %s" % player) print("Soldier: %s" % Soldier) if player > Soldier: print("YOU WIN!") from player import inventory from items import item_money if item_money not in inventory: inventory.append(item_money) print("Soldier: 'Here take my gold.''") elif Soldier > player: print("YOU LOSE!") elif player == Soldier: print("DRAW!")
def checkProgress(current_room): from player import inventory, story_progress if current_room[ "name"] == "Samantha's Office" and not stage_1["Completion"]: stage_1["Completion"] = True elif current_room["name"] == "Samantha's Office" and ( STORY_TALKED_TO_SAMANTHA in story_progress) and not stage_2["Completion"]: stage_2["Completion"] = True elif (STORY_TALKED_TO_STEPHEN in story_progress) and not stage_3["Completion"]: Stephen["inventory"].remove(item_usb) inventory.append(item_usb) stage_3["Completion"] = True elif current_room[ "name"] == "Computer Mainframe" and not stage_3_3["Completion"]: if not stage_3_2["Completion"]: story_progress.append(STORY_ENTER_MAINFRAME) if (item_usb in inventory) and (item_login in inventory): story_progress.append(STORY_USB_IN_MAINFRAME) inventory.remove(item_usb) print("login and usb inputted") stage_3_2["Completion"] = True if item_ink in inventory: print("printing diagnostics") inventory.append(item_vault_log) inventory.remove(item_ink) stage_3_3["Completion"] = True story_progress.append(STORY_HAS_DIAGNOSTICS) else: print("printer out of ink, please refill") elif (item_usb in inventory) or (item_login in inventory): if item_usb in inventory: print("Need login details") elif item_login in inventory: print("Please input usb") else: print("usb and login required") elif stage_3_2["Completion"] and not stage_3_3["Completion"]: if item_ink in inventory: print("printing diagnostics") inventory.append(item_vault_log) inventory.remove(item_ink) stage_3_3["Completion"] = True story_progress.append(STORY_HAS_DIAGNOSTICS) else: print("printer out of ink, please refill") elif (STORY_HAS_DIAGNOSTICS in story_progress) and not stage_3_4["Completion"]: if item_vault_log in Stephen["inventory"]: story_progress.append(STORY_COFFEE_STARTED) stage_3_4["Completion"] = True print(stage_4Coffee["StephenStart"]) elif item_vault_log in Debra["inventory"]: story_progress.append(STORY_DOUBLE_STARTED) stage_3_4["Completion"] = True print(stage_4Agent["DebraStart"]) elif (STORY_COFFEE_STARTED in story_progress): if current_room["name"] == "the Vault Room": if not stage_4_1C["Completion"]: story_progress.append(STORY_ENTER_VAULT) if (item_vault_pass in inventory): inventory.append(item_tech) story_progress.append(STORY_HAS_TECH) print("Password accepted. Tech acquired") stage_4_1C["Completion"] = True else: print("Vault Password required.") elif (STORY_HAS_TECH in story_progress) and not stage_4_2C["Completion"]: if item_tech in Stephen["inventory"]: story_progress.append(STORY_COFFEE_COLLECTION_STARTED) stage_4_2C["Completion"] = True elif (STORY_COFFEE_COLLECTION_STARTED in story_progress) and not stage_5Coffee["Completion"]: if (item_mugs in Stephen["inventory"]) and ( item_power_lead in Stephen["inventory"]) and (item_heat_plate in Stephen["inventory"]): story_progress.append(STORY_COFFEE_MADE) stage_5Coffee["Completion"] = True print(stage_6Coffee["StephenStart"]) elif (STORY_COFFEE_MADE in story_progress) and not stage_6Coffee["Completion"]: if current_room["name"] == "Computer Mainframe": inventory.append(item_usb) elif item_usb in Stephen["inventory"]: print(stage_7Coffee["StephenStart"]) story_progress.append(STORY_USB_BACK) elif (STORY_DOUBLE_STARTED in story_progress): if not stage_4Agent["Completion"]: if (item_camera in Debra["inventory"]) and ( item_recorder in Debra["inventory"]) and (item_gun in Debra["inventory"]): story_progress.append(STORY_EVIDENCE_FOUND) stage_4Agent["Completion"] = True Debra["inventory"].remove(item_gun) inventory.append(item_gun) print(stage_5Agent["DebraStart"]) elif not stage_5Agent[ "Completion"] and STORY_EVIDENCE_FOUND in story_progress: if current_room[ "name"] == "Computer Mainframe" and item_gun in inventory: print("Running fingerprints...") time.sleep(2) print("Match found!") print("Fingerprints match Jenifer's data.") elif current_room["name"] == "the Break Room": if STORY_CORRECT_AGENT in story_progress: stage_5Agent["Completion"] = True print(stage_6Agent["SamanthaStart"]) choice = [] while choice != ["chest"] and choice != ["leg"]: shoot = input("Shoot Jenifer in the CHEST or LEG: ") choice = normalise_input(shoot) if choice == ["chest"]: story_progress.append(STORY_CHEST_SHOT) print(stage_7Agent["SamanthaStart"]) elif choice == ["leg"]: story_progress.append(STORY_LEG_SHOT) print(stage_8Agent["SamanthaStart"]) elif STORY_INCORRECT_AGENT in story_progress: stage_5Agent["Completion"] = True print(stage_9Agent["SamanthaStart"])