Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions your-project/.ipynb_checkpoints/god_save_the_queen-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -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": [
"<class 'str'>\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
}
74 changes: 74 additions & 0 deletions your-project/codigobase.py
Original file line number Diff line number Diff line change
@@ -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)
Loading