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"); }
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); }
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); }
public static eCardColor GetColorOf(eCardId id) { if (id == eCardId.joker) { return(eCardColor.all); } if ((((uint)id) & ((uint)3 << 28)) != 0) { return(eCardColor.black); //if one of the two first color bit == 1 its black } if ((((uint)id) & ((uint)3 << 30)) != 0) { return(eCardColor.red); //if one of the two last color bit == 1 its red } return(eCardColor.none); }
public static eCardFaction GetFactionOf(eCardId id) { return((eCardFaction)((uint)id & (uint)eCardFaction.all)); }
public static eCardValue GetValueOf(eCardId id) { return((eCardValue)(((uint)id << 4) >> 4)); }
public Sprite sprite; //{ get; protected set; } public Card(eCardId id) { cardId = id; //sprite = cardSet.set[id]; }