示例#1
0
        public override void ViewHas(Player viewer, Owner newOwner, Card card)
        {
            var originalOwner = _viewCards[viewer, card];
            if (newOwner < originalOwner)
            {
                if (!(_cardOwners[card] <= newOwner))
                {
                    throw new InvalidOperationException($"View: {viewer} Card: {card} Owner:{_cardOwners[card]} Mistake:{newOwner}");
                }
                var newOwnerCount = _viewCount[viewer, newOwner] + 1;

                _viewCards[viewer, card] = newOwner;
                _viewCount[viewer, newOwner] = newOwnerCount;

                if (newOwner.MaxCount() == newOwnerCount)
                {
                    foreach (var c in Card.AllCards)
                    {
                        var co = _viewCards[viewer, c];
                        if (co > newOwner)
                        {
                            var nco = co - newOwner;
                            if (nco != co)
                            {
                                ViewHas(viewer, nco, c);
                            }
                        }
                    }
                }
            }
        }