diff --git a/your-project/.ipynb_checkpoints/god_save_the_queen-checkpoint.ipynb b/your-project/.ipynb_checkpoints/god_save_the_queen-checkpoint.ipynb new file mode 100644 index 0000000..e33942f --- /dev/null +++ b/your-project/.ipynb_checkpoints/god_save_the_queen-checkpoint.ipynb @@ -0,0 +1,174 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# SAVE THE QUEEN " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## El juego consiste en que el jugador intente adivinar la palabra que la computadora elije al azar para poder salvar a la reina." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Vidas: 3\n", + "### Cantidad de jugadores: 1 " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "#Library \n", + "\n", + "import random \n", + "from random import randint\n", + "import re" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "['crown', 'united', 'kingdom', 'royalty', 'royal', 'estate', 'buckingham', 'empress', 'tiara', 'viscount', 'throne', 'castle']\n" + ] + } + ], + "source": [ + "textooptativo = open(\"texto.txt\", \"r\")\n", + "lista_texto = list(textooptativo.readlines())\n", + "#print(lista_texto)\n", + "#print(type(lista_texto))\n", + "txtplano = \"\".join(lista_texto)\n", + "#txtplano = re.replace(\"\\n\", \" \", txtplano)\n", + "texto = re.sub(\"[,.]\", \"\", txtplano).split()\n", + "#print(texto)\n", + "\n", + "texto2 = []\n", + "for t in texto: \n", + " texto2.append(t)\n", + "#print(texto2)\n", + "\n", + "txtplano2 = \" \".join(texto2)\n", + "print(type(txtplano2))\n", + "\n", + "txtplano2 = list(txtplano2.lower().split())\n", + "print(txtplano2)\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + " \n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Arrenge the letters to save our Queen\n", + "['v', 's', 'u', 't', 'o', 'i', 'c', 'n']\n", + " ftuuft\n", + "Our Queen is still in danger\n", + "Try again, your sword have 2 hits!\n", + "['v', 's', 'u', 't', 'o', 'i', 'c', 'n']\n", + " dtdt\n", + "Our Queen is still in danger\n", + "Try again, your sword have 1 hits!\n", + "['v', 's', 'u', 't', 'o', 'i', 'c', 'n']\n", + " viscount\n", + "You got a hit, deal 2 more\n", + "['s', 'e', 'p', 'r', 's', 'e', 'm']\n", + " eggew\n", + "The Dragon ate the Queen, You lose!!!\n" + ] + } + ], + "source": [ + "#words\n", + "\n", + "import random\n", + "from random import randint\n", + "\n", + "#words = [\"crown\", \"united kingdom\", \"royalty\", \"castle\", \"empress\", \"buckingham\", \"tiara\", \"viscount\", \"royal estate\", \"throne\"]\n", + "player1 = 1\n", + "nivelx = 3\n", + "vidas = 3\n", + "\n", + "def nivel(x):\n", + " global player1\n", + " return player1\n", + "\n", + "\n", + "print(\"Arrenge the letters to save our Queen\")\n", + "while player1 == 1 and nivelx > 0:\n", + " b = txtplano2[randint(0,9)]\n", + " a = list(b)\n", + " random.shuffle(a)\n", + " print(a)\n", + " while vidas >=1:\n", + " player = input(\" \")\n", + " if player == b:\n", + " if nivelx != 1:\n", + " print (\"You got a hit, deal %i more\" % (nivelx -1))\n", + " nivel(player1)\n", + " elif nivelx == 1:\n", + " print(\"You win\")\n", + " nivelx -= 1\n", + " break\n", + " elif player != b:\n", + " if vidas ==1:\n", + " print(\"The Dragon ate the Queen, You lose!!!\")\n", + " player1 = 'perdiste'\n", + " break\n", + " else:\n", + " print(\"Our Queen is still in danger\")\n", + " vidas -= 1\n", + " print(\"Try again, your sword have %i hits!\" % vidas)\n", + " print(a)\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/your-project/codigobase.py b/your-project/codigobase.py new file mode 100644 index 0000000..9b4dba2 --- /dev/null +++ b/your-project/codigobase.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Thu Jul 4 16:50:36 2019 + +@author: rodolfo | gustavo +""" + +#Juego + +import random +from random import randint +import re + +textooptativo = open("texto.txt", "r") +lista_texto = list(textooptativo.readlines()) +#print(lista_texto) +#print(type(lista_texto)) +txtplano = "".join(lista_texto) +#txtplano = re.replace("\n", " ", txtplano) +texto = re.sub("[,.]", "", txtplano).split() +#print(texto) + +texto2 = [] +for t in texto: + texto2.append(t) +#print(texto2) + +txtplano2 = " ".join(texto2) +#print(type(txtplano2)) + +txtplano2 = list(txtplano2.lower().split()) +#print(txtplano2) + + +import random +from random import randint + +#words = ["crown", "united kingdom", "royalty", "castle", "empress", "buckingham", "tiara", "viscount", "royal estate", "throne"] +player1 = 1 +nivelx = 3 +vidas = 3 + +def nivel(x): + global player1 + return player1 + + +print("Arrenge the letters to save our Queen") +while player1 == 1 and nivelx > 0: + b = txtplano2[randint(0,9)] + a = list(b) + random.shuffle(a) + print(a) + while vidas >=1: + player = input(" ") + if player == b: + if nivelx != 1: + print ("You got a hit, deal %i more" % (nivelx -1)) + nivel(player1) + elif nivelx == 1: + print("You win") + nivelx -= 1 + break + elif player != b: + if vidas ==1: + print("The Dragon ate the Queen, You lose!!!") + player1 = 'perdiste' + break + else: + print("Our Queen is still in danger") + vidas -= 1 + print("Try again, your sword have %i hits!" % vidas) + print(a) diff --git a/your-project/god_save_the_queen.ipynb b/your-project/god_save_the_queen.ipynb new file mode 100644 index 0000000..19a7c96 --- /dev/null +++ b/your-project/god_save_the_queen.ipynb @@ -0,0 +1,169 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# SAVE THE QUEEN " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## El juego consiste en que el jugador intente adivinar la palabra que la computadora elije al azar para poder salvar a la reina." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Vidas: 3\n", + "### Cantidad de jugadores: 1 " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "#Library \n", + "\n", + "import random \n", + "from random import randint\n", + "import re" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "textooptativo = open(\"texto.txt\", \"r\")\n", + "lista_texto = list(textooptativo.readlines())\n", + "#print(lista_texto)\n", + "#print(type(lista_texto))\n", + "txtplano = \"\".join(lista_texto)\n", + "#txtplano = re.replace(\"\\n\", \" \", txtplano)\n", + "texto = re.sub(\"[,.]\", \"\", txtplano).split()\n", + "#print(texto)\n", + "\n", + "texto2 = []\n", + "for t in texto: \n", + " texto2.append(t)\n", + "#print(texto2)\n", + "\n", + "txtplano2 = \" \".join(texto2)\n", + "print(type(txtplano2))\n", + "\n", + "txtplano2 = list(txtplano2.lower().split())\n", + "#print(txtplano2)\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + " \n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Arrenge the letters to save our Queen\n", + "['m', 'g', 'd', 'i', 'k', 'n', 'o']\n", + " dyfy\n", + "Our Queen is still in danger\n", + "Try again, your sword have 2 hits!\n", + "['m', 'g', 'd', 'i', 'k', 'n', 'o']\n", + " fcyf\n", + "Our Queen is still in danger\n", + "Try again, your sword have 1 hits!\n", + "['m', 'g', 'd', 'i', 'k', 'n', 'o']\n", + " fycfy\n", + "The Dragon ate the Queen, You lose!!!\n" + ] + } + ], + "source": [ + "#words\n", + "\n", + "import random\n", + "from random import randint\n", + "\n", + "#words = [\"crown\", \"united kingdom\", \"royalty\", \"castle\", \"empress\", \"buckingham\", \"tiara\", \"viscount\", \"royal estate\", \"throne\"]\n", + "player1 = 1\n", + "nivelx = 3\n", + "vidas = 3\n", + "\n", + "def nivel(x):\n", + " global player1\n", + " return player1\n", + "\n", + "\n", + "print(\"Arrenge the letters to save our Queen\")\n", + "while player1 == 1 and nivelx > 0:\n", + " b = txtplano2[randint(0,9)]\n", + " a = list(b)\n", + " random.shuffle(a)\n", + " print(a)\n", + " while vidas >=1:\n", + " player = input(\" \")\n", + " if player == b:\n", + " if nivelx != 1:\n", + " print (\"You got a hit, deal %i more\" % (nivelx -1))\n", + " nivel(player1)\n", + " elif nivelx == 1:\n", + " print(\"You win\")\n", + " nivelx -= 1\n", + " break\n", + " elif player != b:\n", + " if vidas ==1:\n", + " print(\"The Dragon ate the Queen, You lose!!!\")\n", + " player1 = 'perdiste'\n", + " break\n", + " else:\n", + " print(\"Our Queen is still in danger\")\n", + " vidas -= 1\n", + " print(\"Try again, your sword have %i hits!\" % vidas)\n", + " print(a)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/your-project/readme.txt b/your-project/readme.txt new file mode 100644 index 0000000..e9f6e35 --- /dev/null +++ b/your-project/readme.txt @@ -0,0 +1,29 @@ +Juego - Save the Queen + +Descripción + +Save the queen consiste en un juego de tratar de descifrar la palabra oculta y desordenada para salvar a la reina. +Tendrá 3 vidas para descifrarla y 3 niveles para superar. + +Workflow + +Declaración de variables +Itineración de while, for, else +Definición de funcion +Compilación +Prueba y corrección de bugs +Compilación final + +Organizaction tools + +Jupyter Notebook +Shell +Python +Spyper +Pycharm + +Links + +Repositorios https://github.com/rodolfopardo/Project-Week-1-Build-Your-Own-Game + + diff --git a/your-project/texto.txt b/your-project/texto.txt new file mode 100644 index 0000000..76d29cc --- /dev/null +++ b/your-project/texto.txt @@ -0,0 +1,18 @@ +Crown +Kingdom +Royalty +Estate +Buckingham +Empress +Tiara +Viscount +Throne +Castle +Knight +Crockett +Majesty +Princess +Heir +Commonwealth +Duchess +