所以我正在制作一个基于文本的 rpg,我想出了一个奇怪的语法错误,我似乎无法在线修复:
max_hp = randint((player.level * 0.75) * 50, player.level * 50)
在类敌人。任何帮助将不胜感激 :)。
from random import randint
import math
class Character(object):
def __init__(self,hp,max_hp,strength,level,exp):
self.level = level
self.exp = exp
self.hp = hp
self.max_hp = max_hp
self.strength = strength
class Player(Character):
def __init__(self):
exp = 0
level = 1
max_hp = 100
hp = max_hp
strength = level * 0.5
print max_hp, hp, strength
def Level(level, current_exp):
if current_exp >= level * 100:
level += 1
else:
pass
class Enemy(Character):
def __init__(self):
player = Player()
level = randint(player.level, math.ciel((player.level * .75) + 1)
max_hp = randint((player.level * 0.75) * 50, player.level * 50)
hp = max_hp
strength = randint(player.level + 1, player.level + 3)
print max_hp, strength
player = Player()
enemy = Enemy()