Пример #1
0
        public int GetBestCardPlay(TurnState turnState, ref Queue <CardPlay> cardPlays, int maxScore)
        {
            var bestCardPlays = new Queue <CardPlay>(cardPlays);

            foreach (var card in turnState.RemaingHand)
            {
                var sources = turnState.OwnedMingmings.Where(m => card.CanUseCard(m));

                foreach (var source in sources)
                {
                    var sourceMingming = turnState.GetMingming(source);
                    var allTargets     = turnState.AllTargets.Where(t => card.IsValidTarget(sourceMingming, turnState.GetMingming(t)));

                    foreach (var target in allTargets)
                    {
                        var _turnState = turnState.Clone();
                        var cardplay   = new CardPlay
                        {
                            Card   = card,
                            Source = turnState.GetMingming(source),
                            Target = turnState.GetMingming(target)
                        };

                        var score = _turnState.ApplyCardPlay(cardplay);

                        var _cardPlays = new Queue <CardPlay>(cardPlays);
                        _cardPlays.Enqueue(cardplay);

                        //want to get the final score
                        if (_turnState.HasUsableCards())
                        {
                            score = GetBestCardPlay(_turnState, ref _cardPlays, score);
                        }

                        if (score > maxScore)
                        {
                            bestCardPlays = _cardPlays;
                            maxScore      = score;
                        }
                    }
                }
            }

            cardPlays = bestCardPlays;
            return(maxScore);
        }
Пример #2
0
        public int ApplyCardPlay(CardPlay cardplay)
        {
            var source = OwnedMingmings.First(m => m.Id == cardplay.Source.GetInstanceID());
            var target = AllTargets.First(m => m.Id == cardplay.Target.GetInstanceID());

            var actions = cardplay.Card.InvokeActions(source, target);

            while (actions.MoveNext())
            {
                var test = actions.Current;
            }

            var score = GetScore() + cardplay.Card.GetCardScore();

            RemaingHand.Remove(cardplay.Card);

            return(score);
        }