Пример #1
0
 public PResetTriggerInstaller() : base("重置武将牌")
 {
     TriggerList.Add(new PTrigger("翻面翻回")
     {
         IsLocked  = true,
         Time      = PPeriod.StartTurn.Before,
         Condition = (PGame Game) => {
             return(Game.NowPlayer.BackFace);
         },
         Effect = (PGame Game) => {
             Game.ChangeFace(Game.NowPlayer);
             Game.Monitor.EndTurnDirectly = true;
         }
     });
     TriggerList.Add(new PTrigger("移回游戏")
     {
         IsLocked  = true,
         Time      = PPeriod.StartTurn.Start,
         Condition = (PGame Game) => {
             return(Game.NowPlayer.OutOfGame);
         },
         Effect = (PGame Game) => {
             Game.NowPlayer.Tags.PopTag <PTag>(PTag.OutOfGameTag.Name);
         }
     });
 }
Пример #2
0
 public PChiaTaoFaKuoTriggerInstaller() : base("假道伐虢的记录")
 {
     TriggerList.Add(new PTrigger("假道伐虢[开始记录]")
     {
         IsLocked = true,
         Time     = PPeriod.StartTurn.During,
         Effect   = (PGame Game) => {
             Game.TagManager.PopTag <PChiaTaoFaKuoTag>(PChiaTaoFaKuoTag.TagName);
             Game.TagManager.CreateTag(new PChiaTaoFaKuoTag(new List <PPlayer>()));
         }
     });
     TriggerList.Add(new PTrigger("假道伐虢[经过土地]")
     {
         IsLocked = true,
         Time     = PTime.MovePositionTime,
         Effect   = (PGame Game) => {
             PTransportTag TransportTag = Game.TagManager.FindPeekTag <PTransportTag>(PTransportTag.TagName);
             PPlayer Lord = TransportTag.Destination.Lord;
             if (Lord != null && !Lord.Equals(Game.NowPlayer))
             {
                 PChiaTaoFaKuoTag ChiaTaoFaKuoTag = Game.TagManager.FindPeekTag <PChiaTaoFaKuoTag>(PChiaTaoFaKuoTag.TagName);
                 if (!ChiaTaoFaKuoTag.LordList.Contains(Lord))
                 {
                     ChiaTaoFaKuoTag.LordList.Add(Lord);
                 }
             }
         }
     });
 }
Пример #3
0
        private void AddMouseMovementTriggerToList()
        {
            var triggerLayoutView = new TriggerLayoutView();

            inputNewTriggerEditor.SetMouseMovementTrigger(triggerLayoutView);
            TriggerList.Add(triggerLayoutView);
        }
Пример #4
0
 public PLockTriggerInstaller() : base("连环传递伤害")
 {
     TriggerList.Add(new PTrigger("连环传递伤害")
     {
         IsLocked  = true,
         Time      = PTime.Injure.EndSettle,
         Condition = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             return(InjureTag.ToPlayer != null && InjureTag.Injure > 0 && InjureTag.ToPlayer.Tags.ExistTag(PTag.LockedTag.Name));
         },
         Effect = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             InjureTag.ToPlayer.Tags.PopTag <PTag>(PTag.LockedTag.Name);
             bool Invoke = false;
             Game.Traverse((PPlayer _Player) => {
                 if (!Invoke && _Player.Tags.ExistTag(PTag.LockedTag.Name))
                 {
                     Invoke = true;
                     PNetworkManager.NetworkServer.TellClients(new PPushTextOrder(_Player.Index.ToString(), "触发连锁伤害", PPushType.Injure.Name));
                     Game.Injure(InjureTag.FromPlayer, _Player, InjureTag.Injure, InjureTag.InjureSource);
                 }
             }, Game.GetNextPlayer(InjureTag.ToPlayer));
         }
     });
 }
Пример #5
0
 private void OnTriggerStay(Collider other)
 {
     if (!TriggerList.Contains(other.gameObject))
     {
         TriggerList.Add(other.gameObject);
     }
 }
Пример #6
0
        private void AddMouseHoldTriggerToList(Trigger trigger)
        {
            var mouseHoldTrigger  = (MouseHoldTrigger)trigger;
            var triggerLayoutView = new TriggerLayoutView();

            inputNewTriggerEditor.SetMouseHoldTrigger(mouseHoldTrigger.Button, triggerLayoutView);
            TriggerList.Add(triggerLayoutView);
        }
Пример #7
0
        private void AddTouchPadTriggerToList(Trigger trigger)
        {
            var newTouchpadTrigger = (TouchPressTrigger)trigger;
            var triggerLayoutView  = new TriggerLayoutView();

            inputNewTriggerEditor.SetTouchPadTrigger(newTouchpadTrigger.State, triggerLayoutView);
            TriggerList.Add(triggerLayoutView);
        }
Пример #8
0
        private void AddKeyTriggerToList(Trigger trigger)
        {
            var newKeyTrigger     = (KeyTrigger)trigger;
            var triggerLayoutView = new TriggerLayoutView();

            inputNewTriggerEditor.SetKeyTrigger(newKeyTrigger.Key, newKeyTrigger.State,
                                                triggerLayoutView);
            TriggerList.Add(triggerLayoutView);
        }
Пример #9
0
        private void AddMouseTriggerToList(Trigger trigger)
        {
            var newMouseTrigger   = (MouseButtonTrigger)trigger;
            var triggerLayoutView = new TriggerLayoutView();

            inputNewTriggerEditor.SetMouseButtonTrigger(newMouseTrigger.Button, newMouseTrigger.State,
                                                        triggerLayoutView);
            TriggerList.Add(triggerLayoutView);
        }
Пример #10
0
        private void AddGamePadTriggerToList(Trigger trigger)
        {
            var newGamepadTrigger = (GamePadButtonTrigger)trigger;
            var triggerLayoutView = new TriggerLayoutView();

            inputNewTriggerEditor.SetGamePadTrigger(newGamepadTrigger.Button, newGamepadTrigger.State,
                                                    triggerLayoutView);
            TriggerList.Add(triggerLayoutView);
        }
Пример #11
0
 public PPeriodTriggerInstaller() : base("阶段切换")
 {
     foreach (PPeriod Period in TurnFlow)
     {
         TriggerList.Add(new PTrigger(Period.Name + "结束,进入下一阶段")
         {
             IsLocked = true,
             Time     = Period.Next,
             Effect   = ChangePeriod
         });
     }
 }
Пример #12
0
        public void AddNewTrigger()
        {
            if (string.IsNullOrEmpty(SelectedCommand))
            {
                return;
            }
            var triggerLayoutView = new TriggerLayoutView();

            inputNewTriggerEditor.CreateNewTriggerBox(availableCommands, SelectedCommand,
                                                      triggerLayoutView);
            TriggerList.Add(triggerLayoutView);
            RaisePropertyChanged("TriggerList");
        }
Пример #13
0
        /// <summary>
        /// Start a trigger group.
        /// For more information, see: https://osu.ppy.sh/help/wiki/Storyboard_Scripting/Compound_Commands
        /// </summary>
        /// <param name="startTime">Group start time.</param>
        /// <param name="endTime">Group end time.</param>
        /// <param name="triggerName">A valid trigger name.</param>
        public Trigger StartTrigger(int startTime, int endTime, string triggerName)
        {
            if (_isLooping || _isTriggering)
            {
                throw new Exception("You can not start another loop when the previous one isn't end.");
            }

            _isTriggering = true;
            var trig = new Trigger(startTime, endTime, triggerName);

            TriggerList.Add(trig);
            return(trig);
        }
Пример #14
0
        /// <summary>
        /// Start a trigger group.
        /// For more information, see: https://osu.ppy.sh/help/wiki/Storyboard_Scripting/Compound_Commands
        /// </summary>
        /// <param name="startTime">Group start time.</param>
        /// <param name="endTime">Group end time.</param>
        /// <param name="triggerType">Trigger type. It can be specified in a flag form like TriggerType.HitSoundWhistle | TriggerType.HitSoundSoft.</param>
        /// <param name="listenSample">If use the listenSample, the trigger will listen to all hitsound in a track like HitsoundAllNormal.</param>
        /// <param name="customSampleSet">Listen to a specific track. 0 represents default track.</param>
        public Trigger StartTrigger(int startTime, int endTime, TriggerType triggerType, bool listenSample = false, uint?customSampleSet = null)
        {
            if (_isLooping || _isTriggering)
            {
                throw new Exception("You can not start another loop when the previous one isn't end.");
            }

            _isTriggering = true;
            var trig = new Trigger(startTime, endTime, triggerType, listenSample, customSampleSet);

            TriggerList.Add(trig);
            return(trig);
        }
Пример #15
0
 public PWalkingTriggerInstaller() : base("行走")
 {
     TriggerList.Add(new PTrigger("行走")
     {
         IsLocked = true,
         Time     = PPeriod.WalkingStage.During,
         Effect   = (PGame Game) => {
             PStepCountTag Tag   = Game.TagManager.PopTag <PStepCountTag>(PStepCountTag.TagName);
             int RemainStepCount = (Tag != null ? Tag.StepCount : 0);
             Game.MoveForward(Game.NowPlayer, RemainStepCount);
             PNetworkManager.NetworkServer.TellClients(new PCloseDiceOrder());
         }
     });
 }
Пример #16
0
    public PModeArch() : base("模式类成就")
    {
        TriggerList.Add(new PTrigger("独孤求败")
        {
            IsLocked = true,
            Time     = PTime.EndGameTime,
            Effect   = (PGame Game) => {
                Game.GetWinner().ForEach((PPlayer Player) => {
                    if (Game.GameMode is PMode8p)
                    {
                        Announce(Game, Player, "独孤求败");
                    }
                });
            }
        });
        string Juecfs = "绝处逢生";

        TriggerList.Add(new PTrigger("绝处逢生[达到条件]")
        {
            IsLocked = true,
            Time     = PTime.AfterDieTime,
            Effect   = (PGame Game) => {
                if (Game.GameMode is PMode4v4)
                {
                    Game.AlivePlayers().ForEach((PPlayer Player) => {
                        if (Game.Teammates(Player).Count == 1 && Game.Enemies(Player).Count == 4)
                        {
                            Player.Tags.CreateTag(new PTag(Juecfs)
                            {
                                Visible = false
                            });
                        }
                    });
                }
            }
        });
        TriggerList.Add(new PTrigger("绝处逢生")
        {
            IsLocked = true,
            Time     = PTime.EndGameTime,
            Effect   = (PGame Game) => {
                Game.GetWinner().ForEach((PPlayer Player) => {
                    if (Player.Tags.ExistTag(Juecfs))
                    {
                        Announce(Game, Player, "绝处逢生");
                    }
                });
            }
        });
    }
 public PTransportTriggerInstaller() : base("移动位置")
 {
     TriggerList.Add(new PTrigger("移动位置")
     {
         IsLocked = true,
         Time     = PTime.MovePositionTime,
         Effect   = (PGame Game) => {
             PTransportTag Tag = Game.TagManager.FindPeekTag <PTransportTag>(PTransportTag.TagName);
             if (Tag.Player != null && Tag.Destination != null)
             {
                 Tag.Player.Position = Tag.Destination;
                 PNetworkManager.NetworkServer.TellClients(new PMovePositionOrder(Tag.Player.Index.ToString(), Tag.Destination.Index.ToString()));
             }
         }
     });
 }
Пример #18
0
 public PFreeTimeTriggerInstaller() : base("玩家空闲时间点")
 {
     foreach (PTime Time in new PTime[] { PPeriod.FirstFreeTime.During, PPeriod.SecondFreeTime.During })
     {
         TriggerList.Add(new PTrigger("玩家的空闲时间点")
         {
             IsLocked  = true,
             Time      = Time,
             Condition = (PGame Game) => Game.NowPlayer.IsUser,
             Effect    = (PGame Game) => {
                 Game.TagManager.CreateTag(PTag.FreeTimeOperationTag);
                 PThread.WaitUntil(() => !Game.TagManager.ExistTag(PTag.FreeTimeOperationTag.Name));
             }
         });
     }
 }
Пример #19
0
        public void AddTriggerRecord(TriggerRecord trigger)
        {
            if (TriggerList == null)
            {
                TriggerList = new List <TriggerRecord>();
            }
            trigger.ParentActor = this;
            TriggerList.Add(trigger);
            //add into TriggerSystem
            long   nowTick  = DateTime.Now.Ticks;
            double interval = (nowTick - _lastStepTick) / TimeSpan.TicksPerMillisecond;

            if (interval < 50)
            {
                ((TriggerSystem)_currentView.MainTriggerSystem).RegisterTrigger(trigger);
            }
        }
Пример #20
0
 public PAmbushTriggerInstaller() : base("触发伏兵")
 {
     TriggerList.Add(new PTrigger("触发伏兵")
     {
         IsLocked  = true,
         Time      = PPeriod.AmbushStage.During,
         Condition = (PGame Game) => {
             return(Game.NowPlayer.Area.AmbushCardArea.CardNumber > 0);
         },
         Effect = (PGame Game) => {
             for (int i = Game.NowPlayer.Area.AmbushCardArea.CardNumber - 1; i >= 0; --i)
             {
                 PCard AmbushCard = Game.NowPlayer.Area.AmbushCardArea.CardList[i];
                 if (AmbushCard != null)
                 {
                     ((PAmbushCardModel)AmbushCard.Model).AnnouceInvokeJudge(Game, Game.NowPlayer, AmbushCard);
                 }
             }
         }
     });
 }
 public POutOfGameTriggerInstaller() : base("防止伤害")
 {
     TriggerList.Add(new PTrigger("移出游戏[防止伤害]")
     {
         IsLocked  = true,
         Time      = PTime.Injure.StartSettle,
         Condition = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             return((InjureTag.FromPlayer != null && InjureTag.FromPlayer.OutOfGame) || (InjureTag.ToPlayer != null && InjureTag.ToPlayer.OutOfGame) && InjureTag.Injure > 0);
         },
         Effect = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             InjureTag.Injure     = 0;
             string Name          = string.Empty;
             if (InjureTag.FromPlayer != null && InjureTag.FromPlayer.OutOfGame)
             {
                 Name = InjureTag.FromPlayer.Name;
             }
             else if (InjureTag.ToPlayer != null && InjureTag.ToPlayer.OutOfGame)
             {
                 Name = InjureTag.ToPlayer.Name;
             }
             PNetworkManager.NetworkServer.TellClients(new PShowInformationOrder("因" + Name + "移出游戏,伤害防止"));
         }
     });
     TriggerList.Add(new PTrigger("空城[防止伤害]")
     {
         IsLocked  = true,
         Time      = PTime.Injure.StartSettle,
         Condition = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             return((InjureTag.ToPlayer != null && InjureTag.ToPlayer.Tags.ExistTag(PKuungCheevngChiTag.TagName)) && InjureTag.Injure > 0);
         },
         Effect = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             InjureTag.Injure     = 0;
             PNetworkManager.NetworkServer.TellClients(new PShowInformationOrder("因" + InjureTag.ToPlayer.Name + "空城,伤害防止"));
         }
     });
 }
Пример #22
0
 public PDiceTriggerInstaller() : base("掷骰子")
 {
     TriggerList.Add(new PTrigger("掷骰子")
     {
         IsLocked = true,
         Time     = PPeriod.DiceStage.During,
         Effect   = (PGame Game) => {
             int DiceResult = PMath.RandInt(1, 6);
             PNetworkManager.NetworkServer.TellClients(new PDiceResultOrder(DiceResult.ToString()));
             Game.TagManager.CreateTag(new PDiceResultTag(DiceResult));
         }
     });
     TriggerList.Add(new PTrigger("点数转为步数")
     {
         IsLocked = true,
         Time     = PPeriod.WalkingStage.Before,
         Effect   = (PGame Game) => {
             PDiceResultTag Tag = Game.TagManager.PopTag <PDiceResultTag>(PDiceResultTag.TagName);
             int DiceResult     = (Tag != null ? Tag.DiceResult : 0);
             Game.TagManager.CreateTag(new PStepCountTag(DiceResult));
         }
     });
 }
Пример #23
0
 public PCardArch() : base("卡牌类成就")
 {
     TriggerList.Add(new PTrigger("吃掉电脑屏幕")
     {
         IsLocked = true,
         Time     = PTime.EndGameTime,
         Effect   = (PGame Game) => {
             Game.GetWinner().ForEach((PPlayer Player) => {
                 if (Player.Area.HandCardArea.CardNumber >= 17)
                 {
                     Announce(Game, Player, "吃掉电脑屏幕");
                 }
             });
         }
     });
     TriggerList.Add(new PTrigger("海天一色")
     {
         IsLocked = true,
         Time     = PTime.DieTime,
         Effect   = (PGame Game) => {
             PDyingTag DyingTag   = Game.TagManager.FindPeekTag <PDyingTag>(PDyingTag.TagName);
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             if (InjureTag != null && DyingTag != null && DyingTag.Player.Equals(InjureTag.ToPlayer) && InjureTag.InjureSource is PCard && ((PCard)InjureTag.InjureSource).Model is P_ManTiienKuoHai)
             {
                 PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
                 if (UseCardTag != null && UseCardTag.User != null && UseCardTag.Card.Equals(InjureTag.InjureSource))
                 {
                     Announce(Game, UseCardTag.User, "海天一色");
                 }
             }
         }
     });
     TriggerList.Add(new PTrigger("口蜜腹剑")
     {
         IsLocked = true,
         Time     = PTime.DieTime,
         Effect   = (PGame Game) => {
             PDyingTag DyingTag   = Game.TagManager.FindPeekTag <PDyingTag>(PDyingTag.TagName);
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             if (InjureTag != null && DyingTag != null && DyingTag.Player.Equals(InjureTag.ToPlayer) && InjureTag.InjureSource is PCard && ((PCard)InjureTag.InjureSource).Model is P_HsiaoLiTsaangTao)
             {
                 PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
                 if (UseCardTag != null && UseCardTag.User != null && UseCardTag.Card.Equals(InjureTag.InjureSource))
                 {
                     Announce(Game, UseCardTag.User, "口蜜腹剑");
                 }
             }
         }
     });
     #region 出其不意
     string Chuqby = "出其不意";
     TriggerList.Add(new PTrigger("出其不意[初始化]")
     {
         IsLocked = true,
         Time     = PPeriod.StartTurn.During,
         Effect   = (PGame Game) => {
             Game.NowPlayer.Tags.CreateTag(new PUsedTag(Chuqby, 1));
         }
     });
     TriggerList.Add(new PTrigger("出其不意[使用暗度陈仓]")
     {
         IsLocked  = true,
         Time      = PTime.Card.EndSettleTime,
         Condition = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             return(UseCardTag.TargetList.Contains(Game.NowPlayer) && UseCardTag.Card.Model is P_AnTuCheevnTsaang);
         },
         Effect = (PGame Game) => {
             Game.NowPlayer.Tags.FindPeekTag <PUsedTag>(PUsedTag.TagNamePrefix + Chuqby).Count = 1;
         }
     });
     TriggerList.Add(new PTrigger("出其不意")
     {
         IsLocked  = true,
         Time      = PTime.PurchaseLandTime,
         Condition = (PGame Game) => {
             PPurchaseLandTag PurchaseLandTag = Game.TagManager.FindPeekTag <PPurchaseLandTag>(PPurchaseLandTag.TagName);
             return(PurchaseLandTag.Player.Equals(Game.NowPlayer) && PurchaseLandTag.Block.IsBusinessLand && Game.NowPlayer.Tags.FindPeekTag <PUsedTag>(PUsedTag.TagNamePrefix + Chuqby).Count > 0);
         },
         Effect = (PGame Game) => {
             Announce(Game, Game.NowPlayer, "出其不意");
         }
     });
     #endregion
     #region 百足之虫
     string Baizzc = "百足之虫";
     MultiPlayerTriggerList.Add((PPlayer Player) =>
                                new PTrigger("百足之虫[初始化]")
     {
         IsLocked = true,
         Time     = PTime.StartGameTime,
         Effect   = (PGame Game) => {
             Player.Tags.CreateTag(new PUsedTag(Baizzc, 2));
         }
     });
     MultiPlayerTriggerList.Add((PPlayer Player) =>
                                new PTrigger("百足之虫[使用借尸还魂]")
     {
         IsLocked  = true,
         Time      = PTime.Card.EndSettleTime,
         Condition = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             return(UseCardTag.TargetList.Contains(Player) && UseCardTag.Card.Model is P_ChiehShihHuanHun);
         },
         Effect = (PGame Game) => {
             PUsedTag UsedTag = Player.Tags.FindPeekTag <PUsedTag>(PUsedTag.TagNamePrefix + Baizzc);
             UsedTag.Count++;
             if (UsedTag.Count >= UsedTag.Limit)
             {
                 Announce(Game, Player, Baizzc);
             }
         }
     });
     #endregion
     #region 护花使者
     string Huhsz = "护花使者";
     MultiPlayerTriggerList.Add((PPlayer Player) =>
                                new PTrigger("护花使者[初始化]")
     {
         IsLocked = true,
         Time     = PPeriod.StartTurn.Start,
         Effect   = (PGame Game) => {
             Player.Tags.PopTag <PHuszTag>(PHuszTag.TagName);
         }
     });
     TriggerList.Add(new PTrigger("护花使者[使用调虎离山]")
     {
         IsLocked  = true,
         Time      = PTime.Card.EndSettleTime,
         Condition = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             return(UseCardTag.Card.Model is P_TiaoHuLiShan);
         },
         Effect = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             UseCardTag.TargetList.ForEach((PPlayer Player) => {
                 if (!Player.Tags.ExistTag(PHuszTag.TagName) && Player.TeamIndex == UseCardTag.User.TeamIndex)
                 {
                     Player.Tags.CreateTag(new PHuszTag(UseCardTag.User));
                 }
             });
         }
     });
     TriggerList.Add(new PTrigger("护花使者")
     {
         IsLocked  = true,
         Time      = PTime.Injure.StartSettle,
         Condition = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             return(InjureTag.ToPlayer != null && InjureTag.ToPlayer.Tags.ExistTag(PHuszTag.TagName));
         },
         Effect = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             Announce(Game, InjureTag.ToPlayer.Tags.FindPeekTag <PHuszTag>(PHuszTag.TagName).User, Huhsz);
         }
     });
     #endregion
     TriggerList.Add(new PTrigger("搬石砸脚")
     {
         IsLocked = true,
         Time     = PTime.Card.EndSettleTime,
         Effect   = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             if (UseCardTag.Card.Model is P_PaaoChuanYinYoo &&
                 UseCardTag.TargetList.TrueForAll((PPlayer Player) => Player.TeamIndex == UseCardTag.User.TeamIndex))
             {
                 Announce(Game, UseCardTag.User, "搬石砸脚");
             }
         }
     });
     #region 水至清则无鱼
     string Shuizqzwy = "水至清则无鱼";
     TriggerList.Add(new PTrigger("水至清则无鱼[初始化]")
     {
         IsLocked = true,
         Time     = PTime.Card.AfterEmitTargetTime,
         Effect   = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             if (UseCardTag.Card.Model is P_HunShuiMoYoo)
             {
                 UseCardTag.User.Tags.CreateTag(new PCardInjureTag(UseCardTag.Card, 0));
             }
         }
     });
     TriggerList.Add(new PTrigger("水至清则无鱼[增量计算]")
     {
         IsLocked = true,
         Time     = PTime.Injure.EndSettle,
         Effect   = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             if (InjureTag.Injure > 0 && InjureTag.FromPlayer != null &&
                 InjureTag.InjureSource is PCard && ((PCard)InjureTag.InjureSource).Model is P_HunShuiMoYoo &&
                 InjureTag.FromPlayer.Tags.ExistTag(PCardInjureTag.TagName + P_HunShuiMoYoo.CardName))
             {
                 InjureTag.FromPlayer.Tags.FindPeekTag <PCardInjureTag>(PCardInjureTag.TagName + P_HunShuiMoYoo.CardName).TotalInjure += InjureTag.Injure;
             }
         }
     });
     TriggerList.Add(new PTrigger("水至清则无鱼")
     {
         IsLocked = true,
         Time     = PTime.Card.EndSettleTime,
         Effect   = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             if (UseCardTag.Card.Model is P_HunShuiMoYoo && UseCardTag.User.Tags.ExistTag(PCardInjureTag.TagName + P_HunShuiMoYoo.CardName))
             {
                 PCardInjureTag CardInjureTag = UseCardTag.User.Tags.PopTag <PCardInjureTag>(PCardInjureTag.TagName + P_HunShuiMoYoo.CardName);
                 if (CardInjureTag.TotalInjure >= 3500)
                 {
                     Announce(Game, UseCardTag.User, Shuizqzwy);
                 }
             }
         }
     });
     #endregion
     #region 逃出生天
     string Taocst = "逃出生天";
     TriggerList.Add(new PTrigger("逃出生天[初始化]")
     {
         IsLocked = true,
         Time     = PPeriod.StartTurn.During,
         Effect   = (PGame Game) => {
             Game.NowPlayer.Tags.CreateTag(new PUsedTag(Taocst, 1));
         }
     });
     TriggerList.Add(new PTrigger("逃出生天[使用金蝉脱壳]")
     {
         IsLocked  = true,
         Time      = PTime.Card.EndSettleTime,
         Condition = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             return(Game.NowPlayer.Equals(UseCardTag.User) && UseCardTag.Card.Model is P_ChinChaanToowChiiao);
         },
         Effect = (PGame Game) => {
             Game.NowPlayer.Tags.FindPeekTag <PUsedTag>(PUsedTag.TagNamePrefix + Taocst).Count = 1;
         }
     });
     TriggerList.Add(new PTrigger("逃出生天")
     {
         IsLocked  = true,
         Time      = PPeriod.SettleStage.Before,
         Condition = (PGame Game) => {
             return(Game.NowPlayer.Tags.FindPeekTag <PUsedTag>(PUsedTag.TagNamePrefix + Taocst).Count > 0 &&
                    (Game.NowPlayer.Position.GetMoneyStopPercent > 0 || Game.NowPlayer.Position.GetMoneyStopSolid > 0));
         },
         Effect = (PGame Game) => {
             Announce(Game, Game.NowPlayer, Taocst);
         }
     });
     #endregion
     #region 无处可逃
     string Wuckt = "无处可逃";
     TriggerList.Add(new PTrigger("无处可逃[初始化]")
     {
         IsLocked = true,
         Time     = PTime.Card.AfterEmitTargetTime,
         Effect   = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             if (UseCardTag.Card.Model is P_KuanMevnChoTsev)
             {
                 UseCardTag.User.Tags.CreateTag(new PCardInjureTag(UseCardTag.Card, 0));
             }
         }
     });
     TriggerList.Add(new PTrigger("无处可逃[增量计算]")
     {
         IsLocked = true,
         Time     = PTime.Injure.EndSettle,
         Effect   = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             if (InjureTag.Injure > 0 && InjureTag.FromPlayer != null &&
                 InjureTag.InjureSource is PCard && ((PCard)InjureTag.InjureSource).Model is P_KuanMevnChoTsev &&
                 InjureTag.FromPlayer.Tags.ExistTag(PCardInjureTag.TagName + P_KuanMevnChoTsev.CardName))
             {
                 InjureTag.FromPlayer.Tags.FindPeekTag <PCardInjureTag>(PCardInjureTag.TagName + P_KuanMevnChoTsev.CardName).TotalInjure += InjureTag.Injure;
             }
         }
     });
     TriggerList.Add(new PTrigger("无处可逃")
     {
         IsLocked = true,
         Time     = PTime.Card.EndSettleTime,
         Effect   = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             if (UseCardTag.Card.Model is P_KuanMevnChoTsev && UseCardTag.User.Tags.ExistTag(PCardInjureTag.TagName + P_KuanMevnChoTsev.CardName))
             {
                 PCardInjureTag CardInjureTag = UseCardTag.User.Tags.PopTag <PCardInjureTag>(PCardInjureTag.TagName + P_KuanMevnChoTsev.CardName);
                 if (CardInjureTag.TotalInjure >= 7000)
                 {
                     Announce(Game, UseCardTag.User, Wuckt);
                 }
             }
         }
     });
     #endregion
     TriggerList.Add(new PTrigger("不安好心")
     {
         IsLocked = true,
         Time     = PTime.DieTime,
         Effect   = (PGame Game) => {
             PDyingTag DyingTag   = Game.TagManager.FindPeekTag <PDyingTag>(PDyingTag.TagName);
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             if (InjureTag != null && DyingTag != null && DyingTag.Player.Equals(InjureTag.ToPlayer) && InjureTag.InjureSource is PCard && ((PCard)InjureTag.InjureSource).Model is P_ChiaTaoFaKuo)
             {
                 PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
                 if (UseCardTag != null && UseCardTag.User != null && UseCardTag.Card.Equals(InjureTag.InjureSource))
                 {
                     Announce(Game, UseCardTag.User, "不安好心");
                 }
             }
         }
     });
     #region 装疯卖傻
     string Zhuangfms = "装疯卖傻";
     MultiPlayerTriggerList.Add((PPlayer Player) =>
                                new PTrigger("装疯卖傻[初始化]")
     {
         IsLocked = true,
         Time     = PPeriod.StartTurn.Start,
         Effect   = (PGame Game) => {
             Player.Tags.PopTag <PZhuangfmsTag>(PZhuangfmsTag.TagName);
         }
     });
     TriggerList.Add(new PTrigger("装疯卖傻[使用假痴不癫]")
     {
         IsLocked  = true,
         Time      = PTime.Card.EndSettleTime,
         Condition = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             return(UseCardTag.Card.Model is P_ChiaChiihPuTien);
         },
         Effect = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             UseCardTag.TargetList.ForEach((PPlayer Player) => {
                 if (!Player.Tags.ExistTag(PZhuangfmsTag.TagName) && Player.TeamIndex == UseCardTag.User.TeamIndex)
                 {
                     Player.Tags.CreateTag(new PZhuangfmsTag(UseCardTag.User));
                 }
             });
         }
     });
     TriggerList.Add(new PTrigger("装疯卖傻")
     {
         IsLocked  = true,
         Time      = PTime.Injure.StartSettle,
         Condition = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             return(InjureTag.ToPlayer != null && InjureTag.ToPlayer.Tags.ExistTag(PZhuangfmsTag.TagName));
         },
         Effect = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             Announce(Game, InjureTag.ToPlayer.Tags.FindPeekTag <PZhuangfmsTag>(PZhuangfmsTag.TagName).User, Zhuangfms);
         }
     });
     #endregion
     #region  病相怜
     TriggerList.Add(new PTrigger("同病相怜")
     {
         IsLocked  = true,
         Time      = PTime.Injure.AcceptInjure,
         Condition = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             return(InjureTag.ToPlayer != null && InjureTag.Injure > 0 && InjureTag.ToPlayer.Tags.ExistTag(PTag.LockedTag.Name) &&
                    InjureTag.InjureSource is PCard && ((PCard)InjureTag.InjureSource).Model is P_ShanTien);
         },
         Effect = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             Announce(Game, InjureTag.ToPlayer, "同病相怜");
         }
     });
     #endregion
     #region 谁是赢家
     string Uzuyj = "谁是赢家";
     MultiPlayerTriggerList.Add((PPlayer Player) =>
                                new PTrigger("谁是赢家[初始化]")
     {
         IsLocked = true,
         Time     = PPeriod.StartTurn.Start,
         Effect   = (PGame Game) => {
             Player.Tags.PopTag <PTag>(Uzuyj);
         }
     });
     TriggerList.Add(new PTrigger("谁是赢家[使用走为上计]")
     {
         IsLocked  = true,
         Time      = PTime.Card.EndSettleTime,
         Condition = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             return(UseCardTag.Card.Model is P_TsouWeiShangChi);
         },
         Effect = (PGame Game) => {
             PUseCardTag UseCardTag = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             UseCardTag.TargetList.ForEach((PPlayer Player) => {
                 if (!Player.Tags.ExistTag(Uzuyj))
                 {
                     Player.Tags.CreateTag(new PTag(Uzuyj)
                     {
                         Visible = false
                     });
                 }
             });
         }
     });
     TriggerList.Add(new PTrigger("谁是赢家")
     {
         IsLocked = true,
         Time     = PTime.EndGameTime,
         Effect   = (PGame Game) => {
             Game.GetWinner().ForEach((PPlayer Player) => {
                 if (Player.Tags.ExistTag(Uzuyj))
                 {
                     Announce(Game, Player, Uzuyj);
                 }
             });
         }
     });
     #endregion
 }
Пример #24
0
    public bool Capture(string outputData1, EncoderRProcCapture encoderRProcCapture,
                        bool compujump, Preferences.TriggerTypes cutByTriggers, double restClustersSeconds, bool playSoundsFromFile)
    {
        /*
         * removed at 1.7.0
         * if(simulated) {
         *      bool success = initSimulated();
         *      if(! success)
         *              return false;
         * }
         */

        lastTriggerOn = 0;
        inertialCalibratedFirstCross0Pos = 0;

        //only for cutByTriggers == Preferences.TriggerTypes.START_AT_FIRST_ON
        bool firstTriggerHappened = false;

        //playSoundsFromFile
        DateTime lastTriggeredSound = DateTime.MinValue;

        if (capturingInertialBG)
        {
            /*
             * reset capture list. If not done here, list will grow at each set
             * also this fixes the initial 0s after a set
             */
            EncoderCaptureInertialBackgroundStatic.Initialize();
        }

        do
        {
            //1 read data
            try {
                byteReaded = readByte();
            } catch {
                if (!simulated)
                {
                    LogB.Error("Maybe encoder cable is disconnected");
                    cancel = true;
                }

                break;
            }

            //2 check if readed data is a trigger
            if (byteReaded == TRIGGER_ON)
            {
                if (playSoundsFromFile)
                {
                    TimeSpan ts = DateTime.Now.Subtract(lastTriggeredSound);
                    if (ts.TotalMilliseconds > 50)
                    {
                        Util.NextSongInList();
                        lastTriggeredSound = DateTime.Now;
                    }

                    continue;
                }

                Trigger trigger = new Trigger(Trigger.Modes.ENCODER, i, true);
                if (triggerList.IsSpurious(trigger))
                {
                    triggerList.RemoveLastOff();
                    continue;
                }

                //TriggerTypes.START_AT_FIRST_ON starts capture at first trigger. So when this happens, reset capture
                if (cutByTriggers == Preferences.TriggerTypes.START_AT_FIRST_ON && !firstTriggerHappened)
                {
                    LogB.Information("Cleaning on capture");

                    startCaptureFromHere();

                    firstTriggerHappened = true;
                    i = -1;                     //will be 0 on next loop start
                    continue;
                }

                if (cutByTriggers != Preferences.TriggerTypes.NO_TRIGGERS)
                {
                    ecc           = new EncoderCaptureCurve(lastTriggerOn, i);
                    lastTriggerOn = i;

                    double [] curve = new double[ecc.endFrame - ecc.startFrame];
                    //int mySum = 0;
                    for (int k = 0, j = ecc.startFrame; j < ecc.endFrame; j++)
                    {
                        curve[k] = encoderReaded[j];
                        k++;
                        //mySum += encoderReaded[j];
                    }
                    //ecc.up = (mySum >= 0);
                    ecc.up = true;                     //make all concentric for the swimming application
                    LogB.Debug("curve stuff" + ecc.startFrame + ":" + ecc.endFrame + ":" + encoderReaded.Count);

                    bool success = encoderRProcCapture.SendCurve(
                        ecc.startFrame,
                        UtilEncoder.CompressData(curve, 25)                                     //compressed
                        );
                    if (!success)
                    {
                        cancel = true;
                    }

                    Ecca.curvesAccepted++;
                    Ecca.ecc.Add(ecc);
                    LogB.Information(ecc.ToString());
                }
                triggerList.Add(trigger);
                continue;
            }
            else if (byteReaded == TRIGGER_OFF)
            {
                if (!playSoundsFromFile)
                {
                    Trigger trigger = new Trigger(Trigger.Modes.ENCODER, i, false);
                    triggerList.Add(trigger);
                }

                continue;
            }

            //3 if is not trigger: convertByte
            byteReaded = convertByte(byteReaded);
            //LogB.Information(" byte: " + byteReaded);

            i = i + 1;
            if (i >= 0)
            {
                if (cont)
                {
                    recordedTimeCont++;
                }

                if (byteReaded == 0)
                {
                    consecutiveZeros++;

                    //clean variables when we are on cont and long time elapsed
                    if (cont && Ecca.curvesAccepted == 0 && consecutiveZeros >= consecutiveZerosMax)
                    {
                        LogB.Information("Cleaning on capture");

                        //remove this time on existing trigger records
                        triggerList.Substract(consecutiveZeros);

                        startCaptureFromHere();

                        i = -1;                         //will be 0 on next loop start
                        continue;
                    }
                }
                else
                {
                    consecutiveZeros = -1;
                }

                //stop if n seconds of inactivity
                //but it has to be moved a little bit first, just to give time to the people
                //if(consecutiveZeros >= consecutiveZerosMax && sum > 0) #Not OK because sum maybe is 0: +1,+1,-1,-1
                //if(consecutiveZeros >= consecutiveZerosMax && ecca.ecc.Count > 0) #Not ok because when ecca is created, ecc.Count == 1

                /*
                 * process ends
                 * (
                 * when a curve has been found and then there are n seconds of inactivity, or
                 * when not in cont and a curve has not been found and then there are 2*n seconds of inactivity
                 * ) and if consecutiveZeros > restClustersSeconds * 1.500
                 *
                 * 1500 is conversion to milliseconds and * 1.5 to have enough time to move after clusters res
                 */
                if (
                    automaticallyEndByTime &&
                    (
                        (Ecca.curvesAccepted > 0 && consecutiveZeros >= consecutiveZerosMax) ||
                        (!cont && Ecca.curvesAccepted == 0 && consecutiveZeros >= (2 * consecutiveZerosMax))
                    ) &&
                    (restClustersSeconds == 0 || consecutiveZeros > restClustersSeconds * 1500)
                    )
                {
                    finish = true;
                    LogB.Information("SHOULD FINISH");
                }


                //on inertialCalibrated set mark where 0 is crossed for the first time
                if (inertialCalibrated && inertialCalibratedFirstCross0Pos == 0)
                {
                    if ((sumInertialDisc <= 0 && sumInertialDisc + byteReaded > 0) ||
                        (sumInertialDisc >= 0 && sumInertialDisc + byteReaded < 0))
                    {
                        inertialCalibratedFirstCross0Pos = i;
                    }
                }

                sumInertialDisc += byteReaded;
                encoderReadedInertialDisc.Add(byteReaded);

                if (inertialCalibrated && sumInertialDisc > 0)
                {
                    byteReaded *= -1;
                }

                sum += byteReaded;
                encoderReaded.Add(byteReaded);


                if (!showOnlyBars)
                {
                    assignEncoderCapturePoints();

                    EncoderCapturePointsCaptured = i;
                }

                if (!showOnlyBars)
                {
                    encoderCapturePointsAdaptativeDisplay();
                }

                // ---- prepare to send to R ----

                //if string goes up or down, store the direction
                //direction is only up or down
                if (byteReaded != 0)
                {
                    directionNow = (int)byteReaded / (int)Math.Abs(byteReaded);                       //1 (up) or -1 (down)
                }
                //if we don't have changed the direction, store the last non-zero that we can find
                if (directionChangeCount == 0 && directionNow == directionLastMSecond)
                {
                    //check which is the last non-zero value
                    //this is suitable to find where starts the only-zeros previous to the change
                    if (byteReaded != 0)
                    {
                        lastNonZero = i;
                    }
                }

                bool sendCurveMaybe = false;

                //if it's different than the last direction, mark the start of change
                if (directionNow != directionLastMSecond)
                {
                    directionLastMSecond = directionNow;
                    directionChangeCount = 0;
                }
                else if (directionNow != directionCompleted)
                {
                    //we are in a different direction than the last completed

                    //we cannot add byteReaded because then is difficult to come back n frames to know the max point
                    //directionChangeCount += byteReaded
                    directionChangeCount++;

                    if (directionChangeCount > directionChangePeriod)                           //count >= than change_period
                    {
                        sendCurveMaybe = true;
                    }
                }

                /*
                 * on inertialCalibrated don't send curve until 0 is crossed
                 * this ensures first stored phase will be ecc, that's what the rest of the program is expecting
                 * TODO: maybe this can be problematic with triggers maybe can be desinchronized, just move values
                 */
                if (inertialCalibrated && inertialCalibratedFirstCross0Pos == 0)
                {
                    sendCurveMaybe = false;
                }

                //if cutByTriggers, triggers send the curve at the beginning of this method
                if (cutByTriggers != Preferences.TriggerTypes.NO_TRIGGERS)
                {
                    sendCurveMaybe = false;
                }

                if (sendCurveMaybe)
                {
                    //int startFrame = previousFrameChange - directionChangeCount;	//startFrame

                    /*
                     * at startFrame we do the "-directionChangePeriod" because
                     * we want data a little bit earlier, because we want some zeros
                     * that will be removed by reduceCurveBySpeed
                     * if not done, then the data:
                     * 0 0 0 0 0 0 0 0 0 1
                     * will start at 10th digit (the 1)
                     * if done, then at speed will be like this:
                     * 0 0 0 0.01 0.04 0.06 0.07 0.08 0.09 1
                     * and will start at fourth digit
                     */

                    //this is better, takes a lot of time before, and then reduceCurveBySpeed will cut it
                    //but reduceCurveBySpeed is not implemented on inertial
                    //TODO: implement it
                    int startFrame = previousEnd;                       //startFrame
                    LogB.Debug("startFrame", startFrame.ToString());
                    if (startFrame < 0)
                    {
                        startFrame = 0;
                    }

                    //on inertial start when crossing 0 first time
                    if (inertialCalibrated && startFrame < inertialCalibratedFirstCross0Pos)
                    {
                        startFrame = inertialCalibratedFirstCross0Pos;
                    }

                    LogB.Information("TTTT - i," + i.ToString() +
                                     "; directionChangeCount: " +
                                     directionChangeCount.ToString() +
                                     "; lastNonZero: " +
                                     lastNonZero.ToString() +
                                     "; final: " +
                                     ((i - directionChangeCount + lastNonZero) / 2).ToString());

                    ecc = new EncoderCaptureCurve(
                        startFrame,
                        (i - directionChangeCount + lastNonZero) / 2                                    //endFrame
                        //to find endFrame, first substract directionChangePeriod from i
                        //then find the middle point between that and lastNonZero
                        //this means that the end is in central point at displacements == 0
                        );

                    //since 1.5.0 secundary thread is capturing and sending data to R process
                    //while main thread is reading data coming from R and updating GUI

                    LogB.Debug("curve stuff" + ecc.startFrame + ":" + ecc.endFrame + ":" + encoderReaded.Count);
                    if (ecc.endFrame - ecc.startFrame > 0)
                    {
                        double [] curve = new double[ecc.endFrame - ecc.startFrame];
                        int       mySum = 0;
                        for (int k = 0, j = ecc.startFrame; j < ecc.endFrame; j++)
                        {
                            curve[k] = encoderReaded[j];
                            k++;
                            mySum += encoderReaded[j];
                        }
                        ecc.up = (mySum >= 0);

                        previousEnd = ecc.endFrame;

                        //22-may-2015: This is done in R now

                        //1) check heightCurve in a fast way first to discard curves soon
                        //   only process curves with height >= min_height
                        //2) if it's concentric, only take the concentric curves,
                        //   but if it's concentric and inertial: take both.
                        //
                        //   When capturing on inertial, we have the first graph
                        //   that will be converted to the second.
                        //   we need the eccentric phase in order to detect the Ci2

                        /*
                         *             /\
                         *            /  \
                         *           /    \
                         *____      C1     \      ___
                         *    \    /        \    /
                         *     \  /          \  C2
                         *      \/            \/
                         *
                         * C1, C2: two concentric phases
                         */

                        /*
                         *____                    ___
                         *    \    /\      /\    /
                         *     \ Ci1 \   Ci2 \ Ci3
                         *      \/    \  /    \/
                         *             \/
                         *
                         * Ci1, Ci2, Ci3: three concentric phases on inertial
                         *
                         * Since 1.6.1:
                         * on inertial curve is sent when rope is fully extended,
                         * this will allow to see at the moment c or e. Not wait the change of direction to see both
                         */


                        //store in a boolean to not call shouldSendCurve() two times because it changes some variables
                        bool shouldSendCurveBool = shouldSendCurve();
                        if (shouldSendCurveBool)
                        {
                            //if compujump, wakeup screen if it's off
                            //do it on the first repetition because it will not be sleeping on the rest of repetitions
                            if (compujump && Ecca.curvesAccepted == 0)
                            {
                                Networks.WakeUpRaspberryIfNeeded();
                            }

                            bool success = encoderRProcCapture.SendCurve(
                                ecc.startFrame,
                                UtilEncoder.CompressData(curve, 25)                                             //compressed
                                );
                            if (!success)
                            {
                                cancel = true;
                            }

                            Ecca.curvesAccepted++;
                            Ecca.ecc.Add(ecc);
                            LogB.Information(ecc.ToString());

                            lastDirectionStoredIsUp = ecc.up;
                        }
                    }

                    //on inertial is different
                    markDirectionChanged();
                }

                //this is for visual feedback of remaining time
                msCount++;
                if (msCount >= 1000)
                {
                    Countdown--;
                    msCount = 1;
                }
            }
        } while ((cont || i < (recordingTime - 1)) && !cancel && !finish);

        LogB.Debug("runEncoderCaptureCsharp main bucle end");

        //leave some time to capture.R be able to paint data, and to create two Roptions.txt file correctly
        if (simulated)
        {
            System.Threading.Thread.Sleep(2000);
        }
        else if (!capturingInertialBG)
        {
            sp.Close();
        }

        if (cancel)
        {
            return(false);
        }

        saveToFile(outputData1);

        LogB.Debug("runEncoderCaptureCsharp ended");

        return(true);
    }
Пример #25
0
 public PCardTriggerInstaller() : base("卡牌移入移出区域")
 {
     TriggerList.Add(new PTrigger("游戏开始时摸牌")
     {
         IsLocked = true,
         Time     = PTime.StartGameTime,
         Effect   = (PGame Game) => {
             Game.PlayerList.ForEach((PPlayer Player) => {
                 Game.GetCard(Player, Config.StartGameCardCount);
                 int LuckyCardCount = 0;
                 while (LuckyCardCount < 3 && Player.IsUser && PNetworkManager.NetworkServer.ChooseManager.AskYesOrNo(Player, "是否使用手气卡?剩余次数=" + (3 - LuckyCardCount)))
                 {
                     Game.CardManager.ThrowAll(Player.Area);
                     LuckyCardCount++;
                     Game.GetCard(Player, Config.StartGameCardCount);
                 }
             });
         }
     });
     TriggerList.Add(new PTrigger("卡牌移入手牌装载触发器")
     {
         IsLocked  = true,
         Time      = PTime.Card.EnterAreaTime,
         Condition = (PGame Game) => {
             PMoveCardTag MoveTagFlag = Game.TagManager.FindPeekTag <PMoveCardTag>(PMoveCardTag.TagName);
             return(MoveTagFlag.Destination.IsHandCardArea());
         },
         Effect = (PGame Game) => {
             PMoveCardTag MoveTagFlag = Game.TagManager.FindPeekTag <PMoveCardTag>(PMoveCardTag.TagName);
             PPlayer Accepter         = MoveTagFlag.Destination.Owner;
             MoveTagFlag.Card.MoveInHandTriggerList = MoveTagFlag.Card.Model.MoveInHandTriggerList.ConvertAll((Func <PPlayer, PCard, PTrigger> Trigger) => Trigger(Accepter, MoveTagFlag.Card));
             MoveTagFlag.Card.MoveInHandTriggerList.ForEach((PTrigger Trigger) => {
                 Game.Monitor.AddTrigger(Trigger);
             });
         }
     });
     TriggerList.Add(new PTrigger("卡牌移出手牌摘下触发器")
     {
         IsLocked  = true,
         Time      = PTime.Card.LeaveAreaTime,
         Condition = (PGame Game) => {
             PMoveCardTag MoveTagFlag = Game.TagManager.FindPeekTag <PMoveCardTag>(PMoveCardTag.TagName);
             return(MoveTagFlag.Source.IsHandCardArea());
         },
         Effect = (PGame Game) => {
             PMoveCardTag MoveTagFlag = Game.TagManager.FindPeekTag <PMoveCardTag>(PMoveCardTag.TagName);
             PPlayer Giver            = MoveTagFlag.Source.Owner;
             MoveTagFlag.Card.MoveInHandTriggerList.ForEach((PTrigger Trigger) => {
                 Game.Monitor.RemoveTrigger(Trigger);
             });
         }
     });
     TriggerList.Add(new PTrigger("卡牌移入装备区装载触发器")
     {
         IsLocked  = true,
         Time      = PTime.Card.EnterAreaTime,
         Condition = (PGame Game) => {
             PMoveCardTag MoveTagFlag = Game.TagManager.FindPeekTag <PMoveCardTag>(PMoveCardTag.TagName);
             return(MoveTagFlag.Destination.IsEquipmentArea());
         },
         Effect = (PGame Game) => {
             PMoveCardTag MoveTagFlag = Game.TagManager.FindPeekTag <PMoveCardTag>(PMoveCardTag.TagName);
             PPlayer Accepter         = MoveTagFlag.Destination.Owner;
             MoveTagFlag.Card.MoveInEquipTriggerList = MoveTagFlag.Card.Model.MoveInEquipTriggerList.ConvertAll((Func <PPlayer, PCard, PTrigger> Trigger) => Trigger(Accepter, MoveTagFlag.Card));
             MoveTagFlag.Card.MoveInEquipTriggerList.ForEach((PTrigger Trigger) => {
                 Game.Monitor.AddTrigger(Trigger);
             });
         }
     });
     TriggerList.Add(new PTrigger("卡牌移出装备区摘下触发器")
     {
         IsLocked  = true,
         Time      = PTime.Card.LeaveAreaTime,
         Condition = (PGame Game) => {
             PMoveCardTag MoveTagFlag = Game.TagManager.FindPeekTag <PMoveCardTag>(PMoveCardTag.TagName);
             return(MoveTagFlag.Source.IsEquipmentArea());
         },
         Effect = (PGame Game) => {
             PMoveCardTag MoveTagFlag = Game.TagManager.FindPeekTag <PMoveCardTag>(PMoveCardTag.TagName);
             PPlayer Giver            = MoveTagFlag.Source.Owner;
             MoveTagFlag.Card.MoveInEquipTriggerList.ForEach((PTrigger Trigger) => {
                 Game.Monitor.RemoveTrigger(Trigger);
             });
         }
     });
     TriggerList.Add(new PTrigger("通知客户端卡牌指定目标")
     {
         IsLocked = true,
         Time     = PTime.Card.AfterEmitTargetTime,
         Effect   = (PGame Game) => {
             PUseCardTag UseCardTag    = Game.TagManager.FindPeekTag <PUseCardTag>(PUseCardTag.TagName);
             PPlayer User              = UseCardTag.User;
             PCard Card                = UseCardTag.Card;
             List <PPlayer> TargetList = UseCardTag.TargetList;
             if (User != null && Card != null && TargetList != null && !TargetList.Contains(null))
             {
                 PNetworkManager.NetworkServer.TellClients(new PPushTextOrder(User.Index.ToString(), Card.Model.Name, PPushType.Information.Name));
                 if (Card.Name.Equals(Card.Model.Name))
                 {
                     PNetworkManager.NetworkServer.TellClients(new PShowInformationOrder(User.Name + "使用了" + Card.Name));
                 }
                 else
                 {
                     PNetworkManager.NetworkServer.TellClients(new PShowInformationOrder(User.Name + "把" + Card.Name + "当做" + Card.Model.Name + "使用"));
                 }
                 PNetworkManager.NetworkServer.TellClients(new PShowInformationOrder("目标:" + string.Join(",", TargetList.ConvertAll((PPlayer Player) => Player.Name))));
             }
         }
     });
 }
Пример #26
0
 public PLandArch() : base("土地类成就")
 {
     TriggerList.Add(new PTrigger("地产大亨")
     {
         IsLocked = true,
         Time     = PTime.EndGameTime,
         Effect   = (PGame Game) => {
             Game.GetWinner().ForEach((PPlayer Player) => {
                 if (Game.Map.BlockList.FindAll((PBlock Block) => Player.Equals(Block.Lord)).Count >= 15)
                 {
                     Announce(Game, Player, "地产大亨");
                 }
             });
         }
     });
     TriggerList.Add(new PTrigger("大包工头")
     {
         IsLocked = true,
         Time     = PTime.EndGameTime,
         Effect   = (PGame Game) => {
             Game.GetWinner().ForEach((PPlayer Player) => {
                 if (PMath.Sum(Game.Map.BlockList.FindAll((PBlock Block) => Player.Equals(Block.Lord)).ConvertAll((PBlock Block) => (double)Block.HouseNumber)) >= 30)
                 {
                     Announce(Game, Player, "大包工头");
                 }
             });
         }
     });
     TriggerList.Add(new PTrigger("双11剁手")
     {
         IsLocked = true,
         Time     = PTime.DieTime,
         Effect   = (PGame Game) => {
             PDyingTag DyingTag   = Game.TagManager.FindPeekTag <PDyingTag>(PDyingTag.TagName);
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             if (InjureTag != null && DyingTag != null && DyingTag.Player.Equals(InjureTag.ToPlayer) && InjureTag.InjureSource is PBlock && ((PBlock)InjureTag.InjureSource).BusinessType.Equals(PBusinessType.ShoppingCenter))
             {
                 Announce(Game, DyingTag.Player, "双11剁手");
             }
         }
     });
     TriggerList.Add(new PTrigger("化学爆炸")
     {
         IsLocked = true,
         Time     = PTime.DieTime,
         Effect   = (PGame Game) => {
             PDyingTag DyingTag   = Game.TagManager.FindPeekTag <PDyingTag>(PDyingTag.TagName);
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             if (InjureTag != null && DyingTag != null && DyingTag.Player.Equals(InjureTag.ToPlayer) && InjureTag.InjureSource is PBlock && ((PBlock)InjureTag.InjureSource).BusinessType.Equals(PBusinessType.Institute))
             {
                 Announce(Game, DyingTag.Player, "化学爆炸");
             }
         }
     });
     TriggerList.Add(new PTrigger("舍身饲虎")
     {
         IsLocked = true,
         Time     = PTime.DieTime,
         Effect   = (PGame Game) => {
             PDyingTag DyingTag   = Game.TagManager.FindPeekTag <PDyingTag>(PDyingTag.TagName);
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             if (InjureTag != null && DyingTag != null && DyingTag.Player.Equals(InjureTag.ToPlayer) && InjureTag.InjureSource is PBlock && ((PBlock)InjureTag.InjureSource).BusinessType.Equals(PBusinessType.Park))
             {
                 Announce(Game, DyingTag.Player, "舍身饲虎");
             }
         }
     });
     TriggerList.Add(new PTrigger("撞墙")
     {
         IsLocked = true,
         Time     = PTime.DieTime,
         Effect   = (PGame Game) => {
             PDyingTag DyingTag   = Game.TagManager.FindPeekTag <PDyingTag>(PDyingTag.TagName);
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             if (InjureTag != null && DyingTag != null && DyingTag.Player.Equals(InjureTag.ToPlayer) && InjureTag.InjureSource is PBlock && ((PBlock)InjureTag.InjureSource).BusinessType.Equals(PBusinessType.Castle))
             {
                 Announce(Game, DyingTag.Player, "撞墙");
             }
         }
     });
     TriggerList.Add(new PTrigger("卖身")
     {
         IsLocked = true,
         Time     = PTime.DieTime,
         Effect   = (PGame Game) => {
             PDyingTag DyingTag   = Game.TagManager.FindPeekTag <PDyingTag>(PDyingTag.TagName);
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             if (InjureTag != null && DyingTag != null && DyingTag.Player.Equals(InjureTag.ToPlayer) && InjureTag.InjureSource is PBlock && ((PBlock)InjureTag.InjureSource).BusinessType.Equals(PBusinessType.Pawnshop))
             {
                 Announce(Game, DyingTag.Player, "卖身");
             }
         }
     });
     TriggerList.Add(new PTrigger("连锁商城")
     {
         IsLocked = true,
         Time     = PTime.EndGameTime,
         Effect   = (PGame Game) => {
             Game.GetWinner().ForEach((PPlayer Player) => {
                 if (Game.Map.BlockList.FindAll((PBlock Block) => Player.Equals(Block.Lord) && Block.BusinessType.Equals(PBusinessType.ShoppingCenter)).Count >= 3)
                 {
                     Announce(Game, Player, "连锁商城");
                 }
             });
         }
     });
     TriggerList.Add(new PTrigger("5A级景区")
     {
         IsLocked = true,
         Time     = PTime.EndGameTime,
         Effect   = (PGame Game) => {
             Game.GetWinner().ForEach((PPlayer Player) => {
                 if (Game.Map.BlockList.Exists((PBlock Block) => Player.Equals(Block.Lord) && Block.BusinessType.Equals(PBusinessType.Park) && Block.HouseNumber >= 5))
                 {
                     Announce(Game, Player, "5A级景区");
                 }
             });
         }
     });
     TriggerList.Add(new PTrigger("十三太堡")
     {
         IsLocked = true,
         Time     = PTime.EndGameTime,
         Effect   = (PGame Game) => {
             Game.GetWinner().ForEach((PPlayer Player) => {
                 if (Game.Map.BlockList.Exists((PBlock Block) => Player.Equals(Block.Lord) && Block.BusinessType.Equals(PBusinessType.Castle) && Block.HouseNumber >= 13))
                 {
                     Announce(Game, Player, "十三太堡");
                 }
             });
         }
     });
 }
Пример #27
0
 public PMoneyArch() : base("金钱类成就")
 {
     TriggerList.Add(new PTrigger("开始游戏")
     {
         IsLocked = true,
         Time     = PTime.StartGameTime,
         Effect   = (PGame Game) => {
             Game.PlayerList.ForEach((PPlayer Player) => {
                 Announce(Game, Player, "开始游戏");
             });
         }
     });
     TriggerList.Add(new PTrigger("炸弹")
     {
         IsLocked  = true,
         Time      = PTime.Injure.EmitInjure,
         Condition = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             return(InjureTag.Injure >= 10000 && InjureTag.FromPlayer != null);
         },
         Effect = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             Announce(Game, InjureTag.FromPlayer, "炸弹");
         }
     });
     TriggerList.Add(new PTrigger("踩到地雷")
     {
         IsLocked  = true,
         Time      = PTime.Injure.EmitInjure,
         Condition = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             return(InjureTag.Injure >= 10000 && InjureTag.ToPlayer != null);
         },
         Effect = (PGame Game) => {
             PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
             Announce(Game, InjureTag.ToPlayer, "踩到地雷");
         }
     });
     TriggerList.Add(new PTrigger("疯狂试探")
     {
         IsLocked = true,
         Time     = PTime.EndGameTime,
         Effect   = (PGame Game) => {
             Game.GetWinner().ForEach((PPlayer Player) => {
                 if (Player.IsAlive && Player.Money > 0 && Player.Money < 3000)
                 {
                     Announce(Game, Player, "疯狂试探");
                 }
             });
         }
     });
     TriggerList.Add(new PTrigger("叫我爸爸")
     {
         IsLocked  = true,
         Time      = PPeriod.StartTurn.During,
         Condition = (PGame Game) => {
             return(Game.NowPlayer.Money >= 88000);
         },
         Effect = (PGame Game) => {
             Announce(Game, Game.NowPlayer, "叫我爸爸");
         }
     });
 }
Пример #28
0
    public PChooseGeneralTriggerInstaller() : base("选将")
    {
        TriggerList.Add(new PTrigger("选将")
        {
            IsLocked = true,
            Time     = PTime.ChooseGeneralTime,
            Effect   = (PGame Game) => {
                List <PGeneral> Generals = new List <PGeneral>();

                #region  将卡的结算
                List <PGeneral> AvailableGenerals = new List <PGeneral>();
                AvailableGenerals = ListSubTypeInstances <PGeneral>().FindAll((PGeneral General) => !(General is P_Soldier) && General.CanBeChoose);
                Game.Traverse((PPlayer Player) => {
                    if (!(Player.General is P_Soldier))
                    {
                        AvailableGenerals.RemoveAll((PGeneral General) => General.Name.Equals(Player.General.Name));
                    }
                });
                List <PAge> Ages = new List <PAge>()
                {
                    PAge.Classic, PAge.Medieval, PAge.Renaissance, PAge.Industrial
                };
                for (int i = 0; i < 8; ++i)
                {
                    Generals.Add(new P_Soldier());
                }
                Game.Traverse((PPlayer Player) => {
                    // 现在不能主动选将
                    if (Player.IsUser && PNetworkManager.NetworkServer.ChooseManager.AskYesOrNo(Player, "是否使用点将卡?"))
                    {
                        PAge Age = Ages[PNetworkManager.NetworkServer.ChooseManager.Ask(Player, "选择时代", Ages.ConvertAll((PAge _Age) => _Age.Name).ToArray())];
                        List <PGeneral> PossibleGenerals = AvailableGenerals.FindAll((PGeneral General) => General.Age.Equals(Age));
                        PGeneral TargetGeneral           = PossibleGenerals[PNetworkManager.NetworkServer.ChooseManager.Ask(Player, "点将", PossibleGenerals.ConvertAll((PGeneral General) => General.Name).ToArray())];
                        Generals[Player.Index]           = TargetGeneral;
                        PLogger.Log(Player.Index + "号玩家选择了" + TargetGeneral.Name);
                    }
                }, Game.PlayerList[0]);
                // 去掉重复的将
                AvailableGenerals.ForEach((PGeneral General) => {
                    List <int> ChosenIndex = new List <int>();
                    for (int i = 0; i < 8; ++i)
                    {
                        if (Generals[i].Equals(General))
                        {
                            ChosenIndex.Add(i);
                        }
                    }
                    if (ChosenIndex.Count > 1)
                    {
                        PMath.Wash(ChosenIndex);
                        for (int i = 1; i < ChosenIndex.Count; ++i)
                        {
                            Generals[ChosenIndex[i]] = new P_Soldier();
                        }
                    }
                });
                // 剩下的将随机
                // 每个人有4个将可选
                // 其中最多1个免费将
                List <PGeneral> Selected = new List <PGeneral>();
                for (int i = 0; i < Game.PlayerNumber; ++i)
                {
                    if (Generals[i] is P_Soldier)
                    {
                        List <PGeneral> PossibleGenerals = new List <PGeneral>();
                        PMath.Wash(AvailableGenerals);
                        bool NoFreeGeneral = true;
                        foreach (PGeneral General in AvailableGenerals)
                        {
                            if (!Generals.Contains(General) && !Selected.Contains(General) && (NoFreeGeneral || General.Cost != 0))
                            {
                                if (Game.PlayerList[i].IsAI ||
                                    PNetworkManager.NetworkServer.ChooseManager.AskHaveGeneral(Game.PlayerList[i], General.Name))
                                {
                                    Selected.Add(General);
                                    PossibleGenerals.Add(General);
                                    if (General.Cost == 0)
                                    {
                                        NoFreeGeneral = false;
                                    }
                                }
                            }
                            if (PossibleGenerals.Count >= 4)
                            {
                                break;
                            }
                        }
                        if (PossibleGenerals.Count == 1)
                        {
                            Generals[i] = PossibleGenerals[0];
                        }
                        else
                        {
                            if (Game.PlayerList[i].IsAI)
                            {
                                PMath.Wash(PossibleGenerals);
                                Generals[i] = PossibleGenerals.Find((PGeneral _General) => _General.NewGeneral);
                                if (Generals[i] == null)
                                {
                                    Generals[i] = PossibleGenerals[0];
                                }
                            }
                            else
                            {
                                Generals[i] = PossibleGenerals[PNetworkManager.NetworkServer.ChooseManager.Ask(Game.PlayerList[i], "点将",
                                                                                                               PossibleGenerals.ConvertAll((PGeneral General) => General.Name).ToArray())];
                            }
                        }
                    }
                }
                #endregion

                #region 全AI模式下指定武将
                if (Game.PlayerList.TrueForAll((PPlayer _Player) => _Player.IsAI))
                {
                    string dataDirectory       = PPath.GetPath("Data\\User\\special.txt");
                    StreamReader ArcFileReader = new StreamReader(dataDirectory, Encoding.UTF8);
                    string Line = string.Empty;
                    while ((Line = ArcFileReader.ReadLine()) != null)
                    {
                        if (Line.Length > 0 && Line[0] != '#')
                        {
                            string[] LineData = Line.Split('|');
                            if (LineData.Length == Game.PlayerNumber)
                            {
                                for (int i = 0; i < Game.PlayerNumber; ++i)
                                {
                                    PGeneral General = AvailableGenerals.Find((PGeneral _General) => _General.Name.Equals(LineData[i]));
                                    if (General != null)
                                    {
                                        Generals[i] = General;
                                    }
                                }
                            }
                            break;
                        }
                    }
                    ArcFileReader.Close();
                }
                #endregion

                Game.Traverse((PPlayer Player) => {
                    if (Player.General is P_Soldier)
                    {
                        Player.General = Generals[Player.Index];
                    }
                    Player.Age = Player.General.Age;
                    Player.Sex = Player.General.Sex;
                    Player.General.SkillList.ForEach((PSkill Skill) => {
                        Skill.TriggerList.ForEach((Func <PPlayer, PSkill, PTrigger> TriggerGenerator) => {
                            Game.Monitor.AddTrigger(TriggerGenerator(Player, Skill));
                        });
                    });
                    PNetworkManager.NetworkServer.TellClients(new PRefreshGeneralOrder(Player));
                }, Game.PlayerList[0]);
            }
        });
    }
Пример #29
0
    public PBlockTriggerInstaller() : base("格子的停留结算")
    {
        TriggerList.Add(new PTrigger("初始化结算阶段购买土地或房屋的次数")
        {
            IsLocked = true,
            Time     = PPeriod.SettleStage.Before,
            Effect   = (PGame Game) => {
                Game.TagManager.CreateTag(new PPurchaseTag(1, 0));
            }
        });
        TriggerList.Add(new PTrigger("清除结算阶段购买土地或房屋的次数")
        {
            IsLocked = true,
            Time     = PPeriod.SettleStage.After,
            Effect   = (PGame Game) => {
                Game.TagManager.PopTag <PPurchaseTag>(PPurchaseTag.TagName);
            }
        });
        TriggerList.Add(new PTrigger("奖励点(固定数额)")
        {
            IsLocked  = true,
            Time      = PPeriod.SettleStage.During,
            Condition = (PGame Game) => {
                return(Game.NowPlayer.Position.GetMoneyStopSolid > 0);
            },
            Effect = (PGame Game) => {
                Game.GetMoney(Game.NowPlayer, Game.NowPlayer.Position.GetMoneyStopSolid);
            }
        });
        TriggerList.Add(new PTrigger("奖励点(百分比)")
        {
            IsLocked  = true,
            Time      = PPeriod.SettleStage.During,
            Condition = (PGame Game) => {
                return(Game.NowPlayer.Position.GetMoneyStopPercent > 0);
            },
            Effect = (PGame Game) => {
                Game.GetMoney(Game.NowPlayer, PMath.Percent(Game.NowPlayer.Money, Game.NowPlayer.Position.GetMoneyStopPercent));
            }
        });
        TriggerList.Add(new PTrigger("天灾(固定数额)")
        {
            IsLocked  = true,
            Time      = PPeriod.SettleStage.During,
            Condition = (PGame Game) => {
                return(Game.NowPlayer.Position.GetMoneyStopSolid < 0);
            },
            Effect = (PGame Game) => {
                Game.Injure(null, Game.NowPlayer, -Game.NowPlayer.Position.GetMoneyStopSolid, null);
            }
        });
        TriggerList.Add(new PTrigger("天灾(百分比)")
        {
            IsLocked  = true,
            Time      = PPeriod.SettleStage.During,
            Condition = (PGame Game) => {
                return(Game.NowPlayer.Position.GetMoneyStopPercent < 0);
            },
            Effect = (PGame Game) => {
                Game.Injure(null, Game.NowPlayer, PMath.Percent(Game.NowPlayer.Money, -Game.NowPlayer.Position.GetMoneyStopPercent), null);
            }
        });
        TriggerList.Add(new PTrigger("牌库")
        {
            IsLocked  = true,
            Time      = PPeriod.SettleStage.During,
            Condition = (PGame Game) => {
                return(Game.NowPlayer.Position.GetCardStop > 0);
            },
            Effect = (PGame Game) => {
                Game.GetCard(Game.NowPlayer, Game.NowPlayer.Position.GetCardStop);
            }
        });
        MultiPlayerTriggerList.Add((PPlayer Player) => new PTrigger("购买土地")
        {
            IsLocked  = false,
            Player    = Player,
            Time      = PPeriod.SettleStage.During,
            Condition = (PGame Game) => {
                PBlock NowBlock          = Game.NowPlayer.Position;
                PPurchaseTag PurchaseTag = Game.TagManager.FindPeekTag <PPurchaseTag>(PPurchaseTag.TagName);
                return(Game.NowPlayer.Equals(Player) && NowBlock.CanPurchase && NowBlock.Lord == null && PurchaseTag.Count < PurchaseTag.Limit && NowBlock.Price < Game.NowPlayer.Money);
            },
            Effect = (PGame Game) => {
                Game.TagManager.FindPeekTag <PPurchaseTag>(PPurchaseTag.TagName).Count++;
                Game.PurchaseLand(Game.NowPlayer, Game.NowPlayer.Position);
            }
        });
        MultiPlayerTriggerList.Add((PPlayer Player) => new PTrigger("购买房屋")
        {
            IsLocked  = false,
            Player    = Player,
            Time      = PPeriod.SettleStage.During,
            CanRepeat = true,
            Condition = (PGame Game) => {
                PBlock NowBlock          = Game.NowPlayer.Position;
                PPurchaseTag PurchaseTag = Game.TagManager.FindPeekTag <PPurchaseTag>(PPurchaseTag.TagName);
                return(Game.NowPlayer.Equals(Player) && Game.NowPlayer.Equals(NowBlock.Lord) && PurchaseTag.Count < PurchaseTag.Limit && NowBlock.HousePrice < Game.NowPlayer.Money);
            },
            AICondition = (PGame Game) => {
                PBlock NowBlock          = Game.NowPlayer.Position;
                PPurchaseTag PurchaseTag = Game.TagManager.FindPeekTag <PPurchaseTag>(PPurchaseTag.TagName);

                /*
                 * AI的买房策略:
                 * 第1次:必买
                 * 第2次:钱多于20000 or 钱多于10000且地价高于2000
                 * 以上:钱多于15000且地价多于3000 or 钱多于10000且为购物中心
                 *
                 * 必买:公园 or 破军歌姬
                 * 必不买:廉颇 or 无房被兵
                 *
                 * 赵云:2000次数上限为3,1000无限建
                 */
                if (NowBlock.BusinessType.Equals(PBusinessType.Park))
                {
                    return(true);
                }
                if (Player.General is P_Gabriel && Game.AlivePlayersExist <P_IzayoiMiku>())
                {
                    return(true);
                }
                if (Player.General is P_LianPo)
                {
                    return(false);
                }
                if (Player.Area.AmbushCardArea.CardList.Exists((PCard Card) => Card.Model is P_PingLiangTsuunTuan) && !Player.HasHouse)
                {
                    return(false);
                }
                if (PurchaseTag.Count == 0)
                {
                    return(true);
                }
                if (PurchaseTag.Count == 1)
                {
                    if (Player.Money >= 20000)
                    {
                        return(true);
                    }
                    else if (Player.Money >= 10000 && NowBlock.Price >= 2000)
                    {
                        return(true);
                    }
                }
                if (Player.Money >= 15000 && NowBlock.Price >= 3000)
                {
                    return(true);
                }
                if (Player.Money >= 10000 && (NowBlock.BusinessType.Equals(PBusinessType.ShoppingCenter) || NowBlock.BusinessType.Equals(PBusinessType.Club)))
                {
                    return(true);
                }
                if (Player.General is P_ZhaoYun)
                {
                    if (Player.Money >= 5000 && NowBlock.Price < 3000 && PurchaseTag.Count <= 2)
                    {
                        return(true);
                    }
                    if (Player.Money >= 2000 && NowBlock.Price < 2000)
                    {
                        return(true);
                    }
                }
                return(false);
            },
            Effect = (PGame Game) => {
                Game.TagManager.FindPeekTag <PPurchaseTag>(PPurchaseTag.TagName).Count++;
                Game.PurchaseHouse(Game.NowPlayer, Game.NowPlayer.Position);
            }
        });
        MultiPlayerTriggerList.Add((PPlayer Player) => new PTrigger("研究所[视察研究成果]")
        {
            Player    = Player,
            Time      = PPeriod.SettleStage.During,
            Condition = (PGame Game) => {
                PBlock NowBlock = Game.NowPlayer.Position;
                return(Player.Equals(NowBlock.Lord) && NowBlock.BusinessType.Equals(PBusinessType.Institute));
            },
            AICondition = (PGame Game) => {
                return(Player.TeamIndex == Game.NowPlayer.TeamIndex);
            },
            Effect = (PGame Game) => {
                int Number = PMath.RandInt(2, 7) / 2;
                Game.GetCard(Game.NowPlayer, Number);
            }
        });
        MultiPlayerTriggerList.Add((PPlayer Player) => new PTrigger("当铺[典当手牌]")
        {
            Player    = Player,
            Time      = PPeriod.SettleStage.During,
            Condition = (PGame Game) => {
                PBlock NowBlock = Game.NowPlayer.Position;
                return(Game.NowPlayer.Equals(Player) && NowBlock.Lord != null && Player.Area.HandCardArea.CardNumber > 0 && NowBlock.BusinessType.Equals(PBusinessType.Pawnshop));
            },
            AICondition = (PGame Game) => {
                return(Game.NowPlayer.TeamIndex == Game.NowPlayer.Position.Lord.TeamIndex || PAiCardExpectation.FindLeastValuable(Game, Player, Player, true, false, false, true).Value < 750);
            },
            Effect = (PGame Game) => {
                Game.GiveCardTo(Game.NowPlayer, Game.NowPlayer.Position.Lord, true, false);
                Game.GetMoney(Game.NowPlayer, 2000);
            }
        });
        TriggerList.Add(new PTrigger("公园[扩建政府补助]")
        {
            IsLocked  = true,
            Time      = PTime.PurchaseHouseTime,
            Condition = (PGame Game) => {
                return(Game.TagManager.FindPeekTag <PPurchaseHouseTag>(PPurchaseHouseTag.TagName).Block.BusinessType.Equals(PBusinessType.Park));
            },
            Effect = (PGame Game) => {
                PPurchaseHouseTag PurchaseHouseTag = Game.TagManager.FindPeekTag <PPurchaseHouseTag>(PPurchaseHouseTag.TagName);
                Game.GetMoney(PurchaseHouseTag.Player, PMath.Percent(PurchaseHouseTag.Block.Price, 10));
            }
        });
        MultiPlayerTriggerList.Add((PPlayer Player) => new PTrigger("收取过路费")
        {
            Player    = Player,
            Time      = PPeriod.SettleStage.During,
            Condition = (PGame Game) => {
                return(!Game.NowPlayer.Equals(Player) && Player.Equals(Game.NowPlayer.Position.Lord));
            },
            AICondition = (PGame Game) => {
                if ((Game.NowPlayer.General is P_PanYue || Game.NowPlayer.General is P_ChenSheng) && Game.NowPlayer.TeamIndex == Player.TeamIndex)
                {
                    // 给闲居和起义让路
                    return(false);
                }
                return(PAiTargetChooser.InjureExpect(Game, Player, Player, Game.NowPlayer, Game.NowPlayer.Position.Toll, Game.NowPlayer.Position) > 0);
            },
            Effect = (PGame Game) => {
                Game.Toll(Player, Game.NowPlayer, Game.NowPlayer.Position);
            }
        });
    }
 public PBlockPassTriggerInstaller() : base("格子的经过结算")
 {
     TriggerList.Add(new PTrigger("经过奖励点(固定数额)")
     {
         IsLocked  = true,
         Time      = PTime.PassBlockTime,
         Condition = (PGame Game) => {
             return(Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Block.GetMoneyPassSolid > 0);
         },
         Effect = (PGame Game) => {
             Game.GetMoney(Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Player, Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Block.GetMoneyPassSolid);
         }
     });
     TriggerList.Add(new PTrigger("经过奖励点(百分比)")
     {
         IsLocked  = true,
         Time      = PTime.PassBlockTime,
         Condition = (PGame Game) => {
             return(Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Block.GetMoneyPassPercent > 0);
         },
         Effect = (PGame Game) => {
             Game.GetMoney(Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Player, PMath.Percent(Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Player.Money, Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Block.GetMoneyPassPercent));
         }
     });
     TriggerList.Add(new PTrigger("经过天灾(固定数额)")
     {
         IsLocked  = true,
         Time      = PTime.PassBlockTime,
         Condition = (PGame Game) => {
             return(Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Block.GetMoneyPassSolid < 0);
         },
         Effect = (PGame Game) => {
             Game.Injure(null, Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Player, -Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Block.GetMoneyPassSolid, null);
         }
     });
     TriggerList.Add(new PTrigger("经过天灾(百分比)")
     {
         IsLocked  = true,
         Time      = PTime.PassBlockTime,
         Condition = (PGame Game) => {
             return(Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Block.GetMoneyPassPercent < 0);
         },
         Effect = (PGame Game) => {
             Game.Injure(null, Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Player, PMath.Percent(Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Player.Money, -Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Block.GetMoneyPassPercent), null);
         }
     });
     MultiPlayerTriggerList.Add((PPlayer Player) => new PTrigger("经过祭坛[献祭]")
     {
         Player    = Player,
         Time      = PTime.PassBlockTime,
         Condition = (PGame Game) => {
             PPassBlockTag PassBlockTag = Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName);
             return(Player.Equals(PassBlockTag.Block.Lord) && PassBlockTag.Block.BusinessType.Equals(PBusinessType.Altar));
         },
         AICondition = (PGame Game) => {
             PPassBlockTag PassBlockTag = Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName);
             return(Player.TeamIndex != PassBlockTag.Player.TeamIndex);
         },
         Effect = (PGame Game) => {
             PPassBlockTag PassBlockTag = Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName);
             Game.LoseMoney(PassBlockTag.Player, 1000);
         }
     });
     TriggerList.Add(new PTrigger("牌库")
     {
         IsLocked  = true,
         Time      = PTime.PassBlockTime,
         Condition = (PGame Game) => {
             return(Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Block.GetCardPass > 0);
         },
         Effect = (PGame Game) => {
             Game.GetCard(Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Player, Game.TagManager.FindPeekTag <PPassBlockTag>(PPassBlockTag.TagName).Block.GetCardPass);
         }
     });
 }