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
38 changes: 31 additions & 7 deletions src/kata1/rps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,41 @@
#'Ganaste!'
#'Perdiste!'
def quienGana(player, ai):
return ""

# Pasamos las opciones recibidad a minusculas para que no pueda haber fallos
player = player.lower()
ai = ai.lower()

# Si son iguales
if player == ai:
return 'Empate!'
# Piedra gana a tijeras
elif player == "piedra" and ai == "tijeras":
return "Ganaste!"
# Papel gana a piedra
elif player == "papel" and ai == "piedra":
return "Ganaste!"
# Tijeras gana a papel
elif player == "tijeras" and ai == "papel":
return "Ganaste!"
# Si no es ninguna de las opciones anteriores quiere decir que pierdo
return "Perdiste!"

# Entry Point
def Game():
#
#

# Pregunta al usuario su eleccíon
player = input("¿Piedra, Papel o Tijeras?")
print("JUGADOR: " + player)

#
#
# Utilizamos el randint para sacar una opción de la lista de opciones
ai = options[randint(0,2)]
print("MÁQUINA: " + ai)

# Asignamos a la variable winner la función quienGana
winner = quienGana(player, ai)

# Imprimimos resultado
print("RESULTADO: " + winner)

print(winner)

Game()
6 changes: 3 additions & 3 deletions src/kata2/rpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import string

def RandomPasswordGenerator(passLen=10):
#
#

caracteres = string.ascii_uppercase + string.ascii_lowercase + string.digits
longitud = passLen
cadena = ""
#
#

Expand Down
31 changes: 17 additions & 14 deletions src/kata3/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@
# Definimos algunas funciones para los comandos. Estos generalmente toman los dos argumentos update y context
def start(update, context):
"""Envia un mensaje cuando se emita el comando /start."""
return ""
update.message.reply_text("Hola, Geeks!")
return "Hola, Geeks!"

def help(update, context):
"""Envia un mensaje cuando se emita el comando /help."""
return ""
update.message.reply_text("Ayudame!")
return "Ayudame!"

def mayus(update, context):
#
return ""
texto = update.message.text.upper()
update.message.reply_text(texto)
return str(texto)

def alreves(update, context):
"""Repite el mensaje del usuario."""
#
return ""
texto = update.message.text[::-1]
update.message.reply_text(texto)
return str(texto)

def error(update, context):
"""Envia los errores por consola"""
Expand All @@ -34,18 +38,18 @@ def error(update, context):
def main():
"""Inicio del Bot"""
#Colocamos el Token creado por FatherBot
updater = Updater("", use_context=True)
updater = Updater("1271734615:AAEnAUIeTI3MDDUbv8mYeMKZke74-g5vGl8", use_context=True)

# Es el Registro de Comandos a través del dispartcher
dp = #
dp = updater.dispatcher

# Añadimos a la lista de Registro todos los comandos con su función [start - help - mayus]
#
#
#

dp.add_handler(CommandHandler("start", start))
dp.add_handler(CommandHandler("help", help))
dp.add_handler(CommandHandler("mayus", mayus))
# Este comando es un Trigger que se lanza cuando no hay comandos [alreves]
#
dp.add_handler(MessageHandler(Filters.text, alreves))

# Y este espera al error
dp.add_error_handler(error)
Expand All @@ -55,6 +59,5 @@ def main():

updater.idle()


if __name__ == '__main__':
main()