diff --git a/src/kata1/rps.py b/src/kata1/rps.py index defdd99..e0fdca2 100644 --- a/src/kata1/rps.py +++ b/src/kata1/rps.py @@ -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() diff --git a/src/kata2/rpg.py b/src/kata2/rpg.py index b8339d2..f61aec7 100644 --- a/src/kata2/rpg.py +++ b/src/kata2/rpg.py @@ -4,9 +4,9 @@ import string def RandomPasswordGenerator(passLen=10): - # - # - + caracteres = string.ascii_uppercase + string.ascii_lowercase + string.digits + longitud = passLen + cadena = "" # # diff --git a/src/kata3/bot.py b/src/kata3/bot.py index 00f6b3b..4be40bc 100644 --- a/src/kata3/bot.py +++ b/src/kata3/bot.py @@ -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""" @@ -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) @@ -55,6 +59,5 @@ def main(): updater.idle() - if __name__ == '__main__': main()