Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private IEnumerable<CrapsBet> GetCrapsBets(XElement playCheckEvent, List<XElement> otherEventsInElement)
- {
- var crapsBets = new List<CrapsBet>();
- var betsIn = playCheckEvent.Element("In").Element("Craps").Element("Table").Elements();
- var betsOut = playCheckEvent.Element("Out").Element("Craps").Element("Table").Elements();
- //Current event count
- var rollNumber = Convert.ToInt32(playCheckEvent.Element("In").Element("Craps").Attribute("rollNumber").Value);
- foreach (var betPlayedOn in betsOut)
- {
- //Check if bet has been given new position
- if (betPlayedOn.Attribute("newName") == null)
- {
- crapsBets.Add(new CrapsBet(betPlayedOn.Attribute("name").Value, betPlayedOn.Attribute("position").Value,
- decimal.Divide(Convert.ToDecimal(betPlayedOn.Attribute("payoutInCents").Value), 100)));
- }
- else
- {
- crapsBets.Add(new CrapsBet(betPlayedOn.Attribute("name").Value, betPlayedOn.Attribute("position").Value,
- decimal.Divide(Convert.ToDecimal(betPlayedOn.Attribute("payoutInCents").Value), 100),
- betPlayedOn.Attribute("newName").Value, betPlayedOn.Attribute("newPosition").Value));
- }
- }
- foreach (var t in crapsBets)
- {
- foreach (var bet in betsIn)
- {
- if (t.BetName == bet.Attribute("name").Value &&
- t.Position == bet.Attribute("position").Value)
- {
- t.Wager = decimal.Divide(Convert.ToDecimal(bet.Attribute("wagerInCents").Value), 100);
- }
- }
- if (t.Wager != 0) continue;
- //If wager amount is 0, the bet wager was taken from previous roll bet. Take the bet amount from previous bet.
- //Bet amount could be multiple betting rounds back
- for (var i = rollNumber - 2; i >= 0; i--)
- {
- var prevEventInBets = XElement.Parse(otherEventsInElement[i].ToString()).Element("In").Element("Craps").Element("Table").Elements();
- foreach (var prevBet in prevEventInBets)
- {
- if (t.BetName == prevBet.Attribute("name").Value &&
- t.Position == prevBet.Attribute("position").Value)
- {
- t.Wager = decimal.Divide(Convert.ToDecimal(prevBet.Attribute("wagerInCents").Value),
- 100);
- break;
- }
- if (t.Wager != 0) break;
- }
- }
- }
- return crapsBets;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement