diff --git a/your-code/.ipynb_checkpoints/main-checkpoint.ipynb b/your-code/.ipynb_checkpoints/main-checkpoint.ipynb new file mode 100644 index 00000000..de95ac0e --- /dev/null +++ b/your-code/.ipynb_checkpoints/main-checkpoint.ipynb @@ -0,0 +1,918 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# import libraries\n", + "from pathlib import Path\n", + "import random\n", + "\n", + "import playsound as ps\n", + "from playsound import playsound\n", + "\n", + "from PIL import Image\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#Questions & answers\n", + "\n", + "question_a = {\n", + " \"name\": \"Question a\",\n", + " \"type\": \"question\",\n", + " \"correct answer\": \"a\"\n", + "}\n", + "\n", + "answers_a = {\n", + " \"a\": \"Spanish\",\n", + " \"b\": \"Italian\",\n", + " \"c\": \"French\"\n", + "}\n", + "\n", + "question_b = {\n", + " \"name\": \"Question b\",\n", + " \"type\": \"question\",\n", + " \"correct answer\": \"b\"\n", + "}\n", + "\n", + "answers_b = {\n", + " \"a\": \"Potato\",\n", + " \"b\": \"Rice\",\n", + " \"c\": \"Bread\"\n", + "}\n", + "\n", + "question_c = {\n", + " \"name\": \"Question c\",\n", + " \"type\": \"question\",\n", + " \"correct answer\": \"a\"\n", + "}\n", + "\n", + "answers_c = {\n", + " \"a\": \"Whale\",\n", + " \"b\": \"Elephant\",\n", + " \"c\": \"Rhinoceros\"\n", + "}\n", + "\n", + "question_d = {\n", + " \"name\": \"Question d\",\n", + " \"type\": \"question\",\n", + " \"correct answer\": \"c\"\n", + "}\n", + "\n", + "answers_d = {\n", + " \"a\": \"Water\",\n", + " \"b\": \"Iron\",\n", + " \"c\": \"\"\n", + "}\n", + "\n", + "# define rooms and items\n", + "\n", + "couch = {\n", + " \"name\": \"couch\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "door_a = {\n", + " \"name\": \"door a\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_a = {\n", + " \"name\": \"key for door a\",\n", + " \"type\": \"key\",\n", + " \"target\": door_a,\n", + " \"question\": question_a\n", + "}\n", + "\n", + "piano = {\n", + " \"name\": \"piano\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "game_room = {\n", + " \"name\": \"game room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "#New Rooms\n", + "\n", + "door_b = {\n", + " \"name\": \"door b\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_c = {\n", + " \"name\": \"door c\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_d = {\n", + " \"name\": \"door d\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "\n", + "door_blue = {\n", + " \"name\": \"door blue\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_pink = {\n", + " \"name\": \"door pink\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_red = {\n", + " \"name\": \"door red\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_black = {\n", + " \"name\": \"door black\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_white = {\n", + " \"name\": \"door white\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_b = {\n", + " \"name\": \"key for door b\",\n", + " \"type\": \"key\",\n", + " \"target\": door_b,\n", + " \"question\": question_b\n", + "}\n", + "\n", + "key_c = {\n", + " \"name\": \"key for door c\",\n", + " \"type\": \"key\",\n", + " \"target\": door_c,\n", + " \"question\": question_c\n", + "}\n", + "\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d,\n", + " \"question\": question_d\n", + "}\n", + "\n", + "queen_bed = {\n", + " \"name\": \"Queen Bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "double_bed = {\n", + " \"name\": \"Double Bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dresser = {\n", + " \"name\": \"Dresser\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dining_table = {\n", + " \"name\": \"Dining Table\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "bedroom_1 = {\n", + " \"name\": \"Bed Room 1\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "bedroom_2 = {\n", + " \"name\": \"Bed Room 2\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "living_room = {\n", + " \"name\": \"Living Room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "ghost_room = {\n", + " \"name\": \"Ghost Room\",\n", + " \"type\": \"room\"\n", + "}\n", + "\n", + "#all_rooms = [game_room, bedroom_1, bedroom_2, living_room, outside]\n", + "\n", + "#all_doors = [door_a, door_b, door_c, door_d]\n", + "\n", + "# define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"game room\": [couch, piano, door_a],\n", + " \"piano\": [key_a],\n", + " \"Bed Room 1\": [queen_bed, door_a, door_b, door_c],\n", + " \"Queen Bed\": [key_b],\n", + " \"Bed Room 2\": [double_bed, dresser, door_b],\n", + " \"Double Bed\": [key_c],\n", + " \"Dresser\": [key_d],\n", + " \"Living Room\": [dining_table, door_c, door_d],\n", + " \"Ghost Room\": [door_blue, door_pink, door_red, door_black, door_white],\n", + " \"outside\": [door_d],\n", + " \"door a\": [game_room, bedroom_1],\n", + " \"door b\": [bedroom_1, bedroom_2],\n", + " \"door c\": [bedroom_1, living_room],\n", + " \"door d\": [living_room, outside], \n", + " \"key a\": [question_a],\n", + " \"Question a\": [answers_a],\n", + " \"key b\": [question_b],\n", + " \"Question b\": [answers_b],\n", + " \"key c\": [question_c],\n", + " \"Question c\": [answers_c],\n", + " \"key d\": [question_d],\n", + " \"Question d\": [answers_d] \n", + "}\n", + "\n", + "# define game state. Do not directly change this dict. \n", + "# Instead, when a new game starts, make a copy of this\n", + "# dict and use the copy to store gameplay state. This \n", + "# way you can replay the game multiple times.\n", + "\n", + "# Added language, hard_scape and escape door\n", + "\n", + "INIT_GAME_STATE = {\n", + " \"language\": 'en',\n", + " \"current_room\": game_room,\n", + " \"keys_collected\": [],\n", + " \"hard_scape\": 0,\n", + " \"target_room\": outside,\n", + " \"escape door\": door_blue\n", + "}\n", + "\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#Creating the Multi Language dictionaries\n", + "\n", + "#English dictionary\n", + "\n", + "lang_texts_en = {}\n", + "lang_texts_en['yes'] = 'yes'\n", + "lang_texts_en['no'] = 'no'\n", + "lang_texts_en['explore'] = 'explore'\n", + "lang_texts_en['examine'] = 'examine'\n", + "lang_texts_en['integer'] = 'Please type only the number of the options'\n", + "lang_texts_en['intro'] = '''You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!'''\n", + "lang_texts_en['escape'] = 'RUN! And do not come back again!\\n\\nCongrats! You escaped the room!'\n", + "lang_texts_en['in'] = 'You are now in '\n", + "lang_texts_en['next_room'] = 'Do you want to go to the next room?'\n", + "lang_texts_en['examine_do'] = 'What would you like to examine?'\n", + "lang_texts_en['repeat'] = \"Not sure what you mean. Choose a valid option.\"\n", + "lang_texts_en['explore_do'] = 'You explore the room. This is '\n", + "lang_texts_en['find'] = 'You find '\n", + "lang_texts_en['you_examine'] = 'You examine '\n", + "lang_texts_en['unlock'] = 'You unlock it with a key you have.'\n", + "lang_texts_en['locked'] = \"It is locked but you don't have the key.\"\n", + "lang_texts_en['nothing'] = \"There isn't anything interesting about it.\"\n", + "lang_texts_en['none'] = 'The item you requested is not found in the current room.'\n", + "lang_texts_en['option'] = 'Option:'\n", + "lang_texts_en['select'] = 'Select one option:'\n", + "lang_texts_en['selected'] = 'Selected option: '\n", + "lang_texts_en['no_valid'] = 'Please select a valid number'\n", + "lang_texts_en['couch'] = 'couch'\n", + "lang_texts_en['piano'] = 'piano'\n", + "lang_texts_en['door a'] = 'door a'\n", + "lang_texts_en['Queen Bed'] = 'Queen Bed'\n", + "lang_texts_en['door b'] = 'door b'\n", + "lang_texts_en['door c'] = 'door c'\n", + "lang_texts_en['Double Bed'] = 'Double Bed'\n", + "lang_texts_en['Dresser'] = 'Dresser'\n", + "lang_texts_en['Dining Table'] = 'Dining Table'\n", + "lang_texts_en['door d'] = 'door d'\n", + "lang_texts_en['game room'] = 'Game room'\n", + "lang_texts_en['Bed Room 1'] = 'Bed Room 1'\n", + "lang_texts_en['Bed Room 2'] = 'Bed Room 2'\n", + "lang_texts_en['Living Room'] = 'Living Room'\n", + "lang_texts_en['outside'] = 'outside'\n", + "lang_texts_en['key for door a'] = 'key for door a'\n", + "lang_texts_en['key for door b'] = 'key for door b'\n", + "lang_texts_en['key for door c'] = 'key for door c'\n", + "lang_texts_en['key for door d'] = 'key for door d'\n", + "lang_texts_en['Question a'] = 'What nationality was Columbus believed to be?'\n", + "lang_texts_en['Question b'] = 'What is the most consumed food in the world?'\n", + "lang_texts_en['Question c'] = 'What is the largest mammal in the world?'\n", + "lang_texts_en['Question d'] = 'What weighs more than 1 kg of water or 1kg of iron?'\n", + "lang_texts_en['door blue'] = 'Door Blue'\n", + "lang_texts_en['door pink'] = 'Door Pink'\n", + "lang_texts_en['door red'] = 'Door Red'\n", + "lang_texts_en['door black'] = 'Door Black'\n", + "lang_texts_en['door white'] = 'Door White'\n", + "lang_texts_en['ghost quiz'] = 'Ghost Quiz'\n", + "lang_texts_en['Question a correct'] = 'Right... Keep looking for the exit...'\n", + "lang_texts_en['Question a failed'] = 'You wont scape... ever'\n", + "lang_texts_en['Question b correct'] = 'You can go... for now...'\n", + "lang_texts_en['Question b failed'] = 'Nice try...'\n", + "lang_texts_en['Question c correct'] = 'True...Who would think a mammal can live underwater?...'\n", + "lang_texts_en['Question c failed'] = 'You will not be allowed to go anywhere...'\n", + "lang_texts_en['Question d correct'] = 'Clever...'\n", + "lang_texts_en['Question d failed'] = 'Hehehehe...'\n", + "lang_texts_en['choose_door'] = 'As you failed in your answers... it is time to choose a door.'\n", + "lang_texts_en['correct_door'] = 'Congratulations! You can live for one day more'\n", + "lang_texts_en['wrong_door'] = 'Time to stay here... FOREVER!'\n", + "lang_texts_en['Spanish'] = 'Spanish'\n", + "lang_texts_en['Italian'] = 'Italian'\n", + "lang_texts_en['French'] = 'French'\n", + "lang_texts_en['Potato'] = 'Potato'\n", + "lang_texts_en['Rice'] = 'Rice'\n", + "lang_texts_en['Bread'] = 'Bread'\n", + "lang_texts_en['Whale'] = 'Whale'\n", + "lang_texts_en['Elephant'] = 'Elephant'\n", + "lang_texts_en['Rhinoceros'] = 'Rhinoceros'\n", + "lang_texts_en['Water'] = 'Water'\n", + "lang_texts_en['Iron'] = 'Iron'\n", + "lang_texts_en[''] = ''\n", + "\n", + "\n", + "#Spanish dictionary\n", + "\n", + "lang_texts_es = {}\n", + "lang_texts_es['yes'] = 'sí'\n", + "lang_texts_es['no'] = 'no'\n", + "lang_texts_es['explore'] = 'explorar'\n", + "lang_texts_es['examine'] = 'examinar'\n", + "lang_texts_es['integer'] = 'Por favor teclea solamente números de las opciones'\n", + "lang_texts_es['intro'] = 'Te despiertas en un sofá y te encuentras en una casa extraña sin ventanas en la que nunca has estado antes. No recuerdas por qué estás aquí y qué había sucedido antes. Sientes que se acerca un peligro desconocido y debes salir de la casa, ¡YA!'\n", + "lang_texts_es['escape'] = '¡CORRE! ¡y no vuelvas más!\\n\\n¡Felicidades! ¡Has escapado!'\n", + "lang_texts_es['in'] = 'Estás en '\n", + "lang_texts_es['next_room'] = '¿Quieres ir a la siguiente habitación?'\n", + "lang_texts_es['examine_do'] = '¿Qué te gustaría examinar?'\n", + "lang_texts_es['repeat'] = \"No estoy seguro de lo que quieres. Seleccionar una opción válida.\"\n", + "lang_texts_es['explore_do'] = 'Exploras la habitación. Esta es '\n", + "lang_texts_es['find'] = 'Encuentras '\n", + "lang_texts_es['you_examine'] = 'Tú examinas '\n", + "lang_texts_es['unlock'] = 'La abres con la llave que tú tienes.'\n", + "lang_texts_es['locked'] = \"Está cerrada pero tú no tienes la llave.\"\n", + "lang_texts_es['nothing'] = \"No se ve nada interesante\"\n", + "lang_texts_es['none'] = 'El elemento que solició no se encuentra en la sala actual.'\n", + "lang_texts_es['option'] = 'Opción:'\n", + "lang_texts_es['select'] = 'Escoge una opción:'\n", + "lang_texts_es['selected'] = 'Opción escogida: '\n", + "lang_texts_es['no_valid'] = 'Por favor, escoge un número válido'\n", + "lang_texts_es['couch'] = 'sofá'\n", + "lang_texts_es['piano'] = 'piano'\n", + "lang_texts_es['door a'] = 'puerta a'\n", + "lang_texts_es['Queen Bed'] = 'Cama de matrimonio'\n", + "lang_texts_es['door b'] = 'puerta b'\n", + "lang_texts_es['door c'] = 'puerta c'\n", + "lang_texts_es['Double Bed'] = 'Cama Doble'\n", + "lang_texts_es['Dresser'] = 'Cómoda'\n", + "lang_texts_es['Dining Table'] = 'Mesa de comedor'\n", + "lang_texts_es['door d'] = 'puerta d'\n", + "lang_texts_es['game room'] = 'Habitación de juegos'\n", + "lang_texts_es['Bed Room 1'] = 'Habitación 1'\n", + "lang_texts_es['Bed Room 2'] = 'Habitación 2'\n", + "lang_texts_es['Living Room'] = 'Sala de estar'\n", + "lang_texts_es['outside'] = 'Fuera'\n", + "lang_texts_es['key for door a'] = 'llave para puerta a'\n", + "lang_texts_es['key for door b'] = 'llave para puerta b'\n", + "lang_texts_es['key for door c'] = 'llave para puerta c'\n", + "lang_texts_es['key for door d'] = 'llave para puerta d'\n", + "lang_texts_es['Question a'] = '¿De qué nacionalidad se creía que era Colón?'\n", + "lang_texts_es['Question b'] = '¿Cuál es el alimento más consumido en el mundo?'\n", + "lang_texts_es['Question c'] = '¿Cuál es el mamífero más grande del mundo?'\n", + "lang_texts_es['Question d'] = '¿Qué pesa más, 1 kg de agua o 1 kg de hierro?'\n", + "lang_texts_es['door blue'] = 'Puerta Azul'\n", + "lang_texts_es['door pink'] = 'Puerta Rosa'\n", + "lang_texts_es['door red'] = 'Puerta Roja'\n", + "lang_texts_es['door black'] = 'Puerta Negra'\n", + "lang_texts_es['door white'] = 'Puerta Blanca'\n", + "lang_texts_es['ghost quiz'] = 'Acertijo Fantasma'\n", + "lang_texts_es['Question a correct'] = 'Bien... Sigue buscando la salida...'\n", + "lang_texts_es['Question a failed'] = 'Tú no escaparás... nunca'\n", + "lang_texts_es['Question b correct'] = 'Puedes irte... por ahora...'\n", + "lang_texts_es['Question b failed'] = 'Buen intento...'\n", + "lang_texts_es['Question c correct'] = 'Cierto... ¿Quién pensaría que un mamífero puede vivir bajo el agua?...'\n", + "lang_texts_es['Question c failed'] = 'No se te permitirá ir a ningún lado...'\n", + "lang_texts_es['Question d correct'] = 'Inteligente...'\n", + "lang_texts_es['Question d failed'] = 'Jejejeje...'\n", + "lang_texts_es['choose_door'] = 'Como fallaste en tus respuestas... es hora de elegir una puerta.'\n", + "lang_texts_es['correct_door'] = '¡Felicidades! Puedes vivir un día más'\n", + "lang_texts_es['wrong_door'] = 'Es hora de quedarse aquí... ¡PARA SIEMPRE!'\n", + "lang_texts_es['Spanish'] = 'Española'\n", + "lang_texts_es['Italian'] = 'Italiana'\n", + "lang_texts_es['French'] = 'Francesa'\n", + "lang_texts_es['Potato'] = 'Patata'\n", + "lang_texts_es['Rice'] = 'Arroz'\n", + "lang_texts_es['Bread'] = 'Pan'\n", + "lang_texts_es['Whale'] = 'Ballena'\n", + "lang_texts_es['Elephant'] = 'Elefante'\n", + "lang_texts_es['Rhinoceros'] = 'Rinoceronte'\n", + "lang_texts_es['Water'] = 'Agua'\n", + "lang_texts_es['Iron'] = 'Hierro'\n", + "lang_texts_es[''] = ''\n", + "\n", + "#Italian dictionary\n", + "\n", + "lang_texts_it = {}\n", + "lang_texts_it['yes'] = 'si'\n", + "lang_texts_it['no'] = 'no'\n", + "lang_texts_it['explore'] = 'esplorare'\n", + "lang_texts_it['examine'] = 'esaminare'\n", + "lang_texts_it['integer'] = 'Per favore, digita solo il numero delle opzioni disponibili'\n", + "lang_texts_it['intro'] = 'Ci si sveglia su un divano e ci si ritrova in una strana casa senza finestre in cui non si è mai stati prima. Non ricordate perché siete qui e cosa è successo prima. Sentite che un pericolo sconosciuto si sta avvicinando e dovete uscire dalla casa, ORA!'\n", + "lang_texts_it['escape'] = 'CORRERE! E non tornare più!\\n\\nCongratulazioni! Sei riuscito a fuggire dalla stanza!'\n", + "lang_texts_it['in'] = 'Ora siete nella '\n", + "lang_texts_it['next_room'] = 'Vuoi andare nella prossima stanza?'\n", + "lang_texts_it['examine_do'] = 'Cosa desideri esaminare?'\n", + "lang_texts_it['repeat'] = \"Non sono sicuro di cosa intendi. Scegli un'opzione valida.\"\n", + "lang_texts_it['explore_do'] = 'Esplorate la stanza. Questo è '\n", + "lang_texts_it['find'] = 'Tu trovi '\n", + "lang_texts_it['you_examine'] = 'Tu esamini '\n", + "lang_texts_it['unlock'] = 'La apri con una chiave che possiedi.'\n", + "lang_texts_it['locked'] = \"È chiusa a chiave ma non avete la chiave.\"\n", + "lang_texts_it['nothing'] = \"Non c'è nulla di interessante\"\n", + "lang_texts_it['none'] = \"L'oggetto richiesto non si trova nella stanza attuale.\"\n", + "lang_texts_it['option'] = 'Opzione:'\n", + "lang_texts_it['select'] = 'Seleziona una opzione:'\n", + "lang_texts_it['selected'] = 'Opzione selezionata: '\n", + "lang_texts_it['no_valid'] = ' Selezionare un numero valido'\n", + "lang_texts_it['couch'] = 'Divano'\n", + "lang_texts_it['piano'] = 'Pianoforte'\n", + "lang_texts_it['door a'] = 'porta a'\n", + "lang_texts_it['Queen Bed'] = 'Letto matrimoniale'\n", + "lang_texts_it['door b'] = 'porta b'\n", + "lang_texts_it['door c'] = 'porta c'\n", + "lang_texts_it['Double Bed'] = 'Letto doppio'\n", + "lang_texts_it['Dresser'] = 'Comò'\n", + "lang_texts_it['Dining Table'] = 'Tavolo da pranzo'\n", + "lang_texts_it['door d'] = 'porta d'\n", + "lang_texts_it['game room'] = 'Sala giochi'\n", + "lang_texts_it['Bed Room 1'] = 'Camera da letto 1'\n", + "lang_texts_it['Bed Room 2'] = 'Camera da letto 2'\n", + "lang_texts_it['Living Room'] = 'Soggiorno'\n", + "lang_texts_it['outside'] = 'Fuori'\n", + "lang_texts_it['key for door a'] = 'chiave per porta a'\n", + "lang_texts_it['key for door b'] = 'chiave per porta b'\n", + "lang_texts_it['key for door c'] = 'chiave per porta c'\n", + "lang_texts_it['key for door d'] = 'chiave per porta d'\n", + "lang_texts_it['Question a'] = 'Di quale nazionalità si credeva fosse Colombo?'\n", + "lang_texts_it['Question b'] = 'Qual è il cibo più consumato al mondo?'\n", + "lang_texts_it['Question c'] = 'Qual è il mammifero più grande del mondo?'\n", + "lang_texts_it['Question d'] = 'Che pesa di più, 1 kg di acqua o 1 kg di ferro?'\n", + "lang_texts_it['door blue'] = 'Porta Blu'\n", + "lang_texts_it['door pink'] = 'Porta Rosa'\n", + "lang_texts_it['door red'] = 'Porta Rossa'\n", + "lang_texts_it['door black'] = 'Porta Nera'\n", + "lang_texts_it['door white'] = 'Porta Bianca'\n", + "lang_texts_it['ghost quiz'] = \"L'enigma dei fantasmi\"\n", + "lang_texts_it['Question a correct'] = \"Bene... Continua a cercare l'uscita...\"\n", + "lang_texts_it['Question a failed'] = 'Non fuggirai... mai'\n", + "lang_texts_it['Question b correct'] = 'Puoi andare... per ora...'\n", + "lang_texts_it['Question b failed'] = 'Bel tentativo...'\n", + "lang_texts_it['Question c correct'] = \"Vero...Chi penserebbe che un mammifero possa vivere sott'acqua?...\"\n", + "lang_texts_it['Question c failed'] = 'Non ti sarà permesso andare da nessuna parte...'\n", + "lang_texts_it['Question d correct'] = 'Intelligente...'\n", + "lang_texts_it['Question d failed'] = 'ehehehehe...'\n", + "lang_texts_it['choose_door'] = 'Dal momento che hai fallito le tue risposte... è ora di scegliere una porta.'\n", + "lang_texts_it['correct_door'] = 'Congratulazioni! puoi vivere un altro giorno'\n", + "lang_texts_it['wrong_door'] = 'È ora di restare qui... PER SEMPRE!'\n", + "lang_texts_it['Spanish'] = 'Spagnolo'\n", + "lang_texts_it['Italian'] = 'Italiano'\n", + "lang_texts_it['French'] = 'Francese'\n", + "lang_texts_it['Potato'] = 'Patata'\n", + "lang_texts_it['Rice'] = 'Riso'\n", + "lang_texts_it['Bread'] = 'Pane'\n", + "lang_texts_it['Whale'] = 'Balena'\n", + "lang_texts_it['Elephant'] = 'Elefante'\n", + "lang_texts_it['Rhinoceros'] = 'Rinoceronte'\n", + "lang_texts_it['Water'] = 'Acqua'\n", + "lang_texts_it['Iron'] = 'Ferro'\n", + "lang_texts_it[''] = ''\n", + "\n", + "#Portuguese dictionary\n", + "\n", + "lang_texts_pt = {}\n", + "lang_texts_pt['yes'] = 'sim'\n", + "lang_texts_pt['no'] = 'não'\n", + "lang_texts_pt['explore'] = 'explorar'\n", + "lang_texts_pt['examine'] = 'examinar'\n", + "lang_texts_pt['integer'] = 'Por favor, digite apenas o número das opções'\n", + "lang_texts_pt['intro'] = 'Você acorda em um sofá e se encontra em uma casa estranha, sem janelas, na qual nunca esteve antes. Você não se lembra por que está aqui e o que aconteceu antes. Você sente que algum perigo desconhecido está se aproximando e você deve sair de casa, AGORA!'\n", + "lang_texts_pt['escape'] = 'CORRE! E não volte mais!\\n\\nParabéns! Você escapou do quarto!'\n", + "lang_texts_pt['in'] = 'Você está agora em '\n", + "lang_texts_pt['next_room'] = 'Você quer ir para a próxima sala?'\n", + "lang_texts_pt['examine_do'] = 'O que você gostaria de examinar?'\n", + "lang_texts_pt['repeat'] = \"Não tenho certeza do que você quer dizer. Escolha uma opção válida.\"\n", + "lang_texts_pt['explore_do'] = 'Você explora a sala. Isto é '\n", + "lang_texts_pt['find'] = 'Você encontra '\n", + "lang_texts_pt['you_examine'] = 'Você examina '\n", + "lang_texts_pt['unlock'] = 'Você desbloqueia com uma chave que você tem.'\n", + "lang_texts_pt['locked'] = \"Está trancado, mas você não tem a chave.\"\n", + "lang_texts_pt['nothing'] = \"Não há nada de interessante nisso.\"\n", + "lang_texts_pt['none'] = 'O item solicitado não foi encontrado na sala atual.'\n", + "lang_texts_pt['option'] = 'Opção:'\n", + "lang_texts_pt['select'] = 'Selecione uma opção:'\n", + "lang_texts_pt['selected'] = 'Opção selecionada: '\n", + "lang_texts_pt['no_valid'] = 'Por favor, selecione um número válido'\n", + "lang_texts_pt['couch'] = 'sofá'\n", + "lang_texts_pt['piano'] = 'piano'\n", + "lang_texts_pt['door a'] = 'porta a'\n", + "lang_texts_pt['Queen Bed'] = 'Cama de casal'\n", + "lang_texts_pt['door b'] = 'porta b'\n", + "lang_texts_pt['door c'] = 'porta c'\n", + "lang_texts_pt['Double Bed'] = 'Cama Dupla'\n", + "lang_texts_pt['Dresser'] = 'Aparador'\n", + "lang_texts_pt['Dining Table'] = 'Mesa de jantar'\n", + "lang_texts_pt['door d'] = 'porta d'\n", + "lang_texts_pt['game room'] = 'Sala de jogos'\n", + "lang_texts_pt['Bed Room 1'] = 'Quarto 1'\n", + "lang_texts_pt['Bed Room 2'] = 'Quarto 2'\n", + "lang_texts_pt['Living Room'] = 'Sala de estar'\n", + "lang_texts_pt['outside'] = 'fora'\n", + "lang_texts_pt['key for door a'] = 'chave para porta a'\n", + "lang_texts_pt['key for door b'] = 'chave para porta b'\n", + "lang_texts_pt['key for door c'] = 'chave para porta c'\n", + "lang_texts_pt['key for door d'] = 'chave para porta d'\n", + "lang_texts_pt['Question a'] = 'Qual era a nacionalidade de Colombo?'\n", + "lang_texts_pt['Question b'] = 'Qual é o alimento mais consumido no mundo?'\n", + "lang_texts_pt['Question c'] = 'Qual é o maior mamífero do mundo?'\n", + "lang_texts_pt['Question d'] = 'O que pesa mais, 1 kg de água ou 1 kg de ferro?'\n", + "lang_texts_pt['door blue'] = 'Porta Azul'\n", + "lang_texts_pt['door pink'] = 'Porta Rosa'\n", + "lang_texts_pt['door red'] = 'Porta Vermelha'\n", + "lang_texts_pt['door black'] = 'Porta Preta'\n", + "lang_texts_pt['door white'] = 'Porta Branca'\n", + "lang_texts_pt['ghost quiz'] = 'Teste Fantasma'\n", + "lang_texts_pt['Question a correct'] = 'Ok... Continue procurando a saída...'\n", + "lang_texts_pt['Question a failed'] = 'Você não vai escapar... nunca'\n", + "lang_texts_pt['Question b correct'] = 'Você pode ir... por enquanto...'\n", + "lang_texts_pt['Question b failed'] = 'Boa tentativa...'\n", + "lang_texts_pt['Question c correct'] = \"Certo... Quem pensaria que um mamífero poderia viver debaixo d'água?...\"\n", + "lang_texts_pt['Question c failed'] = 'Você não poderá ir a lugar nenhum...'\n", + "lang_texts_pt['Question d correct'] = 'Inteligente...'\n", + "lang_texts_pt['Question d failed'] = 'Hehehehe...'\n", + "lang_texts_pt['choose_door'] = 'Já que você falhou em suas respostas... é hora de escolher uma porta.'\n", + "lang_texts_pt['correct_door'] = 'Parabéns! você pode viver outro dia'\n", + "lang_texts_pt['wrong_door'] = 'É hora de ficar aqui... PARA SEMPRE!'\n", + "lang_texts_pt['Spanish'] = 'Espanhol'\n", + "lang_texts_pt['Italian'] = 'Italiano'\n", + "lang_texts_pt['French'] = 'Francesa'\n", + "lang_texts_pt['Potato'] = 'Batata'\n", + "lang_texts_pt['Rice'] = 'Arroz'\n", + "lang_texts_pt['Bread'] = 'Pão'\n", + "lang_texts_pt['Whale'] = 'Baleia'\n", + "lang_texts_pt['Elephant'] = 'Elefante'\n", + "lang_texts_pt['Rhinoceros'] = 'Rinoceronte'\n", + "lang_texts_pt['Water'] = 'Água'\n", + "lang_texts_pt['Iron'] = 'Ferro'\n", + "lang_texts_pt[''] = ''\n", + "\n", + "#Main Dictionary to choose which dictionary we will need\n", + "\n", + "\n", + "lang_game = {}\n", + "lang_game['en'] = ['english',lang_texts_en]\n", + "lang_game['es'] = ['spanish',lang_texts_es]\n", + "lang_game['it'] = ['italian',lang_texts_it]\n", + "lang_game['pt'] = ['portuguese',lang_texts_pt]\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def selectFromDict(options, name=''):\n", + " \"\"\"\n", + " Function to add options instead of writing\n", + " \"\"\"\n", + "\n", + " index = 0\n", + " indexValidList = []\n", + " print(name)\n", + " print(lang_game[game_state[\"language\"]][1]['select'])\n", + " for optionName in options:\n", + " index = index + 1\n", + " indexValidList.extend([options[optionName]])\n", + " print(str(index) + ') ' + optionName)\n", + " inputValid = False\n", + " while not inputValid:\n", + " try:\n", + " inputRaw = int(input(lang_game[game_state[\"language\"]][1]['option']))\n", + " \n", + " inputNo = inputRaw - 1\n", + " if inputNo > -1 and inputNo < len(indexValidList):\n", + " selected = indexValidList[inputNo] \n", + " print(lang_game[game_state[\"language\"]][1]['selected'] + list(options.keys())[list(options.values()).index(selected)]) \n", + " inputValid = True\n", + " break\n", + " else:\n", + " print(lang_game[game_state[\"language\"]][1]['no_valid'])\n", + " except ValueError:\n", + " print(lang_game[game_state[\"language\"]][1]['integer'])\n", + " \n", + " print('\\n')\n", + " \n", + " return selected\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def ghost_quiz(key):\n", + " \"\"\"\n", + " Function to ask a question every time that find a key\n", + " Every fail increases the dificulty to escape \n", + " \"\"\"\n", + " answer = selectFromDict({lang_game[game_state[\"language\"]][1][value]:key for key,value in object_relations[key['question']['name']][0].items()},lang_game[game_state[\"language\"]][1][key['question']['name']])\n", + " \n", + " if answer == key['question']['correct answer']:\n", + " print(lang_game[game_state[\"language\"]][1][key['question']['name'] + ' correct'])\n", + " else:\n", + " print(lang_game[game_state[\"language\"]][1][key['question']['name'] + ' failed'])\n", + " game_state['hard_scape'] += 1\n", + " \n", + "def ghost_doors(): \n", + " \"\"\"\n", + " Function to give the chance to choose a door when failed any question\n", + "\n", + " \"\"\"\n", + " \n", + " if (game_state[\"hard_scape\"]>0):\n", + " print(lang_game[game_state[\"language\"]][1]['choose_door'])\n", + "\n", + " game_state['escape door'] = object_relations['Ghost Room'][random.randrange(game_state[\"hard_scape\"]+1)]\n", + " \n", + " #Test for the escape door\n", + " #print(game_state['escape door'])\n", + "\n", + " dict_escape_room = {}\n", + " for i in range(game_state[\"hard_scape\"]+1): \n", + " dict_escape_room[lang_game[game_state[\"language\"]][1][object_relations['Ghost Room'][i]['name']]] = i \n", + "\n", + " if (game_state['escape door'] == object_relations['Ghost Room'][selectFromDict(dict_escape_room,'')]):\n", + " print(lang_game[game_state[\"language\"]][1]['correct_door'])\n", + " play_sound('victory')\n", + " else:\n", + " print(lang_game[game_state[\"language\"]][1]['wrong_door'])\n", + " play_sound('fail')\n", + " else: \n", + " print(lang_game[game_state[\"language\"]][1]['escape']) \n", + " play_sound('victory')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def play_sound(sound):\n", + " \"\"\"\n", + " Play the sound selected\n", + " \"\"\"\n", + " \n", + " if (sound == 'piano'):\n", + " playsound(Path(\"sounds/piano_sound_effect.mp3\"))\n", + " elif (sound == 'victory'):\n", + " playsound(Path(\"sounds/Victory_sound.mp3\"))\n", + " elif (sound == 'fail'): \n", + " playsound(Path(\"sounds/Fail_sound_effect.mp3\"))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def show_room(room):\n", + " \"\"\"\n", + " Show an image related to the room\n", + " \"\"\"\n", + " \n", + " if (room[\"name\"].lower() == game_room['name'].lower()): \n", + " img = Image.open(Path('images/Game_room.png'))\n", + " img.show()\n", + " elif (room[\"name\"].lower() == bedroom_1['name'].lower()):\n", + " img = Image.open(Path('images/Bedroom_1.png'))\n", + " img.show()\n", + " elif (room[\"name\"].lower() == bedroom_2['name'].lower()):\n", + " img = Image.open(Path('images/Bedroom_2.png'))\n", + " img.show()\n", + " elif (room[\"name\"].lower() == living_room['name'].lower()):\n", + " img = Image.open(Path('images/Living_room.png'))\n", + " img.show()\n", + " \n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def linebreak():\n", + " \"\"\"\n", + " Print a line break\n", + " \"\"\"\n", + " print(\"\\n\\n\")\n", + "\n", + "def start_game():\n", + " \"\"\"\n", + " Start the game\n", + " \"\"\"\n", + " \n", + " #game language selection\n", + " \n", + " game_state['language'] = (selectFromDict({value[0]:key for key,value in lang_game.items()},'Which language do you want to use?')) \n", + " \n", + " #intro of the game \n", + " \n", + " print(lang_game[game_state[\"language\"]][1]['intro'])\n", + " \n", + " #create a loop because inside the play_room function could create problems the execution of the playroom recursively\n", + " \n", + " while game_state['current_room'] != game_state['target_room']:\n", + " play_room(game_state[\"current_room\"]) \n", + " \n", + " if(game_state[\"current_room\"] == game_state[\"target_room\"]):\n", + " ghost_doors() \n", + " \n", + "def play_room(room):\n", + " \"\"\"\n", + " Play a room. First check if the room being played is the target room.\n", + " If it is, the game will end with success. Otherwise, let player either \n", + " explore (list all items in this room) or examine an item found here.\n", + " \"\"\"\n", + " \n", + " show_room(room)\n", + " \n", + " while game_state['current_room'] != game_state['target_room']:\n", + " linebreak() \n", + " \n", + " print(lang_game[game_state[\"language\"]][1]['in'] + lang_game[game_state[\"language\"]][1][room[\"name\"]]) \n", + "\n", + " intended_action = selectFromDict({lang_game[game_state[\"language\"]][1]['examine']:'examine',lang_game[game_state[\"language\"]][1]['explore']:'explore'})\n", + "\n", + " if intended_action == \"explore\":\n", + " explore_room(room)\n", + "\n", + " #create loop ouside to prevent the execution of the function recursively \n", + " #play_room(room)\n", + " elif intended_action == \"examine\":\n", + "\n", + " game_state[\"current_room\"] = examine_item(selectFromDict({lang_game[game_state[\"language\"]][1][items['name']]:items['name'] for items in object_relations[game_state['current_room']['name']]},lang_game[game_state[\"language\"]][1]['examine_do']))\n", + " if (game_state[\"current_room\"] != room):\n", + " return \n", + " else:\n", + "\n", + " print(lang_game[game_state[\"language\"]][1]['repeat'])\n", + "\n", + " #create loop ouside to prevent the execution of the function recursively \n", + " #play_room(room)\n", + "\n", + " linebreak()\n", + "\n", + "def explore_room(room):\n", + " \"\"\"\n", + " Explore a room. List all items belonging to this room.\n", + " \"\"\"\n", + " \n", + " items = [lang_game[game_state[\"language\"]][1][i[\"name\"]] for i in object_relations[room[\"name\"]]]\n", + " \n", + " print(lang_game[game_state[\"language\"]][1]['explore_do'] + lang_game[game_state[\"language\"]][1][room[\"name\"]] + '. ' + lang_game[game_state[\"language\"]][1]['find'] + \", \".join(items))\n", + "\n", + "def get_next_room_of_door(door, current_room):\n", + " \"\"\"\n", + " From object_relations, find the two rooms connected to the given door.\n", + " Return the room that is not the current_room.\n", + " \"\"\"\n", + " connected_rooms = object_relations[door[\"name\"]]\n", + " for room in connected_rooms:\n", + " if(not current_room == room):\n", + " return room\n", + "\n", + "def examine_item(item_name):\n", + " \"\"\"\n", + " Examine an item which can be a door or furniture.\n", + " First make sure the intended item belongs to the current room.\n", + " Then check if the item is a door. Tell player if key hasn't been \n", + " collected yet. Otherwise ask player if they want to go to the next\n", + " room. If the item is not a door, then check if it contains keys.\n", + " Collect the key if found and update the game state. At the end,\n", + " play either the current or the next room depending on the game state\n", + " to keep playing.\n", + " \"\"\"\n", + " \n", + " current_room = game_state[\"current_room\"]\n", + " next_room = \"\"\n", + " output = None\n", + " \n", + " for item in object_relations[current_room[\"name\"]]:\n", + " if(item[\"name\"] == item_name):\n", + " key_found = False\n", + " \n", + " output = lang_game[game_state[\"language\"]][1]['you_examine'] + lang_game[game_state[\"language\"]][1][item_name] + \". \"\n", + " \n", + " if(item[\"type\"] == \"door\"):\n", + " have_key = False\n", + " \n", + " for key in game_state[\"keys_collected\"]:\n", + " if(key[\"target\"] == item):\n", + " have_key = True\n", + " if(have_key): \n", + " output += lang_game[game_state[\"language\"]][1]['unlock']\n", + " \n", + " next_room = get_next_room_of_door(item, current_room)\n", + " else: \n", + " output += lang_game[game_state[\"language\"]][1]['locked']\n", + " else:\n", + " if(item[\"name\"] == 'piano'):\n", + " play_sound('piano')\n", + " \n", + " if(item[\"name\"] in object_relations and len(object_relations[item[\"name\"]])>0):\n", + " item_found = object_relations[item[\"name\"]].pop()\n", + " game_state[\"keys_collected\"].append(item_found)\n", + " \n", + " key_found = True\n", + " \n", + " output += lang_game[game_state[\"language\"]][1]['find'] + lang_game[game_state[\"language\"]][1][item_found[\"name\"]] + \".\"\n", + " else:\n", + " output += lang_game[game_state[\"language\"]][1]['nothing']\n", + " \n", + " print(output)\n", + " \n", + " if (key_found): \n", + " print(\"\\n\" + lang_game[game_state[\"language\"]][1]['ghost quiz'] + \"\\n\")\n", + " ghost_quiz(item_found)\n", + " \n", + " break\n", + "\n", + " if(output is None): \n", + " print(lang_game[game_state[\"language\"]][1]['none'])\n", + " \n", + " if(next_room and selectFromDict({lang_game[game_state[\"language\"]][1]['yes']:'yes',lang_game[game_state[\"language\"]][1]['no']:'no'},lang_game[game_state[\"language\"]][1]['next_room']) == 'yes'):\n", + " #create loop ouside to prevent the execution of the function recursively \n", + " #play_room(next_room)\n", + " #game_state[\"current_room\"] = next_room\n", + " return next_room\n", + " else:\n", + " #create loop ouside to prevent the execution of the function recursively \n", + " #play_room(current_room)\n", + " return current_room" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "game_state = INIT_GAME_STATE.copy()\n", + "\n", + "start_game()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/your-code/.ipynb_checkpoints/main_Oscar_Iglesias v1-checkpoint.ipynb b/your-code/.ipynb_checkpoints/main_Oscar_Iglesias v1-checkpoint.ipynb new file mode 100644 index 00000000..7878f70d --- /dev/null +++ b/your-code/.ipynb_checkpoints/main_Oscar_Iglesias v1-checkpoint.ipynb @@ -0,0 +1,672 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "# define rooms and items\n", + "\n", + "couch = {\n", + " \"name\": \"couch\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "door_a = {\n", + " \"name\": \"door a\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_a = {\n", + " \"name\": \"key for door a\",\n", + " \"type\": \"key\",\n", + " \"target\": door_a,\n", + "}\n", + "\n", + "piano = {\n", + " \"name\": \"piano\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "game_room = {\n", + " \"name\": \"game room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "#New Rooms\n", + "\n", + "door_b = {\n", + " \"name\": \"door b\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_c = {\n", + " \"name\": \"door c\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_d = {\n", + " \"name\": \"door d\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_b = {\n", + " \"name\": \"key for door b\",\n", + " \"type\": \"key\",\n", + " \"target\": door_b,\n", + "}\n", + "\n", + "key_c = {\n", + " \"name\": \"key for door c\",\n", + " \"type\": \"key\",\n", + " \"target\": door_c,\n", + "}\n", + "\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d,\n", + "}\n", + "\n", + "queen_bed = {\n", + " \"name\": \"Queen Bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "double_bed = {\n", + " \"name\": \"Double Bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dresser = {\n", + " \"name\": \"Dresser\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dining_table = {\n", + " \"name\": \"Dining Table\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "bedroom_1 = {\n", + " \"name\": \"Bed Room 1\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "bedroom_2 = {\n", + " \"name\": \"Bed Room 2\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "living_room = {\n", + " \"name\": \"Living Room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "\n", + "#all_rooms = [game_room, bedroom_1, bedroom_2, living_room, outside]\n", + "\n", + "#all_doors = [door_a, door_b, door_c, door_d]\n", + "\n", + "# define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"game room\": [couch, piano, door_a],\n", + " \"piano\": [key_a],\n", + " \"Bed Room 1\": [queen_bed, door_b, door_c],\n", + " \"Queen Bed\": [key_b],\n", + " \"Bed Room 2\": [double_bed, dresser, door_b],\n", + " \"Double Bed\": [key_c],\n", + " \"Dresser\": [key_d],\n", + " \"Living Room\": [dining_table, door_d],\n", + " \"outside\": [door_d],\n", + " \"door a\": [game_room, bedroom_1],\n", + " \"door b\": [bedroom_1, bedroom_2],\n", + " \"door c\": [bedroom_1, living_room],\n", + " \"door d\": [living_room, outside]\n", + "}\n", + "\n", + "# define game state. Do not directly change this dict. \n", + "# Instead, when a new game starts, make a copy of this\n", + "# dict and use the copy to store gameplay state. This \n", + "# way you can replay the game multiple times.\n", + "\n", + "# Added language\n", + "\n", + "INIT_GAME_STATE = {\n", + " \"language\": 'en',\n", + " \"current_room\": game_room,\n", + " \"keys_collected\": [],\n", + " \"target_room\": outside\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "#Creating the Multi Language dictionaries\n", + "\n", + "#English dictionary\n", + "\n", + "lang_texts_en = {}\n", + "lang_texts_en['yes'] = 'yes'\n", + "lang_texts_en['no'] = 'no'\n", + "lang_texts_en['explore'] = 'explore'\n", + "lang_texts_en['examine'] = 'examine'\n", + "lang_texts_en['integer'] = 'Please type only the number of the options'\n", + "lang_texts_en['intro'] = '''You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!'''\n", + "lang_texts_en['escape'] = 'Congrats! You escaped the room!'\n", + "lang_texts_en['in'] = 'You are now in '\n", + "lang_texts_en['next_room'] = 'Do you want to go to the next room?'\n", + "lang_texts_en['examine_do'] = 'What would you like to examine?'\n", + "lang_texts_en['repeat'] = \"Not sure what you mean. Choose a valid option.\"\n", + "lang_texts_en['explore_do'] = 'You explore the room. This is '\n", + "lang_texts_en['find'] = 'You find '\n", + "lang_texts_en['you_examine'] = 'You examine '\n", + "lang_texts_en['unlock'] = 'You unlock it with a key you have.'\n", + "lang_texts_en['locked'] = \"It is locked but you don't have the key.\"\n", + "lang_texts_en['nothing'] = \"There isn't anything interesting about it.\"\n", + "lang_texts_en['none'] = 'The item you requested is not found in the current room.'\n", + "lang_texts_en['option'] = 'Option:'\n", + "lang_texts_en['select'] = 'Select one option:'\n", + "lang_texts_en['selected'] = 'Selected option: '\n", + "lang_texts_en['no_valid'] = 'Please select a valid number'\n", + "lang_texts_en['couch'] = 'couch'\n", + "lang_texts_en['piano'] = 'piano'\n", + "lang_texts_en['door a'] = 'door a'\n", + "lang_texts_en['Queen Bed'] = 'Queen Bed'\n", + "lang_texts_en['door b'] = 'door b'\n", + "lang_texts_en['door c'] = 'door c'\n", + "lang_texts_en['Double Bed'] = 'Double Bed'\n", + "lang_texts_en['Dresser'] = 'Dresser'\n", + "lang_texts_en['Dining Table'] = 'Dining Table'\n", + "lang_texts_en['door d'] = 'door d'\n", + "lang_texts_en['game room'] = 'Game room'\n", + "lang_texts_en['Bed Room 1'] = 'Bed Room 1'\n", + "lang_texts_en['Bed Room 2'] = 'Bed Room 2'\n", + "lang_texts_en['Living Room'] = 'Living Room'\n", + "lang_texts_en['outside'] = 'outside'\n", + "lang_texts_en['key for door a'] = 'key for door a'\n", + "lang_texts_en['key for door b'] = 'key for door b'\n", + "lang_texts_en['key for door c'] = 'key for door c'\n", + "lang_texts_en['key for door d'] = 'key for door d'\n", + "\n", + "#Spanish dictionary\n", + "\n", + "lang_texts_es = {}\n", + "lang_texts_es['yes'] = 'sí'\n", + "lang_texts_es['no'] = 'no'\n", + "lang_texts_es['explore'] = 'explorar'\n", + "lang_texts_es['examine'] = 'examinar'\n", + "lang_texts_es['integer'] = 'Por favor teclea solamente números de las opciones'\n", + "lang_texts_es['intro'] = 'Te despiertas en un sofá y te encuentras en una casa extraña sin ventanas en la que nunca has estado antes. No recuerdas por qué estás aquí y qué había sucedido antes. Sientes que se acerca un peligro desconocido y debes salir de la casa, ¡YA!'\n", + "lang_texts_es['escape'] = '¡Felicidades! ¡Has escapado!'\n", + "lang_texts_es['in'] = 'Estás en '\n", + "lang_texts_es['next_room'] = '¿Quieres ir a la siguiente habitación?'\n", + "lang_texts_es['examine_do'] = '¿Qué te gustaría examinar?'\n", + "lang_texts_es['repeat'] = \"No estoy seguro de lo que quieres. Seleccionar una opción válida.\"\n", + "lang_texts_es['explore_do'] = 'Exploras la habitación. Esta es '\n", + "lang_texts_es['find'] = 'Encuentras '\n", + "lang_texts_es['you_examine'] = 'Tú examinas '\n", + "lang_texts_es['unlock'] = 'La abres con la llave que tú tienes.'\n", + "lang_texts_es['locked'] = \"Está cerrada pero tú no tienes la llave.\"\n", + "lang_texts_es['nothing'] = \"No se ve nada interesante\"\n", + "lang_texts_es['none'] = 'El elemento que solició no se encuentra en la sala actual.'\n", + "lang_texts_es['option'] = 'Opción:'\n", + "lang_texts_es['select'] = 'Escoge una opción:'\n", + "lang_texts_es['selected'] = 'Opción escogida: '\n", + "lang_texts_es['no_valid'] = 'Por favor, escoge un número válido'\n", + "lang_texts_es['couch'] = 'sofá'\n", + "lang_texts_es['piano'] = 'piano'\n", + "lang_texts_es['door a'] = 'puerta a'\n", + "lang_texts_es['Queen Bed'] = 'Cama de matrimonio'\n", + "lang_texts_es['door b'] = 'puerta b'\n", + "lang_texts_es['door c'] = 'puerta c'\n", + "lang_texts_es['Double Bed'] = 'Cama Doble'\n", + "lang_texts_es['Dresser'] = 'Cómoda'\n", + "lang_texts_es['Dining Table'] = 'Mesa de comedor'\n", + "lang_texts_es['door d'] = 'puerta d'\n", + "lang_texts_es['game room'] = 'Habitación de juegos'\n", + "lang_texts_es['Bed Room 1'] = 'Habitación 1'\n", + "lang_texts_es['Bed Room 2'] = 'Habitación 2'\n", + "lang_texts_es['Living Room'] = 'Sala de estar'\n", + "lang_texts_es['outside'] = 'Fuera'\n", + "lang_texts_es['key for door a'] = 'llave para puerta a'\n", + "lang_texts_es['key for door b'] = 'llave para puerta b'\n", + "lang_texts_es['key for door c'] = 'llave para puerta c'\n", + "lang_texts_es['key for door d'] = 'llave para puerta d'\n", + "\n", + "#Portuguese dictionary\n", + "\n", + "lang_texts_pt = {}\n", + "lang_texts_pt['yes'] = 'sim'\n", + "lang_texts_pt['no'] = 'não'\n", + "lang_texts_pt['explore'] = 'explorar'\n", + "lang_texts_pt['examine'] = 'examinar'\n", + "lang_texts_pt['integer'] = 'Por favor, digite apenas o número das opções'\n", + "lang_texts_pt['intro'] = 'Você acorda em um sofá e se encontra em uma casa estranha, sem janelas, na qual nunca esteve antes. Você não se lembra por que está aqui e o que aconteceu antes. Você sente que algum perigo desconhecido está se aproximando e você deve sair de casa, AGORA!'\n", + "lang_texts_pt['escape'] = 'Parabéns! Você escapou do quarto!'\n", + "lang_texts_pt['in'] = 'Você está agora em '\n", + "lang_texts_pt['next_room'] = 'Você quer ir para a próxima sala?'\n", + "lang_texts_pt['examine_do'] = 'O que você gostaria de examinar?'\n", + "lang_texts_pt['repeat'] = \"Não tenho certeza do que você quer dizer. Escolha uma opção válida.\"\n", + "lang_texts_pt['explore_do'] = 'Você explora a sala. Isto é '\n", + "lang_texts_pt['find'] = 'Você encontra '\n", + "lang_texts_pt['you_examine'] = 'Você examina '\n", + "lang_texts_pt['unlock'] = 'Você desbloqueia com uma chave que você tem.'\n", + "lang_texts_pt['locked'] = \"Está trancado, mas você não tem a chave.\"\n", + "lang_texts_pt['nothing'] = \"Não há nada de interessante nisso.\"\n", + "lang_texts_pt['none'] = 'O item solicitado não foi encontrado na sala atual.'\n", + "lang_texts_pt['option'] = 'Opção:'\n", + "lang_texts_pt['select'] = 'Selecione uma opção:'\n", + "lang_texts_pt['selected'] = 'Opção selecionada: '\n", + "lang_texts_pt['no_valid'] = 'Por favor, selecione um número válido'\n", + "lang_texts_pt['couch'] = 'sofá'\n", + "lang_texts_pt['piano'] = 'piano'\n", + "lang_texts_pt['door a'] = 'porta a'\n", + "lang_texts_pt['Queen Bed'] = 'Cama de casal'\n", + "lang_texts_pt['door b'] = 'prta b'\n", + "lang_texts_pt['door c'] = 'porta c'\n", + "lang_texts_pt['Double Bed'] = 'Cama Dupla'\n", + "lang_texts_pt['Dresser'] = 'Aparador'\n", + "lang_texts_pt['Dining Table'] = 'Mesa de jantar'\n", + "lang_texts_pt['door d'] = 'porta d'\n", + "lang_texts_pt['game room'] = 'Sala de jogos'\n", + "lang_texts_pt['Bed Room 1'] = 'Quarto 1'\n", + "lang_texts_pt['Bed Room 2'] = 'Quarto 2'\n", + "lang_texts_pt['Living Room'] = 'Sala de estar'\n", + "lang_texts_pt['outside'] = 'fora'\n", + "lang_texts_pt['key for door a'] = 'chave para porta a'\n", + "lang_texts_pt['key for door b'] = 'chave para porta b'\n", + "lang_texts_pt['key for door c'] = 'chave para porta c'\n", + "lang_texts_pt['key for door d'] = 'chave para porta d'\n", + "\n", + "\n", + "#Main Dictionary to choose which dictionary we will need\n", + "\n", + "\n", + "lang_game = {}\n", + "lang_game['en'] = ['english',lang_texts_en]\n", + "lang_game['es'] = ['spanish',lang_texts_es]\n", + "lang_game['pt'] = ['portuguese',lang_texts_pt]\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "def selectFromDict(options, name=''):\n", + "\"\"\"\n", + "Function to add options instead of writing\n", + "\"\"\"\n", + "\n", + " index = 0\n", + " indexValidList = []\n", + " print(name)\n", + " print(lang_game[game_state[\"language\"]][1]['select'])\n", + " for optionName in options:\n", + " index = index + 1\n", + " indexValidList.extend([options[optionName]])\n", + " print(str(index) + ') ' + optionName)\n", + " inputValid = False\n", + " while not inputValid:\n", + " try:\n", + " inputRaw = int(input(lang_game[game_state[\"language\"]][1]['option']))\n", + " \n", + " inputNo = inputRaw - 1\n", + " if inputNo > -1 and inputNo < len(indexValidList):\n", + " selected = indexValidList[inputNo] \n", + " print(lang_game[game_state[\"language\"]][1]['selected'] + list(options.keys())[list(options.values()).index(selected)]) \n", + " inputValid = True\n", + " break\n", + " else:\n", + " print(lang_game[game_state[\"language\"]][1]['no_valid'])\n", + " except ValueError:\n", + " print(lang_game[game_state[\"language\"]][1]['integer'])\n", + " \n", + " print('\\n')\n", + " \n", + " return selected\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "def linebreak():\n", + " \"\"\"\n", + " Print a line break\n", + " \"\"\"\n", + " print(\"\\n\\n\")\n", + "\n", + "def start_game():\n", + " \"\"\"\n", + " Start the game\n", + " \"\"\"\n", + "\n", + " #game language selection\n", + " \n", + " game_state['language'] = (selectFromDict({value[0]:key for key,value in lang_game.items()},'Which language do you want to use?')) \n", + " \n", + " #intro of the game \n", + " \n", + " print(lang_game[game_state[\"language\"]][1]['intro'])\n", + " \n", + " #create a loop because inside the play_room function could create problems the execution of the playroom recursively\n", + " \n", + " while game_state['current_room'] != game_state['target_room']:\n", + " play_room(game_state[\"current_room\"])\n", + "\n", + "def play_room(room):\n", + " \"\"\"\n", + " Play a room. First check if the room being played is the target room.\n", + " If it is, the game will end with success. Otherwise, let player either \n", + " explore (list all items in this room) or examine an item found here.\n", + " \"\"\"\n", + " \n", + " #game_state[\"current_room\"] = room\n", + " if(game_state[\"current_room\"] == game_state[\"target_room\"]): \n", + " print(lang_game[game_state[\"language\"]][1]['escape'])\n", + " else: \n", + " while game_state['current_room'] != game_state['target_room']:\n", + " print(\"\\n\")\n", + " print(lang_game[game_state[\"language\"]][1]['in'] + lang_game[game_state[\"language\"]][1][room[\"name\"]]) \n", + "\n", + " intended_action = selectFromDict({lang_game[game_state[\"language\"]][1]['examine']:'examine',lang_game[game_state[\"language\"]][1]['explore']:'explore'})\n", + "\n", + " if intended_action == \"explore\":\n", + " explore_room(room)\n", + " \n", + " #create loop ouside to prevent the execution of the function recursively \n", + " #play_room(room)\n", + " elif intended_action == \"examine\":\n", + "\n", + " game_state[\"current_room\"] = examine_item(selectFromDict({lang_game[game_state[\"language\"]][1][items['name']]:items['name'] for items in object_relations[game_state['current_room']['name']]},lang_game[game_state[\"language\"]][1]['examine_do']))\n", + " if (game_state[\"current_room\"] != room):\n", + " return \n", + " else:\n", + "\n", + " print(lang_game[game_state[\"language\"]][1]['repeat'])\n", + " \n", + " #create loop ouside to prevent the execution of the function recursively \n", + " #play_room(room)\n", + " \n", + " linebreak()\n", + "\n", + "def explore_room(room):\n", + " \"\"\"\n", + " Explore a room. List all items belonging to this room.\n", + " \"\"\"\n", + " \n", + " items = [lang_game[game_state[\"language\"]][1][i[\"name\"]] for i in object_relations[room[\"name\"]]]\n", + " \n", + " print(lang_game[game_state[\"language\"]][1]['explore_do'] + lang_game[game_state[\"language\"]][1][room[\"name\"]] + '. ' + lang_game[game_state[\"language\"]][1]['find'] + \", \".join(items))\n", + "\n", + "def get_next_room_of_door(door, current_room):\n", + " \"\"\"\n", + " From object_relations, find the two rooms connected to the given door.\n", + " Return the room that is not the current_room.\n", + " \"\"\"\n", + " connected_rooms = object_relations[door[\"name\"]]\n", + " for room in connected_rooms:\n", + " if(not current_room == room):\n", + " return room\n", + "\n", + "def examine_item(item_name):\n", + " \"\"\"\n", + " Examine an item which can be a door or furniture.\n", + " First make sure the intended item belongs to the current room.\n", + " Then check if the item is a door. Tell player if key hasn't been \n", + " collected yet. Otherwise ask player if they want to go to the next\n", + " room. If the item is not a door, then check if it contains keys.\n", + " Collect the key if found and update the game state. At the end,\n", + " play either the current or the next room depending on the game state\n", + " to keep playing.\n", + " \"\"\"\n", + " \n", + " current_room = game_state[\"current_room\"]\n", + " next_room = \"\"\n", + " output = None\n", + " \n", + " for item in object_relations[current_room[\"name\"]]:\n", + " if(item[\"name\"] == item_name):\n", + " \n", + " output = lang_game[game_state[\"language\"]][1]['you_examine'] + lang_game[game_state[\"language\"]][1][item_name] + \". \"\n", + " \n", + " if(item[\"type\"] == \"door\"):\n", + " have_key = False\n", + " \n", + " for key in game_state[\"keys_collected\"]:\n", + " if(key[\"target\"] == item):\n", + " have_key = True\n", + " if(have_key): \n", + " output += lang_game[game_state[\"language\"]][1]['unlock']\n", + " \n", + " next_room = get_next_room_of_door(item, current_room)\n", + " else: \n", + " output += lang_game[game_state[\"language\"]][1]['locked']\n", + " else:\n", + " if(item[\"name\"] in object_relations and len(object_relations[item[\"name\"]])>0):\n", + " item_found = object_relations[item[\"name\"]].pop()\n", + " game_state[\"keys_collected\"].append(item_found)\n", + " \n", + " output += lang_game[game_state[\"language\"]][1]['find'] + lang_game[game_state[\"language\"]][1][item_found[\"name\"]] + \".\"\n", + " else:\n", + " output += lang_game[game_state[\"language\"]][1]['nothing']\n", + " print(output)\n", + " break\n", + "\n", + " if(output is None): \n", + " print(lang_game[game_state[\"language\"]][1]['none'])\n", + " \n", + " if(next_room and selectFromDict({lang_game[game_state[\"language\"]][1]['yes']:'yes',lang_game[game_state[\"language\"]][1]['no']:'no'},lang_game[game_state[\"language\"]][1]['next_room']) == 'yes'):\n", + " #create loop ouside to prevent the execution of the function recursively \n", + " #play_room(next_room)\n", + " #game_state[\"current_room\"] = next_room\n", + " return next_room\n", + " else:\n", + " #create loop ouside to prevent the execution of the function recursively \n", + " #play_room(current_room)\n", + " return current_room" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Which language do you want to use?\n", + "Select one option:\n", + "1) english\n", + "2) spanish\n", + "Option:1\n", + "Selected option: english\n", + "\n", + "\n", + "You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!\n", + "\n", + "\n", + "You are now in Game room\n", + "\n", + "Select one option:\n", + "1) examine\n", + "2) explore\n", + "Option:1\n", + "Selected option: examine\n", + "\n", + "\n", + "What would you like to examine?\n", + "Select one option:\n", + "1) couch\n", + "2) piano\n", + "3) door a\n", + "Option:2\n", + "Selected option: piano\n", + "\n", + "\n", + "You examine piano. You find key for door a.\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "You are now in Game room\n", + "\n", + "Select one option:\n", + "1) examine\n", + "2) explore\n", + "Option:1\n", + "Selected option: examine\n", + "\n", + "\n", + "What would you like to examine?\n", + "Select one option:\n", + "1) couch\n", + "2) piano\n", + "3) door a\n", + "Option:3\n", + "Selected option: door a\n", + "\n", + "\n", + "You examine door a. You unlock it with a key you have.\n", + "Do you want to go to the next room?\n", + "Select one option:\n", + "1) yes\n", + "2) no\n", + "Option:1\n", + "Selected option: yes\n", + "\n", + "\n", + "\n", + "\n", + "You are now in Bed Room 1\n", + "\n", + "Select one option:\n", + "1) examine\n", + "2) explore\n", + "Option:2\n", + "Selected option: explore\n", + "\n", + "\n", + "You explore the room. This is Bed Room 1. You find Queen Bed, door b, door c\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "You are now in Bed Room 1\n", + "\n", + "Select one option:\n", + "1) examine\n", + "2) explore\n", + "Option:2\n", + "Selected option: explore\n", + "\n", + "\n", + "You explore the room. This is Bed Room 1. You find Queen Bed, door b, door c\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "You are now in Bed Room 1\n", + "\n", + "Select one option:\n", + "1) examine\n", + "2) explore\n", + "Option:1\n", + "Selected option: examine\n", + "\n", + "\n", + "What would you like to examine?\n", + "Select one option:\n", + "1) Queen Bed\n", + "2) door b\n", + "3) door c\n", + "Option:1\n", + "Selected option: Queen Bed\n", + "\n", + "\n", + "You examine Queen Bed. You find key for door b.\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "You are now in Bed Room 1\n", + "\n", + "Select one option:\n", + "1) examine\n", + "2) explore\n", + "Option:2\n", + "Selected option: explore\n", + "\n", + "\n", + "You explore the room. This is Bed Room 1. You find Queen Bed, door b, door c\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "You are now in Bed Room 1\n", + "\n", + "Select one option:\n", + "1) examine\n", + "2) explore\n" + ] + } + ], + "source": [ + "game_state = INIT_GAME_STATE.copy()\n", + "\n", + "start_game()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/your-code/.ipynb_checkpoints/main_Oscar_Iglesias v2-checkpoint.ipynb b/your-code/.ipynb_checkpoints/main_Oscar_Iglesias v2-checkpoint.ipynb new file mode 100644 index 00000000..655fb5b6 --- /dev/null +++ b/your-code/.ipynb_checkpoints/main_Oscar_Iglesias v2-checkpoint.ipynb @@ -0,0 +1,439 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [], + "source": [ + "# define rooms and items\n", + "\n", + "couch = {\n", + " \"name\": \"couch\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "door_a = {\n", + " \"name\": \"door a\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_a = {\n", + " \"name\": \"key for door a\",\n", + " \"type\": \"key\",\n", + " \"target\": door_a,\n", + "}\n", + "\n", + "piano = {\n", + " \"name\": \"piano\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "game_room = {\n", + " \"name\": \"game room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "\"\"\"\n", + "New Rooms\n", + "\"\"\"\n", + "\n", + "door_b = {\n", + " \"name\": \"door b\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_c = {\n", + " \"name\": \"door c\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_d = {\n", + " \"name\": \"door d\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_b = {\n", + " \"name\": \"key for door b\",\n", + " \"type\": \"key\",\n", + " \"target\": door_b,\n", + "}\n", + "\n", + "key_c = {\n", + " \"name\": \"key for door c\",\n", + " \"type\": \"key\",\n", + " \"target\": door_c,\n", + "}\n", + "\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d,\n", + "}\n", + "\n", + "queen_bed = {\n", + " \"name\": \"Queen Bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "double_bed = {\n", + " \"name\": \"Double Bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dresser = {\n", + " \"name\": \"Dresser\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dining_table = {\n", + " \"name\": \"Dining Table\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "bedroom_1 = {\n", + " \"name\": \"Bed Room 1\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "bedroom_2 = {\n", + " \"name\": \"Bed Room 2\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "living_room = {\n", + " \"name\": \"Living Room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "\n", + "all_rooms = [game_room, bedroom_1, bedroom_2, living_room, outside]\n", + "\n", + "all_doors = [door_a, door_b, door_c, door_d]\n", + "\n", + "# define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"game room\": [couch, piano, door_a],\n", + " \"piano\": [key_a],\n", + " \"Bed Room 1\": [queen_bed, door_b, door_c],\n", + " \"Queen Bed\": [key_b],\n", + " \"Bed Room 2\": [double_bed, dresser, door_b],\n", + " \"Double Bed\": [key_c],\n", + " \"Dresser\": [key_d],\n", + " \"Living Room\": [dining_table, door_d],\n", + " \"outside\": [door_d],\n", + " \"door a\": [game_room, bedroom_1],\n", + " \"door b\": [bedroom_1, bedroom_2],\n", + " \"door c\": [bedroom_1, living_room],\n", + " \"door d\": [living_room, outside]\n", + "}\n", + "\n", + "# define game state. Do not directly change this dict. \n", + "# Instead, when a new game starts, make a copy of this\n", + "# dict and use the copy to store gameplay state. This \n", + "# way you can replay the game multiple times.\n", + "\n", + "INIT_GAME_STATE = {\n", + " \"language\": 'es',\n", + " \"current_room\": game_room,\n", + " \"keys_collected\": [],\n", + " \"target_room\": outside\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [], + "source": [ + "#Function to add options instead of writing\n", + "opt_yn = {}\n", + "opt_yn['Yes'] = 'yes'\n", + "opt_yn['No'] = 'no'\n", + "\n", + "def selectFromDict(options, name):\n", + "\n", + " index = 0\n", + " indexValidList = []\n", + " print('Select a ' + name + ':')\n", + " for optionName in options:\n", + " index = index + 1\n", + " indexValidList.extend([options[optionName]])\n", + " print(str(index) + ') ' + optionName)\n", + " inputValid = False\n", + " while not inputValid:\n", + " inputRaw = input(name + ': ')\n", + " inputNo = int(inputRaw) - 1\n", + " if inputNo > -1 and inputNo < len(indexValidList):\n", + " selected = indexValidList[inputNo]\n", + " print('Selected ' + name + ': ' + selected)\n", + " inputValid = True\n", + " break\n", + " else:\n", + " print('Please select a valid ' + name + ' number')\n", + "\n", + " return selected\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [], + "source": [ + "'''\n", + "Multi Language\n", + "'''\n", + "\n", + "'''\n", + "English\n", + "'''\n", + "\n", + "lang_texts_en = {}\n", + "lang_texts_en['yes'] = 'yes'\n", + "lang_texts_en['no'] = 'no'\n", + "lang_texts_en['intro'] = '''You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!'''\n", + "lang_texts_en['escape'] = 'Congrats! You escaped the room!'\n", + "lang_texts_en['in'] = 'You are now in '\n", + "lang_texts_en['to_do'] = \"What would you like to do? Type 'explore' or 'examine'?\"\n", + "lang_texts_en['examine'] = 'What would you like to examine?'\n", + "lang_texts_en['repeat'] = \"Not sure what you mean. Type 'explore' or 'examine'.\"\n", + "lang_texts_en['explore'] = 'You explore the room. This is '\n", + "lang_texts_en['find'] = 'You find '\n", + "lang_texts_en['you_examine'] = 'You examine '\n", + "lang_texts_en['unlock'] = 'You unlock it with a key you have.'\n", + "lang_texts_en['locked'] = \"It is locked but you don't have the key.\"\n", + "lang_texts_en['nothing'] = \"There isn't anything interesting about it.\"\n", + "lang_texts_en['none'] = 'The item you requested is not found in the current room.'\n", + "\n", + "'''\n", + "Spanish\n", + "'''\n", + "\n", + "lang_texts_es = {}\n", + "lang_texts_es['yes'] = 'sí'\n", + "lang_texts_es['no'] = 'no'\n", + "lang_texts_es['intro'] = 'Te despiertas en un sofá y te encuentras en una casa extraña sin ventanas en la que nunca has estado antes. No recuerdas por qué estás aquí y qué había sucedido antes. Sientes que se acerca un peligro desconocido y debes salir de la casa, ¡YA!'\n", + "lang_texts_es['escape'] = '¡Felicidades! ¡Has escapado!'\n", + "lang_texts_es['in'] = 'Estás en '\n", + "lang_texts_es['to_do'] = \"¿Qué te gustaría hacer? Teclea 'explore' o 'examine'\"\n", + "lang_texts_es['examine'] = '¿Qué te gustaría examinar?'\n", + "lang_texts_es['repeat'] = \"No estoy seguro de lo que quieres. Teclea 'explore' o 'examine'.\"\n", + "lang_texts_es['explore'] = 'Exploras la habitación. Esta es '\n", + "lang_texts_es['find'] = 'Encuentras '\n", + "lang_texts_es['you_examine'] = 'Tú examinas '\n", + "lang_texts_es['unlock'] = 'La abres con la llave que tú tienes.'\n", + "lang_texts_es['locked'] = \"Está cerrada pero tú no tienes la llave.\"\n", + "lang_texts_es['nothing'] = \"No se ve nada interesante\"\n", + "lang_texts_es['none'] = 'El elemento que solició no se encuentra en la sala actual.'\n", + "\n", + "'''\n", + "Dictionary\n", + "'''\n", + "\n", + "lang_game = {}\n", + "lang_game['en'] = ['english',lang_texts_en]\n", + "lang_game['es'] = ['spanish',lang_texts_es]\n", + "\n", + "\n", + "#lang_game[game_state[\"language\"]][1]['find']\n" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [], + "source": [ + "def linebreak():\n", + " \"\"\"\n", + " Print a line break\n", + " \"\"\"\n", + " print(\"\\n\\n\")\n", + "\n", + "def start_game():\n", + " \"\"\"\n", + " Start the game\n", + " \"\"\"\n", + " \n", + " print(lang_game[game_state[\"language\"]][1]['intro'])\n", + " \n", + " play_room(game_state[\"current_room\"])\n", + "\n", + "def play_room(room):\n", + " \"\"\"\n", + " Play a room. First check if the room being played is the target room.\n", + " If it is, the game will end with success. Otherwise, let player either \n", + " explore (list all items in this room) or examine an item found here.\n", + " \"\"\"\n", + " game_state[\"current_room\"] = room\n", + " if(game_state[\"current_room\"] == game_state[\"target_room\"]): \n", + " print(lang_game[game_state[\"language\"]][1]['escape'])\n", + " else: \n", + " print(lang_game[game_state[\"language\"]][1]['in'] + room[\"name\"]) \n", + " \n", + " intended_action = input(lang_game[game_state[\"language\"]][1]['to_do']).strip()\n", + " \n", + " if intended_action == \"explore\":\n", + " explore_room(room)\n", + " play_room(room)\n", + " elif intended_action == \"examine\":\n", + " \n", + " examine_item(input(lang_game[game_state[\"language\"]][1]['examine']).strip()) \n", + " \n", + " else:\n", + " \n", + " print(lang_game[game_state[\"language\"]][1]['repeat'])\n", + " \n", + " play_room(room)\n", + " linebreak()\n", + "\n", + "def explore_room(room):\n", + " \"\"\"\n", + " Explore a room. List all items belonging to this room.\n", + " \"\"\"\n", + " items = [i[\"name\"] for i in object_relations[room[\"name\"]]]\n", + " \n", + " print(lang_game[game_state[\"language\"]][1]['explore'] + room[\"name\"] + '. ' + lang_game[game_state[\"language\"]][1]['find'] + \", \".join(items))\n", + "\n", + "def get_next_room_of_door(door, current_room):\n", + " \"\"\"\n", + " From object_relations, find the two rooms connected to the given door.\n", + " Return the room that is not the current_room.\n", + " \"\"\"\n", + " connected_rooms = object_relations[door[\"name\"]]\n", + " for room in connected_rooms:\n", + " if(not current_room == room):\n", + " return room\n", + "\n", + "def examine_item(item_name):\n", + " \"\"\"\n", + " Examine an item which can be a door or furniture.\n", + " First make sure the intended item belongs to the current room.\n", + " Then check if the item is a door. Tell player if key hasn't been \n", + " collected yet. Otherwise ask player if they want to go to the next\n", + " room. If the item is not a door, then check if it contains keys.\n", + " Collect the key if found and update the game state. At the end,\n", + " play either the current or the next room depending on the game state\n", + " to keep playing.\n", + " \"\"\"\n", + " current_room = game_state[\"current_room\"]\n", + " next_room = \"\"\n", + " output = None\n", + " \n", + " for item in object_relations[current_room[\"name\"]]:\n", + " if(item[\"name\"] == item_name):\n", + " \n", + " output = lang_game[game_state[\"language\"]][1]['you_examine'] + item_name + \". \"\n", + " \n", + " if(item[\"type\"] == \"door\"):\n", + " have_key = False\n", + " for key in game_state[\"keys_collected\"]:\n", + " if(key[\"target\"] == item):\n", + " have_key = True\n", + " if(have_key): \n", + " output += lang_game[game_state[\"language\"]][1]['unlock']\n", + " \n", + " next_room = get_next_room_of_door(item, current_room)\n", + " else: \n", + " output += lang_game[game_state[\"language\"]][1]['locked']\n", + " else:\n", + " if(item[\"name\"] in object_relations and len(object_relations[item[\"name\"]])>0):\n", + " item_found = object_relations[item[\"name\"]].pop()\n", + " game_state[\"keys_collected\"].append(item_found)\n", + " \n", + " output += lang_game[game_state[\"language\"]][1]['find'] + item_found[\"name\"] + \".\"\n", + " else:\n", + " output += lang_game[game_state[\"language\"]][1]['nothing']\n", + " print(output)\n", + " break\n", + "\n", + " if(output is None): \n", + " print(lang_game[game_state[\"language\"]][1]['none'])\n", + " \n", + " #if(next_room and input(\"Do you want to go to the next room? Ener 'yes' or 'no'\").strip() == 'yes'):\n", + " if(next_room and selectFromDict(opt_yn, 'option') == 'yes'):\n", + " play_room(next_room)\n", + " else:\n", + " play_room(current_room)" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Select a language:\n", + "1) english\n", + "2) spanish\n", + "language: 2\n", + "Selected language: es\n", + "Te despiertas en un sofá y te encuentras en una casa extraña sin ventanas en la que nunca has estado antes. No recuerdas por qué estás aquí y qué había sucedido antes. Sientes que se acerca un peligro desconocido y debes salir de la casa, ¡YA!\n", + "Estás en game room\n" + ] + }, + { + "ename": "KeyboardInterrupt", + "evalue": "Interrupted by user", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", + "Input \u001b[0;32mIn [44]\u001b[0m, in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m game_state \u001b[38;5;241m=\u001b[39m INIT_GAME_STATE\u001b[38;5;241m.\u001b[39mcopy()\n\u001b[1;32m 3\u001b[0m game_state[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlanguage\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m (selectFromDict({value[\u001b[38;5;241m0\u001b[39m]:key \u001b[38;5;28;01mfor\u001b[39;00m key,value \u001b[38;5;129;01min\u001b[39;00m lang_game\u001b[38;5;241m.\u001b[39mitems()},\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlanguage\u001b[39m\u001b[38;5;124m'\u001b[39m))\n\u001b[0;32m----> 5\u001b[0m \u001b[43mstart_game\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", + "Input \u001b[0;32mIn [40]\u001b[0m, in \u001b[0;36mstart_game\u001b[0;34m()\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 9\u001b[0m \u001b[38;5;124;03mStart the game\u001b[39;00m\n\u001b[1;32m 10\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 12\u001b[0m \u001b[38;5;28mprint\u001b[39m(lang_game[game_state[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlanguage\u001b[39m\u001b[38;5;124m\"\u001b[39m]][\u001b[38;5;241m1\u001b[39m][\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mintro\u001b[39m\u001b[38;5;124m'\u001b[39m])\n\u001b[0;32m---> 14\u001b[0m \u001b[43mplay_room\u001b[49m\u001b[43m(\u001b[49m\u001b[43mgame_state\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcurrent_room\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n", + "Input \u001b[0;32mIn [40]\u001b[0m, in \u001b[0;36mplay_room\u001b[0;34m(room)\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m: \n\u001b[1;32m 26\u001b[0m \u001b[38;5;28mprint\u001b[39m(lang_game[game_state[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlanguage\u001b[39m\u001b[38;5;124m\"\u001b[39m]][\u001b[38;5;241m1\u001b[39m][\u001b[38;5;124m'\u001b[39m\u001b[38;5;124min\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m+\u001b[39m room[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m\"\u001b[39m]) \n\u001b[0;32m---> 28\u001b[0m intended_action \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43minput\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mlang_game\u001b[49m\u001b[43m[\u001b[49m\u001b[43mgame_state\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mlanguage\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mto_do\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mstrip()\n\u001b[1;32m 30\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m intended_action \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mexplore\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 31\u001b[0m explore_room(room)\n", + "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/ipykernel/kernelbase.py:1075\u001b[0m, in \u001b[0;36mKernel.raw_input\u001b[0;34m(self, prompt)\u001b[0m\n\u001b[1;32m 1071\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_allow_stdin:\n\u001b[1;32m 1072\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m StdinNotImplementedError(\n\u001b[1;32m 1073\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mraw_input was called, but this frontend does not support input requests.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 1074\u001b[0m )\n\u001b[0;32m-> 1075\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_input_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1076\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mstr\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mprompt\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1077\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_parent_ident\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mshell\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1078\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_parent\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mshell\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1079\u001b[0m \u001b[43m \u001b[49m\u001b[43mpassword\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 1080\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/ipykernel/kernelbase.py:1120\u001b[0m, in \u001b[0;36mKernel._input_request\u001b[0;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[1;32m 1117\u001b[0m \u001b[38;5;28;01mbreak\u001b[39;00m\n\u001b[1;32m 1118\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m:\n\u001b[1;32m 1119\u001b[0m \u001b[38;5;66;03m# re-raise KeyboardInterrupt, to truncate traceback\u001b[39;00m\n\u001b[0;32m-> 1120\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInterrupted by user\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28mNone\u001b[39m\n\u001b[1;32m 1121\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m:\n\u001b[1;32m 1122\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlog\u001b[38;5;241m.\u001b[39mwarning(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInvalid Message:\u001b[39m\u001b[38;5;124m\"\u001b[39m, exc_info\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n", + "\u001b[0;31mKeyboardInterrupt\u001b[0m: Interrupted by user" + ] + } + ], + "source": [ + "game_state = INIT_GAME_STATE.copy()\n", + "\n", + "game_state['language'] = (selectFromDict({value[0]:key for key,value in lang_game.items()},'language'))\n", + "\n", + "start_game()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/your-code/.ipynb_checkpoints/main_Oscar_Iglesias-checkpoint.ipynb b/your-code/.ipynb_checkpoints/main_Oscar_Iglesias-checkpoint.ipynb new file mode 100644 index 00000000..7232c5e6 --- /dev/null +++ b/your-code/.ipynb_checkpoints/main_Oscar_Iglesias-checkpoint.ipynb @@ -0,0 +1,465 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "# define rooms and items\n", + "\n", + "couch = {\n", + " \"name\": \"couch\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "door_a = {\n", + " \"name\": \"door a\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_a = {\n", + " \"name\": \"key for door a\",\n", + " \"type\": \"key\",\n", + " \"target\": door_a,\n", + "}\n", + "\n", + "piano = {\n", + " \"name\": \"piano\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "game_room = {\n", + " \"name\": \"game room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "\"\"\"\n", + "New Rooms\n", + "\"\"\"\n", + "\n", + "door_b = {\n", + " \"name\": \"door b\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_c = {\n", + " \"name\": \"door c\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_d = {\n", + " \"name\": \"door d\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_b = {\n", + " \"name\": \"key for door b\",\n", + " \"type\": \"key\",\n", + " \"target\": door_b,\n", + "}\n", + "\n", + "key_c = {\n", + " \"name\": \"key for door c\",\n", + " \"type\": \"key\",\n", + " \"target\": door_c,\n", + "}\n", + "\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d,\n", + "}\n", + "\n", + "queen_bed = {\n", + " \"name\": \"Queen Bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "double_bed = {\n", + " \"name\": \"Double Bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dresser = {\n", + " \"name\": \"Dresser\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dining_table = {\n", + " \"name\": \"Dining Table\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "bedroom_1 = {\n", + " \"name\": \"Bed Room 1\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "bedroom_2 = {\n", + " \"name\": \"Bed Room 2\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "living_room = {\n", + " \"name\": \"Living Room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "\n", + "all_rooms = [game_room, bedroom_1, bedroom_2, living_room, outside]\n", + "\n", + "all_doors = [door_a, door_b, door_c, door_d]\n", + "\n", + "# define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"game room\": [couch, piano, door_a],\n", + " \"piano\": [key_a],\n", + " \"Bed Room 1\": [queen_bed, door_b, door_c],\n", + " \"Queen Bed\": [key_b],\n", + " \"Bed Room 2\": [double_bed, dresser, door_b],\n", + " \"Double Bed\": [key_c],\n", + " \"Dresser\": [key_d],\n", + " \"Living Room\": [dining_table, door_d],\n", + " \"outside\": [door_d],\n", + " \"door a\": [game_room, bedroom_1],\n", + " \"door b\": [bedroom_1, bedroom_2],\n", + " \"door c\": [bedroom_1, living_room],\n", + " \"door d\": [living_room, outside]\n", + "}\n", + "\n", + "# define game state. Do not directly change this dict. \n", + "# Instead, when a new game starts, make a copy of this\n", + "# dict and use the copy to store gameplay state. This \n", + "# way you can replay the game multiple times.\n", + "\n", + "INIT_GAME_STATE = {\n", + " \"language\": 'es',\n", + " \"current_room\": game_room,\n", + " \"keys_collected\": [],\n", + " \"target_room\": outside\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'game room': [{'name': 'couch', 'type': 'furniture'}, {'name': 'piano', 'type': 'furniture'}, {'name': 'door a', 'type': 'door'}], 'piano': [{'name': 'key for door a', 'type': 'key', 'target': {'name': 'door a', 'type': 'door'}}], 'Bed Room 1': [{'name': 'Queen Bed', 'type': 'furniture'}, {'name': 'door b', 'type': 'door'}, {'name': 'door c', 'type': 'door'}], 'Queen Bed': [{'name': 'key for door b', 'type': 'key', 'target': {'name': 'door b', 'type': 'door'}}], 'Bed Room 2': [{'name': 'Double Bed', 'type': 'furniture'}, {'name': 'Dresser', 'type': 'furniture'}, {'name': 'door b', 'type': 'door'}], 'Double Bed': [{'name': 'key for door c', 'type': 'key', 'target': {'name': 'door c', 'type': 'door'}}], 'Dresser': [{'name': 'key for door d', 'type': 'key', 'target': {'name': 'door d', 'type': 'door'}}], 'Living Room': [{'name': 'Dining Table', 'type': 'furniture'}, {'name': 'door d', 'type': 'door'}], 'outside': [{'name': 'door d', 'type': 'door'}], 'door a': [{'name': 'game room', 'type': 'room'}, {'name': 'Bed Room 1', 'type': 'room'}], 'door b': [{'name': 'Bed Room 1', 'type': 'room'}, {'name': 'Bed Room 2', 'type': 'room'}], 'door c': [{'name': 'Bed Room 1', 'type': 'room'}, {'name': 'Living Room', 'type': 'room'}], 'door d': [{'name': 'Living Room', 'type': 'room'}, {'name': 'outside'}]}\n" + ] + } + ], + "source": [ + "#Function to add options instead of writing\n", + "opt_yn = {}\n", + "opt_yn['Yes'] = 'yes'\n", + "opt_yn['No'] = 'no'\n", + "\n", + "def selectFromDict(options, name):\n", + "\n", + " index = 0\n", + " indexValidList = []\n", + " print('Select a ' + name + ':')\n", + " for optionName in options:\n", + " index = index + 1\n", + " indexValidList.extend([options[optionName]])\n", + " print(str(index) + ') ' + optionName)\n", + " inputValid = False\n", + " while not inputValid:\n", + " inputRaw = input(name + ': ')\n", + " inputNo = int(inputRaw) - 1\n", + " if inputNo > -1 and inputNo < len(indexValidList):\n", + " selected = indexValidList[inputNo]\n", + " print('Selected ' + name + ': ' + selected)\n", + " inputValid = True\n", + " break\n", + " else:\n", + " print('Please select a valid ' + name + ' number')\n", + "\n", + " return selected\n", + "\n", + "print(object_relations)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'yes': 'yes', 'no': 'no', 'intro': \"You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!\", 'escape': 'Congrats! You escaped the room!', 'in': 'You are now in ', 'to_do': \"What would you like to do? Type 'explore' or 'examine'?\", 'examine': 'What would you like to examine?', 'repeat': \"Not sure what you mean. Type 'explore' or 'examine'.\", 'explore': 'You explore the room. This is ', 'find': 'You find ', 'you_examine': 'You examine ', 'unlock': 'You unlock it with a key you have.', 'locked': \"It is locked but you don't have the key.\", 'nothing': \"There isn't anything interesting about it.\", 'none': 'The item you requested is not found in the current room.'}\n", + "{'yes': 'sí', 'no': 'no', 'intro': 'Te despiertas en un sofá y te encuentras en una casa extraña sin ventanas en la que nunca has estado antes. No recuerdas por qué estás aquí y qué había sucedido antes. Sientes que se acerca un peligro desconocido y debes salir de la casa, ¡YA!', 'escape': '¡Felicidades! ¡Has escapado!', 'in': 'Estás en ', 'to_do': \"¿Qué te gustaría hacer? Teclea 'explore' o 'examine'\", 'examine': '¿Qué te gustaría examinar?', 'repeat': \"No estoy seguro de lo que quieres. Teclea 'explore' o 'examine'.\", 'explore': 'Exploras la habitación. Esta es ', 'find': 'Encuentras ', 'you_examine': 'Tú examinas ', 'unlock': 'La abres con la llave que tú tienes.', 'locked': 'Está cerrada pero tú no tienes la llave.', 'nothing': 'No se ve nada interesante', 'none': 'El elemento que solició no se encuentra en la sala actual.'}\n", + "{'en': [{'yes': 'yes', 'no': 'no', 'intro': \"You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!\", 'escape': 'Congrats! You escaped the room!', 'in': 'You are now in ', 'to_do': \"What would you like to do? Type 'explore' or 'examine'?\", 'examine': 'What would you like to examine?', 'repeat': \"Not sure what you mean. Type 'explore' or 'examine'.\", 'explore': 'You explore the room. This is ', 'find': 'You find ', 'you_examine': 'You examine ', 'unlock': 'You unlock it with a key you have.', 'locked': \"It is locked but you don't have the key.\", 'nothing': \"There isn't anything interesting about it.\", 'none': 'The item you requested is not found in the current room.'}], 'es': [{'yes': 'sí', 'no': 'no', 'intro': 'Te despiertas en un sofá y te encuentras en una casa extraña sin ventanas en la que nunca has estado antes. No recuerdas por qué estás aquí y qué había sucedido antes. Sientes que se acerca un peligro desconocido y debes salir de la casa, ¡YA!', 'escape': '¡Felicidades! ¡Has escapado!', 'in': 'Estás en ', 'to_do': \"¿Qué te gustaría hacer? Teclea 'explore' o 'examine'\", 'examine': '¿Qué te gustaría examinar?', 'repeat': \"No estoy seguro de lo que quieres. Teclea 'explore' o 'examine'.\", 'explore': 'Exploras la habitación. Esta es ', 'find': 'Encuentras ', 'you_examine': 'Tú examinas ', 'unlock': 'La abres con la llave que tú tienes.', 'locked': 'Está cerrada pero tú no tienes la llave.', 'nothing': 'No se ve nada interesante', 'none': 'El elemento que solició no se encuentra en la sala actual.'}]}\n" + ] + }, + { + "data": { + "text/plain": [ + "'Encuentras '" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "'''\n", + "Multi Language\n", + "'''\n", + "\n", + "'''\n", + "English\n", + "'''\n", + "\n", + "lang_texts_en = {}\n", + "lang_texts_en['yes'] = 'yes'\n", + "lang_texts_en['no'] = 'no'\n", + "lang_texts_en['intro'] = '''You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!'''\n", + "lang_texts_en['escape'] = 'Congrats! You escaped the room!'\n", + "lang_texts_en['in'] = 'You are now in '\n", + "lang_texts_en['to_do'] = \"What would you like to do? Type 'explore' or 'examine'?\"\n", + "lang_texts_en['examine'] = 'What would you like to examine?'\n", + "lang_texts_en['repeat'] = \"Not sure what you mean. Type 'explore' or 'examine'.\"\n", + "lang_texts_en['explore'] = 'You explore the room. This is '\n", + "lang_texts_en['find'] = 'You find '\n", + "lang_texts_en['you_examine'] = 'You examine '\n", + "lang_texts_en['unlock'] = 'You unlock it with a key you have.'\n", + "lang_texts_en['locked'] = \"It is locked but you don't have the key.\"\n", + "lang_texts_en['nothing'] = \"There isn't anything interesting about it.\"\n", + "lang_texts_en['none'] = 'The item you requested is not found in the current room.'\n", + "\n", + "'''\n", + "Spanish\n", + "'''\n", + "\n", + "lang_texts_es = {}\n", + "lang_texts_es['yes'] = 'sí'\n", + "lang_texts_es['no'] = 'no'\n", + "lang_texts_es['intro'] = 'Te despiertas en un sofá y te encuentras en una casa extraña sin ventanas en la que nunca has estado antes. No recuerdas por qué estás aquí y qué había sucedido antes. Sientes que se acerca un peligro desconocido y debes salir de la casa, ¡YA!'\n", + "lang_texts_es['escape'] = '¡Felicidades! ¡Has escapado!'\n", + "lang_texts_es['in'] = 'Estás en '\n", + "lang_texts_es['to_do'] = \"¿Qué te gustaría hacer? Teclea 'explore' o 'examine'\"\n", + "lang_texts_es['examine'] = '¿Qué te gustaría examinar?'\n", + "lang_texts_es['repeat'] = \"No estoy seguro de lo que quieres. Teclea 'explore' o 'examine'.\"\n", + "lang_texts_es['explore'] = 'Exploras la habitación. Esta es '\n", + "lang_texts_es['find'] = 'Encuentras '\n", + "lang_texts_es['you_examine'] = 'Tú examinas '\n", + "lang_texts_es['unlock'] = 'La abres con la llave que tú tienes.'\n", + "lang_texts_es['locked'] = \"Está cerrada pero tú no tienes la llave.\"\n", + "lang_texts_es['nothing'] = \"No se ve nada interesante\"\n", + "lang_texts_es['none'] = 'El elemento que solició no se encuentra en la sala actual.'\n", + "\n", + "'''\n", + "Dictionary\n", + "'''\n", + "\n", + "lang_game = {}\n", + "lang_game['en'] = [lang_texts_en]\n", + "lang_game['es'] = [lang_texts_es]\n", + "\n", + "print(lang_texts_en)\n", + "print(lang_texts_es)\n", + "print(lang_game)\n", + "\n", + "lang_game['es'][0]['find']\n", + "lang_game[game_state[\"language\"]][0]['find']" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "def linebreak():\n", + " \"\"\"\n", + " Print a line break\n", + " \"\"\"\n", + " print(\"\\n\\n\")\n", + "\n", + "def start_game():\n", + " \"\"\"\n", + " Start the game\n", + " \"\"\"\n", + " \n", + " print(lang_game[game_state[\"language\"]][0]['intro'])\n", + " \n", + " play_room(game_state[\"current_room\"])\n", + "\n", + "def play_room(room):\n", + " \"\"\"\n", + " Play a room. First check if the room being played is the target room.\n", + " If it is, the game will end with success. Otherwise, let player either \n", + " explore (list all items in this room) or examine an item found here.\n", + " \"\"\"\n", + " game_state[\"current_room\"] = room\n", + " if(game_state[\"current_room\"] == game_state[\"target_room\"]): \n", + " print(lang_game[game_state[\"language\"]][0]['escape'])\n", + " else: \n", + " print(lang_game[game_state[\"language\"]][0]['in'] + room[\"name\"]) \n", + " \n", + " intended_action = input(lang_game[game_state[\"language\"]][0]['to_do']).strip()\n", + " \n", + " if intended_action == \"explore\":\n", + " explore_room(room)\n", + " play_room(room)\n", + " elif intended_action == \"examine\":\n", + " \n", + " examine_item(input(lang_game[game_state[\"language\"]][0]['examine']).strip()) \n", + " \n", + " else:\n", + " \n", + " print(lang_game[game_state[\"language\"]][0]['repeat'])\n", + " \n", + " play_room(room)\n", + " linebreak()\n", + "\n", + "def explore_room(room):\n", + " \"\"\"\n", + " Explore a room. List all items belonging to this room.\n", + " \"\"\"\n", + " items = [i[\"name\"] for i in object_relations[room[\"name\"]]]\n", + " \n", + " print(lang_game[game_state[\"language\"]][0]['explore'] + room[\"name\"] + '. ' + lang_game[game_state[\"language\"]][0]['find'] + \", \".join(items))\n", + "\n", + "def get_next_room_of_door(door, current_room):\n", + " \"\"\"\n", + " From object_relations, find the two rooms connected to the given door.\n", + " Return the room that is not the current_room.\n", + " \"\"\"\n", + " connected_rooms = object_relations[door[\"name\"]]\n", + " for room in connected_rooms:\n", + " if(not current_room == room):\n", + " return room\n", + "\n", + "def examine_item(item_name):\n", + " \"\"\"\n", + " Examine an item which can be a door or furniture.\n", + " First make sure the intended item belongs to the current room.\n", + " Then check if the item is a door. Tell player if key hasn't been \n", + " collected yet. Otherwise ask player if they want to go to the next\n", + " room. If the item is not a door, then check if it contains keys.\n", + " Collect the key if found and update the game state. At the end,\n", + " play either the current or the next room depending on the game state\n", + " to keep playing.\n", + " \"\"\"\n", + " current_room = game_state[\"current_room\"]\n", + " next_room = \"\"\n", + " output = None\n", + " \n", + " for item in object_relations[current_room[\"name\"]]:\n", + " if(item[\"name\"] == item_name):\n", + " \n", + " output = lang_game[game_state[\"language\"]][0]['you_examine'] + item_name + \". \"\n", + " \n", + " if(item[\"type\"] == \"door\"):\n", + " have_key = False\n", + " for key in game_state[\"keys_collected\"]:\n", + " if(key[\"target\"] == item):\n", + " have_key = True\n", + " if(have_key): \n", + " output += lang_game[game_state[\"language\"]][0]['unlock']\n", + " \n", + " next_room = get_next_room_of_door(item, current_room)\n", + " else: \n", + " output += lang_game[game_state[\"language\"]][0]['locked']\n", + " else:\n", + " if(item[\"name\"] in object_relations and len(object_relations[item[\"name\"]])>0):\n", + " item_found = object_relations[item[\"name\"]].pop()\n", + " game_state[\"keys_collected\"].append(item_found)\n", + " \n", + " output += lang_game[game_state[\"language\"]][0]['find'] + item_found[\"name\"] + \".\"\n", + " else:\n", + " output += lang_game[game_state[\"language\"]][0]['nothing']\n", + " print(output)\n", + " break\n", + "\n", + " if(output is None): \n", + " print(lang_game[game_state[\"language\"]][0]['none'])\n", + " \n", + " #if(next_room and input(\"Do you want to go to the next room? Ener 'yes' or 'no'\").strip() == 'yes'):\n", + " if(next_room and selectFromDict(opt_yn, 'option') == 'yes'):\n", + " play_room(next_room)\n", + " else:\n", + " play_room(current_room)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Te despiertas en un sofá y te encuentras en una casa extraña sin ventanas en la que nunca has estado antes. No recuerdas por qué estás aquí y qué había sucedido antes. Sientes que se acerca un peligro desconocido y debes salir de la casa, ¡YA!\n", + "Estás en game room\n", + "¿Qué te gustaría hacer? Teclea 'explore' o 'examine'explore\n", + "Exploras la habitación. Esta es game room. Encuentras couch, piano, door a\n", + "Estás en game room\n", + "¿Qué te gustaría hacer? Teclea 'explore' o 'examine'examine\n", + "¿Qué te gustaría examinar?couch\n", + "Tú examinas couch. No se ve nada interesante\n", + "Estás en game room\n", + "¿Qué te gustaría hacer? Teclea 'explore' o 'examine'examine\n", + "¿Qué te gustaría examinar?door a\n", + "Tú examinas door a. Está cerrada pero tú no tienes la llave.\n", + "Estás en game room\n", + "¿Qué te gustaría hacer? Teclea 'explore' o 'examine'examine\n", + "¿Qué te gustaría examinar?piano\n", + "Tú examinas piano. Encuentras key for door a.\n", + "Estás en game room\n" + ] + } + ], + "source": [ + "game_state = INIT_GAME_STATE.copy()\n", + "\n", + "start_game()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/your-code/sample-code.ipynb b/your-code/.ipynb_checkpoints/sample-code-checkpoint.ipynb similarity index 99% rename from your-code/sample-code.ipynb rename to your-code/.ipynb_checkpoints/sample-code-checkpoint.ipynb index a6f8a94d..90704b03 100644 --- a/your-code/sample-code.ipynb +++ b/your-code/.ipynb_checkpoints/sample-code-checkpoint.ipynb @@ -226,7 +226,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -240,7 +240,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.9.12" } }, "nbformat": 4, diff --git a/your-code/images/Bedroom_1.png b/your-code/images/Bedroom_1.png new file mode 100644 index 00000000..8a1c6f3f Binary files /dev/null and b/your-code/images/Bedroom_1.png differ diff --git a/your-code/images/Bedroom_2.png b/your-code/images/Bedroom_2.png new file mode 100644 index 00000000..a94151fd Binary files /dev/null and b/your-code/images/Bedroom_2.png differ diff --git a/your-code/images/Game_room.png b/your-code/images/Game_room.png new file mode 100644 index 00000000..6bbd0667 Binary files /dev/null and b/your-code/images/Game_room.png differ diff --git a/your-code/images/Living_room.png b/your-code/images/Living_room.png new file mode 100644 index 00000000..59f70cef Binary files /dev/null and b/your-code/images/Living_room.png differ diff --git a/your-code/images/Main_view.png b/your-code/images/Main_view.png new file mode 100644 index 00000000..24cf91ab Binary files /dev/null and b/your-code/images/Main_view.png differ diff --git a/your-code/main.ipynb b/your-code/main.ipynb new file mode 100644 index 00000000..de95ac0e --- /dev/null +++ b/your-code/main.ipynb @@ -0,0 +1,918 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# import libraries\n", + "from pathlib import Path\n", + "import random\n", + "\n", + "import playsound as ps\n", + "from playsound import playsound\n", + "\n", + "from PIL import Image\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#Questions & answers\n", + "\n", + "question_a = {\n", + " \"name\": \"Question a\",\n", + " \"type\": \"question\",\n", + " \"correct answer\": \"a\"\n", + "}\n", + "\n", + "answers_a = {\n", + " \"a\": \"Spanish\",\n", + " \"b\": \"Italian\",\n", + " \"c\": \"French\"\n", + "}\n", + "\n", + "question_b = {\n", + " \"name\": \"Question b\",\n", + " \"type\": \"question\",\n", + " \"correct answer\": \"b\"\n", + "}\n", + "\n", + "answers_b = {\n", + " \"a\": \"Potato\",\n", + " \"b\": \"Rice\",\n", + " \"c\": \"Bread\"\n", + "}\n", + "\n", + "question_c = {\n", + " \"name\": \"Question c\",\n", + " \"type\": \"question\",\n", + " \"correct answer\": \"a\"\n", + "}\n", + "\n", + "answers_c = {\n", + " \"a\": \"Whale\",\n", + " \"b\": \"Elephant\",\n", + " \"c\": \"Rhinoceros\"\n", + "}\n", + "\n", + "question_d = {\n", + " \"name\": \"Question d\",\n", + " \"type\": \"question\",\n", + " \"correct answer\": \"c\"\n", + "}\n", + "\n", + "answers_d = {\n", + " \"a\": \"Water\",\n", + " \"b\": \"Iron\",\n", + " \"c\": \"\"\n", + "}\n", + "\n", + "# define rooms and items\n", + "\n", + "couch = {\n", + " \"name\": \"couch\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "door_a = {\n", + " \"name\": \"door a\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_a = {\n", + " \"name\": \"key for door a\",\n", + " \"type\": \"key\",\n", + " \"target\": door_a,\n", + " \"question\": question_a\n", + "}\n", + "\n", + "piano = {\n", + " \"name\": \"piano\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "game_room = {\n", + " \"name\": \"game room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "#New Rooms\n", + "\n", + "door_b = {\n", + " \"name\": \"door b\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_c = {\n", + " \"name\": \"door c\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_d = {\n", + " \"name\": \"door d\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "\n", + "door_blue = {\n", + " \"name\": \"door blue\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_pink = {\n", + " \"name\": \"door pink\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_red = {\n", + " \"name\": \"door red\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_black = {\n", + " \"name\": \"door black\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_white = {\n", + " \"name\": \"door white\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_b = {\n", + " \"name\": \"key for door b\",\n", + " \"type\": \"key\",\n", + " \"target\": door_b,\n", + " \"question\": question_b\n", + "}\n", + "\n", + "key_c = {\n", + " \"name\": \"key for door c\",\n", + " \"type\": \"key\",\n", + " \"target\": door_c,\n", + " \"question\": question_c\n", + "}\n", + "\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d,\n", + " \"question\": question_d\n", + "}\n", + "\n", + "queen_bed = {\n", + " \"name\": \"Queen Bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "double_bed = {\n", + " \"name\": \"Double Bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dresser = {\n", + " \"name\": \"Dresser\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dining_table = {\n", + " \"name\": \"Dining Table\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "bedroom_1 = {\n", + " \"name\": \"Bed Room 1\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "bedroom_2 = {\n", + " \"name\": \"Bed Room 2\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "living_room = {\n", + " \"name\": \"Living Room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "ghost_room = {\n", + " \"name\": \"Ghost Room\",\n", + " \"type\": \"room\"\n", + "}\n", + "\n", + "#all_rooms = [game_room, bedroom_1, bedroom_2, living_room, outside]\n", + "\n", + "#all_doors = [door_a, door_b, door_c, door_d]\n", + "\n", + "# define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"game room\": [couch, piano, door_a],\n", + " \"piano\": [key_a],\n", + " \"Bed Room 1\": [queen_bed, door_a, door_b, door_c],\n", + " \"Queen Bed\": [key_b],\n", + " \"Bed Room 2\": [double_bed, dresser, door_b],\n", + " \"Double Bed\": [key_c],\n", + " \"Dresser\": [key_d],\n", + " \"Living Room\": [dining_table, door_c, door_d],\n", + " \"Ghost Room\": [door_blue, door_pink, door_red, door_black, door_white],\n", + " \"outside\": [door_d],\n", + " \"door a\": [game_room, bedroom_1],\n", + " \"door b\": [bedroom_1, bedroom_2],\n", + " \"door c\": [bedroom_1, living_room],\n", + " \"door d\": [living_room, outside], \n", + " \"key a\": [question_a],\n", + " \"Question a\": [answers_a],\n", + " \"key b\": [question_b],\n", + " \"Question b\": [answers_b],\n", + " \"key c\": [question_c],\n", + " \"Question c\": [answers_c],\n", + " \"key d\": [question_d],\n", + " \"Question d\": [answers_d] \n", + "}\n", + "\n", + "# define game state. Do not directly change this dict. \n", + "# Instead, when a new game starts, make a copy of this\n", + "# dict and use the copy to store gameplay state. This \n", + "# way you can replay the game multiple times.\n", + "\n", + "# Added language, hard_scape and escape door\n", + "\n", + "INIT_GAME_STATE = {\n", + " \"language\": 'en',\n", + " \"current_room\": game_room,\n", + " \"keys_collected\": [],\n", + " \"hard_scape\": 0,\n", + " \"target_room\": outside,\n", + " \"escape door\": door_blue\n", + "}\n", + "\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#Creating the Multi Language dictionaries\n", + "\n", + "#English dictionary\n", + "\n", + "lang_texts_en = {}\n", + "lang_texts_en['yes'] = 'yes'\n", + "lang_texts_en['no'] = 'no'\n", + "lang_texts_en['explore'] = 'explore'\n", + "lang_texts_en['examine'] = 'examine'\n", + "lang_texts_en['integer'] = 'Please type only the number of the options'\n", + "lang_texts_en['intro'] = '''You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!'''\n", + "lang_texts_en['escape'] = 'RUN! And do not come back again!\\n\\nCongrats! You escaped the room!'\n", + "lang_texts_en['in'] = 'You are now in '\n", + "lang_texts_en['next_room'] = 'Do you want to go to the next room?'\n", + "lang_texts_en['examine_do'] = 'What would you like to examine?'\n", + "lang_texts_en['repeat'] = \"Not sure what you mean. Choose a valid option.\"\n", + "lang_texts_en['explore_do'] = 'You explore the room. This is '\n", + "lang_texts_en['find'] = 'You find '\n", + "lang_texts_en['you_examine'] = 'You examine '\n", + "lang_texts_en['unlock'] = 'You unlock it with a key you have.'\n", + "lang_texts_en['locked'] = \"It is locked but you don't have the key.\"\n", + "lang_texts_en['nothing'] = \"There isn't anything interesting about it.\"\n", + "lang_texts_en['none'] = 'The item you requested is not found in the current room.'\n", + "lang_texts_en['option'] = 'Option:'\n", + "lang_texts_en['select'] = 'Select one option:'\n", + "lang_texts_en['selected'] = 'Selected option: '\n", + "lang_texts_en['no_valid'] = 'Please select a valid number'\n", + "lang_texts_en['couch'] = 'couch'\n", + "lang_texts_en['piano'] = 'piano'\n", + "lang_texts_en['door a'] = 'door a'\n", + "lang_texts_en['Queen Bed'] = 'Queen Bed'\n", + "lang_texts_en['door b'] = 'door b'\n", + "lang_texts_en['door c'] = 'door c'\n", + "lang_texts_en['Double Bed'] = 'Double Bed'\n", + "lang_texts_en['Dresser'] = 'Dresser'\n", + "lang_texts_en['Dining Table'] = 'Dining Table'\n", + "lang_texts_en['door d'] = 'door d'\n", + "lang_texts_en['game room'] = 'Game room'\n", + "lang_texts_en['Bed Room 1'] = 'Bed Room 1'\n", + "lang_texts_en['Bed Room 2'] = 'Bed Room 2'\n", + "lang_texts_en['Living Room'] = 'Living Room'\n", + "lang_texts_en['outside'] = 'outside'\n", + "lang_texts_en['key for door a'] = 'key for door a'\n", + "lang_texts_en['key for door b'] = 'key for door b'\n", + "lang_texts_en['key for door c'] = 'key for door c'\n", + "lang_texts_en['key for door d'] = 'key for door d'\n", + "lang_texts_en['Question a'] = 'What nationality was Columbus believed to be?'\n", + "lang_texts_en['Question b'] = 'What is the most consumed food in the world?'\n", + "lang_texts_en['Question c'] = 'What is the largest mammal in the world?'\n", + "lang_texts_en['Question d'] = 'What weighs more than 1 kg of water or 1kg of iron?'\n", + "lang_texts_en['door blue'] = 'Door Blue'\n", + "lang_texts_en['door pink'] = 'Door Pink'\n", + "lang_texts_en['door red'] = 'Door Red'\n", + "lang_texts_en['door black'] = 'Door Black'\n", + "lang_texts_en['door white'] = 'Door White'\n", + "lang_texts_en['ghost quiz'] = 'Ghost Quiz'\n", + "lang_texts_en['Question a correct'] = 'Right... Keep looking for the exit...'\n", + "lang_texts_en['Question a failed'] = 'You wont scape... ever'\n", + "lang_texts_en['Question b correct'] = 'You can go... for now...'\n", + "lang_texts_en['Question b failed'] = 'Nice try...'\n", + "lang_texts_en['Question c correct'] = 'True...Who would think a mammal can live underwater?...'\n", + "lang_texts_en['Question c failed'] = 'You will not be allowed to go anywhere...'\n", + "lang_texts_en['Question d correct'] = 'Clever...'\n", + "lang_texts_en['Question d failed'] = 'Hehehehe...'\n", + "lang_texts_en['choose_door'] = 'As you failed in your answers... it is time to choose a door.'\n", + "lang_texts_en['correct_door'] = 'Congratulations! You can live for one day more'\n", + "lang_texts_en['wrong_door'] = 'Time to stay here... FOREVER!'\n", + "lang_texts_en['Spanish'] = 'Spanish'\n", + "lang_texts_en['Italian'] = 'Italian'\n", + "lang_texts_en['French'] = 'French'\n", + "lang_texts_en['Potato'] = 'Potato'\n", + "lang_texts_en['Rice'] = 'Rice'\n", + "lang_texts_en['Bread'] = 'Bread'\n", + "lang_texts_en['Whale'] = 'Whale'\n", + "lang_texts_en['Elephant'] = 'Elephant'\n", + "lang_texts_en['Rhinoceros'] = 'Rhinoceros'\n", + "lang_texts_en['Water'] = 'Water'\n", + "lang_texts_en['Iron'] = 'Iron'\n", + "lang_texts_en[''] = ''\n", + "\n", + "\n", + "#Spanish dictionary\n", + "\n", + "lang_texts_es = {}\n", + "lang_texts_es['yes'] = 'sí'\n", + "lang_texts_es['no'] = 'no'\n", + "lang_texts_es['explore'] = 'explorar'\n", + "lang_texts_es['examine'] = 'examinar'\n", + "lang_texts_es['integer'] = 'Por favor teclea solamente números de las opciones'\n", + "lang_texts_es['intro'] = 'Te despiertas en un sofá y te encuentras en una casa extraña sin ventanas en la que nunca has estado antes. No recuerdas por qué estás aquí y qué había sucedido antes. Sientes que se acerca un peligro desconocido y debes salir de la casa, ¡YA!'\n", + "lang_texts_es['escape'] = '¡CORRE! ¡y no vuelvas más!\\n\\n¡Felicidades! ¡Has escapado!'\n", + "lang_texts_es['in'] = 'Estás en '\n", + "lang_texts_es['next_room'] = '¿Quieres ir a la siguiente habitación?'\n", + "lang_texts_es['examine_do'] = '¿Qué te gustaría examinar?'\n", + "lang_texts_es['repeat'] = \"No estoy seguro de lo que quieres. Seleccionar una opción válida.\"\n", + "lang_texts_es['explore_do'] = 'Exploras la habitación. Esta es '\n", + "lang_texts_es['find'] = 'Encuentras '\n", + "lang_texts_es['you_examine'] = 'Tú examinas '\n", + "lang_texts_es['unlock'] = 'La abres con la llave que tú tienes.'\n", + "lang_texts_es['locked'] = \"Está cerrada pero tú no tienes la llave.\"\n", + "lang_texts_es['nothing'] = \"No se ve nada interesante\"\n", + "lang_texts_es['none'] = 'El elemento que solició no se encuentra en la sala actual.'\n", + "lang_texts_es['option'] = 'Opción:'\n", + "lang_texts_es['select'] = 'Escoge una opción:'\n", + "lang_texts_es['selected'] = 'Opción escogida: '\n", + "lang_texts_es['no_valid'] = 'Por favor, escoge un número válido'\n", + "lang_texts_es['couch'] = 'sofá'\n", + "lang_texts_es['piano'] = 'piano'\n", + "lang_texts_es['door a'] = 'puerta a'\n", + "lang_texts_es['Queen Bed'] = 'Cama de matrimonio'\n", + "lang_texts_es['door b'] = 'puerta b'\n", + "lang_texts_es['door c'] = 'puerta c'\n", + "lang_texts_es['Double Bed'] = 'Cama Doble'\n", + "lang_texts_es['Dresser'] = 'Cómoda'\n", + "lang_texts_es['Dining Table'] = 'Mesa de comedor'\n", + "lang_texts_es['door d'] = 'puerta d'\n", + "lang_texts_es['game room'] = 'Habitación de juegos'\n", + "lang_texts_es['Bed Room 1'] = 'Habitación 1'\n", + "lang_texts_es['Bed Room 2'] = 'Habitación 2'\n", + "lang_texts_es['Living Room'] = 'Sala de estar'\n", + "lang_texts_es['outside'] = 'Fuera'\n", + "lang_texts_es['key for door a'] = 'llave para puerta a'\n", + "lang_texts_es['key for door b'] = 'llave para puerta b'\n", + "lang_texts_es['key for door c'] = 'llave para puerta c'\n", + "lang_texts_es['key for door d'] = 'llave para puerta d'\n", + "lang_texts_es['Question a'] = '¿De qué nacionalidad se creía que era Colón?'\n", + "lang_texts_es['Question b'] = '¿Cuál es el alimento más consumido en el mundo?'\n", + "lang_texts_es['Question c'] = '¿Cuál es el mamífero más grande del mundo?'\n", + "lang_texts_es['Question d'] = '¿Qué pesa más, 1 kg de agua o 1 kg de hierro?'\n", + "lang_texts_es['door blue'] = 'Puerta Azul'\n", + "lang_texts_es['door pink'] = 'Puerta Rosa'\n", + "lang_texts_es['door red'] = 'Puerta Roja'\n", + "lang_texts_es['door black'] = 'Puerta Negra'\n", + "lang_texts_es['door white'] = 'Puerta Blanca'\n", + "lang_texts_es['ghost quiz'] = 'Acertijo Fantasma'\n", + "lang_texts_es['Question a correct'] = 'Bien... Sigue buscando la salida...'\n", + "lang_texts_es['Question a failed'] = 'Tú no escaparás... nunca'\n", + "lang_texts_es['Question b correct'] = 'Puedes irte... por ahora...'\n", + "lang_texts_es['Question b failed'] = 'Buen intento...'\n", + "lang_texts_es['Question c correct'] = 'Cierto... ¿Quién pensaría que un mamífero puede vivir bajo el agua?...'\n", + "lang_texts_es['Question c failed'] = 'No se te permitirá ir a ningún lado...'\n", + "lang_texts_es['Question d correct'] = 'Inteligente...'\n", + "lang_texts_es['Question d failed'] = 'Jejejeje...'\n", + "lang_texts_es['choose_door'] = 'Como fallaste en tus respuestas... es hora de elegir una puerta.'\n", + "lang_texts_es['correct_door'] = '¡Felicidades! Puedes vivir un día más'\n", + "lang_texts_es['wrong_door'] = 'Es hora de quedarse aquí... ¡PARA SIEMPRE!'\n", + "lang_texts_es['Spanish'] = 'Española'\n", + "lang_texts_es['Italian'] = 'Italiana'\n", + "lang_texts_es['French'] = 'Francesa'\n", + "lang_texts_es['Potato'] = 'Patata'\n", + "lang_texts_es['Rice'] = 'Arroz'\n", + "lang_texts_es['Bread'] = 'Pan'\n", + "lang_texts_es['Whale'] = 'Ballena'\n", + "lang_texts_es['Elephant'] = 'Elefante'\n", + "lang_texts_es['Rhinoceros'] = 'Rinoceronte'\n", + "lang_texts_es['Water'] = 'Agua'\n", + "lang_texts_es['Iron'] = 'Hierro'\n", + "lang_texts_es[''] = ''\n", + "\n", + "#Italian dictionary\n", + "\n", + "lang_texts_it = {}\n", + "lang_texts_it['yes'] = 'si'\n", + "lang_texts_it['no'] = 'no'\n", + "lang_texts_it['explore'] = 'esplorare'\n", + "lang_texts_it['examine'] = 'esaminare'\n", + "lang_texts_it['integer'] = 'Per favore, digita solo il numero delle opzioni disponibili'\n", + "lang_texts_it['intro'] = 'Ci si sveglia su un divano e ci si ritrova in una strana casa senza finestre in cui non si è mai stati prima. Non ricordate perché siete qui e cosa è successo prima. Sentite che un pericolo sconosciuto si sta avvicinando e dovete uscire dalla casa, ORA!'\n", + "lang_texts_it['escape'] = 'CORRERE! E non tornare più!\\n\\nCongratulazioni! Sei riuscito a fuggire dalla stanza!'\n", + "lang_texts_it['in'] = 'Ora siete nella '\n", + "lang_texts_it['next_room'] = 'Vuoi andare nella prossima stanza?'\n", + "lang_texts_it['examine_do'] = 'Cosa desideri esaminare?'\n", + "lang_texts_it['repeat'] = \"Non sono sicuro di cosa intendi. Scegli un'opzione valida.\"\n", + "lang_texts_it['explore_do'] = 'Esplorate la stanza. Questo è '\n", + "lang_texts_it['find'] = 'Tu trovi '\n", + "lang_texts_it['you_examine'] = 'Tu esamini '\n", + "lang_texts_it['unlock'] = 'La apri con una chiave che possiedi.'\n", + "lang_texts_it['locked'] = \"È chiusa a chiave ma non avete la chiave.\"\n", + "lang_texts_it['nothing'] = \"Non c'è nulla di interessante\"\n", + "lang_texts_it['none'] = \"L'oggetto richiesto non si trova nella stanza attuale.\"\n", + "lang_texts_it['option'] = 'Opzione:'\n", + "lang_texts_it['select'] = 'Seleziona una opzione:'\n", + "lang_texts_it['selected'] = 'Opzione selezionata: '\n", + "lang_texts_it['no_valid'] = ' Selezionare un numero valido'\n", + "lang_texts_it['couch'] = 'Divano'\n", + "lang_texts_it['piano'] = 'Pianoforte'\n", + "lang_texts_it['door a'] = 'porta a'\n", + "lang_texts_it['Queen Bed'] = 'Letto matrimoniale'\n", + "lang_texts_it['door b'] = 'porta b'\n", + "lang_texts_it['door c'] = 'porta c'\n", + "lang_texts_it['Double Bed'] = 'Letto doppio'\n", + "lang_texts_it['Dresser'] = 'Comò'\n", + "lang_texts_it['Dining Table'] = 'Tavolo da pranzo'\n", + "lang_texts_it['door d'] = 'porta d'\n", + "lang_texts_it['game room'] = 'Sala giochi'\n", + "lang_texts_it['Bed Room 1'] = 'Camera da letto 1'\n", + "lang_texts_it['Bed Room 2'] = 'Camera da letto 2'\n", + "lang_texts_it['Living Room'] = 'Soggiorno'\n", + "lang_texts_it['outside'] = 'Fuori'\n", + "lang_texts_it['key for door a'] = 'chiave per porta a'\n", + "lang_texts_it['key for door b'] = 'chiave per porta b'\n", + "lang_texts_it['key for door c'] = 'chiave per porta c'\n", + "lang_texts_it['key for door d'] = 'chiave per porta d'\n", + "lang_texts_it['Question a'] = 'Di quale nazionalità si credeva fosse Colombo?'\n", + "lang_texts_it['Question b'] = 'Qual è il cibo più consumato al mondo?'\n", + "lang_texts_it['Question c'] = 'Qual è il mammifero più grande del mondo?'\n", + "lang_texts_it['Question d'] = 'Che pesa di più, 1 kg di acqua o 1 kg di ferro?'\n", + "lang_texts_it['door blue'] = 'Porta Blu'\n", + "lang_texts_it['door pink'] = 'Porta Rosa'\n", + "lang_texts_it['door red'] = 'Porta Rossa'\n", + "lang_texts_it['door black'] = 'Porta Nera'\n", + "lang_texts_it['door white'] = 'Porta Bianca'\n", + "lang_texts_it['ghost quiz'] = \"L'enigma dei fantasmi\"\n", + "lang_texts_it['Question a correct'] = \"Bene... Continua a cercare l'uscita...\"\n", + "lang_texts_it['Question a failed'] = 'Non fuggirai... mai'\n", + "lang_texts_it['Question b correct'] = 'Puoi andare... per ora...'\n", + "lang_texts_it['Question b failed'] = 'Bel tentativo...'\n", + "lang_texts_it['Question c correct'] = \"Vero...Chi penserebbe che un mammifero possa vivere sott'acqua?...\"\n", + "lang_texts_it['Question c failed'] = 'Non ti sarà permesso andare da nessuna parte...'\n", + "lang_texts_it['Question d correct'] = 'Intelligente...'\n", + "lang_texts_it['Question d failed'] = 'ehehehehe...'\n", + "lang_texts_it['choose_door'] = 'Dal momento che hai fallito le tue risposte... è ora di scegliere una porta.'\n", + "lang_texts_it['correct_door'] = 'Congratulazioni! puoi vivere un altro giorno'\n", + "lang_texts_it['wrong_door'] = 'È ora di restare qui... PER SEMPRE!'\n", + "lang_texts_it['Spanish'] = 'Spagnolo'\n", + "lang_texts_it['Italian'] = 'Italiano'\n", + "lang_texts_it['French'] = 'Francese'\n", + "lang_texts_it['Potato'] = 'Patata'\n", + "lang_texts_it['Rice'] = 'Riso'\n", + "lang_texts_it['Bread'] = 'Pane'\n", + "lang_texts_it['Whale'] = 'Balena'\n", + "lang_texts_it['Elephant'] = 'Elefante'\n", + "lang_texts_it['Rhinoceros'] = 'Rinoceronte'\n", + "lang_texts_it['Water'] = 'Acqua'\n", + "lang_texts_it['Iron'] = 'Ferro'\n", + "lang_texts_it[''] = ''\n", + "\n", + "#Portuguese dictionary\n", + "\n", + "lang_texts_pt = {}\n", + "lang_texts_pt['yes'] = 'sim'\n", + "lang_texts_pt['no'] = 'não'\n", + "lang_texts_pt['explore'] = 'explorar'\n", + "lang_texts_pt['examine'] = 'examinar'\n", + "lang_texts_pt['integer'] = 'Por favor, digite apenas o número das opções'\n", + "lang_texts_pt['intro'] = 'Você acorda em um sofá e se encontra em uma casa estranha, sem janelas, na qual nunca esteve antes. Você não se lembra por que está aqui e o que aconteceu antes. Você sente que algum perigo desconhecido está se aproximando e você deve sair de casa, AGORA!'\n", + "lang_texts_pt['escape'] = 'CORRE! E não volte mais!\\n\\nParabéns! Você escapou do quarto!'\n", + "lang_texts_pt['in'] = 'Você está agora em '\n", + "lang_texts_pt['next_room'] = 'Você quer ir para a próxima sala?'\n", + "lang_texts_pt['examine_do'] = 'O que você gostaria de examinar?'\n", + "lang_texts_pt['repeat'] = \"Não tenho certeza do que você quer dizer. Escolha uma opção válida.\"\n", + "lang_texts_pt['explore_do'] = 'Você explora a sala. Isto é '\n", + "lang_texts_pt['find'] = 'Você encontra '\n", + "lang_texts_pt['you_examine'] = 'Você examina '\n", + "lang_texts_pt['unlock'] = 'Você desbloqueia com uma chave que você tem.'\n", + "lang_texts_pt['locked'] = \"Está trancado, mas você não tem a chave.\"\n", + "lang_texts_pt['nothing'] = \"Não há nada de interessante nisso.\"\n", + "lang_texts_pt['none'] = 'O item solicitado não foi encontrado na sala atual.'\n", + "lang_texts_pt['option'] = 'Opção:'\n", + "lang_texts_pt['select'] = 'Selecione uma opção:'\n", + "lang_texts_pt['selected'] = 'Opção selecionada: '\n", + "lang_texts_pt['no_valid'] = 'Por favor, selecione um número válido'\n", + "lang_texts_pt['couch'] = 'sofá'\n", + "lang_texts_pt['piano'] = 'piano'\n", + "lang_texts_pt['door a'] = 'porta a'\n", + "lang_texts_pt['Queen Bed'] = 'Cama de casal'\n", + "lang_texts_pt['door b'] = 'porta b'\n", + "lang_texts_pt['door c'] = 'porta c'\n", + "lang_texts_pt['Double Bed'] = 'Cama Dupla'\n", + "lang_texts_pt['Dresser'] = 'Aparador'\n", + "lang_texts_pt['Dining Table'] = 'Mesa de jantar'\n", + "lang_texts_pt['door d'] = 'porta d'\n", + "lang_texts_pt['game room'] = 'Sala de jogos'\n", + "lang_texts_pt['Bed Room 1'] = 'Quarto 1'\n", + "lang_texts_pt['Bed Room 2'] = 'Quarto 2'\n", + "lang_texts_pt['Living Room'] = 'Sala de estar'\n", + "lang_texts_pt['outside'] = 'fora'\n", + "lang_texts_pt['key for door a'] = 'chave para porta a'\n", + "lang_texts_pt['key for door b'] = 'chave para porta b'\n", + "lang_texts_pt['key for door c'] = 'chave para porta c'\n", + "lang_texts_pt['key for door d'] = 'chave para porta d'\n", + "lang_texts_pt['Question a'] = 'Qual era a nacionalidade de Colombo?'\n", + "lang_texts_pt['Question b'] = 'Qual é o alimento mais consumido no mundo?'\n", + "lang_texts_pt['Question c'] = 'Qual é o maior mamífero do mundo?'\n", + "lang_texts_pt['Question d'] = 'O que pesa mais, 1 kg de água ou 1 kg de ferro?'\n", + "lang_texts_pt['door blue'] = 'Porta Azul'\n", + "lang_texts_pt['door pink'] = 'Porta Rosa'\n", + "lang_texts_pt['door red'] = 'Porta Vermelha'\n", + "lang_texts_pt['door black'] = 'Porta Preta'\n", + "lang_texts_pt['door white'] = 'Porta Branca'\n", + "lang_texts_pt['ghost quiz'] = 'Teste Fantasma'\n", + "lang_texts_pt['Question a correct'] = 'Ok... Continue procurando a saída...'\n", + "lang_texts_pt['Question a failed'] = 'Você não vai escapar... nunca'\n", + "lang_texts_pt['Question b correct'] = 'Você pode ir... por enquanto...'\n", + "lang_texts_pt['Question b failed'] = 'Boa tentativa...'\n", + "lang_texts_pt['Question c correct'] = \"Certo... Quem pensaria que um mamífero poderia viver debaixo d'água?...\"\n", + "lang_texts_pt['Question c failed'] = 'Você não poderá ir a lugar nenhum...'\n", + "lang_texts_pt['Question d correct'] = 'Inteligente...'\n", + "lang_texts_pt['Question d failed'] = 'Hehehehe...'\n", + "lang_texts_pt['choose_door'] = 'Já que você falhou em suas respostas... é hora de escolher uma porta.'\n", + "lang_texts_pt['correct_door'] = 'Parabéns! você pode viver outro dia'\n", + "lang_texts_pt['wrong_door'] = 'É hora de ficar aqui... PARA SEMPRE!'\n", + "lang_texts_pt['Spanish'] = 'Espanhol'\n", + "lang_texts_pt['Italian'] = 'Italiano'\n", + "lang_texts_pt['French'] = 'Francesa'\n", + "lang_texts_pt['Potato'] = 'Batata'\n", + "lang_texts_pt['Rice'] = 'Arroz'\n", + "lang_texts_pt['Bread'] = 'Pão'\n", + "lang_texts_pt['Whale'] = 'Baleia'\n", + "lang_texts_pt['Elephant'] = 'Elefante'\n", + "lang_texts_pt['Rhinoceros'] = 'Rinoceronte'\n", + "lang_texts_pt['Water'] = 'Água'\n", + "lang_texts_pt['Iron'] = 'Ferro'\n", + "lang_texts_pt[''] = ''\n", + "\n", + "#Main Dictionary to choose which dictionary we will need\n", + "\n", + "\n", + "lang_game = {}\n", + "lang_game['en'] = ['english',lang_texts_en]\n", + "lang_game['es'] = ['spanish',lang_texts_es]\n", + "lang_game['it'] = ['italian',lang_texts_it]\n", + "lang_game['pt'] = ['portuguese',lang_texts_pt]\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def selectFromDict(options, name=''):\n", + " \"\"\"\n", + " Function to add options instead of writing\n", + " \"\"\"\n", + "\n", + " index = 0\n", + " indexValidList = []\n", + " print(name)\n", + " print(lang_game[game_state[\"language\"]][1]['select'])\n", + " for optionName in options:\n", + " index = index + 1\n", + " indexValidList.extend([options[optionName]])\n", + " print(str(index) + ') ' + optionName)\n", + " inputValid = False\n", + " while not inputValid:\n", + " try:\n", + " inputRaw = int(input(lang_game[game_state[\"language\"]][1]['option']))\n", + " \n", + " inputNo = inputRaw - 1\n", + " if inputNo > -1 and inputNo < len(indexValidList):\n", + " selected = indexValidList[inputNo] \n", + " print(lang_game[game_state[\"language\"]][1]['selected'] + list(options.keys())[list(options.values()).index(selected)]) \n", + " inputValid = True\n", + " break\n", + " else:\n", + " print(lang_game[game_state[\"language\"]][1]['no_valid'])\n", + " except ValueError:\n", + " print(lang_game[game_state[\"language\"]][1]['integer'])\n", + " \n", + " print('\\n')\n", + " \n", + " return selected\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def ghost_quiz(key):\n", + " \"\"\"\n", + " Function to ask a question every time that find a key\n", + " Every fail increases the dificulty to escape \n", + " \"\"\"\n", + " answer = selectFromDict({lang_game[game_state[\"language\"]][1][value]:key for key,value in object_relations[key['question']['name']][0].items()},lang_game[game_state[\"language\"]][1][key['question']['name']])\n", + " \n", + " if answer == key['question']['correct answer']:\n", + " print(lang_game[game_state[\"language\"]][1][key['question']['name'] + ' correct'])\n", + " else:\n", + " print(lang_game[game_state[\"language\"]][1][key['question']['name'] + ' failed'])\n", + " game_state['hard_scape'] += 1\n", + " \n", + "def ghost_doors(): \n", + " \"\"\"\n", + " Function to give the chance to choose a door when failed any question\n", + "\n", + " \"\"\"\n", + " \n", + " if (game_state[\"hard_scape\"]>0):\n", + " print(lang_game[game_state[\"language\"]][1]['choose_door'])\n", + "\n", + " game_state['escape door'] = object_relations['Ghost Room'][random.randrange(game_state[\"hard_scape\"]+1)]\n", + " \n", + " #Test for the escape door\n", + " #print(game_state['escape door'])\n", + "\n", + " dict_escape_room = {}\n", + " for i in range(game_state[\"hard_scape\"]+1): \n", + " dict_escape_room[lang_game[game_state[\"language\"]][1][object_relations['Ghost Room'][i]['name']]] = i \n", + "\n", + " if (game_state['escape door'] == object_relations['Ghost Room'][selectFromDict(dict_escape_room,'')]):\n", + " print(lang_game[game_state[\"language\"]][1]['correct_door'])\n", + " play_sound('victory')\n", + " else:\n", + " print(lang_game[game_state[\"language\"]][1]['wrong_door'])\n", + " play_sound('fail')\n", + " else: \n", + " print(lang_game[game_state[\"language\"]][1]['escape']) \n", + " play_sound('victory')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def play_sound(sound):\n", + " \"\"\"\n", + " Play the sound selected\n", + " \"\"\"\n", + " \n", + " if (sound == 'piano'):\n", + " playsound(Path(\"sounds/piano_sound_effect.mp3\"))\n", + " elif (sound == 'victory'):\n", + " playsound(Path(\"sounds/Victory_sound.mp3\"))\n", + " elif (sound == 'fail'): \n", + " playsound(Path(\"sounds/Fail_sound_effect.mp3\"))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def show_room(room):\n", + " \"\"\"\n", + " Show an image related to the room\n", + " \"\"\"\n", + " \n", + " if (room[\"name\"].lower() == game_room['name'].lower()): \n", + " img = Image.open(Path('images/Game_room.png'))\n", + " img.show()\n", + " elif (room[\"name\"].lower() == bedroom_1['name'].lower()):\n", + " img = Image.open(Path('images/Bedroom_1.png'))\n", + " img.show()\n", + " elif (room[\"name\"].lower() == bedroom_2['name'].lower()):\n", + " img = Image.open(Path('images/Bedroom_2.png'))\n", + " img.show()\n", + " elif (room[\"name\"].lower() == living_room['name'].lower()):\n", + " img = Image.open(Path('images/Living_room.png'))\n", + " img.show()\n", + " \n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def linebreak():\n", + " \"\"\"\n", + " Print a line break\n", + " \"\"\"\n", + " print(\"\\n\\n\")\n", + "\n", + "def start_game():\n", + " \"\"\"\n", + " Start the game\n", + " \"\"\"\n", + " \n", + " #game language selection\n", + " \n", + " game_state['language'] = (selectFromDict({value[0]:key for key,value in lang_game.items()},'Which language do you want to use?')) \n", + " \n", + " #intro of the game \n", + " \n", + " print(lang_game[game_state[\"language\"]][1]['intro'])\n", + " \n", + " #create a loop because inside the play_room function could create problems the execution of the playroom recursively\n", + " \n", + " while game_state['current_room'] != game_state['target_room']:\n", + " play_room(game_state[\"current_room\"]) \n", + " \n", + " if(game_state[\"current_room\"] == game_state[\"target_room\"]):\n", + " ghost_doors() \n", + " \n", + "def play_room(room):\n", + " \"\"\"\n", + " Play a room. First check if the room being played is the target room.\n", + " If it is, the game will end with success. Otherwise, let player either \n", + " explore (list all items in this room) or examine an item found here.\n", + " \"\"\"\n", + " \n", + " show_room(room)\n", + " \n", + " while game_state['current_room'] != game_state['target_room']:\n", + " linebreak() \n", + " \n", + " print(lang_game[game_state[\"language\"]][1]['in'] + lang_game[game_state[\"language\"]][1][room[\"name\"]]) \n", + "\n", + " intended_action = selectFromDict({lang_game[game_state[\"language\"]][1]['examine']:'examine',lang_game[game_state[\"language\"]][1]['explore']:'explore'})\n", + "\n", + " if intended_action == \"explore\":\n", + " explore_room(room)\n", + "\n", + " #create loop ouside to prevent the execution of the function recursively \n", + " #play_room(room)\n", + " elif intended_action == \"examine\":\n", + "\n", + " game_state[\"current_room\"] = examine_item(selectFromDict({lang_game[game_state[\"language\"]][1][items['name']]:items['name'] for items in object_relations[game_state['current_room']['name']]},lang_game[game_state[\"language\"]][1]['examine_do']))\n", + " if (game_state[\"current_room\"] != room):\n", + " return \n", + " else:\n", + "\n", + " print(lang_game[game_state[\"language\"]][1]['repeat'])\n", + "\n", + " #create loop ouside to prevent the execution of the function recursively \n", + " #play_room(room)\n", + "\n", + " linebreak()\n", + "\n", + "def explore_room(room):\n", + " \"\"\"\n", + " Explore a room. List all items belonging to this room.\n", + " \"\"\"\n", + " \n", + " items = [lang_game[game_state[\"language\"]][1][i[\"name\"]] for i in object_relations[room[\"name\"]]]\n", + " \n", + " print(lang_game[game_state[\"language\"]][1]['explore_do'] + lang_game[game_state[\"language\"]][1][room[\"name\"]] + '. ' + lang_game[game_state[\"language\"]][1]['find'] + \", \".join(items))\n", + "\n", + "def get_next_room_of_door(door, current_room):\n", + " \"\"\"\n", + " From object_relations, find the two rooms connected to the given door.\n", + " Return the room that is not the current_room.\n", + " \"\"\"\n", + " connected_rooms = object_relations[door[\"name\"]]\n", + " for room in connected_rooms:\n", + " if(not current_room == room):\n", + " return room\n", + "\n", + "def examine_item(item_name):\n", + " \"\"\"\n", + " Examine an item which can be a door or furniture.\n", + " First make sure the intended item belongs to the current room.\n", + " Then check if the item is a door. Tell player if key hasn't been \n", + " collected yet. Otherwise ask player if they want to go to the next\n", + " room. If the item is not a door, then check if it contains keys.\n", + " Collect the key if found and update the game state. At the end,\n", + " play either the current or the next room depending on the game state\n", + " to keep playing.\n", + " \"\"\"\n", + " \n", + " current_room = game_state[\"current_room\"]\n", + " next_room = \"\"\n", + " output = None\n", + " \n", + " for item in object_relations[current_room[\"name\"]]:\n", + " if(item[\"name\"] == item_name):\n", + " key_found = False\n", + " \n", + " output = lang_game[game_state[\"language\"]][1]['you_examine'] + lang_game[game_state[\"language\"]][1][item_name] + \". \"\n", + " \n", + " if(item[\"type\"] == \"door\"):\n", + " have_key = False\n", + " \n", + " for key in game_state[\"keys_collected\"]:\n", + " if(key[\"target\"] == item):\n", + " have_key = True\n", + " if(have_key): \n", + " output += lang_game[game_state[\"language\"]][1]['unlock']\n", + " \n", + " next_room = get_next_room_of_door(item, current_room)\n", + " else: \n", + " output += lang_game[game_state[\"language\"]][1]['locked']\n", + " else:\n", + " if(item[\"name\"] == 'piano'):\n", + " play_sound('piano')\n", + " \n", + " if(item[\"name\"] in object_relations and len(object_relations[item[\"name\"]])>0):\n", + " item_found = object_relations[item[\"name\"]].pop()\n", + " game_state[\"keys_collected\"].append(item_found)\n", + " \n", + " key_found = True\n", + " \n", + " output += lang_game[game_state[\"language\"]][1]['find'] + lang_game[game_state[\"language\"]][1][item_found[\"name\"]] + \".\"\n", + " else:\n", + " output += lang_game[game_state[\"language\"]][1]['nothing']\n", + " \n", + " print(output)\n", + " \n", + " if (key_found): \n", + " print(\"\\n\" + lang_game[game_state[\"language\"]][1]['ghost quiz'] + \"\\n\")\n", + " ghost_quiz(item_found)\n", + " \n", + " break\n", + "\n", + " if(output is None): \n", + " print(lang_game[game_state[\"language\"]][1]['none'])\n", + " \n", + " if(next_room and selectFromDict({lang_game[game_state[\"language\"]][1]['yes']:'yes',lang_game[game_state[\"language\"]][1]['no']:'no'},lang_game[game_state[\"language\"]][1]['next_room']) == 'yes'):\n", + " #create loop ouside to prevent the execution of the function recursively \n", + " #play_room(next_room)\n", + " #game_state[\"current_room\"] = next_room\n", + " return next_room\n", + " else:\n", + " #create loop ouside to prevent the execution of the function recursively \n", + " #play_room(current_room)\n", + " return current_room" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "game_state = INIT_GAME_STATE.copy()\n", + "\n", + "start_game()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/your-code/main.py b/your-code/main.py new file mode 100644 index 00000000..10c92e5a --- /dev/null +++ b/your-code/main.py @@ -0,0 +1,867 @@ +#!/usr/bin/env python +# coding: utf-8 + +# In[ ]: + + +# import libraries +from pathlib import Path +import random + +import playsound as ps +from playsound import playsound + +from PIL import Image + + +# In[ ]: + + +#Questions & answers + +question_a = { + "name": "Question a", + "type": "question", + "correct answer": "a" +} + +answers_a = { + "a": "Spanish", + "b": "Italian", + "c": "French" +} + +question_b = { + "name": "Question b", + "type": "question", + "correct answer": "b" +} + +answers_b = { + "a": "Potato", + "b": "Rice", + "c": "Bread" +} + +question_c = { + "name": "Question c", + "type": "question", + "correct answer": "a" +} + +answers_c = { + "a": "Whale", + "b": "Elephant", + "c": "Rhinoceros" +} + +question_d = { + "name": "Question d", + "type": "question", + "correct answer": "c" +} + +answers_d = { + "a": "Water", + "b": "Iron", + "c": "" +} + +# define rooms and items + +couch = { + "name": "couch", + "type": "furniture", +} + +door_a = { + "name": "door a", + "type": "door", +} + +key_a = { + "name": "key for door a", + "type": "key", + "target": door_a, + "question": question_a +} + +piano = { + "name": "piano", + "type": "furniture", +} + +game_room = { + "name": "game room", + "type": "room", +} + +outside = { + "name": "outside" +} + +#New Rooms + +door_b = { + "name": "door b", + "type": "door", +} + +door_c = { + "name": "door c", + "type": "door", +} + +door_d = { + "name": "door d", + "type": "door", +} + + +door_blue = { + "name": "door blue", + "type": "door", +} + +door_pink = { + "name": "door pink", + "type": "door", +} + +door_red = { + "name": "door red", + "type": "door", +} + +door_black = { + "name": "door black", + "type": "door", +} + +door_white = { + "name": "door white", + "type": "door", +} + +key_b = { + "name": "key for door b", + "type": "key", + "target": door_b, + "question": question_b +} + +key_c = { + "name": "key for door c", + "type": "key", + "target": door_c, + "question": question_c +} + +key_d = { + "name": "key for door d", + "type": "key", + "target": door_d, + "question": question_d +} + +queen_bed = { + "name": "Queen Bed", + "type": "furniture", +} + +double_bed = { + "name": "Double Bed", + "type": "furniture", +} + +dresser = { + "name": "Dresser", + "type": "furniture", +} + +dining_table = { + "name": "Dining Table", + "type": "furniture", +} + +bedroom_1 = { + "name": "Bed Room 1", + "type": "room", +} + +bedroom_2 = { + "name": "Bed Room 2", + "type": "room", +} + +living_room = { + "name": "Living Room", + "type": "room", +} + +ghost_room = { + "name": "Ghost Room", + "type": "room" +} + +#all_rooms = [game_room, bedroom_1, bedroom_2, living_room, outside] + +#all_doors = [door_a, door_b, door_c, door_d] + +# define which items/rooms are related + +object_relations = { + "game room": [couch, piano, door_a], + "piano": [key_a], + "Bed Room 1": [queen_bed, door_a, door_b, door_c], + "Queen Bed": [key_b], + "Bed Room 2": [double_bed, dresser, door_b], + "Double Bed": [key_c], + "Dresser": [key_d], + "Living Room": [dining_table, door_c, door_d], + "Ghost Room": [door_blue, door_pink, door_red, door_black, door_white], + "outside": [door_d], + "door a": [game_room, bedroom_1], + "door b": [bedroom_1, bedroom_2], + "door c": [bedroom_1, living_room], + "door d": [living_room, outside], + "key a": [question_a], + "Question a": [answers_a], + "key b": [question_b], + "Question b": [answers_b], + "key c": [question_c], + "Question c": [answers_c], + "key d": [question_d], + "Question d": [answers_d] +} + +# define game state. Do not directly change this dict. +# Instead, when a new game starts, make a copy of this +# dict and use the copy to store gameplay state. This +# way you can replay the game multiple times. + +# Added language, hard_scape and escape door + +INIT_GAME_STATE = { + "language": 'en', + "current_room": game_room, + "keys_collected": [], + "hard_scape": 0, + "target_room": outside, + "escape door": door_blue +} + + + + +# In[ ]: + + +#Creating the Multi Language dictionaries + +#English dictionary + +lang_texts_en = {} +lang_texts_en['yes'] = 'yes' +lang_texts_en['no'] = 'no' +lang_texts_en['explore'] = 'explore' +lang_texts_en['examine'] = 'examine' +lang_texts_en['integer'] = 'Please type only the number of the options' +lang_texts_en['intro'] = '''You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!''' +lang_texts_en['escape'] = 'RUN! And do not come back again!\n\nCongrats! You escaped the room!' +lang_texts_en['in'] = 'You are now in ' +lang_texts_en['next_room'] = 'Do you want to go to the next room?' +lang_texts_en['examine_do'] = 'What would you like to examine?' +lang_texts_en['repeat'] = "Not sure what you mean. Choose a valid option." +lang_texts_en['explore_do'] = 'You explore the room. This is ' +lang_texts_en['find'] = 'You find ' +lang_texts_en['you_examine'] = 'You examine ' +lang_texts_en['unlock'] = 'You unlock it with a key you have.' +lang_texts_en['locked'] = "It is locked but you don't have the key." +lang_texts_en['nothing'] = "There isn't anything interesting about it." +lang_texts_en['none'] = 'The item you requested is not found in the current room.' +lang_texts_en['option'] = 'Option:' +lang_texts_en['select'] = 'Select one option:' +lang_texts_en['selected'] = 'Selected option: ' +lang_texts_en['no_valid'] = 'Please select a valid number' +lang_texts_en['couch'] = 'couch' +lang_texts_en['piano'] = 'piano' +lang_texts_en['door a'] = 'door a' +lang_texts_en['Queen Bed'] = 'Queen Bed' +lang_texts_en['door b'] = 'door b' +lang_texts_en['door c'] = 'door c' +lang_texts_en['Double Bed'] = 'Double Bed' +lang_texts_en['Dresser'] = 'Dresser' +lang_texts_en['Dining Table'] = 'Dining Table' +lang_texts_en['door d'] = 'door d' +lang_texts_en['game room'] = 'Game room' +lang_texts_en['Bed Room 1'] = 'Bed Room 1' +lang_texts_en['Bed Room 2'] = 'Bed Room 2' +lang_texts_en['Living Room'] = 'Living Room' +lang_texts_en['outside'] = 'outside' +lang_texts_en['key for door a'] = 'key for door a' +lang_texts_en['key for door b'] = 'key for door b' +lang_texts_en['key for door c'] = 'key for door c' +lang_texts_en['key for door d'] = 'key for door d' +lang_texts_en['Question a'] = 'What nationality was Columbus believed to be?' +lang_texts_en['Question b'] = 'What is the most consumed food in the world?' +lang_texts_en['Question c'] = 'What is the largest mammal in the world?' +lang_texts_en['Question d'] = 'What weighs more than 1 kg of water or 1kg of iron?' +lang_texts_en['door blue'] = 'Door Blue' +lang_texts_en['door pink'] = 'Door Pink' +lang_texts_en['door red'] = 'Door Red' +lang_texts_en['door black'] = 'Door Black' +lang_texts_en['door white'] = 'Door White' +lang_texts_en['ghost quiz'] = 'Ghost Quiz' +lang_texts_en['Question a correct'] = 'Right... Keep looking for the exit...' +lang_texts_en['Question a failed'] = 'You wont scape... ever' +lang_texts_en['Question b correct'] = 'You can go... for now...' +lang_texts_en['Question b failed'] = 'Nice try...' +lang_texts_en['Question c correct'] = 'True...Who would think a mammal can live underwater?...' +lang_texts_en['Question c failed'] = 'You will not be allowed to go anywhere...' +lang_texts_en['Question d correct'] = 'Clever...' +lang_texts_en['Question d failed'] = 'Hehehehe...' +lang_texts_en['choose_door'] = 'As you failed in your answers... it is time to choose a door.' +lang_texts_en['correct_door'] = 'Congratulations! You can live for one day more' +lang_texts_en['wrong_door'] = 'Time to stay here... FOREVER!' +lang_texts_en['Spanish'] = 'Spanish' +lang_texts_en['Italian'] = 'Italian' +lang_texts_en['French'] = 'French' +lang_texts_en['Potato'] = 'Potato' +lang_texts_en['Rice'] = 'Rice' +lang_texts_en['Bread'] = 'Bread' +lang_texts_en['Whale'] = 'Whale' +lang_texts_en['Elephant'] = 'Elephant' +lang_texts_en['Rhinoceros'] = 'Rhinoceros' +lang_texts_en['Water'] = 'Water' +lang_texts_en['Iron'] = 'Iron' +lang_texts_en[''] = '' + + +#Spanish dictionary + +lang_texts_es = {} +lang_texts_es['yes'] = 'sí' +lang_texts_es['no'] = 'no' +lang_texts_es['explore'] = 'explorar' +lang_texts_es['examine'] = 'examinar' +lang_texts_es['integer'] = 'Por favor teclea solamente números de las opciones' +lang_texts_es['intro'] = 'Te despiertas en un sofá y te encuentras en una casa extraña sin ventanas en la que nunca has estado antes. No recuerdas por qué estás aquí y qué había sucedido antes. Sientes que se acerca un peligro desconocido y debes salir de la casa, ¡YA!' +lang_texts_es['escape'] = '¡CORRE! ¡y no vuelvas más!\n\n¡Felicidades! ¡Has escapado!' +lang_texts_es['in'] = 'Estás en ' +lang_texts_es['next_room'] = '¿Quieres ir a la siguiente habitación?' +lang_texts_es['examine_do'] = '¿Qué te gustaría examinar?' +lang_texts_es['repeat'] = "No estoy seguro de lo que quieres. Seleccionar una opción válida." +lang_texts_es['explore_do'] = 'Exploras la habitación. Esta es ' +lang_texts_es['find'] = 'Encuentras ' +lang_texts_es['you_examine'] = 'Tú examinas ' +lang_texts_es['unlock'] = 'La abres con la llave que tú tienes.' +lang_texts_es['locked'] = "Está cerrada pero tú no tienes la llave." +lang_texts_es['nothing'] = "No se ve nada interesante" +lang_texts_es['none'] = 'El elemento que solició no se encuentra en la sala actual.' +lang_texts_es['option'] = 'Opción:' +lang_texts_es['select'] = 'Escoge una opción:' +lang_texts_es['selected'] = 'Opción escogida: ' +lang_texts_es['no_valid'] = 'Por favor, escoge un número válido' +lang_texts_es['couch'] = 'sofá' +lang_texts_es['piano'] = 'piano' +lang_texts_es['door a'] = 'puerta a' +lang_texts_es['Queen Bed'] = 'Cama de matrimonio' +lang_texts_es['door b'] = 'puerta b' +lang_texts_es['door c'] = 'puerta c' +lang_texts_es['Double Bed'] = 'Cama Doble' +lang_texts_es['Dresser'] = 'Cómoda' +lang_texts_es['Dining Table'] = 'Mesa de comedor' +lang_texts_es['door d'] = 'puerta d' +lang_texts_es['game room'] = 'Habitación de juegos' +lang_texts_es['Bed Room 1'] = 'Habitación 1' +lang_texts_es['Bed Room 2'] = 'Habitación 2' +lang_texts_es['Living Room'] = 'Sala de estar' +lang_texts_es['outside'] = 'Fuera' +lang_texts_es['key for door a'] = 'llave para puerta a' +lang_texts_es['key for door b'] = 'llave para puerta b' +lang_texts_es['key for door c'] = 'llave para puerta c' +lang_texts_es['key for door d'] = 'llave para puerta d' +lang_texts_es['Question a'] = '¿De qué nacionalidad se creía que era Colón?' +lang_texts_es['Question b'] = '¿Cuál es el alimento más consumido en el mundo?' +lang_texts_es['Question c'] = '¿Cuál es el mamífero más grande del mundo?' +lang_texts_es['Question d'] = '¿Qué pesa más, 1 kg de agua o 1 kg de hierro?' +lang_texts_es['door blue'] = 'Puerta Azul' +lang_texts_es['door pink'] = 'Puerta Rosa' +lang_texts_es['door red'] = 'Puerta Roja' +lang_texts_es['door black'] = 'Puerta Negra' +lang_texts_es['door white'] = 'Puerta Blanca' +lang_texts_es['ghost quiz'] = 'Acertijo Fantasma' +lang_texts_es['Question a correct'] = 'Bien... Sigue buscando la salida...' +lang_texts_es['Question a failed'] = 'Tú no escaparás... nunca' +lang_texts_es['Question b correct'] = 'Puedes irte... por ahora...' +lang_texts_es['Question b failed'] = 'Buen intento...' +lang_texts_es['Question c correct'] = 'Cierto... ¿Quién pensaría que un mamífero puede vivir bajo el agua?...' +lang_texts_es['Question c failed'] = 'No se te permitirá ir a ningún lado...' +lang_texts_es['Question d correct'] = 'Inteligente...' +lang_texts_es['Question d failed'] = 'Jejejeje...' +lang_texts_es['choose_door'] = 'Como fallaste en tus respuestas... es hora de elegir una puerta.' +lang_texts_es['correct_door'] = '¡Felicidades! Puedes vivir un día más' +lang_texts_es['wrong_door'] = 'Es hora de quedarse aquí... ¡PARA SIEMPRE!' +lang_texts_es['Spanish'] = 'Española' +lang_texts_es['Italian'] = 'Italiana' +lang_texts_es['French'] = 'Francesa' +lang_texts_es['Potato'] = 'Patata' +lang_texts_es['Rice'] = 'Arroz' +lang_texts_es['Bread'] = 'Pan' +lang_texts_es['Whale'] = 'Ballena' +lang_texts_es['Elephant'] = 'Elefante' +lang_texts_es['Rhinoceros'] = 'Rinoceronte' +lang_texts_es['Water'] = 'Agua' +lang_texts_es['Iron'] = 'Hierro' +lang_texts_es[''] = '' + +#Italian dictionary + +lang_texts_it = {} +lang_texts_it['yes'] = 'si' +lang_texts_it['no'] = 'no' +lang_texts_it['explore'] = 'esplorare' +lang_texts_it['examine'] = 'esaminare' +lang_texts_it['integer'] = 'Per favore, digita solo il numero delle opzioni disponibili' +lang_texts_it['intro'] = 'Ci si sveglia su un divano e ci si ritrova in una strana casa senza finestre in cui non si è mai stati prima. Non ricordate perché siete qui e cosa è successo prima. Sentite che un pericolo sconosciuto si sta avvicinando e dovete uscire dalla casa, ORA!' +lang_texts_it['escape'] = 'CORRERE! E non tornare più!\n\nCongratulazioni! Sei riuscito a fuggire dalla stanza!' +lang_texts_it['in'] = 'Ora siete nella ' +lang_texts_it['next_room'] = 'Vuoi andare nella prossima stanza?' +lang_texts_it['examine_do'] = 'Cosa desideri esaminare?' +lang_texts_it['repeat'] = "Non sono sicuro di cosa intendi. Scegli un'opzione valida." +lang_texts_it['explore_do'] = 'Esplorate la stanza. Questo è ' +lang_texts_it['find'] = 'Tu trovi ' +lang_texts_it['you_examine'] = 'Tu esamini ' +lang_texts_it['unlock'] = 'La apri con una chiave che possiedi.' +lang_texts_it['locked'] = "È chiusa a chiave ma non avete la chiave." +lang_texts_it['nothing'] = "Non c'è nulla di interessante" +lang_texts_it['none'] = "L'oggetto richiesto non si trova nella stanza attuale." +lang_texts_it['option'] = 'Opzione:' +lang_texts_it['select'] = 'Seleziona una opzione:' +lang_texts_it['selected'] = 'Opzione selezionata: ' +lang_texts_it['no_valid'] = ' Selezionare un numero valido' +lang_texts_it['couch'] = 'Divano' +lang_texts_it['piano'] = 'Pianoforte' +lang_texts_it['door a'] = 'porta a' +lang_texts_it['Queen Bed'] = 'Letto matrimoniale' +lang_texts_it['door b'] = 'porta b' +lang_texts_it['door c'] = 'porta c' +lang_texts_it['Double Bed'] = 'Letto doppio' +lang_texts_it['Dresser'] = 'Comò' +lang_texts_it['Dining Table'] = 'Tavolo da pranzo' +lang_texts_it['door d'] = 'porta d' +lang_texts_it['game room'] = 'Sala giochi' +lang_texts_it['Bed Room 1'] = 'Camera da letto 1' +lang_texts_it['Bed Room 2'] = 'Camera da letto 2' +lang_texts_it['Living Room'] = 'Soggiorno' +lang_texts_it['outside'] = 'Fuori' +lang_texts_it['key for door a'] = 'chiave per porta a' +lang_texts_it['key for door b'] = 'chiave per porta b' +lang_texts_it['key for door c'] = 'chiave per porta c' +lang_texts_it['key for door d'] = 'chiave per porta d' +lang_texts_it['Question a'] = 'Di quale nazionalità si credeva fosse Colombo?' +lang_texts_it['Question b'] = 'Qual è il cibo più consumato al mondo?' +lang_texts_it['Question c'] = 'Qual è il mammifero più grande del mondo?' +lang_texts_it['Question d'] = 'Che pesa di più, 1 kg di acqua o 1 kg di ferro?' +lang_texts_it['door blue'] = 'Porta Blu' +lang_texts_it['door pink'] = 'Porta Rosa' +lang_texts_it['door red'] = 'Porta Rossa' +lang_texts_it['door black'] = 'Porta Nera' +lang_texts_it['door white'] = 'Porta Bianca' +lang_texts_it['ghost quiz'] = "L'enigma dei fantasmi" +lang_texts_it['Question a correct'] = "Bene... Continua a cercare l'uscita..." +lang_texts_it['Question a failed'] = 'Non fuggirai... mai' +lang_texts_it['Question b correct'] = 'Puoi andare... per ora...' +lang_texts_it['Question b failed'] = 'Bel tentativo...' +lang_texts_it['Question c correct'] = "Vero...Chi penserebbe che un mammifero possa vivere sott'acqua?..." +lang_texts_it['Question c failed'] = 'Non ti sarà permesso andare da nessuna parte...' +lang_texts_it['Question d correct'] = 'Intelligente...' +lang_texts_it['Question d failed'] = 'ehehehehe...' +lang_texts_it['choose_door'] = 'Dal momento che hai fallito le tue risposte... è ora di scegliere una porta.' +lang_texts_it['correct_door'] = 'Congratulazioni! puoi vivere un altro giorno' +lang_texts_it['wrong_door'] = 'È ora di restare qui... PER SEMPRE!' +lang_texts_it['Spanish'] = 'Spagnolo' +lang_texts_it['Italian'] = 'Italiano' +lang_texts_it['French'] = 'Francese' +lang_texts_it['Potato'] = 'Patata' +lang_texts_it['Rice'] = 'Riso' +lang_texts_it['Bread'] = 'Pane' +lang_texts_it['Whale'] = 'Balena' +lang_texts_it['Elephant'] = 'Elefante' +lang_texts_it['Rhinoceros'] = 'Rinoceronte' +lang_texts_it['Water'] = 'Acqua' +lang_texts_it['Iron'] = 'Ferro' +lang_texts_it[''] = '' + +#Portuguese dictionary + +lang_texts_pt = {} +lang_texts_pt['yes'] = 'sim' +lang_texts_pt['no'] = 'não' +lang_texts_pt['explore'] = 'explorar' +lang_texts_pt['examine'] = 'examinar' +lang_texts_pt['integer'] = 'Por favor, digite apenas o número das opções' +lang_texts_pt['intro'] = 'Você acorda em um sofá e se encontra em uma casa estranha, sem janelas, na qual nunca esteve antes. Você não se lembra por que está aqui e o que aconteceu antes. Você sente que algum perigo desconhecido está se aproximando e você deve sair de casa, AGORA!' +lang_texts_pt['escape'] = 'CORRE! E não volte mais!\n\nParabéns! Você escapou do quarto!' +lang_texts_pt['in'] = 'Você está agora em ' +lang_texts_pt['next_room'] = 'Você quer ir para a próxima sala?' +lang_texts_pt['examine_do'] = 'O que você gostaria de examinar?' +lang_texts_pt['repeat'] = "Não tenho certeza do que você quer dizer. Escolha uma opção válida." +lang_texts_pt['explore_do'] = 'Você explora a sala. Isto é ' +lang_texts_pt['find'] = 'Você encontra ' +lang_texts_pt['you_examine'] = 'Você examina ' +lang_texts_pt['unlock'] = 'Você desbloqueia com uma chave que você tem.' +lang_texts_pt['locked'] = "Está trancado, mas você não tem a chave." +lang_texts_pt['nothing'] = "Não há nada de interessante nisso." +lang_texts_pt['none'] = 'O item solicitado não foi encontrado na sala atual.' +lang_texts_pt['option'] = 'Opção:' +lang_texts_pt['select'] = 'Selecione uma opção:' +lang_texts_pt['selected'] = 'Opção selecionada: ' +lang_texts_pt['no_valid'] = 'Por favor, selecione um número válido' +lang_texts_pt['couch'] = 'sofá' +lang_texts_pt['piano'] = 'piano' +lang_texts_pt['door a'] = 'porta a' +lang_texts_pt['Queen Bed'] = 'Cama de casal' +lang_texts_pt['door b'] = 'porta b' +lang_texts_pt['door c'] = 'porta c' +lang_texts_pt['Double Bed'] = 'Cama Dupla' +lang_texts_pt['Dresser'] = 'Aparador' +lang_texts_pt['Dining Table'] = 'Mesa de jantar' +lang_texts_pt['door d'] = 'porta d' +lang_texts_pt['game room'] = 'Sala de jogos' +lang_texts_pt['Bed Room 1'] = 'Quarto 1' +lang_texts_pt['Bed Room 2'] = 'Quarto 2' +lang_texts_pt['Living Room'] = 'Sala de estar' +lang_texts_pt['outside'] = 'fora' +lang_texts_pt['key for door a'] = 'chave para porta a' +lang_texts_pt['key for door b'] = 'chave para porta b' +lang_texts_pt['key for door c'] = 'chave para porta c' +lang_texts_pt['key for door d'] = 'chave para porta d' +lang_texts_pt['Question a'] = 'Qual era a nacionalidade de Colombo?' +lang_texts_pt['Question b'] = 'Qual é o alimento mais consumido no mundo?' +lang_texts_pt['Question c'] = 'Qual é o maior mamífero do mundo?' +lang_texts_pt['Question d'] = 'O que pesa mais, 1 kg de água ou 1 kg de ferro?' +lang_texts_pt['door blue'] = 'Porta Azul' +lang_texts_pt['door pink'] = 'Porta Rosa' +lang_texts_pt['door red'] = 'Porta Vermelha' +lang_texts_pt['door black'] = 'Porta Preta' +lang_texts_pt['door white'] = 'Porta Branca' +lang_texts_pt['ghost quiz'] = 'Teste Fantasma' +lang_texts_pt['Question a correct'] = 'Ok... Continue procurando a saída...' +lang_texts_pt['Question a failed'] = 'Você não vai escapar... nunca' +lang_texts_pt['Question b correct'] = 'Você pode ir... por enquanto...' +lang_texts_pt['Question b failed'] = 'Boa tentativa...' +lang_texts_pt['Question c correct'] = "Certo... Quem pensaria que um mamífero poderia viver debaixo d'água?..." +lang_texts_pt['Question c failed'] = 'Você não poderá ir a lugar nenhum...' +lang_texts_pt['Question d correct'] = 'Inteligente...' +lang_texts_pt['Question d failed'] = 'Hehehehe...' +lang_texts_pt['choose_door'] = 'Já que você falhou em suas respostas... é hora de escolher uma porta.' +lang_texts_pt['correct_door'] = 'Parabéns! você pode viver outro dia' +lang_texts_pt['wrong_door'] = 'É hora de ficar aqui... PARA SEMPRE!' +lang_texts_pt['Spanish'] = 'Espanhol' +lang_texts_pt['Italian'] = 'Italiano' +lang_texts_pt['French'] = 'Francesa' +lang_texts_pt['Potato'] = 'Batata' +lang_texts_pt['Rice'] = 'Arroz' +lang_texts_pt['Bread'] = 'Pão' +lang_texts_pt['Whale'] = 'Baleia' +lang_texts_pt['Elephant'] = 'Elefante' +lang_texts_pt['Rhinoceros'] = 'Rinoceronte' +lang_texts_pt['Water'] = 'Água' +lang_texts_pt['Iron'] = 'Ferro' +lang_texts_pt[''] = '' + +#Main Dictionary to choose which dictionary we will need + + +lang_game = {} +lang_game['en'] = ['english',lang_texts_en] +lang_game['es'] = ['spanish',lang_texts_es] +lang_game['it'] = ['italian',lang_texts_it] +lang_game['pt'] = ['portuguese',lang_texts_pt] + + +# In[ ]: + + +def selectFromDict(options, name=''): + """ + Function to add options instead of writing + """ + + index = 0 + indexValidList = [] + print(name) + print(lang_game[game_state["language"]][1]['select']) + for optionName in options: + index = index + 1 + indexValidList.extend([options[optionName]]) + print(str(index) + ') ' + optionName) + inputValid = False + while not inputValid: + try: + inputRaw = int(input(lang_game[game_state["language"]][1]['option'])) + + inputNo = inputRaw - 1 + if inputNo > -1 and inputNo < len(indexValidList): + selected = indexValidList[inputNo] + print(lang_game[game_state["language"]][1]['selected'] + list(options.keys())[list(options.values()).index(selected)]) + inputValid = True + break + else: + print(lang_game[game_state["language"]][1]['no_valid']) + except ValueError: + print(lang_game[game_state["language"]][1]['integer']) + + print('\n') + + return selected + + +# In[ ]: + + +def ghost_quiz(key): + """ + Function to ask a question every time that find a key + Every fail increases the dificulty to escape + """ + answer = selectFromDict({lang_game[game_state["language"]][1][value]:key for key,value in object_relations[key['question']['name']][0].items()},lang_game[game_state["language"]][1][key['question']['name']]) + + if answer == key['question']['correct answer']: + print(lang_game[game_state["language"]][1][key['question']['name'] + ' correct']) + else: + print(lang_game[game_state["language"]][1][key['question']['name'] + ' failed']) + game_state['hard_scape'] += 1 + +def ghost_doors(): + """ + Function to give the chance to choose a door when failed any question + + """ + + if (game_state["hard_scape"]>0): + print(lang_game[game_state["language"]][1]['choose_door']) + + game_state['escape door'] = object_relations['Ghost Room'][random.randrange(game_state["hard_scape"]+1)] + + #Test for the escape door + #print(game_state['escape door']) + + dict_escape_room = {} + for i in range(game_state["hard_scape"]+1): + dict_escape_room[lang_game[game_state["language"]][1][object_relations['Ghost Room'][i]['name']]] = i + + if (game_state['escape door'] == object_relations['Ghost Room'][selectFromDict(dict_escape_room,'')]): + print(lang_game[game_state["language"]][1]['correct_door']) + play_sound('victory') + else: + print(lang_game[game_state["language"]][1]['wrong_door']) + play_sound('fail') + else: + print(lang_game[game_state["language"]][1]['escape']) + play_sound('victory') + + +# In[ ]: + + +def play_sound(sound): + """ + Play the sound selected + """ + + if (sound == 'piano'): + playsound(Path("sounds/piano_sound_effect.mp3")) + elif (sound == 'victory'): + playsound(Path("sounds/Victory_sound.mp3")) + elif (sound == 'fail'): + playsound(Path("sounds/Fail_sound_effect.mp3")) + + +# In[ ]: + + +def show_room(room): + """ + Show an image related to the room + """ + + if (room["name"].lower() == game_room['name'].lower()): + img = Image.open(Path('images/Game_room.png')) + img.show() + elif (room["name"].lower() == bedroom_1['name'].lower()): + img = Image.open(Path('images/Bedroom_1.png')) + img.show() + elif (room["name"].lower() == bedroom_2['name'].lower()): + img = Image.open(Path('images/Bedroom_2.png')) + img.show() + elif (room["name"].lower() == living_room['name'].lower()): + img = Image.open(Path('images/Living_room.png')) + img.show() + + + + +# In[ ]: + + +def linebreak(): + """ + Print a line break + """ + print("\n\n") + +def start_game(): + """ + Start the game + """ + + #game language selection + + game_state['language'] = (selectFromDict({value[0]:key for key,value in lang_game.items()},'Which language do you want to use?')) + + #intro of the game + + print(lang_game[game_state["language"]][1]['intro']) + + #create a loop because inside the play_room function could create problems the execution of the playroom recursively + + while game_state['current_room'] != game_state['target_room']: + play_room(game_state["current_room"]) + + if(game_state["current_room"] == game_state["target_room"]): + ghost_doors() + +def play_room(room): + """ + Play a room. First check if the room being played is the target room. + If it is, the game will end with success. Otherwise, let player either + explore (list all items in this room) or examine an item found here. + """ + + show_room(room) + + while game_state['current_room'] != game_state['target_room']: + linebreak() + + print(lang_game[game_state["language"]][1]['in'] + lang_game[game_state["language"]][1][room["name"]]) + + intended_action = selectFromDict({lang_game[game_state["language"]][1]['examine']:'examine',lang_game[game_state["language"]][1]['explore']:'explore'}) + + if intended_action == "explore": + explore_room(room) + + #create loop ouside to prevent the execution of the function recursively + #play_room(room) + elif intended_action == "examine": + + game_state["current_room"] = examine_item(selectFromDict({lang_game[game_state["language"]][1][items['name']]:items['name'] for items in object_relations[game_state['current_room']['name']]},lang_game[game_state["language"]][1]['examine_do'])) + if (game_state["current_room"] != room): + return + else: + + print(lang_game[game_state["language"]][1]['repeat']) + + #create loop ouside to prevent the execution of the function recursively + #play_room(room) + + linebreak() + +def explore_room(room): + """ + Explore a room. List all items belonging to this room. + """ + + items = [lang_game[game_state["language"]][1][i["name"]] for i in object_relations[room["name"]]] + + print(lang_game[game_state["language"]][1]['explore_do'] + lang_game[game_state["language"]][1][room["name"]] + '. ' + lang_game[game_state["language"]][1]['find'] + ", ".join(items)) + +def get_next_room_of_door(door, current_room): + """ + From object_relations, find the two rooms connected to the given door. + Return the room that is not the current_room. + """ + connected_rooms = object_relations[door["name"]] + for room in connected_rooms: + if(not current_room == room): + return room + +def examine_item(item_name): + """ + Examine an item which can be a door or furniture. + First make sure the intended item belongs to the current room. + Then check if the item is a door. Tell player if key hasn't been + collected yet. Otherwise ask player if they want to go to the next + room. If the item is not a door, then check if it contains keys. + Collect the key if found and update the game state. At the end, + play either the current or the next room depending on the game state + to keep playing. + """ + + current_room = game_state["current_room"] + next_room = "" + output = None + + for item in object_relations[current_room["name"]]: + if(item["name"] == item_name): + key_found = False + + output = lang_game[game_state["language"]][1]['you_examine'] + lang_game[game_state["language"]][1][item_name] + ". " + + if(item["type"] == "door"): + have_key = False + + for key in game_state["keys_collected"]: + if(key["target"] == item): + have_key = True + if(have_key): + output += lang_game[game_state["language"]][1]['unlock'] + + next_room = get_next_room_of_door(item, current_room) + else: + output += lang_game[game_state["language"]][1]['locked'] + else: + if(item["name"] == 'piano'): + play_sound('piano') + + if(item["name"] in object_relations and len(object_relations[item["name"]])>0): + item_found = object_relations[item["name"]].pop() + game_state["keys_collected"].append(item_found) + + key_found = True + + output += lang_game[game_state["language"]][1]['find'] + lang_game[game_state["language"]][1][item_found["name"]] + "." + else: + output += lang_game[game_state["language"]][1]['nothing'] + + print(output) + + if (key_found): + print("\n" + lang_game[game_state["language"]][1]['ghost quiz'] + "\n") + ghost_quiz(item_found) + + break + + if(output is None): + print(lang_game[game_state["language"]][1]['none']) + + if(next_room and selectFromDict({lang_game[game_state["language"]][1]['yes']:'yes',lang_game[game_state["language"]][1]['no']:'no'},lang_game[game_state["language"]][1]['next_room']) == 'yes'): + #create loop ouside to prevent the execution of the function recursively + #play_room(next_room) + #game_state["current_room"] = next_room + return next_room + else: + #create loop ouside to prevent the execution of the function recursively + #play_room(current_room) + return current_room + + +# In[ ]: + + +game_state = INIT_GAME_STATE.copy() + +start_game() + diff --git a/your-code/main.spec b/your-code/main.spec new file mode 100644 index 00000000..94977244 --- /dev/null +++ b/your-code/main.spec @@ -0,0 +1,44 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis( + ['main.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False, +) +pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='main', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) diff --git a/your-code/sounds/Fail_sound_effect.mp3 b/your-code/sounds/Fail_sound_effect.mp3 new file mode 100644 index 00000000..f54bc5c6 Binary files /dev/null and b/your-code/sounds/Fail_sound_effect.mp3 differ diff --git a/your-code/sounds/Victory_sound.mp3 b/your-code/sounds/Victory_sound.mp3 new file mode 100644 index 00000000..cbc4db8a Binary files /dev/null and b/your-code/sounds/Victory_sound.mp3 differ diff --git a/your-code/sounds/piano_sound_effect.mp3 b/your-code/sounds/piano_sound_effect.mp3 new file mode 100644 index 00000000..71e01f8c Binary files /dev/null and b/your-code/sounds/piano_sound_effect.mp3 differ