public override void Check(int[] hand, UsersProperties user) { for (int j = (int)Cards.CardTypes.Ace; j <= (int)Cards.CardTypes.King * 4; j++) { int two = -1; int counterForThree = Straight.Count(rep => rep / 4 == j / 4); if (counterForThree == 3) { for (int k = (int)Cards.CardTypes.Ace; k <= (int)Cards.CardTypes.King * 4; k++) { if (k / 4 == j / 4) { continue; } int counterForTwo = Straight.Count(rep => rep / 4 == k / 4); if (counterForTwo != 2 || k / 4 == two) { continue; } two = k / 4; if (j == 0) { UpdateHand(user, Hand.Combinations.FullHouse, 13 * 3 + (k / 4) * 2); } if (k != 0) { continue; } UpdateHand(user, Hand.Combinations.FullHouse, j / 4 * 3 + 13 * 2); } } } }
public override void Check(int[] hand, UsersProperties user) { for (int tc = 16; tc >= 12; tc--) { var tempTable1 = hand[tc] / 4 == (int)Cards.CardTypes.Ace ? 13 : hand[tc] / 4; int max = tc - 12; for (int k = 1; k <= max; k++) { if (tc - k < 12) { max--; } if (tc - k < 12) { continue; } if (RightCard != LeftCard) { continue; } if (tempTable1 != hand[tc - k] / 4 || tempTable1 == Kicker) { continue; } UpdateHand(user, Hand.Combinations.TwoPair, Kicker + tempTable1); } } }
public CardVariables(UsersProperties user, IReadOnlyList <int> hand) { var k = (int)MainPoker.TableCards.FirstCard; Straight[0] = hand[user.RightCard]; Straight[1] = hand[user.LeftCard]; for (int j = 2; j < Straight.Length; j++) { Straight[j] = hand[k]; k++; } Clubs = SeparateSuits(Straight, Cards.CardSuits.Club); Diamonds = SeparateSuits(Straight, Cards.CardSuits.Diamond); Hearts = SeparateSuits(Straight, Cards.CardSuits.Heart); Spades = SeparateSuits(Straight, Cards.CardSuits.Spade); ClubsDistincted = SeparateCardTypes(Clubs); DiamondsDistincted = SeparateCardTypes(Diamonds); HeartsDistincted = SeparateCardTypes(Hearts); SpadesDistincted = SeparateCardTypes(Spades); CombinedArrays = new[] { ClubsDistincted, DiamondsDistincted, HeartsDistincted, SpadesDistincted }; bool handContainsAce = !(hand[user.RightCard] / 4 != (int)Cards.CardTypes.Ace && hand[user.LeftCard] / 4 != (int)Cards.CardTypes.Ace); bool rightCardIsAce = hand[user.RightCard] / 4 == (int)Cards.CardTypes.Ace; bool leftCardIsAce = hand[user.LeftCard] / 4 == (int)Cards.CardTypes.Ace; Kicker = !handContainsAce ? (hand[user.RightCard] / 4 > hand[user.LeftCard] / 4 ? hand[user.RightCard] / 4 : hand[user.LeftCard] / 4) : 13; RightCard = rightCardIsAce ? 13 : hand[user.RightCard] / 4; LeftCard = leftCardIsAce ? 13 : hand[user.LeftCard] / 4; SumOfHands = RightCard + LeftCard; }
public override void Check(int[] hand, UsersProperties user) { if (user.Type != -1) { return; } for (int tc = 16; tc >= 12; tc--) { var tempTable1 = hand[tc] / 4 == (int)Cards.CardTypes.Ace ? 13 : hand[tc] / 4; int max = tc - 12; for (int k = 1; k <= max; k++) { var tempTable2 = hand[tc - k] / 4 == (int)Cards.CardTypes.Ace ? 13 : hand[tc - k] / 4; if (tc - k < 12) { max--; } if (tc - k < 12) { continue; } if (tempTable1 != tempTable2) { continue; } UpdateHand(user, Hand.Combinations.PairTable, tempTable1 + Kicker / 6); } } }
public override void Check(int[] hand, UsersProperties user) { for (int j = 0; j <= 12; j++) { int[] fh = Straight.Where(o => o / 4 == j).ToArray(); if (fh.Length != 3) { continue; } var tempT = fh.Max() / 4 == (int)Cards.CardTypes.Ace ? 13 : fh.Max() / 4; //left card != rightcard ne sa v otedelen if poneje namalqm nesting if (LeftCard != RightCard && LeftCard == tempT) { UpdateHand(user, Hand.Combinations.ThreeOfAKind, LeftCard * 6 + RightCard / 4); } else if (LeftCard != RightCard && RightCard == tempT) { UpdateHand(user, Hand.Combinations.ThreeOfAKind, RightCard * 6 + LeftCard / 4); } else if (LeftCard == RightCard && LeftCard == tempT) { UpdateHand(user, Hand.Combinations.ThreeOfAKind, RightCard * 6); } if (LeftCard == tempT || RightCard == tempT) { continue; } UpdateHand(user, Hand.Combinations.ThreeOfAKind, tempT * 6 + Kicker / 4); } }
public override void Check(int[] hand, UsersProperties user) { if (RightCard != LeftCard) { return; } UpdateHand(user, Hand.Combinations.Pair, Kicker); }
public void UpdateHand(UsersProperties user, Hand.Combinations combinationType, int power) { user.Type = (int)combinationType; user.Power = power + user.Type * 100; MainPoker.Win.Add(new Hand { Power = user.Power, Current = user.Type }); }
public override void Check(int[] hand, UsersProperties user) { foreach (var array in CombinedArrays) { Array.Sort(array); } foreach (var t in CombinedArrays.Where(t => t.Length >= 5).Where(t => t[0] + 4 == t[4])) { UpdateHand(user, Hand.Combinations.StraightFlush, t.Max() / 4); } }
public override void Check(int[] hand, UsersProperties user) { if (user.Type != -1) { return; } user.Type = (int)Hand.Combinations.HighCard; user.Power = Kicker; MainPoker.Win.Add(new Hand { Power = user.Power, Current = user.Type }); }
public override void Check(int[] hand, UsersProperties user) { foreach ( var t in CombinedArrays.Where(t => t.Length >= 5) .Where( t => t.Contains((int)Cards.CardTypes.Ace) && t.Contains((int)Cards.CardTypes.Ten) && t.Contains((int)Cards.CardTypes.Jack) && t.Contains((int)Cards.CardTypes.Queen) && t.Contains((int)Cards.CardTypes.King))) { UpdateHand(user, Hand.Combinations.RoyalFlush, t.Max() / 4); } }
public override void Check(int[] hand, UsersProperties user) { for (int tc = 16; tc >= 12; tc--) { var tempTable1 = hand[tc] / 4 == (int)Cards.CardTypes.Ace ? 13 : hand[tc] / 4; if (RightCard == tempTable1) { UpdateHand(user, Hand.Combinations.Pair, RightCard * 6 + LeftCard / 6); } else if (LeftCard == tempTable1) { UpdateHand(user, Hand.Combinations.Pair, LeftCard * 6 + RightCard / 6); } } }
public override void Check(int[] hand, UsersProperties user) { for (int tc = 16; tc >= 12; tc--) { var tempTable1 = hand[tc] / 4 == (int)Cards.CardTypes.Ace ? 13 : hand[tc] / 4; for (int tc1 = 16; tc1 >= 12; tc1--) { var tempTable2 = hand[tc1] / 4 == (int)Cards.CardTypes.Ace ? 13 : hand[tc1] / 4; int max = tc - 12; int max1 = tc1 - 12; for (int k = 1; k <= max; k++) { if (tc - k <= 12) { continue; } for (int k1 = 1; k1 <= max1; k1++) { if (tc - k < 12) { max--; } if (tc1 - k1 < 12) { max1--; } if (tc - k < 12) { continue; } if (tc1 - k1 < 12) { continue; } if (tempTable1 != hand[tc - k] / 4 || tempTable2 != hand[tc1 - k1] / 4 || tempTable1 == tempTable2) { continue; } UpdateHand(user, Hand.Combinations.TwoPair, tempTable1 + tempTable2); } } } } }
public override void Check(int[] hand, UsersProperties user) { for (int tc = 16; tc >= 12; tc--) { var tempTable1 = hand[tc] / 4 == (int)Cards.CardTypes.Ace ? 13 : hand[tc] / 4; for (int tc1 = 16; tc1 >= 12; tc1--) { var tempTable2 = hand[tc1] / 4 == (int)Cards.CardTypes.Ace ? 13 : hand[tc1] / 4; if (RightCard != LeftCard && (RightCard == tempTable1 && LeftCard == tempTable2)) { UpdateHand(user, Hand.Combinations.TwoPair, SumOfHands); } } } }
public override void Check(int[] hand, UsersProperties user) { for (int j = 0; j <= 3; j++) { if (Straight[j] / 4 == Straight[j + 1] / 4 && Straight[j] / 4 == Straight[j + 2] / 4 && Straight[j] / 4 == Straight[j + 3] / 4) { UpdateHand(user, Hand.Combinations.FourOfAKind, Straight[j] / 4 * 4); } if (Straight[j] / 4 != (int)Cards.CardTypes.Ace || Straight[j + 1] / 4 != (int)Cards.CardTypes.Ace || Straight[j + 2] / 4 != (int)Cards.CardTypes.Ace || Straight[j + 3] / 4 != (int)Cards.CardTypes.Ace) { continue; } UpdateHand(user, Hand.Combinations.FourOfAKind, 13 * 4); } }
public override void Check(int[] hand, UsersProperties user) { int[] tStr = Straight.Select(o => o / 4).Distinct().ToArray(); for (int j = 0; j < tStr.Length - 4; j++) { if (tStr[j] + 1 == tStr[j + 1] && tStr[j] + 2 == tStr[j + 2] && tStr[j] + 3 == tStr[j + 3] && tStr[j] + 4 == tStr[j + 4]) { UpdateHand(user, Hand.Combinations.Straight, tStr.Max() - 4 == tStr[j] ? tStr.Max() : tStr[j + 4]); } if (tStr[j] != (int)Cards.CardTypes.Ace || tStr[j + 1] != (int)Cards.CardTypes.Ten || tStr[j + 2] != (int)Cards.CardTypes.Jack || tStr[j + 3] != (int)Cards.CardTypes.Queen || tStr[j + 4] != (int)Cards.CardTypes.King) { continue; } UpdateHand(user, Hand.Combinations.Straight, 13); } }
public override void Check(int[] hand, UsersProperties user) { for (int tc = 16; tc >= 12; tc--) { var tempTable1 = hand[tc] / 4 == (int)Cards.CardTypes.Ace ? 13 : hand[tc] / 4; int max = tc - 12; for (int k = 1; k <= max; k++) { var tempTable2 = hand[tc - k] / 4 == (int)Cards.CardTypes.Ace ? 13 : hand[tc - k] / 4; if (tc - k < 12) { max--; } if (tc - k < 12) { continue; } if (RightCard == LeftCard || tempTable1 != tempTable2) { continue; } for (int k1 = 16; k1 >= 12; k1--) { var tempTable3 = hand[k1] / 4 == (int)Cards.CardTypes.Ace ? 13 : hand[k1] / 4; if (LeftCard == tempTable3 && LeftCard != tempTable1) { UpdateHand(user, Hand.Combinations.TwoPair, LeftCard + tempTable1); } if (RightCard != tempTable3 || RightCard == tempTable1) { continue; } UpdateHand(user, Hand.Combinations.TwoPair, RightCard + tempTable1); } } } }
public PairHandTable(UsersProperties user, IReadOnlyList <int> hand) : base(user, hand) { }
public Straight(UsersProperties user, IReadOnlyList <int> hand) : base(user, hand) { }
public static List <PropertyItem> currentList(string property, int cultureId, bool addDefaultItem) { List <PropertyItem> l = new List <PropertyItem>(); switch (property) { case "sex": l = UsersProperties.Sex(cultureId); break; case "country": l = UsersProperties.Countries(cultureId, addDefaultItem); break; case "seeksex": l = UsersProperties.SeekSex(cultureId); break; case "month": l = UsersProperties.Months(cultureId); break; case "day": l = UsersProperties.Days(); break; case "year": l = UsersProperties.Year(); break; case "relationship": l = UsersProperties.Relationships(cultureId, addDefaultItem); break; case "height": l = UsersProperties.Height(); break; case "fashionstyle": l = UsersProperties.FashionStyles(cultureId, addDefaultItem); break; case "drinking": l = UsersProperties.Drinkings(cultureId, addDefaultItem); break; case "smoking": l = UsersProperties.Smokings(cultureId, addDefaultItem); break; case "figure": l = UsersProperties.Figures(cultureId, addDefaultItem); break; case "eyes": l = UsersProperties.Eyes(cultureId, addDefaultItem); break; case "hair": l = UsersProperties.Hair(cultureId, addDefaultItem); break; case "body": l = UsersProperties.Body(cultureId, addDefaultItem); break; case "bodyart": l = UsersProperties.Bodyart(cultureId, addDefaultItem); break; case "look": l = UsersProperties.Look(cultureId, addDefaultItem); break; case "education": l = UsersProperties.Educations(cultureId, addDefaultItem); break; case "ethnicity": l = UsersProperties.Ethnicities(cultureId, addDefaultItem); break; case "religion": l = UsersProperties.Religions(cultureId, addDefaultItem); break; case "profession": l = UsersProperties.Profession(cultureId, addDefaultItem); break; case "salary": l = UsersProperties.Salary(cultureId, addDefaultItem); break; case "diet": l = UsersProperties.Diets(cultureId, addDefaultItem); break; case "freetimefavorite": l = UsersProperties.FreeTimeFavorites(cultureId, addDefaultItem); break; case "hobbies": l = UsersProperties.Hobbies(cultureId, addDefaultItem); break; case "status": l = UsersProperties.Statuses(cultureId, addDefaultItem); break; case "statuspartner": l = UsersProperties.StatusesPartner(cultureId, addDefaultItem); break; case "kids": l = UsersProperties.Kids(cultureId, addDefaultItem); break; case "kidshave": l = UsersProperties.KidsHave(cultureId, addDefaultItem); break; case "kidswant": l = UsersProperties.KidsWant(cultureId, addDefaultItem); break; case "exercise": l = UsersProperties.Excercise(cultureId, addDefaultItem); break; case "sport": l = UsersProperties.Sports(cultureId, addDefaultItem); break; case "music": l = UsersProperties.Music(cultureId, addDefaultItem); break; case "sign": l = UsersProperties.Sign(cultureId, addDefaultItem); break; } return(l); }
public ThreeOfAKind(UsersProperties user, IReadOnlyList <int> hand) : base(user, hand) { }
public HighCard(UsersProperties user, IReadOnlyList <int> hand) : base(user, hand) { }
public TwoPairHandPairTablePair(UsersProperties user, int[] hand) : base(user, hand) { }
protected BaseCombinationAnalyzer(UsersProperties user, IReadOnlyList <int> hand) : base(user, hand) { }
public TwoPairTwoDifferent(UsersProperties user, IReadOnlyList <int> hand) : base(user, hand) { }
public Flush(UsersProperties user, IReadOnlyList <int> hand) : base(user, hand) { }
public override void Check(int[] hand, UsersProperties user) { int[] currentColors = { -1, -1, -1, -1, -1 }; int maxColor; int[] f1 = Straight.Skip(2).Where(o => o % 4 == (int)Cards.CardSuits.Club).ToArray(); int[] f2 = Straight.Skip(2).Where(o => o % 4 == (int)Cards.CardSuits.Diamond).ToArray(); int[] f3 = Straight.Skip(2).Where(o => o % 4 == (int)Cards.CardSuits.Heart).ToArray(); int[] f4 = Straight.Skip(2).Where(o => o % 4 == (int)Cards.CardSuits.Spade).ToArray(); int correct3 = Array.IndexOf(new[] { f1.Length == 3, f2.Length == 3, f3.Length == 3, f4.Length == 3 }, true); int correct4 = Array.IndexOf(new[] { f1.Length == 4, f2.Length == 4, f3.Length == 4, f4.Length == 4 }, true); int correct5 = Array.IndexOf(new [] { f1.Length == 5, f2.Length == 5, f3.Length == 5, f4.Length == 5 }, true); List <int[]> places = new List <int[]> { f1, f2, f3, f4 }; for (int j = 0; j < places.ToArray().Length; j++) { if (correct3 != j && correct4 != j && correct5 != j) { continue; } currentColors = places[j]; break; } if (hand[user.RightCard] % 4 == hand[user.LeftCard] % 4) { maxColor = hand[user.RightCard] / 4 > hand[user.LeftCard] / 4 ? (hand[user.LeftCard] / 4 == (int)Cards.CardTypes.Ace ? hand[user.LeftCard] : hand[user.RightCard]) : hand[user.LeftCard]; } else { if (hand[user.RightCard] % 4 == currentColors[0] % 4) { maxColor = hand[user.RightCard]; } else if (hand[user.LeftCard] % 4 == currentColors[0] % 4) { maxColor = hand[user.LeftCard]; } else { maxColor = -1; } } if (maxColor == -1) { return; } if (currentColors.Length == 3) { if (hand[user.RightCard] % 4 == hand[user.LeftCard] % 4 && hand[user.RightCard] % 4 == currentColors[0] % 4) { var tempPower = hand[user.RightCard] / 4 > hand[user.LeftCard] / 4 ? hand[user.RightCard] / 4 : hand[user.LeftCard] / 4; UpdateHand(user, Hand.Combinations.Flush, tempPower); } } if (currentColors.Length == 4 && maxColor % 4 == currentColors[0] % 4) { UpdateHand(user, Hand.Combinations.Flush, maxColor == (int)Cards.CardTypes.Ace ? 13 : maxColor); } if (currentColors.Length != 5 || currentColors.Max() <= 0 || maxColor % 4 != currentColors[0] % 4) { return; } if (currentColors[0] / 4 == (int)Cards.CardTypes.Ace && maxColor / 4 > currentColors[1] / 4) { UpdateHand(user, Hand.Combinations.Flush, maxColor == (int)Cards.CardTypes.Ace ? 13 : maxColor); } else if (currentColors[0] / 4 < maxColor / 4) { UpdateHand(user, Hand.Combinations.Flush, maxColor == (int)Cards.CardTypes.Ace ? 13 : maxColor); } }
public TwoPairFromTable(UsersProperties user, IReadOnlyList <int> hand) : base(user, hand) { }
public Response Post(UsersProperties theModel) { if (string.IsNullOrEmpty(theModel.Username)) { return(new Response { StatusCode = System.Net.HttpStatusCode.Moved, Location = new Uri(RemoveOldQueryString(Context.Request.AbsoluteUri) + "?msg=1") }); } if (string.IsNullOrEmpty(theModel.OldPassword)) { return(new Response { StatusCode = System.Net.HttpStatusCode.Moved, Location = new Uri(RemoveOldQueryString(Context.Request.AbsoluteUri) + "?msg=2") }); } if (theModel.NewPassword != theModel.NewPasswordCheck) { return(new Response { StatusCode = System.Net.HttpStatusCode.Moved, Location = new Uri(RemoveOldQueryString(Context.Request.AbsoluteUri) + "?msg=3") }); } if (string.IsNullOrEmpty(theModel.NewPassword)) { return(new Response { StatusCode = System.Net.HttpStatusCode.Moved, Location = new Uri(RemoveOldQueryString(Context.Request.AbsoluteUri) + "?msg=4") }); } Task <ProcessResult> UserEntries = ProcessRunner.GetProcessResultAsync("grep", "^" + theModel.Username + " /etc/shadow"); UserEntries.Wait(); var CommandResultLines = UserEntries.Result.GetOutput().Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries) .Select(line => line.TrimEnd()) .ToArray(); if (CommandResultLines.Length == 0) { return(new Response { StatusCode = System.Net.HttpStatusCode.Moved, Location = new Uri(RemoveOldQueryString(Context.Request.AbsoluteUri) + "?msg=5") }); } if (CommandResultLines.Length > 1) { return(new Response { StatusCode = System.Net.HttpStatusCode.Moved, Location = new Uri(RemoveOldQueryString(Context.Request.AbsoluteUri) + "?msg=6") }); } // Format of Line is Username$AlgorithmType$Salt$HashedPassword:OtherMeta string UserEntry = CommandResultLines[0]; const string Dollar = "$"; const string Colon = ":"; int StartIndex = UserEntry.IndexOf(Dollar); int EndHashAlgorithmTypeIndex = UserEntry.IndexOf(Dollar, StartIndex + Dollar.Length); int EndSaltIndex = UserEntry.IndexOf(Dollar, EndHashAlgorithmTypeIndex + Dollar.Length); int EndHashIndex = UserEntry.IndexOf(Colon, StartIndex + Dollar.Length); string HashAlgorithmType = UserEntry.Substring(StartIndex, EndHashAlgorithmTypeIndex - StartIndex + Dollar.Length); // Existing Hash, including the Algorithm Type $6$, the Salt and the Hash string ExistingHash = UserEntry.Substring(StartIndex, EndHashIndex - StartIndex); string Salt = UserEntry.Substring(EndHashAlgorithmTypeIndex + Dollar.Length, EndSaltIndex - EndHashAlgorithmTypeIndex - Dollar.Length); string NewHash = Linux.Crypt(theModel.OldPassword, HashAlgorithmType + Salt + Dollar); if (ExistingHash != NewHash) { return(new Response { StatusCode = System.Net.HttpStatusCode.Moved, Location = new Uri(RemoveOldQueryString(Context.Request.AbsoluteUri) + "?msg=7") }); } Task <ProcessResult> ChangePassword = ProcessRunner.GetProcessResultAsync("bash", "-c \"echo '" + theModel.Username + ":" + theModel.NewPassword + "' | chpasswd\""); ChangePassword.Wait(); if (ChangePassword.Result.Okay()) { return(new Response { StatusCode = System.Net.HttpStatusCode.Moved, Location = new Uri(RemoveOldQueryString(Context.Request.AbsoluteUri) + "?msg=10") }); } else { return(new Response { StatusCode = System.Net.HttpStatusCode.Moved, Location = new Uri(RemoveOldQueryString(Context.Request.AbsoluteUri) + "?msg=9") }); } }
public abstract void Check(int[] hand, UsersProperties user);