/// <summary>
        /// 计算战斗结果
        /// </summary>
        /// <returns></returns>
        public BattleResult Compute()
        {
            //目前先给一个简单的逻辑
            //每个回合按角色顺序行动,直接攻击对方随机单位
            while (!IsFinished())
            {
                //新的一轮,清空行动记录
                actionedRoleId.Clear();
                //【显示】查询当前战场状态
                battleResult.Actions.Add(BattleActionView.QueryBattleStatus(CurrentRoles));

                while (true)
                {
                    Role sourceRole = this.GetNextActionRole();
                    if (sourceRole == null)
                    {
                        break;                     //直到没有角色可以行动了
                    }
                    if (IsFinished())
                    {
                        break;
                    }

                    //Buff & Debuff
                    bool continueAction = true;
                    foreach (Buff buff in sourceRole.buffs)
                    {
                        bool status = runBuff(sourceRole, buff);
                        if (!status)
                        {
                            continueAction = false;
                        }
                    }
                    if (!removeBuffs(sourceRole))
                    {
                        continueAction = false;
                    }
                    if (!continueAction)
                    {
                        actionedRoleId.Add(sourceRole.Id);
                        continue;
                    }

                    //选择攻击对象和技能
                    ActionSet action = selectAction(sourceRole);

                    //放招动画 & 放招消耗
                    battleResult.Actions.Add(BattleActionView.CastSkill(sourceRole, action.skill));
                    performSkillCost(sourceRole, action.skill);

                    //单体攻击
                    if (action.skill.range == Range.Single)
                    {
                        hitSingleEnemy(sourceRole, action.target, action.skill);
                    }

                    //直线攻击
                    if (action.skill.range == Range.Line)
                    {
                        int    pos  = action.target.Position;
                        Role[] team = friendRoles;
                        if (action.target.Team == 1)
                        {
                            team = enemyRoles;
                        }
                        for (int i = pos % eachRowCount; i < memberCount; i += eachRowCount)
                        {
                            if (team[i] != null)
                            {
                                hitSingleEnemy(sourceRole, team[i], action.skill);
                            }
                        }
                    }

                    //群体攻击
                    if (action.skill.range == Range.All)
                    {
                        Role[] team = friendRoles;
                        if ((sourceRole.Team == 0 && sourceRole.getBuff("蛊惑") == null) || (sourceRole.Team == 1 && sourceRole.getBuff("蛊惑") != null))
                        {
                            team = enemyRoles;
                        }

                        for (int i = 0; i < team.Length; i++)
                        {
                            if (team[i] != null)
                            {
                                hitSingleEnemy(sourceRole, team[i], action.skill);
                            }
                        }
                    }

                    if (action.skill.range == Range.AllForEffect)
                    {
                        calcEffects(sourceRole, action.target, action.skill, 0);
                    }

                    //对自己使用的技能
                    if (action.skill.range == Range.Self)
                    {
                        //Buff & Debuff
                        addBuffs(sourceRole, sourceRole, action.skill);

                        //攻击特效
                        calcEffects(sourceRole, action.target, action.skill, 0);
                    }

                    actionedRoleId.Add(sourceRole.Id);
                }
            }
            return(battleResult);
        }
        //选择当前角色的行动,目前仅有战斗行为
        public ActionSet selectAction(Role sourceRole)
        {
            //目前仅选择一个敌方并使用随机技能
            Role targetRole = null;

            //从上至下随机选一个可以施放的技能
            Skill        skill           = sourceRole.Skills[0];
            List <Skill> availableSkills = sourceRole.getAvailableSkills(this);

            if (availableSkills.Count > 0)
            {
                skill = availableSkills[Tools.GetRandomInt(0, availableSkills.Count) % availableSkills.Count];
            }

            //单体攻击
            if (skill.range == Range.Single || skill.range == Range.Line)
            {
                //寻找一个敌人攻击
                while (true)
                {
                    Role r = CurrentRoles[Tools.GetRandomInt(0, CurrentRoles.Count) % CurrentRoles.Count];
                    if (sourceRole.getBuff("蛊惑") != null && sourceRole.Team == r.Team)
                    {
                        targetRole = r;
                        break;
                    }
                    else if (sourceRole.getBuff("蛊惑") == null && r.Team != sourceRole.Team)
                    {
                        targetRole = r;
                        break;
                    }
                }

                ActionSet action = new ActionSet();
                action.skill  = skill;
                action.target = targetRole;
                return(action);
            }

            if (skill.range == Range.All)
            {
                ActionSet action = new ActionSet();
                action.skill  = skill;
                action.target = null;
                return(action);
            }

            if (skill.range == Range.AllForEffect)
            {
                ActionSet action = new ActionSet();
                action.skill = skill;
                Role[] team = friendRoles;
                if ((sourceRole.Team == 0 && sourceRole.getBuff("蛊惑") == null) || (sourceRole.Team == 1 && sourceRole.getBuff("蛊惑") != null))
                {
                    team = enemyRoles;
                }

                foreach (Role role in team)
                {
                    if (role != null)
                    {
                        targetRole    = role;
                        action.target = role;
                        break;
                    }
                }

                return(action);
            }

            //对自己使用的技能(召唤、回血等)
            if (skill.range == Range.Self)
            {
                targetRole = sourceRole;
                ActionSet action = new ActionSet();
                action.skill  = skill;
                action.target = targetRole;
                return(action);
            }

            return(null);
        }