一、基本战斗流程
二、战斗角色设计
三、战斗伤害计算
四、技能设计
五、BUFF设计
六、战斗AI
战斗角色的内容包括如下:
1、属性
2、操作
3、流程控制
1、战斗角色属性
warrior.py
# -*- coding: utf-8-*-
from war_def import *
class CWarriorProp(object):
"""
战斗角色属性类
"""
m_hp = 0
m_hp_max = 0
m_attack = 0
m_defense = 0
def __init__(self):
self.m_base = {}
def init_prop(self, prop_dic):
self.__dict__.update(prop_dic)
self.m_base.update(prop_dic)
def get_hp(self):
return self.m_HP
def get_hp_max(self):
return self.m_HPMax
def get_attack(self):
return self.m_attack
def get_defense(self):
return self.m_defense
def add_apply(self, key, value):
av = getattr(self, key, None)
if av:
setattr(self, key, av + value)
else:
setattr(self, key, value)
def remove_apply(self, key, value):
setattr(self, key, getattr(self, key) - value)
战斗角色类warrior.py
CWarrior继承CWarriorProp
class CWarrior(CWarriorProp):
def __init__(self):
self.m_war = None # 战斗对象
self.m_action = WARACT_FINISH
self.m_command = None # 当前回合的操作
# self.m_buff_slots = buff.CBuffSlots() # buff槽
# self.m_war_hook = {} # 存放被动技能的时机
super(CWarrior, self).__init__()
def set_command(self, ctype, *args):
if ctype == WARCMD_ATTACK:
pass
elif ctype == WARCMD_PERFORM:
pass
elif ctype == WARCMD_DEFEND:
pass
def ready(self, warobj):
pass
def bout(self):
self.m_command = None
def pre_fight(self):
pass
def leave(self):
pass
def is_died(self):
return self.m_hp <= 0