Exemple #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();
            }
        }
        // 摸牌阶段
        public void Stage_addCards()
        {
            player.SetStageNum(EStageState.STAGE_ADDCARDS);
            //ViewManagement.getInstance().printMsg(player.getInfo().getName() + "摸牌");
            ///*System.out.println(player.getState().getId().toString()
            //        + player.getInfo().getName() + "摸牌");*/
            ////绘制动画
            ///*SwingUtilities.invokeLater(new Runnable() {

            //    @Override
            //    public void run() {
            //        PaintService.drawGetCards(player, 2);
            //    }
            //});*/
            player.GetAction().AddOneCardFromList();
            player.GetAction().AddOneCardFromList();

            player.RefreshView();
        }
Exemple #3
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);
     }
 }
Exemple #4
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);
        }
        /// <summary>
        ///  重写use 在目标玩家的所有牌中选择一张 删除
        /// </summary>
        /// <param name="AbstractPlayer"></param>
        public new void Use(AbstractPlayer p, List <AbstractPlayer> players)
        {
            base.Use(p, players);
            // 触发技能
            p.GetTrigger().AfterMagic();

            // 如果无懈,则return
            AskWuXieKeJi(p, players);
            if (isWuXie)
            {
                //ViewManagement.getInstance().printBattleMsg(GetName() + "无效");
                //ViewManagement.getInstance().refreshAll();
                return;
            }
            if (p.GetState().IsAI())
            {
                AbstractPlayer target = players.ElementAt(0);
                if (target.GetState().GetCardList().Count() > 0)
                {
                    AbstractCard c = target.GetState().GetCardList().ElementAt(0);
                    target.GetAction().RemoveCard(c);
                    c.Gc();
                    //ModuleManagement.getInstance().getBattle().addOneCard(c);
                    p.RefreshView();
                    target.RefreshView();
                }
            }
            else
            {
                // pc = (Panel_Control)p.getPanel();
                //ps = new Panel_SelectCard(p, targetPlayers.ElementAt(0),
                //        Panel_SelectCard.CHAI);
                //// 显示选择面板等待处理
                //try {
                //    SwingUtilities.invokeAndWait(run);
                //} catch (InterruptedException e) {
                //    e.printStackTrace();
                //} catch (InvocationTargetException e) {
                //    e.printStackTrace();
                //}
            }
        }
 /**
  * 牌的丢弃方法,提供一些通用操作
  */
 public void throwIt(AbstractPlayer p)
 {
     // 当前出牌区域清空
     p.GetState().GetUsedCard().Clear();
     // 手牌中删除
     p.GetAction().RemoveCard(this);
     if (!p.GetState().IsAI())
     {
         p.UpdateCards();
     }
     // 放入当前出牌区
     // p.getState().getUsedCard().add(this);
     //// 战场中添加
     //ModuleManagement.getInstance().getBattle().addOneCard(this);
     // 丢入弃牌堆
     Gc();
     //// 打印消息
     //ViewManagement.getInstance().printMsg(
     //        p.getInfo().getName() + "丢弃" + this.ToString());
 }
 /// <summary>
 /// 被动响应打出
 /// </summary>
 /// <param name="p"></param>
 /// <param name="players"></param>
 /// <returns></returns>
 public bool RequestUse(AbstractPlayer p,
                        List <AbstractPlayer> players)
 {
     // 当前出牌区域清空
     p.GetState().GetUsedCard().Clear();
     // 放入当前出牌区
     p.GetState().GetUsedCard().Add(this);
     // 手牌中删除
     p.GetAction().RemoveCard(this);
     //// 战场中添加
     //ModuleManagement.getInstance().getBattle().addOneCard(this);
     // 丢入弃牌堆
     Gc();
     //// 打印消息
     //ViewManagement.getInstance().printBattleMsg(
     //p.getInfo().getName() + "打出" + this.ToString());
     // 使用者手牌刷新
     p.RefreshView();
     return(true);
 }
 /// <summary>
 /// 牌的use方法,提供一些通用操作
 /// </summary>
 /// <param name="p"></param>
 /// <param name="players"></param>
 public void Use(AbstractPlayer p, List <AbstractPlayer> players)
 {
     //// 清空战场
     //ModuleManagement.getInstance().getBattle().clear();
     // 当前出牌区域清空
     p.GetState().GetUsedCard().Clear();
     // 放入当前出牌区
     p.GetState().GetUsedCard().Add(this);
     // 手牌中删除
     p.GetAction().RemoveCard(this);
     //// 战场中添加
     //ModuleManagement.getInstance().getBattle().addOneCard(this);
     // 丢入弃牌堆
     Gc();
     // 使用者手牌刷新
     // 此处注释掉的原因是如果在这里刷新,会把一些状态数值给刷掉
     // 所以刷新留到子类具体实现的时候视情况再用
     // p.refreshView();
     DrawEffect(p, players);
 }
 /// <summary>
 /// 执行杀牌的杀流程
 /// </summary>
 /// <param name="p"></param>
 /// <param name="toP"></param>
 public void ExecuteSha(AbstractPlayer p, AbstractPlayer toP)
 {
     if (!toP.GetAction().AvoidSha(p, this))
     {
         // 如果使用者带武器,则调用武器的杀
         AbstractWeaponCard awc = (AbstractWeaponCard)p.GetState()
                 .GetEquipment().GetWeapons();
         if (awc != null)
         {
             awc.ShaWithEquipment(p, toP, this);
         }
         else
         {
             // 判定防具
             IArmor am = (IArmor)toP.GetState().GetEquipment().GetArmor();
             if (am == null || !am.Check(this, toP))
             {
                 p.GetAction().Sha(toP);
             }
         }
     }
     p.RefreshView();
 }
Exemple #10
0
 /// <summary>
 /// 人物死亡
 /// </summary>
 /// <param name="murderer"></param>
 public void Dead(AbstractPlayer murderer)
 {
     //// 全局列表中删除
     //ModuleManagement.getInstance().getPlayerList().remove(player);
     // 设置死亡状态
     player.GetState().SetDead(true);
     player.GetState().SetCurHP(0);
     // 删除手牌
     foreach (AbstractCard c in player.GetState().GetCardList())
     {
         c.Gc();
     }
     player.GetState().GetCardList().Clear();
     // 上下家重置
     player.GetFunction().GetLastPlayer().SetNextPlayer(
         player.GetNextPlayer());
     //检测该人物死亡是否终止游戏
     if (player.GetState().GetId() == EIdentity.ZHUGONG)
     {
         if (GetFanZei() > 0)
         {
             //Frame_Main.me.gameOver(GameOver.FANZEI_WIN);
         }
         else
         {
             //Frame_Main.me.gameOver(GameOver.NEIJIAN_WIN);
         }
         return;
     }
     if (player.GetState().GetId() == EIdentity.FANZEI || player.GetState().GetId() == EIdentity.NEIJIAN)
     {
         int alive = GetFanZeiOrNeiJian();
         Console.WriteLine("反贼或内奸还剩:" + alive + "个");
         if (alive == 0)
         {
             //Frame_Main.me.gameOver(GameOver.ZHUGONG_WIN);
             return;
         }
     }
     // 死亡触发事件
     player.GetTrigger().AfterDead();
     //死亡后的奖惩
     if (murderer != null)
     {
         // 如果死亡者是反贼 凶手获得3张牌
         if (player.GetState().GetId() == EIdentity.FANZEI)
         {
             for (int i = 0; i < 3; i++)
             {
                 murderer.GetAction().AddOneCardFromList();
             }
         }
         //主公误杀忠臣则掉光所有牌
         if (player.GetState().GetId() == EIdentity.ZHONGCHEN &&
             murderer.GetState().GetId() == EIdentity.ZHUGONG)
         {
             murderer.GetState().GetCardList().Clear();
             murderer.GetState().GetEquipment().RemoveALL();
             //AISpeakService.sayFuckBoss(player);
         }
         player.RefreshView();
         murderer.RefreshView();
     }
     //如果在回合中死亡,直接跳出回合,下家开始
     if (player.GetStageNum() != EStageState.STAGE_END)
     {
         Console.WriteLine("dead" + Thread.CurrentThread.Name);
         player.GetNextPlayer().Process();
     }
 }
Exemple #11
0
 public bool CallSha(AbstractPlayer p, AbstractPlayer target)
 {
     return(p.GetAction().Sha(target));
 }
 /// <summary>
 /// 牌从一个玩家传递给另一个玩家
 /// </summary>
 /// <param name="fromP"></param>
 /// <param name="receiverP"></param>
 public new void PassToPlayer(AbstractPlayer fromP, AbstractPlayer receiverP)
 {
     fromP.GetAction().RemoveCard(this);
     receiverP.GetAction().AddCardToHandCard(this);
 }