示例#1
0
        /// <summary>
        /// 玩家扣血 -- 调用扣血触发事件
        /// </summary>
        /// <param name="num">扣血数量</param>
        /// <param name="murderer">凶手</param>
        public void LoseHP(int num, AbstractPlayer murderer)
        {
            int hp = player.GetState().GetCurHP();

            hp -= num;
            player.GetState().SetCurHP(hp);
            //ViewManagement.getInstance().printMsg(
            //        player.getInfo().getName() + "受到" + num + "点伤害");
            player.RefreshView();
            // TODO 如果血量不足,则开始求桃
hp:
            while (player.GetState().GetCurHP() <= 0)
            {
                // 先求自己
                if (player.GetRequest().RequestYao())
                {
                    player.GetAction().TaoSave(player);
                    if (player.GetState().GetCurHP() > 0)
                    {
                        return;
                    }
                    else
                    {
                        continue;
                    }
                }
                // 再求其他人
                List <AbstractPlayer> list = player.GetFunction().GetAllPlayers();
                for (int i = 0; i < list.Count(); i++)
                {
                    // 因为有卡死bug,暂时不问凶手求桃
                    // 经研究为swing中的多线程问题 2013-4-5已解决
                    // if(list.get(i)==murderer)continue;
                    if (list.ElementAt(i).GetRequest().RequestYao())
                    {
                        player.GetAction().TaoSave(player);
                        if (player.GetState().GetCurHP() > 0)
                        {
                            break;
                        }
                    }
                }
                player.GetAction().Dead(murderer);
                return;
            }

            // 调用触发事件
            this.player.GetTrigger().AfterLoseHP(murderer);
            player.RefreshView();
            if (murderer != null)
            {
                murderer.RefreshView();
            }
        }
示例#2
0
 /// <summary>
 /// 决斗 如果目标出杀,则返回true
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public bool JueDou(AbstractPlayer p)
 {
     if (p.GetRequest().RequestSha())
     {
         return(true);
     }
     else
     {
         p.GetAction().LoseHP(1 + player.GetState().GetExtDamage(), player);
         return(false);
     }
 }
示例#3
0
        /// <summary>
        /// 玩家动作 -- 杀 参数p为被杀者! player才是出杀者 2013-3-27曾因混淆出过bug
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public bool Sha(AbstractPlayer p)
        {
            bool flag = false;

            if (!p.GetRequest().RequestShan())
            {
                p.GetAction().LoseHP(1 + player.GetState().GetExtDamage(), player);
                flag = true;
            }
            // 开关
            player.GetState().SetUsedSha(true);
            // 调用触发事件
            player.GetTrigger().AfterSha();
            return(flag);
        }