Пример #1
0
        public void MovePiece(RankEnum rankFrom, FileEnum fileFrom, RankEnum rankTo, FileEnum fileTo)
        {
            Pieces piece = GetPiece(rankFrom, fileFrom);

            SetPiece(rankFrom, fileFrom, Pieces.NONE);
            SetPiece(rankTo, fileTo, piece);
        }
Пример #2
0
        public StartingHand(StartingHandTypeEnum type, RankEnum rank1, RankEnum rank2)
        {
            Type  = type;
            Rank1 = rank1;
            Rank2 = rank2;

            switch (Type)
            {
            case StartingHandTypeEnum.Pair:
                Count = 6;
                Name  = GetNameForPair(this);
                break;

            case StartingHandTypeEnum.Suited:
            case StartingHandTypeEnum.AceXSuited:
                Count = 4;
                Name  = GetNameForSutied(this);
                break;

            case StartingHandTypeEnum.OffSuit:
            case StartingHandTypeEnum.AceXOffsuit:
                Count = 16;
                Name  = GetNameForOffSuit(this);
                break;

            default:
                throw new InvalidOperationException();
            }
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Session" /> class.
 /// </summary>
 /// <param name="Id">Id (required).</param>
 /// <param name="Rank">Rank (required).</param>
 /// <param name="Level">Level (required).</param>
 public Session(Guid?Id = default(Guid?), RankEnum Rank = default(RankEnum), int?Level = default(int?))
 {
     // to ensure "Id" is required (not null)
     if (Id == default(Guid?))
     {
         throw new InvalidDataException("Id is a required property for Session and cannot be null");
     }
     else
     {
         this.Id = Id;
     }
     // to ensure "Rank" is required (not null)
     if (Rank == default(RankEnum))
     {
         throw new InvalidDataException("Rank is a required property for Session and cannot be null");
     }
     else
     {
         this.Rank = Rank;
     }
     // to ensure "Level" is required (not null)
     if (Level == default(int?))
     {
         throw new InvalidDataException("Level is a required property for Session and cannot be null");
     }
     else
     {
         this.Level = Level;
     }
 }
Пример #4
0
 public Card(SuitEnum cardSuit, RankEnum cardRank)
 {
     CardSuit  = cardSuit;
     CardRank  = cardRank;
     CardName  = CardSuit + " " + CardRank;
     CardValue = GetCardValue();
 }
Пример #5
0
        /// <summary>
        /// Builds a Rank object for a given Enum
        /// </summary>
        /// <param name="rankEnum">The Rank Enum to generate the rank for</param>
        /// <returns><see cref="IRank"/></returns>
        public IRank GetRank(RankEnum rankEnum)
        {
            switch (rankEnum)
            {
            case RankEnum.Nine:
                return(new Rank(rankEnum, "9"));

            case RankEnum.Ten:
                return(new Rank(rankEnum, "10"));

            case RankEnum.Jack:
                return(new Rank(rankEnum, "J"));

            case RankEnum.Queen:
                return(new Rank(rankEnum, "Q"));

            case RankEnum.King:
                return(new Rank(rankEnum, "K"));

            case RankEnum.Ace:
                return(new Rank(rankEnum, "A"));

            default:
                return(null);
            }
        }
Пример #6
0
 public OnePair(RankEnum pairRank, RankEnum kicker1, RankEnum kicker2, RankEnum kicker3)
 {
     PairRank = pairRank;
     Kicker1  = kicker1;
     Kicker2  = kicker2;
     Kicker3  = kicker3;
 }
Пример #7
0
        public void GetRank_RankWithCorrectStringGenerated(RankEnum rank, string expectedChar)
        {
            var factory = ConstructFactory();

            var s = factory.GetRank(rank).ToString();

            Assert.Equal(expectedChar, s);
        }
Пример #8
0
 public Flush(RankEnum card1, RankEnum card2, RankEnum card3, RankEnum card4, RankEnum card5)
 {
     Card1 = card1;
     Card2 = card2;
     Card3 = card3;
     Card4 = card4;
     Card5 = card5;
 }
 public static LeaderBoard GetLeaderBoard(RankEnum type = RankEnum.Level, EndlessMode mode = EndlessMode.Default)
 {
     if (type == RankEnum.Level)
     {
         mode = EndlessMode.Default;
     }
     return(leaderBoards[new Tuple <RankEnum, EndlessMode>(type, mode)]);
 }
Пример #10
0
 public HighCard(RankEnum card1, RankEnum card2, RankEnum card3, RankEnum card4, RankEnum card5)
 {
     Card1 = card1;
     Card2 = card2;
     Card3 = card3;
     Card4 = card4;
     Card5 = card5;
 }
Пример #11
0
 public void Setup(SuitEnum _suit, RankEnum _rank)
 {
     suit            = _suit;
     rank            = _rank;
     cardName        = "" + rank.ToString() + " of " + suit.ToString();
     gameObject.name = cardName;
     GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Card_Fronts/" + suit.ToString()[0] + (int)rank);
 }
Пример #12
0
        public void SetPiece(RankEnum rank, FileEnum file, Pieces piece)
        {
            DataRow row = GetBoardDataRow(rank, file);

            if (row != null)
            {
                row[Board.Piece] = piece.ToString("d");
            }
        }
Пример #13
0
        public void IRankEqual_RankEnum(RankEnum firstRank, RankEnum secondRank, bool expectedEqual)
        {
            var rank1 = new Rank(firstRank, " ");
            var rank2 = new Rank(secondRank, " ");

            var areEqual = rank1.Equals(rank2);

            Assert.Equal(expectedEqual, areEqual);
        }
Пример #14
0
 public Tuple <int, string> GetEntry(RankEnum rank)
 {
     return(rank switch
     {
         RankEnum.Solo => new Tuple <int, string>(Solo, ""),
         RankEnum.Duo => new Tuple <int, string>(Duo, DuoNames),
         RankEnum.Trio => new Tuple <int, string>(Trio, TrioNames),
         RankEnum.Quad => new Tuple <int, string>(Quad, QuadNames),
         _ => null,
     });
Пример #15
0
 public Room(int id, string name, string password, int maxPlayers, RoomStateEnum state, RankEnum minRank, RoomModeListEnum mode)
 {
     Id         = id;
     Name       = name;
     Password   = password;
     MaxPlayers = maxPlayers;
     State      = state;
     MinRank    = minRank;
     Mode       = mode;
 }
Пример #16
0
        private DataRow GetBoardDataRow(RankEnum rank, FileEnum file)
        {
            DataRow[] rows = BoardData.Select("r=" + rank.ToString("d") + " AND f=" + file.ToString("d"));

            if (rows.Length > 0)
            {
                return(rows[0]);
            }

            return(null);
        }
Пример #17
0
 private NotifyHeroHolesRequest GenerateHeroHolesRequest(Guid roundId, SuitEnum suit1, RankEnum rank1,
                                                         SuitEnum suit2, RankEnum rank2)
 {
     return(new NotifyHeroHolesRequest()
     {
         RoundId = roundId,
         Holes = new List <Card> {
             new Card(suit1, rank1), new Card(suit2, rank2)
         }
     });
 }
Пример #18
0
        /// <summary>
        /// Over-Used
        /// </summary>
        /// <param name="boardRanks"></param>
        /// <param name="playerRanks"></param>
        /// <returns></returns>
        public static Tuple <int, int> FindStraight(this List <RankEnum> boardRanks, List <RankEnum> playerRanks)
        {
            var boardHighRank = boardRanks.Max();
            var ranks         = new List <RankEnum>();

            foreach (var playerRank in playerRanks)
            {
                if (ranks.All(r => r != playerRank))
                {
                    ranks.Add(playerRank);
                }
            }

            ranks.Sort();

            RankEnum highRank = RankEnum.Undefined;
            RankEnum lowRank  = RankEnum.Undefined;

            if (ranks.Count >= 7 && ranks[6] == ranks[2] + 4)
            {
                //23456
                highRank = ranks[6];
                lowRank  = ranks[5];
            }
            else if (ranks.Count >= 6 && ranks[5] == ranks[1] + 4)
            {
                //12345
                highRank = ranks[5];
                lowRank  = ranks[1];
            }
            else if (ranks.Count >= 5 && ranks[4] == ranks[0] + 4)
            {
                //01234
                highRank = ranks[4];
                lowRank  = ranks[0];
            }

            if (highRank != RankEnum.Undefined)
            {
                int used = 5 - boardRanks.Count(r => r >= lowRank && r <= highRank);
                if (highRank == boardHighRank + 2)
                {
                    return(new Tuple <int, int>(2, used));
                }
                if (highRank == boardHighRank + 1)
                {
                    return(new Tuple <int, int>(1, used));
                }
                return(new Tuple <int, int>(0, used));
            }

            return(null);
        }
    /// <summary>
    /// 添加排名数据.
    /// </summary>
    public RankData AddRankDt(RankEnum rankType, bool isPlayer)
    {
        if (rankType == RankEnum.Null)
        {
            UnityEngine.Debug.LogError("AddRankDt -> rankType was wrong!");
            return(null);
        }
        RankData rankDt = new RankData(rankType, isPlayer);

        RankDtList.Add(rankDt);
        return(rankDt);
    }
Пример #20
0
 public User([JsonProperty("Ip", Required = Required.Always)] string ip,
             [JsonProperty("Mail", Required = Required.Always)] string mail,
             [JsonProperty("ProfileName", Required = Required.Always)] string profileName,
             [JsonProperty("Rank", Required = Required.Always)] RankEnum rank,
             [JsonProperty("Xuid", Required = Required.Always)] long xuid)
 {
     Ip          = ip;
     Mail        = mail;
     ProfileName = profileName;
     Xuid        = xuid;
     Rank        = rank;
 }
Пример #21
0
        private void AddBoardRow(string singleNotation, Pieces piece)
        {
            DataRow  dr   = BoardData.NewRow();
            RankEnum rank = GetRank(singleNotation);
            FileEnum file = GetFile(singleNotation);

            dr["r"] = rank.ToString("d");
            dr["f"] = file.ToString("d");
            dr["p"] = piece.ToString("d");

            BoardData.Rows.Add(dr);
        }
Пример #22
0
 public RangeGrid(RankEnum rank1, RankEnum rank2, bool suited)
 {
     HighRank            = rank1 > rank2 ? rank1 : rank2;
     LowRank             = rank1 > rank2 ? rank2 : rank1;
     Category            = suited ? GridCategoryEnum.Suited : rank1 == rank2 ? GridCategoryEnum.Paired : GridCategoryEnum.Offsuit;
     Card1AvaliableSuits = new List <SuitEnum>()
     {
         SuitEnum.Heart, SuitEnum.Spade, SuitEnum.Diamond, SuitEnum.Club
     };
     Card2AvaliableSuits = new List <SuitEnum>()
     {
         SuitEnum.Heart, SuitEnum.Spade, SuitEnum.Diamond, SuitEnum.Club
     };
 }
Пример #23
0
 private NotifyFlopsRequest GenerateFlopsRequest(Guid roundId,
                                                 SuitEnum suit1, RankEnum rank1,
                                                 SuitEnum suit2, RankEnum rank2,
                                                 SuitEnum suit3, RankEnum rank3)
 {
     return(new NotifyFlopsRequest()
     {
         RoundId = roundId,
         Flops = new List <Card>()
         {
             new Card(suit1, rank1),
             new Card(suit2, rank2),
             new Card(suit3, rank3),
         }
     });
 }
Пример #24
0
        public static string GetStringForRank(RankEnum rank)
        {
            switch (rank)
            {
            case RankEnum.Two:
                return("2");

            case RankEnum.Three:
                return("3");

            case RankEnum.Four:
                return("4");

            case RankEnum.Five:
                return("5");

            case RankEnum.Six:
                return("6");

            case RankEnum.Seven:
                return("7");

            case RankEnum.Eight:
                return("8");

            case RankEnum.Nine:
                return("9");

            case RankEnum.Ten:
                return("T");

            case RankEnum.Jack:
                return("J");

            case RankEnum.Queen:
                return("Q");

            case RankEnum.King:
                return("K");

            case RankEnum.Ace:
                return("A");
            }

            throw new NotSupportedException();
        }
Пример #25
0
        private string GetFen()
        {
            string   fen          = string.Empty;
            int      emptySquares = 0;
            Pieces   piece        = Pieces.NONE;
            RankEnum previousRank = RankEnum.NoRank;
            RankEnum rank         = RankEnum.NoRank;

            foreach (DataRow dr in BoardData.Rows)
            {
                piece = (Pieces)BaseItem.GetColInt32(dr, Board.Piece);
                rank  = (RankEnum)BaseItem.GetColInt32(dr, Board.Rank);

                if (rank != previousRank)
                {
                    if (emptySquares > 0)
                    {
                        fen         += emptySquares;
                        emptySquares = 0;
                    }
                    fen         += "/";
                    previousRank = rank;
                }

                if (piece == Pieces.NONE)
                {
                    emptySquares++;
                }
                else
                {
                    if (emptySquares > 0)
                    {
                        fen         += emptySquares;
                        emptySquares = 0;
                    }
                    fen += GetPieceChar(piece);
                }
            }
            if (emptySquares > 0)
            {
                fen         += emptySquares;
                emptySquares = 0;
            }
            fen = RemoveStartingChar(fen, '/');
            return(fen);
        }
Пример #26
0
        public void Compare_AscendingSuitAscendingRank(SuitEnum card1Suit, RankEnum card1Rank, SuitEnum card2Suit,
                                                       RankEnum card2Rank, SuitEnum trumpSuit, int expectedCompareValue)
        {
            var card1 = new Card(
                new Rank(card1Rank, null),
                FromFactory(card1Suit)
                );
            var card2 = new Card(
                new Rank(card2Rank, null),
                FromFactory(card2Suit)
                );

            var comparer   = new TrumpHandSorter(FromFactory(trumpSuit), true, true);
            var comparison = comparer.Compare(card1, card2);

            Assert.Equal(expectedCompareValue, comparison);
        }
        public void Compare_DescendingSuitDescendingRank(SuitEnum card1Suit, RankEnum card1Rank, SuitEnum card2Suit,
                                                         RankEnum card2Rank, int expectedCompareValue)
        {
            var card1 = new Card(
                new Rank(card1Rank, null),
                new Suit(' ', card1Suit, SuitEnum.Unknown)
                );
            var card2 = new Card(
                new Rank(card2Rank, null),
                new Suit(' ', card2Suit, SuitEnum.Unknown)
                );

            var comparer   = new NoTrumpHandSorter(false, false);
            var comparison = comparer.Compare(card1, card2);

            Assert.Equal(expectedCompareValue, comparison);
        }
Пример #28
0
        public RankEnum GetRank(string singleNotation)
        {
            RankEnum rankEnum = RankEnum.NoRank;
            string   rank     = singleNotation.Substring(1, 1);

            switch (rank)
            {
            case "1":
                rankEnum = RankEnum.Rank1;
                break;

            case "2":
                rankEnum = RankEnum.Rank2;
                break;

            case "3":
                rankEnum = RankEnum.Rank3;
                break;

            case "4":
                rankEnum = RankEnum.Rank4;
                break;

            case "5":
                rankEnum = RankEnum.Rank5;
                break;

            case "6":
                rankEnum = RankEnum.Rank6;
                break;

            case "7":
                rankEnum = RankEnum.Rank7;
                break;

            case "8":
                rankEnum = RankEnum.Rank8;
                break;

            default:
                rankEnum = RankEnum.NoRank;
                break;
            }
            return(rankEnum);
        }
Пример #29
0
        public string GetRankString(RankEnum rank)
        {
            string rankString = string.Empty;

            switch (rank)
            {
            case RankEnum.Rank1:
                rankString = "1";
                break;

            case RankEnum.Rank2:
                rankString = "2";
                break;

            case RankEnum.Rank3:
                rankString = "3";
                break;

            case RankEnum.Rank4:
                rankString = "4";
                break;

            case RankEnum.Rank5:
                rankString = "5";
                break;

            case RankEnum.Rank6:
                rankString = "6";
                break;

            case RankEnum.Rank7:
                rankString = "7";
                break;

            case RankEnum.Rank8:
                rankString = "8";
                break;

            default:
                break;
            }

            return(rankString);
        }
Пример #30
0
 public Deck(RankEnum trumpRank)
 {
     foreach (SuitEnum suit in Enum.GetValues(typeof(SuitEnum)))
     {
         if (suit == SuitEnum.TRUMPS)
         {
             Cards.Add(new Card {
                 Suit = suit, Rank = RankEnum.BLACKJOKER
             });
             Cards.Add(new Card {
                 Suit = suit, Rank = RankEnum.REDJOKER
             });
             Cards.Add(new Card {
                 Suit = suit, Rank = RankEnum.BLACKJOKER
             });
             Cards.Add(new Card {
                 Suit = suit, Rank = RankEnum.REDJOKER
             });
         }
         foreach (RankEnum rank in Enum.GetValues(typeof(RankEnum)))
         {
             if (rank == RankEnum.REDJOKER || rank == RankEnum.BLACKJOKER)
             {
                 break;
             }
             if (rank == trumpRank)
             {
                 Cards.Add(new Card {
                     Suit = SuitEnum.TRUMPS, Rank = rank
                 });
             }
             else
             {
                 Cards.Add(new Card {
                     Suit = suit, Rank = rank
                 });
                 Cards.Add(new Card {
                     Suit = suit, Rank = rank
                 });
             }
         }
     }
     Cards.Shuffle();
 }
Пример #31
0
 public Card(SuitEnum suit, RankEnum rank)
 {
     Suit = suit;
     Rank = rank;
 }
Пример #32
0
 public Value(SuitEnum suit, RankEnum rank)
 {
     _suit = suit;
     _rank = rank;
 }