예제 #1
0
        /// <summary>
        /// 可攻击目标列表的取得
        /// </summary>
        /// <param name="GameId"></param>
        /// <param name="IsHost"></param>
        /// <returns></returns>
        public static string GetFightTargetList(int GameId, bool IsHost)
        {
            var gamestatus = GameRunning_BS[GameId].gameStatus(IsHost);

            SelectUtility.SetTargetSelectEnable(SelectUtility.GetFightSelectOpt(), gamestatus);
            return(SelectUtility.GetTargetListString(gamestatus));
        }
예제 #2
0
        public void OnSelect(SelectInfo selectInfo)
        {
            ISelectable[] selectionChanged;

            //! 選択を反転
            if (Keyboard.Modifiers == ModifierKeys.Control)
            {
                selectionChanged = SelectUtility.ToggleSelect(selectInfo.AllNodes.Concat(selectInfo.Connections), selectInfo.NewSelectNodes.Concat(selectInfo.NewConnections));
            }
            //! 追加選択
            else if (Keyboard.Modifiers == ModifierKeys.Shift)
            {
                selectionChanged = SelectUtility.AddSelect(selectInfo.AllNodes.Concat(selectInfo.Connections), selectInfo.NewSelectNodes.Concat(selectInfo.NewConnections));
            }
            //! 選択されたものだけを選択するが、既に選択済みの場合は何もしない(Nodeをまとめてドラッグする際にこのモードを利用する)
            else if (selectInfo.NewSelectNodes.Any())
            {
                selectionChanged = SelectUtility.SingleSelect(selectInfo.AllNodes.Concat(selectInfo.Connections), selectInfo.NewSelectNodes);
            }
            //! 選択されたものだけを選択状態とする
            else
            {
                selectionChanged = SelectUtility.OnlySelect(selectInfo.AllNodes.Concat(selectInfo.Connections), selectInfo.NewConnections);
            }

            //! 選択が変更されたことをイベントで通知する(undo / redo 等に使用)
            if (selectionChanged.Any())
            {
                SelectionChanged?.Execute(new SelectionChangedEventArgs(selectionChanged));
            }
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TargetSelect_Load(object sender, EventArgs e)
        {
            SelectUtility.SetTargetSelectEnable(SelectOption, actionStatus);
            int Megrate = 3;

            btnMyHero.Hero   = actionStatus.AllRole.MyPublicInfo.Hero;
            btnYourHero.Hero = actionStatus.AllRole.YourPublicInfo.Hero;
            int LeftPos = (Width - (actionStatus.AllRole.MyPublicInfo.BattleField.MinionCount * btnMe1.Width +
                                    (actionStatus.AllRole.MyPublicInfo.BattleField.MinionCount - 1) * Megrate)) / 2;

            for (int i = 0; i < actionStatus.AllRole.MyPublicInfo.BattleField.MinionCount; i++)
            {
                Controls.Find("btnMe" + (i + 1).ToString(), true)[0].Visible             = actionStatus.AllRole.MyPublicInfo.BattleField.BattleMinions[i].能否成为动作对象;
                ((ctlCard)Controls.Find("btnMe" + (i + 1).ToString(), true)[0]).CardInfo = actionStatus.AllRole.MyPublicInfo.BattleField.BattleMinions[i];
                Controls.Find("btnMe" + (i + 1).ToString(), true)[0].Left = LeftPos;
                ((ctlCard)Controls.Find("btnMe" + (i + 1).ToString(), true)[0]).FightClick += (x, y) =>
                {
                    Position.本方对方标识 = true;
                    //这里千万不能使用 i ,每次 i 都是固定值
                    Position.位置 = int.Parse(((Button)x).Parent.Name.Substring("btnMe".Length));
                    Close();
                };
                LeftPos += btnMe1.Width + Megrate;
            }

            LeftPos = (Width - (actionStatus.AllRole.YourPublicInfo.BattleField.MinionCount * btnMe1.Width + (actionStatus.AllRole.YourPublicInfo.BattleField.MinionCount - 1) * Megrate)) / 2;
            for (int i = 0; i < actionStatus.AllRole.YourPublicInfo.BattleField.MinionCount; i++)
            {
                Controls.Find("btnYou" + (i + 1).ToString(), true)[0].Visible             = actionStatus.AllRole.YourPublicInfo.BattleField.BattleMinions[i].能否成为动作对象;
                ((ctlCard)Controls.Find("btnYou" + (i + 1).ToString(), true)[0]).CardInfo = actionStatus.AllRole.YourPublicInfo.BattleField.BattleMinions[i];
                Controls.Find("btnYou" + (i + 1).ToString(), true)[0].Left = LeftPos;
                ((ctlCard)Controls.Find("btnYou" + (i + 1).ToString(), true)[0]).FightClick += (x, y) =>
                {
                    Position.本方对方标识 = false;
                    //这里千万不能使用 i ,每次 i 都是固定值
                    //pos.Postion = i + 1;
                    Position.位置 = int.Parse(((Button)x).Parent.Name.Substring("btnYou".Length));
                    Close();
                };
                LeftPos += btnMe1.Width + Megrate;
            }
            btnMyHero.Enabled = actionStatus.AllRole.MyPublicInfo.Hero.能否成为动作对象;
            btnMyHero.Left    = (Width - btnMyHero.Width) / 2;
            btnMyHero.Click  += (x, y) =>
            {
                Position.本方对方标识 = true;
                Position.位置     = 0;
                Close();
            };
            btnYourHero.Enabled = actionStatus.AllRole.YourPublicInfo.Hero.能否成为动作对象;;
            btnYourHero.Left    = (Width - btnYourHero.Width) / 2;
            btnYourHero.Click  += (x, y) =>
            {
                Position.本方对方标识 = false;
                Position.位置     = 0;
                Close();
            };
        }
예제 #4
0
        /// <summary>
        /// 攻击
        /// </summary>
        /// <param name="MyPos"></param>
        private void Fight(int MyPos)
        {
            GameManager.MyClientManager.CurrentActiveCard = GameManager.MyClientManager.actionStatus.AllRole.MyPublicInfo.BattleField.BattleMinions[MyPos - 1];
            var           YourPos   = SelectPanel(SelectUtility.GetFightSelectOpt());
            List <string> actionlst = RunAction.Fight(GameManager.MyClientManager.actionStatus, MyPos, YourPos.位置, true);

            actionlst.AddRange(SecretCard.奥秘计算(actionlst, GameManager.MyClientManager.actionStatus, GameManager.MyClientManager.GameId));
            GameManager.MyClientManager.actionStatus.AllRole.MyPrivateInfo.ResetHandCardCost(GameManager.MyClientManager.actionStatus);
            if (SystemManager.游戏类型 != SystemManager.GameType.单机版)
            {
                ClientRequest.WriteAction(GameManager.MyClientManager.GameId.ToString(GameServer.GameIdFormat), actionlst);
            }
            DisplayMyInfo();
        }
        public void OnSelect()
        {
            var selectNodes = _panel.GetHitTestChildrenWithRect <NodeControl>(_rect).ToArray();

            if (selectNodes.Any())
            {
                var changed = SelectUtility.OnlySelect(_nodes.OfType <ISelectable>().Concat(_connections), selectNodes);
                SelectionChangedCommand?.Execute(new SelectionChangedEventArgs(changed));
                return;
            }
            var selectConnections = _connections.Where(x => x.HitTestRect(_rect)).ToArray();

            if (selectConnections.Any())
            {
                var changed = SelectUtility.OnlySelect(_nodes.OfType <ISelectable>().Concat(_connections), selectConnections);
                SelectionChangedCommand?.Execute(new SelectionChangedEventArgs(changed));
            }
        }
예제 #6
0
        /// <summary>
        /// 事件处理方法
        /// </summary>
        /// <param name="事件"></param>
        /// <param name="game"></param>
        /// <returns></returns>
        public List <string> 事件处理方法(EventCard.全局事件 事件, ActionStatus game)
        {
            List <string> ActionLst = new List <string>();

            if (!沉默状态 && 自身事件效果.触发效果事件类型 == 事件.触发事件类型)
            {
                if (自身事件效果.触发效果事件方向 != CardUtility.目标选择方向枚举.双方)
                {
                    if (自身事件效果.触发效果事件方向 == CardUtility.目标选择方向枚举.本方 && (!事件.触发位置.本方对方标识))
                    {
                        return(ActionLst);
                    }
                    if (自身事件效果.触发效果事件方向 == CardUtility.目标选择方向枚举.对方 && (事件.触发位置.本方对方标识))
                    {
                        return(ActionLst);
                    }
                }
                if (!string.IsNullOrEmpty(自身事件效果.限制信息) && !SelectUtility.符合选择条件(this, 自身事件效果.限制信息))
                {
                    return(ActionLst);
                }
                ActionLst.Add(Server.ActionCode.strHitEvent + CardUtility.strSplitMark);
                //这里有可能是一个增益表达式!!
                if (自身事件效果.效果编号.StartsWith("A"))
                {
                    ActionLst.AddRange(((SpellCard)CardUtility.GetCardInfoBySN(自身事件效果.效果编号)).UseSpell(game));
                }
                else
                {
                    Effect.PointEffect t   = new Effect.PointEffect();
                    string[]           opt = 自身事件效果.效果编号.Split("/".ToCharArray());
                    t.持续回合 = CardUtility.Max.ToString();
                    t.攻击力  = opt[0];
                    t.生命值  = opt[1];
                    ((Effect.IAtomicEffect)t).DealMinion(game, this);
                }
                潜行特性 = false;
            }
            return(ActionLst);
        }
예제 #7
0
        /// <summary>
        /// 随从卡牌
        /// </summary>
        /// <param name="game"></param>
        /// <param name="CardSn"></param>
        public static void RunBS(ActionStatus game, string CardSn)
        {
            int        MinionPos = -1;
            MinionCard minion    = minion = (MinionCard)CardUtility.GetCardInfoBySN(CardSn);

            //Step1
            if (game.Interrupt.Step == 1)
            {
                if (game.AllRole.MyPublicInfo.BattleField.MinionCount != 0)
                {
                    game.Interrupt.Step       = 2;
                    game.Interrupt.ActionName = "MINIONPOSITION";
                    return;
                }
                else
                {
                    game.Interrupt.SessionData = "MINIONPOSITION:1|";
                }
                MinionPos           = 1;
                game.Interrupt.Step = 2;
            }
            //Step2
            if (game.Interrupt.Step == 2)
            {
                if (MinionPos == -1)
                {
                    MinionPos = int.Parse(game.Interrupt.SessionDic["MINIONPOSITION"]);
                }
                //初始化
                minion.初始化();
                //随从入场
                game.AllRole.MyPublicInfo.BattleField.PutToBattle(MinionPos, minion);
                //必须在放入之前做得原因是,被放入的随从不能被触发这个事件
                game.battleEvenetHandler.事件池.Add(new EventCard.全局事件()
                {
                    触发事件类型 = EventCard.事件类型枚举.召唤,
                    触发位置   = new CardUtility.指定位置结构体()
                    {
                        位置     = MinionPos,
                        本方对方标识 = game.IsHost
                    }
                });
                game.Interrupt.Step = 3;
            }

            //Step3
            if (game.Interrupt.Step == 3 && !string.IsNullOrEmpty(minion.战吼效果))
            {
                SpellCard spell = (SpellCard)CardUtility.GetCardInfoBySN(minion.战吼效果);
                game.Interrupt.Step = 4;
                if (spell.FirstAbilityDefine.IsNeedTargetSelect())
                {
                    //这里先简单假设所有战吼,如果需要指定位置,则自身不能成为指定位置
                    spell.FirstAbilityDefine.MainAbilityDefine.AbliltyPosPicker.CanNotSelectPos.本方对方标识 = true;
                    spell.FirstAbilityDefine.MainAbilityDefine.AbliltyPosPicker.CanNotSelectPos.位置     = int.Parse(game.Interrupt.SessionDic["MINIONPOSITION"]);
                    SelectUtility.SetTargetSelectEnable(spell.FirstAbilityDefine.MainAbilityDefine.AbliltyPosPicker, game);
                    game.Interrupt.ExternalInfo = SelectUtility.GetTargetListString(game);
                    game.Interrupt.ActionName   = "BATTLECRYPOSITION";
                    return;
                }
            }
            if (game.Interrupt.Step == 4)
            {
                //法术位置信息包含在SessionData中,传递下去
                //这种类型的战吼,直接转换为施法
                //这里约定:战吼是无需抉择的
                game.Interrupt.ActionName = "RUNBATTLECRY";
                game.Interrupt.Step       = 1;
                if (game.Interrupt.SessionDic.ContainsKey("BATTLECRYPOSITION") && game.Interrupt.SessionDic["BATTLECRYPOSITION"] == "-1")
                {
                    //放弃战吼,例如没有友方的时候的叫嚣的中士
                    game.Interrupt.Step = 99;
                }
                else
                {
                    UseSpellAction.RunBS(game, minion.战吼效果);
                }
            }
            game.Interrupt.Step       = 99;
            game.Interrupt.ActionName = CardUtility.strOK;
        }
예제 #8
0
        /// <summary>
        /// 使用法术
        /// </summary>
        /// <param name="game"></param>
        /// <param name="IsMyAction">对象方向转换</param>
        public static void RunBS(ActionStatus game, string CardSn)
        {
            List <string> Result = new List <string>();
            SpellCard     spell  = (SpellCard)CardUtility.GetCardInfoBySN(CardSn);

            //Step1
            CardUtility.抉择枚举        PickAbilityResult = CardUtility.抉择枚举.第一效果;
            SpellCard.AbilityDefine ability           = new SpellCard.AbilityDefine();
            if (game.Interrupt.Step == 1)
            {
                switch (spell.效果选择类型)
                {
                case SpellCard.效果选择类型枚举.无需选择:
                    game.Interrupt.ExternalInfo = "1";
                    break;

                case SpellCard.效果选择类型枚举.主动选择:
                    game.Interrupt.Step         = 2;
                    game.Interrupt.ActionName   = "SPELLDECIDE";
                    game.Interrupt.ExternalInfo = spell.FirstAbilityDefine.描述 + CardUtility.strSplitArrayMark + spell.SecondAbilityDefine.描述;
                    return;

                case SpellCard.效果选择类型枚举.自动判定:
                    game.Interrupt.ExternalInfo = "1";
                    if (!ExpressHandler.AbilityPickCondition(game, spell.效果选择条件))
                    {
                        PickAbilityResult           = CardUtility.抉择枚举.第二效果;
                        game.Interrupt.ExternalInfo = "2";
                    }
                    break;

                default:
                    break;
                }
                game.Interrupt.Step = 2;
            }
            //Step2
            if (game.Interrupt.Step == 2)
            {
                if (spell.效果选择类型 == SpellCard.效果选择类型枚举.主动选择 && SystemManager.游戏类型 == SystemManager.GameType.HTML版)
                {
                    switch (game.Interrupt.SessionDic["SPELLDECIDE"])
                    {
                    case "1":
                        PickAbilityResult = CardUtility.抉择枚举.第一效果;
                        break;

                    case "2":
                        PickAbilityResult = CardUtility.抉择枚举.第二效果;
                        break;

                    default:
                        PickAbilityResult = CardUtility.抉择枚举.取消;
                        break;
                    }
                }
                if (PickAbilityResult != CardUtility.抉择枚举.取消)
                {
                    List <EffectDefine> SingleEffectList = new List <EffectDefine>();
                    if (PickAbilityResult == CardUtility.抉择枚举.第一效果)
                    {
                        ability = spell.FirstAbilityDefine;
                    }
                    else
                    {
                        ability = spell.SecondAbilityDefine;
                    }
                    if (game.ActionName == "USEMINIONCARD")
                    {
                        //如果整个大的动作时随从入场,并且如果这个战吼不需要指定位置,则现在的话,将入场随从设定为指定位置
                        ability.MainAbilityDefine.AbliltyPosPicker.SelectedPos.本方对方标识 = true;
                        ability.MainAbilityDefine.AbliltyPosPicker.SelectedPos.位置     = int.Parse(game.Interrupt.SessionDic["MINIONPOSITION"]);
                    }
                    if (ability.IsNeedTargetSelect())
                    {
                        if (game.ActionName == "USEMINIONCARD" && game.Interrupt.SessionDic.ContainsKey("BATTLECRYPOSITION"))
                        {
                            ability.MainAbilityDefine.AbliltyPosPicker.SelectedPos = CardUtility.指定位置结构体.FromString(game.Interrupt.SessionDic["BATTLECRYPOSITION"]);
                        }
                        else
                        {
                            if (game.ActionName == "USESPELLCARD" && game.Interrupt.SessionDic.ContainsKey("SPELLPOSITION"))
                            {
                                ability.MainAbilityDefine.AbliltyPosPicker.SelectedPos = CardUtility.指定位置结构体.FromString(game.Interrupt.SessionDic["SPELLPOSITION"]);
                            }
                            else
                            {
                                ability.MainAbilityDefine.AbliltyPosPicker.CanNotSelectPos.位置 = BattleFieldInfo.UnknowPos;
                                SelectUtility.SetTargetSelectEnable(ability.MainAbilityDefine.AbliltyPosPicker, game);
                                game.Interrupt.ExternalInfo = SelectUtility.GetTargetListString(game);
                                game.Interrupt.ActionName   = "SPELLPOSITION";
                                return;
                            }
                        }
                    }
                    game.Interrupt.Step = 3;
                }
                else
                {
                    game.Interrupt.Step = -1;
                    return;
                }
            }

            if (game.Interrupt.Step == 3)
            {
                SpellCard.RunAbility(game, ability);
                if (spell.法术卡牌类型 == CardBasicInfo.法术卡牌类型枚举.普通卡牌)
                {
                    game.battleEvenetHandler.事件池.Add(new EventCard.全局事件()
                    {
                        触发事件类型 = EventCard.事件类型枚举.施法,
                        触发位置   = new CardUtility.指定位置结构体()
                        {
                            位置     = BattleFieldInfo.HeroPos,
                            本方对方标识 = true
                        }
                    });
                }
            }
            game.Interrupt.Step       = 99;
            game.Interrupt.ActionName = CardUtility.strOK;
        }
예제 #9
0
        /// <summary>
        /// 实施效果
        /// </summary>
        /// <param name="singleEffect"></param>
        /// <param name="game"></param>
        /// <param name="RandomSeed"></param>
        /// <returns></returns>
        public static List <string> RunSingleEffect(EffectDefine singleEffect, ActionStatus game, int RandomSeed)
        {
            List <string> Result  = new List <string>();
            List <string> PosList = SelectUtility.GetTargetList(singleEffect.AbliltyPosPicker, game, RandomSeed);

            foreach (string PosInfo in PosList)
            {
                var PosField  = PosInfo.Split(CardUtility.strSplitMark.ToCharArray());
                var strResult = string.Empty;
                if (PosField[0] == CardUtility.strMe)
                {
                    switch (int.Parse(PosField[1]))
                    {
                    case BattleFieldInfo.HeroPos:
                        Result.Add(GetEffectHandler(singleEffect, game, CardUtility.strMe + CardUtility.strSplitMark + BattleFieldInfo.HeroPos.ToString("D1")).DealHero(game, game.AllRole.MyPublicInfo));
                        break;

                    case BattleFieldInfo.AllMinionPos:
                        for (int i = 0; i < game.AllRole.MyPublicInfo.BattleField.MinionCount; i++)
                        {
                            Result.Add(GetEffectHandler(singleEffect, game, CardUtility.strMe + CardUtility.strSplitMark + (i + 1).ToString("D1")).DealMinion(game, game.AllRole.MyPublicInfo.BattleField.BattleMinions[i]));
                        }
                        break;

                    case BattleFieldInfo.AllRolePos:
                        Result.Add(GetEffectHandler(singleEffect, game, CardUtility.strMe + CardUtility.strSplitMark + BattleFieldInfo.HeroPos.ToString("D1")).DealHero(game, game.AllRole.MyPublicInfo));
                        for (int i = 0; i < game.AllRole.MyPublicInfo.BattleField.MinionCount; i++)
                        {
                            Result.Add(GetEffectHandler(singleEffect, game, CardUtility.strMe + CardUtility.strSplitMark + (i + 1).ToString("D1")).DealMinion(game, game.AllRole.MyPublicInfo.BattleField.BattleMinions[i]));
                        }
                        break;

                    default:
                        Result.Add(GetEffectHandler(singleEffect, game, PosInfo).DealMinion(game, game.AllRole.MyPublicInfo.BattleField.BattleMinions[int.Parse(PosField[1]) - 1]));
                        break;
                    }
                }
                else
                {
                    switch (int.Parse(PosField[1]))
                    {
                    case BattleFieldInfo.HeroPos:
                        Result.Add(GetEffectHandler(singleEffect, game, CardUtility.strYou + CardUtility.strSplitMark + BattleFieldInfo.HeroPos.ToString("D1")).DealHero(game, game.AllRole.YourPublicInfo));
                        break;

                    case BattleFieldInfo.AllMinionPos:
                        for (int i = 0; i < game.AllRole.YourPublicInfo.BattleField.MinionCount; i++)
                        {
                            Result.Add(GetEffectHandler(singleEffect, game, CardUtility.strYou + CardUtility.strSplitMark + (i + 1).ToString("D1")).DealMinion(game, game.AllRole.YourPublicInfo.BattleField.BattleMinions[i]));
                        }
                        break;

                    case BattleFieldInfo.AllRolePos:
                        Result.Add(GetEffectHandler(singleEffect, game, CardUtility.strYou + CardUtility.strSplitMark + BattleFieldInfo.HeroPos.ToString("D1")).DealHero(game, game.AllRole.YourPublicInfo));
                        for (int i = 0; i < game.AllRole.YourPublicInfo.BattleField.MinionCount; i++)
                        {
                            Result.Add(GetEffectHandler(singleEffect, game, CardUtility.strYou + CardUtility.strSplitMark + (i + 1).ToString("D1")).DealMinion(game, game.AllRole.YourPublicInfo.BattleField.BattleMinions[i]));
                        }
                        break;

                    default:
                        Result.Add(GetEffectHandler(singleEffect, game, PosInfo).DealMinion(game, game.AllRole.YourPublicInfo.BattleField.BattleMinions[int.Parse(PosField[1]) - 1]));
                        break;
                    }
                }
            }
            return(Result);
        }