저는 더 많은 코드를 작성해야 할 필요가있는 경우 초보자도 Python만큼 오버플로 할 수 있습니다. 나는 2 일 동안 아무 것도 할 수 없다는 것에 막혔다. 개선이된다면 내 코드를 고치고 효율적으로 만들 수 있도록 말해줘. 또한 아래 함수를 어떻게 호출해야할지 모르겠다. 내가하고 싶은 것을 가진 상자를 나열했지만 어떻게해야할지 모르겠다.도움을 요청하고, 함수를 호출하고, 프로그램을 개선하는 데 도움이 필요합니다.
import random
import time
startingP_health = 30
startingE_health = 30
def player_attack():
global startingE_health
time.sleep(1)
print ("What ability would you like to use? (free speach(fs), capatalism(c), or punch(p)")
ability_choice = input()
if(ability_choice == "fs"):
enemy_health = startingE_health-3
enemy_heath = int(enemy_health)
elif(ability_choice == "c"):
enemy_health = startingE_health-(random.randint(1,6))
enemy_heath = int(enemy_health)
elif(ability_choice == "p"):
enemy_health = startingE_health-(random.randint(2,4))
enemy_heath = int(enemy_health)
else:
print("you fell.")
time.sleep(1)
print ("Enemie's health is now: ",enemy_health)
print("")
return int(enemy_health)
def enemy_attack():
global startingP_health
time.sleep(1)
print ("Enemy kicks you")
print("")
player_health = startingP_health - (random.randint(1,3)
player_health = int(player_health)
time.sleep(1)
print ("Your health is now ",player_health)
print ("")
return int(player_health)
def battle_trotsky():
global player_health
print ("Enemy appears")
print ("")
time.sleep(1)
while player_health > 0 and enemy_health > 0:
##############################
#call function player_attack
#call enemy_attack
##############################
if player_health <=0:
break
if enemy_health <= 0:
time.sleep(1)
print ("You have killed the enemy")
if player_health <= 0:
print("Sorry you failed the mission you must restart the mission"))
################################
#initate function sequence
################################
에 오신 것을 환영합니다 스택 오버플로! 코드가 작동하는 경우 http://codereview.stackexchange.com/을 고려할 수 있습니다. 그렇지 않으면 무엇이 잘못 되었는가에 대한 상세하고 구체적인 설명을 포함하십시오. –
@leaf 기본적으로 3 명의 적을 당신 앞에두고, 3 가지 공격 유형 중 1 가지를 선택하는 게임을 만들고 싶었습니다. 스토리 타입의 게임이지만 줄거리를 추가 할 수 있습니다. (전투 기계가 작동하기를 바랄뿐입니다.) (지금은 명확합니까?) –