Ejemplo n.º 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);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void EnumMembers()
 {
     for (byte o = 0; o < Owner.Count; o++)
     {
         var g = new Owner(o);
         foreach (var m in g.EnumMembers())
         {
             Assert.IsTrue(m <= g);
         }
     }
 }
Ejemplo n.º 3
0
 public void EnumGroups()
 {
     for (byte o = 0; o < Owner.Count; o++)
     {
         var m = new Owner(o);
         foreach (var g in m.EnumGroups())
         {
             Assert.IsTrue(m <= g);
         }
     }
 }
Ejemplo n.º 4
0
 public void ViewReceive(Player viewer, Owner owner, params Card[] cards)
 {
     ViewReceive(viewer, owner, (IEnumerable<Card>) cards);
 }
Ejemplo n.º 5
0
 public override void ViewDoesntHave(Player viewer, Owner owner, Card card)
 {
     var newOwner = _viewCards[viewer, card] - owner;
     ViewHas(viewer, newOwner, card);
 }
Ejemplo n.º 6
0
 public void ViewReceive(Player viewer, Owner owner, IEnumerable<Card> cards)
 {
     foreach (var card in cards)
     {
         if (!(_viewCards[viewer, card] >= owner))
         {
             throw new InvalidOperationException("card already received by " + _viewCards[viewer, card]);
         }
         ViewHas(viewer, owner, card);
     }
 }
Ejemplo n.º 7
0
 public virtual void ViewHas(Player viewer, Owner newOwner, Card card)
 {
 }
Ejemplo n.º 8
0
 public virtual void ViewDoesntHave(Player viewer, Owner owner, Card card)
 {
 }
Ejemplo n.º 9
0
 public bool Equals(Owner other)
 {
     return _owner == other._owner;
 }