コード例 #1
0
ファイル: Card.cs プロジェクト: thepeoplescoder/csharp-cards
        //
        // Constructors
        //
        // A card with an owner
        public Card(SuitType suit, SpotType spot, object owner)
        {
            // Force a joker if one is requested.
            if (suit == SuitType.Joker)                 // Little
            {
                spot = SpotType.Joker;
            }
            else if (spot == SpotType.Joker)
            {
                suit = SuitType.Joker;
            }

            else if (suit == SuitType.BigJoker)         // Big
            {
                spot = SpotType.BigJoker;
            }
            else if (spot == SpotType.BigJoker)
            {
                suit = SuitType.BigJoker;
            }

            // Initalize the fields
            Suit = suit;
            Spot = spot;
            Owner = owner;
        }
コード例 #2
0
 public Suit(int suitIndex, int suitVal)        //specific Suit and Rank Value
 {
     mySuit  = ((SuitType)suitIndex);
     sName   = mySuit.ToString();
     sValue  = suitVal;
     sSymbol = InitSymbol();
 }
コード例 #3
0
 public Card(int cardIndex)
 {
     CardIndex = cardIndex;
     Suit = (SuitType)((cardIndex % 52) / 13);
     Value = ((cardIndex % 52) % 13) + 2;
     
 }
コード例 #4
0
 public Card(string value, SuitType suit, int rank = 0)
 {
     Value = value;
     Suit  = suit;
     Rank  = rank;
     _key  = value + Enum.GetName(typeof(SuitType), suit) + rank.ToString();
 }
コード例 #5
0
ファイル: Netman.cs プロジェクト: gbdu/chess3
        private void server()
        {
            Server.Connect(serverEndPoint);
            string   info = Read(Server);
            SuitType st   = ParseSuit(info);

            resources.mf.Start(st);

            string res = "";
            string prefix;
            string cmd;

            while (res != "terminate")
            {
                res    = Read(Server);
                prefix = res.Substring(0, 3);
                cmd    = res.Substring(3);

                switch (prefix)
                {
                case "up:":     // The other player made a move, update our grid
                    Command_up(cmd);
                    break;
                }
            }
        }
コード例 #6
0
        public Card(int i, SuitType suit)
        {
            _faceValue = i;
            Suit       = suit;
            switch (suit)
            {
            case SuitType.Spades:
                imageSourceString = $@"/images/card deck/{i}-spades.png";
                break;

            case SuitType.Hearts:
                imageSourceString = $@"/images/card deck/{i}-hearts.png";
                break;

            case SuitType.Diamonds:
                imageSourceString = $@"/images/card deck/{i}-diamonds.png";
                break;

            case SuitType.Clubs:
                imageSourceString = $@"/images/card deck/{i}-clubs.png";
                break;

            default:

                imageSourceString = $@"/images/card deck/joker-1.png";
                break;
            }
        }
コード例 #7
0
 public Suit(int suitIndex)        //specific suit with default suit rank C>D>H>S
 {
     mySuit = ((SuitType)suitIndex);
     sName  = mySuit.ToString();
     //	sValue = (int)mySuit;
     sSymbol = InitSymbol();
 }
コード例 #8
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            GUILayout.Space(15);

            serializedObject.Update();
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Initialize"))
            {
                RankType rank = (RankType)serializedObject.FindProperty("rankType").enumValueIndex;
                SuitType suit = (SuitType)serializedObject.FindProperty("suitType").enumValueIndex;
                Undo.RecordObject(peakCard, "Initialize");
                peakCard.Initialize(suit, rank);
                EditorUtility.SetDirty(peakCard);
            }
            if (GUILayout.Button("Set Color"))
            {
                Color tint = serializedObject.FindProperty("tint").colorValue;
                Undo.RecordObject(peakCard, "Set Color");
                peakCard.SetColor(tint);
                EditorUtility.SetDirty(peakCard);
            }
            if (GUILayout.Button("Evaluate Atlas"))
            {
                string atlas = serializedObject.FindProperty("textureAtlas").stringValue;
                Undo.RecordObject(peakCard, "Evaluate Atlas");
                peakCard.EvaluateAtlas(atlas);
                EditorUtility.SetDirty(peakCard);
            }
            EditorGUILayout.EndHorizontal();
            serializedObject.ApplyModifiedProperties();
        }
コード例 #9
0
    // Picking out Meld ( Sequence or Triplets) 3 tiles at a time
    private bool TryMarkAsSequence(SuitType suit, int rank)
    {
        if (rank >= 8)
        {
            return(false);
        }

        if (suit != SuitType.Bams && suit != SuitType.Chars && suit != SuitType.Chars)
        {
            return(false);
        }

        bool found = true;

        for (int i = 0; i <= 2; i++)
        {
            if (!MarkTileAsCheck(suit, rank + i, true))
            {
                found = false;
            }
        }

        if (!found)
        {
            return(false);
        }
        else
        {
            MarkTileAsCheck(suit, rank);
            MarkTileAsCheck(suit, rank + 1);
            MarkTileAsCheck(suit, rank + 2);
            return(true);
        }
    }
コード例 #10
0
        public void Start(SuitType PlayerType)
        {
            started    = true;
            PlayerSuit = PlayerType;

            Invalidate();
        }
コード例 #11
0
        private static Card GetRandomCard()
        {
            RankType rank = (RankType)cardRanks.GetValue(random.Next(cardRanks.Length));
            SuitType suit = (SuitType)cardSuits.GetValue(random.Next(cardSuits.Length));

            return(new Card(rank, suit));;
        }
コード例 #12
0
    // Picking out special case such as ( 555 666 777 ) Bugged
    private int TryMarkAsLinkedTriplet(SuitType suit, int rank)
    {
        if (suit == SuitType.Honor)
        {
            if (TryMarkAsTriplet(suit, rank))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }

        int link = 0;

        for (int i = rank; i < 9; i++)
        {
            if (TryMarkAsTriplet(suit, i))
            {
                link++;
            }
            else
            {
                Debug.Log("here " + link);
                return(link);
            }
        }
        return(link);
    }
コード例 #13
0
    public void Init()
    {
        if (rank == 1)
        {
            rankType = RankType.Ace;
        }
        else
        {
            rankType = (RankType)rank;
        }
        switch (suit)
        {
        case "S":
            suitType = SuitType.Spades;
            break;

        case "D":
            suitType = SuitType.Diamonds;
            break;

        case "C":
            suitType = SuitType.Clubs;
            break;

        case "H":
            suitType = SuitType.Hearts;
            break;

        default:
            break;
        }
    }
コード例 #14
0
        //
        // Constructors
        //

        // A card with an owner
        public Card(SuitType suit, SpotType spot, object owner)
        {
            // Force a joker if one is requested.
            if (suit == SuitType.Joker)                 // Little
            {
                spot = SpotType.Joker;
            }
            else if (spot == SpotType.Joker)
            {
                suit = SuitType.Joker;
            }

            else if (suit == SuitType.BigJoker)         // Big
            {
                spot = SpotType.BigJoker;
            }
            else if (spot == SpotType.BigJoker)
            {
                suit = SuitType.BigJoker;
            }

            // Initalize the fields
            Suit  = suit;
            Spot  = spot;
            Owner = owner;
        }
コード例 #15
0
 public Card(CardNumber number, SuitType suit)
 {
     Number = number;
     Suit   = suit;
     LoadCard();
     AccelerateTowardsOrigin = false;
 }
コード例 #16
0
        // A static method to make a joker
        public static Card NewJoker(JokerType jokerType, object owner)
        {
            SuitType s = (jokerType == JokerType.Big) ? SuitType.BigJoker : SuitType.Joker;

            // Allow the constructor to force the proper type.
            return(new Card(s, SpotType.Two, owner));
        }
コード例 #17
0
    // Sorting the winning combination a tile at a time
    private bool MarkTileAsCheck(SuitType suit, int rank, bool onlyCheck = false)
    {
        for (int i = 0; i < unCheckedTiles.Count; i++)
        {
            if (unCheckedTiles[i].GetRank() == rank && unCheckedTiles[i].GetSuitType() == suit)
            {
                if (!onlyCheck)
                {
                    Tiles tile = unCheckedTiles[i];
                    unCheckedTiles.RemoveAt(i);
                    checkedTiles.Add(tile);

                    unCheckedNumberOfRanksInSuit[(int)suit, rank]--;
                    if (unCheckedNumberOfRanksInSuit[(int)suit, rank] < 0)
                    {
                        Debug.Log("Error in unchecked list");
                    }
                }
                return(true);
            }
        }

        if (!onlyCheck)
        {
            Debug.Log("Error : Tiles Not Found");
        }

        return(false);
    }
コード例 #18
0
 /// <summary>
 /// カードのコピーを作成します。
 /// </summary>
 /// <param name="card">コピー元のカード。</param>
 public Card(Card card)
 {
     suit         = card.suit;
     number       = card.number;
     DeclaredSuit = card.DeclaredSuit;
     Opened       = card.Opened;
 }
コード例 #19
0
ファイル: CardTests.cs プロジェクト: leon-bot-max/Blackjack
        public void TestCardValues(int value, SuitType suit, int blackJackValue)
        {
            Card card = new Card(value, suit);

            Assert.AreEqual(value, card.Value);
            Assert.AreEqual(suit, card.Suit);
            Assert.AreEqual(blackJackValue, card.BlackJackValue);
        }
コード例 #20
0
        public void AndInputIsValidThenCorrectRankAndSuitAreAssigned(
            string value, RankType expectedRank, SuitType expectedSuit)
        {
            var card = CardFactory.CreateCard(value);

            Assert.AreEqual(expectedRank, card.Rank);
            Assert.AreEqual(expectedSuit, card.Suit);
        }
コード例 #21
0
ファイル: Card.cs プロジェクト: BlueBerryBread/sgs_byCsharp
 public Card(SuitType t, int r, CardHandler c)
 {
     Suit       = t;
     Rank       = r;
     Type       = c;
     attributes = null;
     Log        = new UI.ActionLog();
 }
コード例 #22
0
ファイル: CardSuit.cs プロジェクト: hamyul/PlayingCards
        public CardSuit(SuitType type, IPrintMethod printMethod)
        {
            Type         = type;
            Cards        = new List <ICard>();
            _printMethod = printMethod;

            GenerateCards();
        }
コード例 #23
0
ファイル: Card.cs プロジェクト: pxoylngx/sgs
 public Card(SuitType t, int r, CardHandler c)
 {
     Suit = t;
     Rank = r;
     Type = c;
     attributes = null;
     Log = new UI.ActionLog();
 }
コード例 #24
0
ファイル: Card.cs プロジェクト: Gwayaboy/IyeTek.BlackJack
 public Card(CardType cardType, SuitType suitType)
 {
     if (cardType == null)
     {
         throw new ArgumentNullException("cardType", "the card type must be specified");
     }
     _cardType = cardType;
     SuitType = suitType;
 }
コード例 #25
0
ファイル: resources.cs プロジェクト: gbdu/chess3
 static public void InitImages(SuitType player)
 {
     for (int i = (int)RockType.rook; i != (int)RockType.pawn + 1; i++)
     {
         RockType rock = (RockType)i;
         WhiteImages[i] = Image.FromFile("B:\\code\\C#\\Gess\\rocks\\white_" + rock.ToString() + ".gif");
         BlackImages[i] = Image.FromFile("B:\\code\\C#\\Gess\\rocks\\black_" + rock.ToString() + ".gif");
     }
 }
コード例 #26
0
        //

        public static Card ToCard(String msg)
        {
            String     suitString   = msg.Substring(0, msg.IndexOf(','));
            String     numberString = msg.Substring(msg.IndexOf(',') + 1);
            SuitType   suit         = (SuitType)Int32.Parse(suitString);
            CardNumber number       = (CardNumber)Int32.Parse(numberString);

            return(new Card(number, suit));
        }
コード例 #27
0
        public Alteration(int customerId, SuitType suitType, ShortenValue rightShortenValue, ShortenValue leftShortenValue)
        {
            CustomerId        = customerId;
            SuitType          = suitType;
            AlterationStatus  = AlterationStatus.Created;
            RightShortenValue = rightShortenValue;
            LeftShortenValue  = leftShortenValue;

            Validate();
        }
コード例 #28
0
        public void Test_IsConnected_HandNotConnected_IsFalse(SuitType leftCardSuit, RankType leftCardRank, SuitType rightCardSuit, RankType rightCardRank)
        {
            Card leftCard  = new Card(leftCardSuit, leftCardRank);
            Card rightCard = new Card(rightCardSuit, rightCardRank);
            Hand hand      = new Hand(leftCard, rightCard);

            bool expected = hand.IsConnected();

            Assert.AreEqual(expected, false);
        }
コード例 #29
0
        public void Test_IsPaired_HandPaired_IsTrue(SuitType leftCardSuit, RankType leftCardRank, SuitType rightCardSuit, RankType rightCardRank)
        {
            Card leftCard  = new Card(leftCardSuit, leftCardRank);
            Card rightCard = new Card(rightCardSuit, rightCardRank);
            Hand hand      = new Hand(leftCard, rightCard);

            bool expected = hand.IsPaired();

            Assert.AreEqual(expected, true);
        }
コード例 #30
0
 private void GenerateNewCards()
 {
     _cards.Clear();
     for (int i = 0; i < 52; i++)
     {
         int      cardValue = i % 13 + 1;
         SuitType cardSuit  = (SuitType)(i % 4);
         _cards.Push(new Card(cardValue, cardSuit));
     }
 }
コード例 #31
0
        public Card(int value, SuitType suit)
        {
            if (value > 14 || value < 1)
            {
                throw new ArgumentException("Invalid value supplied");
            }

            Suit  = suit;
            Value = value;
        }
コード例 #32
0
        public static string Translate(SuitType suitType)
        {
            string key  = string.Format("Suit.{0}.Text", suitType.ToString());
            string name = Application.Current.TryFindResource(key) as string;

            if (name == null)
            {
                return(string.Empty);
            }
            return(name);
        }
コード例 #33
0
 private bool TryMarkAsTriplet(SuitType suit, int rank)
 {
     if (unCheckedNumberOfRanksInSuit[(int)suit, rank] >= 3)
     {
         MarkTileAsCheck(suit, rank);
         MarkTileAsCheck(suit, rank);
         MarkTileAsCheck(suit, rank);
         return(true);
     }
     return(false);
 }
コード例 #34
0
ファイル: ReadOnlyCard.cs プロジェクト: kissgoodbye/sgs
 public ReadOnlyCard(ICard card)
 {
     type = card.Type;
     place = card.Place;
     rank = card.Rank;
     suit = card.Suit;
     owner = card.Owner;
     suitColor = card.SuitColor;
     if (card.Attributes == null)
     {
         attributes = new Dictionary<CardAttribute, int>();
     }
     else
     {
         attributes = new Dictionary<CardAttribute, int>(card.Attributes);
     }
 }
コード例 #35
0
ファイル: Card.cs プロジェクト: thepeoplescoder/csharp-cards
 //
 // Static helper methods
 //
 // IsJokerSuit ////////////////////////////////////
 public static bool IsJokerSuit(SuitType suit)
 {
     return suit == SuitType.BigJoker || suit == SuitType.Joker;
 }
コード例 #36
0
ファイル: HuoGong.cs プロジェクト: kissgoodbye/sgs
 public HuoGongCardMatchVerifier(SuitType s)
 {
     suit = s;
 }
コード例 #37
0
ファイル: Card.cs プロジェクト: marklincoln7/CIS174_CardGame
 public Card(SuitType suit, PipType pip, int imgIdx)
 {
     Suit = suit;
     Pip = pip;
     ImageIndex = imgIdx;
 }
コード例 #38
0
ファイル: Math54.cs プロジェクト: Scott-Caldwell/ProjectEuler
 public void SetSuit(string card)
 {
     switch (card[1])
     {
         case 'D':
             Suit = SuitType.Diamonds;
             break;
         case 'C':
             Suit = SuitType.Clubs;
             break;
         case 'H':
             Suit = SuitType.Hearts;
             break;
         case 'S':
             Suit = SuitType.Spades;
             break;
         default:
             throw new ArgumentException("Invalid card.");
     }
 }
コード例 #39
0
 public static string Translate(SuitType suitType)
 {
     string key = string.Format("Suit.{0}.Text", suitType.ToString());
     string name = Application.Current.TryFindResource(key) as string;
     if (name == null) return string.Empty;
     return name;
 }
コード例 #40
0
 protected void AddFaceCards(SuitType suitType)
 {
     _cards.AddRange(_faceCardTypes.Select(cardType => new Card(cardType, suitType)));
 }
コード例 #41
0
 protected void AddAce(SuitType suitType, int value = 11)
 {
     _cards.Add(new Card(_aceCardType, suitType));
 }
コード例 #42
0
ファイル: PokerCard.cs プロジェクト: kongres/PockerGame
 public PokerCard(SuitType suit, NumberType number)
 {
     Suit = suit;
     Number = number;
 }
コード例 #43
0
 protected void AddNumericalCards(SuitType suitType)
 {
     var numericalCards = _numericalCardTypes.Select(ct => new Card(ct, suitType));
     _cards.AddRange(numericalCards);
 }
コード例 #44
0
ファイル: 6.10.cs プロジェクト: NikitaVas/CSharp
 public Card(short denomination, SuitType suit)
 {
     Denomination = denomination;
     Suit = suit;
 }
コード例 #45
0
 public Card(SuitType suit, int number)
 {
     Suit = suit;
     Number = number;
 }
コード例 #46
0
ファイル: Card.cs プロジェクト: thepeoplescoder/csharp-cards
 // A card with no owner
 public Card(SuitType suit, SpotType spot)
     : this(suit, spot, null)
 {
 }