예제 #1
0
        public override void Dispose()
        {
            if (this.IsDisposed)
            {
                return;
            }

            base.Dispose();

            Cards.Clear();
            analysis.Clear();
            _isReprompt      = true;
            this.PromptIndex = -1;
        }
예제 #2
0
        private void Test(PromptTestConfig config, CardPromptAnalysis analysis)
        {
            List <Card> target     = new List <Card>();
            CardType    targetType = (CardType)Enum.Parse(typeof(CardType), config.TargetType);
            List <Card> handCards  = new List <Card>();

            CardTestHelper.Create(config.Cards, handCards);
            CardTestHelper.Create(config.Target, target);

            int result = config.Result;

            // 添加提示管道
            analysis.Clear();
            var handlersStr = config.Handles.Split(',');
            var assembly    = analysis.GetType().Assembly;

            foreach (string s in handlersStr)
            {
                Type type = assembly.GetType($"Bomb.CardPrompt.{s}Analyzer");
                analysis.AddLast((IAnalyzer)Activator.CreateInstance(type));
            }

            analysis.Run(handCards, target, targetType);

            // 提示结果数量不对
            Assert.AreEqual(analysis.PrompCardsList.Count, result);

            if (!string.IsNullOrEmpty(config.Prompt))
            {
                string[] groups = config.Prompt.Split('|');

                for (int i = 0; i < analysis.PrompCardsList.Count; i++)
                {
                    var         p    = analysis.PrompCardsList[i];
                    List <Card> temp = new List <Card>();
                    CardTestHelper.Create(groups[i], temp);

                    // 提示目标里面一组提示不对
                    Assert.AreEqual(p.Cards.Count, temp.Count);

                    for (int j = 0; j < p.Cards.Count; j++)
                    {
                        Assert.AreEqual(p.Cards[j].Weight, temp[j].Weight);
                    }
                }
            }
        }