Example #1
0
        public void AtestCardStaticFunctions()
        {
            List <eCardId> allIds = new List <eCardId>((eCardId[])System.Enum.GetValues(typeof(eCardId)));

            allIds.Remove(eCardId.none);
            int i = 0;

            foreach (eCardId id in allIds)
            {
                ++i;
                eCardValue   value   = Card.GetValueOf(id);
                eCardFaction faction = Card.GetFactionOf(id);
                eCardId      testId  = Card.GetIdOf(value, faction);
                eCardColor   color   = Card.GetColorOf(id);
                Assert.That(id, Is.EqualTo(testId), "wanted id doesn't match faction and value");
                if (faction == eCardFaction.club || faction == eCardFaction.spade) //pique ou trèfle
                {
                    Assert.That(color, Is.EqualTo(eCardColor.black), "club or spade should be black");
                }
                else if (faction == eCardFaction.diamond || faction == eCardFaction.heart)
                {
                    Assert.That(color, Is.EqualTo(eCardColor.red), "diamond or heart should be red");
                }
                else if (faction == eCardFaction.none)
                {
                    Assert.That(color, Is.EqualTo(eCardColor.none), "\"none\" faction should be color \"none\"");
                }
            }
            Debug.Log(i + " cards tested");
            Assert.That(i, Is.EqualTo(53), "wrong size of cardId");
        }
Example #2
0
    public static List <eCardId> GetDeckList(eDeckType type, eCardFaction faction)
    {
        List <eCardId> lst = GetDeckList(type);

        lst.RemoveAll(x => Card.GetFactionOf(x) != faction);
        return(lst);
    }
Example #3
0
        private void TestCard(Card card, eCardValue wantedValue, eCardFaction wantedfaction, string msg)
        {
            eCardId    wantedId = Card.GetIdOf(wantedValue, wantedfaction);
            eCardColor color    = Card.GetColorOf(wantedfaction);

            Assert.That(card.cardId, Is.EqualTo(wantedId), msg);
            Assert.That(card.cardValue, Is.EqualTo(wantedValue), msg);
            Assert.That(card.color, Is.EqualTo(color), msg);
            Assert.That(card.faction, Is.EqualTo(wantedfaction), msg);
        }
Example #4
0
        private void TestCard(Card card, eCardId wantedId, string msg)
        {
            eCardValue   value   = Card.GetValueOf(wantedId);
            eCardColor   color   = Card.GetColorOf(wantedId);
            eCardFaction faction = Card.GetFactionOf(wantedId);

            Assert.That(card.cardId, Is.EqualTo(wantedId), msg);
            Assert.That(card.cardValue, Is.EqualTo(value), msg);
            Assert.That(card.color, Is.EqualTo(color), msg);
            Assert.That(card.faction, Is.EqualTo(faction), msg);
        }
Example #5
0
 public static eCardColor GetColorOf(eCardFaction faction)
 {
     if (faction == eCardFaction.all)
     {
         return(eCardColor.all);
     }
     if ((((uint)faction) & ((uint)3 << 28)) != 0)
     {
         return(eCardColor.black);    //if one of the two first color bit == 1 its black
     }
     if ((((uint)faction) & ((uint)3 << 30)) != 0)
     {
         return(eCardColor.red);      //if one of the two last color bi
     }
     return(eCardColor.none);
 }
    private void AddArrayToDictionnary(ref Sprite[] array, eCardFaction faction)
    {
        List <eCardId> lst = Deck.GetDeckList(deckType, faction);

        lst.Sort();
        Debug.Log(faction);
        Debug.Log("lst size = " + lst.Count);
        Debug.Log("Array Size  = " + array.Length);
        if (lst.Count == 0)
        {
            Debug.Log("ERROR : " + faction + " lst = 0"); return;
        }
        for (int i = array.Length - 1; i >= 0; --i)
        {
            set.Add(lst[i], array[i]);
        }
    }
Example #7
0
 public Card(eCardValue value, eCardFaction faction)
 {
     cardId = (eCardId)((uint)value | (uint)faction);
 }
Example #8
0
 public static eCardId GetIdOf(eCardValue value, eCardFaction faction)
 {
     return((eCardId)((uint)faction | (uint)value));
 }