public gameEngineReturnMessage Poll(string accessToken) { pollResponse returnMessage = new pollResponse(); game associatedGame = FindGameByPlayer(accessToken); if (associatedGame == null) { return(null); } returnMessage.gameName = associatedGame.GetId(); returnMessage.status = associatedGame.GetStatus(); List <string> names = associatedGame.GetPlayersNames(); foreach (var n in names) { int? rerollCount = associatedGame.GetPlayerByName(n).GetRerollCount(); pokerDiceHand handClaim = associatedGame.GetPlayerByName(n).GetHandClaim(); bool handClaimMade = handClaim != null; int livesLeft = associatedGame.GetPlayerByName(n).GetLivesRemaining(); returnMessage.playerStatusLines.Add(new playerStatusLine(n, livesLeft, handClaimMade, handClaim, rerollCount)); } returnMessage.awaitingActionFromPlayerName = associatedGame.GetPlayerNameWithActionAwaited(); //Decide whether or not to reveal actual hand to the calling player if (associatedGame.GetPlayerById(accessToken).GetName() == associatedGame.GetPlayerNameCurrentlyHoldingTheHand()) { returnMessage.SetHandToView(associatedGame.GetActualHand()); } return(returnMessage); }
private pokerDiceHand GetPreviousPlayerHandClaim() { int previousPlayerIndex = GetIndexOfPlayerPreviousTo(playerToActIndex); player previousPlayer = playersList[previousPlayerIndex]; pokerDiceHand pdh = previousPlayer.GetHandClaim(); return(pdh); }
private bool StalemateDetected() //Use only within accept hand function { pokerDiceHand AAAAA = new pokerDiceHand("AAAAA"); if (AAAAA == GetPreviousPlayerHandClaim()) { return(true); } return(false); }
public bool Equals(pokerDiceHand obj) { if (ReferenceEquals(obj, null)) { return(false); } if (obj.faces == faces) { return(true); } return(false); }
public pokerDiceHand GetNewHand() { string fiveFacesString = ""; for (int i = 0; i < 5; i++) { fiveFacesString += mDieRoller.Roll(showAsString.y); } pokerDiceHand pdh = new pokerDiceHand(fiveFacesString); return(pdh); }
public bool DeclareHand(string playerId, pokerDiceHand hand) { player p = null; if ((!ConfirmPlayerIsWithActionAwaited(playerId, ref p)) || (this.status != gameStatus.awaitingPlayerToClaimHandRank)) { return(false); } p.SetHandClaim(hand); MoveTurnToNextPlayer(); status = gameStatus.awaitingPlayerDecisionAcceptOrCallLiar; return(true); }
public override bool Equals(object obj) { if (obj == null) { return(false); } pokerDiceHand p = obj as pokerDiceHand; if ((System.Object)p == null) { return(false); } return(faces == p.faces); }
public playerStatusLine (string name, int livesRemaining, bool handClaimMade = false, pokerDiceHand handClaim = null, int?rerolledDiceCount = null) { mName = name; mClaim = null; if (handClaimMade) { mClaim = handClaim; } rerollDiceCount = rerolledDiceCount; mLivesRemaining = livesRemaining; }
private static bool gt(pokerDiceHand lhs, pokerDiceHand rhs) { if (lhs.handKind != rhs.handKind) { return(lhs.handKind < rhs.handKind); } if (lhs.primaryFace != rhs.primaryFace) { return(lhs.primaryFace > rhs.primaryFace); } if (lhs.secondaryFace != rhs.secondaryFace) { return(lhs.secondaryFace > rhs.secondaryFace); } return(lhs.hashcode > rhs.hashcode); }
public bool ReRoll(string playerId, string facesToReRoll) { player p = null; if ((!ConfirmPlayerIsWithActionAwaited(playerId, ref p)) || (this.status != gameStatus.awaitingPlayerToChooseDiceToReRollOrNone)) { return(false); } status = gameStatus.awaitingPlayerToClaimHandRank; p.SetRerollCount(facesToReRoll.Length); pokerDiceHand newHand = reroller.Reroll(currentActualHand, facesToReRoll); currentActualHand = newHand; return(true); }
public pokerDiceHand Reroll(pokerDiceHand oldHand, string facesToReRoll) { string oldFaces = oldHand.getFacesOrderedByRank(); bool remainderFoundOkay = false; string retainedFaces = Remainder(oldFaces, facesToReRoll, ref remainderFoundOkay); if (!remainderFoundOkay) { return(new pokerDiceHand("xxxxx")); } string newFaces = retainedFaces; string newRoll; for (int i = 0; i < facesToReRoll.Length; i++) { newRoll = mDieRoller.Roll(showAsString.y); newFaces += newRoll; } pokerDiceHand pdh = new pokerDiceHand(newFaces); return(pdh); }
public permutationsCalculator() { const int diceCount = 5; diceFaceTicker[] tickerArray = new diceFaceTicker[diceCount]; for (int i = 0; i < diceCount; i++) { tickerArray[i] = new diceFaceTicker(); } for (int j = diceCount - 1; j >= 1; j--) { tickerArray[j - 1].AddNeighbour(tickerArray[j]); } do { pokerDiceHand pdh = new pokerDiceHand(tickerArray[0].GetString()); string diceFacesOrderedByRank = pdh.getFacesOrderedByRank(); if (duplicatesCountTable.ContainsKey(diceFacesOrderedByRank)) { int oldCount = duplicatesCountTable[diceFacesOrderedByRank]; duplicatesCountTable[diceFacesOrderedByRank] = oldCount + 1; } else { duplicatesCountTable.Add(diceFacesOrderedByRank, 1); } tickerArray[0].Tick(); }while (tickerArray[diceCount - 1].hasOverflowed() == false); int debugNumberEntriesInDuplicatesCountTable = duplicatesCountTable.Count; this.permutationTable = "|"; foreach (var pair in duplicatesCountTable) { this.permutationTable += pair.ToString() + "|"; } }
public gameEngineReturnMessage DeclareHand(string accessToken, pokerDiceHand hand) { game associatedGame = FindGameByPlayer(accessToken); boolResponse returnMsg = new boolResponse(); if (associatedGame == null) { returnMsg.okay = false; return(returnMsg); } bool declareAccepted = associatedGame.DeclareHand(accessToken, hand); if (declareAccepted) { returnMsg.okay = true; } else { returnMsg.okay = false; } return(returnMsg); }
public void SetHandClaim(pokerDiceHand hand) { claim = hand; }
public void SetHandToView(pokerDiceHand h) { hand = h; handIsViewableSet = true; }