I'm trying to code a text based adventure game in python, but I can't get the battle system to work. This is what I have so far:
import time
import random
battle_chance = 3
enemies = ['A hoard of Goblins', 'A skeleton army', 'A large troll']
random_index = randrange(len(enemies))
def init_battle():
while True:
x = randint(0,5)
time.sleep(2)
if x == battle_chance:
print(enemies[random_index], "Has approached you.\nWhat do you do?")
I always get an error and I can't figure out how to fix it.
Aucun commentaire:
Enregistrer un commentaire