Python口袋妖怪对战 - 口袋妖怪攻击一次攻击两次

时间:2017-08-22 19:20:35

标签: python-2.7

我是python的新手。我正在努力进行一场宠物小精灵战斗。但我似乎无法弄清楚为什么每当你攻击和敌人攻击时,他们会两次攻击。它应该像这样工作:

*战斗开始

*你攻击敌人

*敌人攻击你

*其中一个晕倒

import time
import random

# pokemon beginning battle
print "mewtwo has appeared"
time.sleep(1)
print "lvl 70"
time.sleep(0.5)
print "HP 128"
print " \n "

# Mewtwo stats
mewtwo_HP = 128
mewtwo_atk = 20
mewtwo_atk2 = 45
move = random.randrange(-1, 1)

# Lapras stats
attack1 = ['hydro pump']
attack2 = ['ice beam']
lapras_HP = 100

attack1range = random.randrange(15,32)

attack2range = random.randrange(20, 25)

run = "you can't run away!"
pokemon = "Lapras"

# Lapras's turn
while True:

    print "Lapras's moves:"
    print "[ice beam][hydro pump]"

    B = raw_input('> ').strip()
    Battle = B

    if Battle in attack1:
        print "Lapras used Hydro pump!"
    mewtwo_HP -= attack1range
    time.sleep(0.5)
    print "Mewtwo has", + mewtwo_HP, 'HP!'

    if Battle in attack2:
        print "Lapras used Ice beam!"
    mewtwo_HP -= attack2range
    time.sleep(0.5)
    print "Mewtwo has", + mewtwo_HP, 'HP!'

# Mewtwo's turn
    if move == 0:
        lapras_HP -= random.randrange(21,27)
        time.sleep(1)
        print "Mewtwo used Psystrike!"
        time.sleep(0.5)
        print "Lapras has", + lapras_HP,'HP!'
    else:
        lapras_HP -= random.randrange(19, 35)
    print "Mewtwo used Psywave!"
    time.sleep(0.5)
    print "Lapras has", + lapras_HP,'HP!'





    if mewtwo_HP <= 0:
        print "Mewtwo fainted!"
    if lapras_HP <= 0:
        print "Lapras fainted!"
        print "you lose!"

如果您有任何建议可以让我的代码变得更好(

0 个答案:

没有答案