-4
私は自分のスキルをテストするための私の最初のミニプロジェクトとしてPythonのテキストRPGで少し作業してきましたが、壁。ここにスクリプトがあります。まず、私のRPGのいくつかを定義しましたが、うまくいきませんでした。
from time import sleep
import random
EXP = 0
EXPCap = 1
Lv = 1
ATK = 5
MATK = 5
DEF = 10
MDEF = 10
HP = 100
EATK = 0
EMATK = 0
EDEF = 0
EMDEF = 0
EHP = 0
MHP = 1
Ename = ("None")
fireorbcount = 0
waterorbcount = 0
earthorbcount = 0
ironcount = 0
windorbcount = 0
windsword = 0
firesword = 0
earthsword = 0
watersword = 0
movement = 1
burn = ("No")
poison = ("No")
Slash = ("UnLocked")
DoubleSlash = ("Locked")
Fireball = ("UnLocked")
FirePillar = ("Locked")
Battlecry = ("Locked")
def Slime():
EHP = 90
EATK = 5
EDEF = 10
EMATK = 5
EMDEF = 2
Ename = Slime
def enemyatk():
if movement == 1:
if random.randint(0,100) >51:
print("Slime uses Stomp!")
HP = HP - (20 + EATK - (DEF/3))
sleep(0.2)
print(name , "has" , HP , "HP out of" , MHP,"!")
sleep(0.2)
if random.randit(0,100) <50:
print("Slime uses Piercing Stomp!")
HP = HP - (20 + EATK)
sleep(0.2)
print(name , "has" , HP , "HP out of" , MHP,"!")
sleep(0.2)
else:
movement = movement + 1
def getdrops():
print("You have defeated" , Ename,"!")
sleep(0.1)
print("You have recieved one water orb!")
waterorbcount = waterorbcount + 1
encounter()
def encounter():
if DoubleSlash == ("UnLocked"):
print("Double Slash")
if FirePillar == ("UnLocked"):
print("Fire Pillar")
if Battlecry == ("Unlocked"):
print("Battle Cry")
atk_1 = input()
if atk_1 == ("Slash"):
EHP = EHP - (40 + ATK - (EDEF/4))
print(Ename , "has" , EHP , "HP remaining!")
enemyatk()
if HP <1:
print("You have been defeated!")
quit()
if EHP <1:
print("The enemy has died!")
getdrops()
print("Please input your name")
name = input()
print("Welcome," , name , "to Pellandia! Please select an action.")
while 1 + 1 == 2:
sleep(0.2)
print("Check Items")
sleep(0.2)
print("Craft")
sleep(0.2)
print("Explore")
sleep(0.2)
print("Quit")
choice = input()
if choice == ("Quit"):
quit()
if choice == ("Check Items"):
print("Fire Orbs:" , fireorbcount)
sleep(0.2)
print("Water Orbs:" , waterorbcount)
sleep(0.2)
print("Wind Orbs:" , windorbcount)
sleep(0.2)
print("Earth Orbs:" , earthorbcount)
sleep(0.2)
print("Iron:" , ironcount)
if choice == ("Explore"):
print("Where would you like to explore?")
sleep(0.2)
print("Plains")
sleep(0.2)
print("Caves")
sleep(0.2)
print("Lava Mountains")
sleep(0.2)
print("Underwater Abyss")
sleep(0.2)
print("Ishgria")
explorec = input()
if explorec == ("Plains"):
Slime()
何らかの理由で、スライム機能が働いていません。私はすでに遭遇を定義しているので、なぜ私は確信していません。スクリプトは停止してメインメニュー(Explore、Check Items、ect)に戻ります。 誰かが私に何が起こっているのかを教えてもらえますか?
何を返すのですか? – James
[mcve]を投稿してください。あなたが投稿したコードのほとんどはあなたの問題と無関係で、複製する必要はないようです。 – Goyo
デバッガでコードをステップしましたか? –