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); }
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(); } }
/// <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; } }
public Card(SuitEnum cardSuit, RankEnum cardRank) { CardSuit = cardSuit; CardRank = cardRank; CardName = CardSuit + " " + CardRank; CardValue = GetCardValue(); }
/// <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); } }
public OnePair(RankEnum pairRank, RankEnum kicker1, RankEnum kicker2, RankEnum kicker3) { PairRank = pairRank; Kicker1 = kicker1; Kicker2 = kicker2; Kicker3 = kicker3; }
public void GetRank_RankWithCorrectStringGenerated(RankEnum rank, string expectedChar) { var factory = ConstructFactory(); var s = factory.GetRank(rank).ToString(); Assert.Equal(expectedChar, s); }
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)]); }
public HighCard(RankEnum card1, RankEnum card2, RankEnum card3, RankEnum card4, RankEnum card5) { Card1 = card1; Card2 = card2; Card3 = card3; Card4 = card4; Card5 = card5; }
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); }
public void SetPiece(RankEnum rank, FileEnum file, Pieces piece) { DataRow row = GetBoardDataRow(rank, file); if (row != null) { row[Board.Piece] = piece.ToString("d"); } }
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); }
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, });
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; }
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); }
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) } }); }
/// <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); }
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; }
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); }
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 }; }
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), } }); }
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(); }
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); }
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); }
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); }
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); }
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(); }
public Card(SuitEnum suit, RankEnum rank) { Suit = suit; Rank = rank; }
public Value(SuitEnum suit, RankEnum rank) { _suit = suit; _rank = rank; }