|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 hnldyxx551 于 2020-4-5 12:17 编辑
开局会给你800块买英雄,每回合买一个,每个职业的价格都不一样。
我已经把游戏的py还有队伍的py都编程好了。就是角色不知道该怎么code。麻烦大佬看一下
DEBUG_PRINT = True
def dprint(s):
if DEBUG_PRINT:
print(s)
### CONSTANT FOR MAGE
MANA_COST = 20
MANA_RECOVERY = 30
### BASE CHARACTER
class Character():
def __init__(self):
self.name = ''
self.maxhp = 800
self.hp = 800
self.maxmana = 0
self.mana = 0
self.str = 0
self.int = 0
self.cost = 9999999999
self.alive = True
def act(self, my_team, enemy):
return
def got_hurt(self, damage):
if damage >= self.hp:
self.hp = 0
self.alive = False
dprint(self.name + ' died!')
else:
self.hp -= damage
dprint(self.name +
f' hurt with remaining hp {self.hp}.')
### FIGHTER
class Fighter(Character):
def __init__(self):
super().__init__()
self.name = 'Fighter'
self.maxhp = 1200
self.hp = 1200
self.str = 100
self.cost = 100
def act(self, my_team, enemy):
target = rand_alive(enemy)
dprint(f'Hurt enemy {target} by damage {self.str}.')
enemy[target].got_hurt(self.str)
### MAGE
class Mage(Character):
def __init__(self):
super().__init__()
self.name = 'Mage'
self.maxmana = 50
self.mana = 50
self.cost = 200
self.int = 400
def cast(self, my_team, enemy):
self.mana -= MANA_COST
target = rand_alive(enemy)
dprint(f'Strike enemy {target} with spell')
enemy[target].got_hurt(self.int)
def act(self, my_team, enemy):
if self.mana < MANA_COST:
self.mana += MANA_RECOVERY
dprint(f'Mana recover to {self.mana}.')
else:
self.cast(my_team, enemy)
### BERSERKER
### ARCHMAGE
### NECROMANCER
狂战士的要求是A Berserker is a Fighter but he costs 200 gold. If his hp is lower than or equal to half of his maximum hp, he will enter the “berserk mode”. This doubles his strength to 200.
秘术师的要求是An ArchMage is a Mage but he costs 600 gold. If he is the only one alive in his own team, he will cast the special spell KABOOM and it inflicts EVERY enemy alive with a damage of double of his intelligence. This KABOOM spell also requires 20 mana to cast.
通灵师的要求是An Necromancer is a Mage but he costs 400 gold. If there are some dead members in his own team, he can cast a spell RAISE DEAD costing 20 mana to revive a random dead team member and recover half of the revived member maximum hp rounded down instead of hurting his enemy this turn.
|
|