public BingoNextInfoTO NextInfo(string session) { WebLoggedUser webUser = Global.GetRegisteredBySession(session); if (webUser == null) { return(null); } Common.Data.UserTO userTO = Global.GetUserTOBySession(session); BingoNextInfoTO to = new BingoNextInfoTO(); List <ResultsBingoTO> nextGames = new List <ResultsBingoTO>(); nextGames = ResultsBingo.GetNextResults(false, true); to.id = nextGames[0].id; to.ticketValue = nextGames[0].ticket_value; BetInfoTO betInfo = ReservedTicketsBingo.GetBetInfo(to.id); to.totalPlayers = betInfo.total_players; to.totalTickets = betInfo.total_tickets; to.turn_type = nextGames[0].turn_type; to.gamePattern = Global.patterns[nextGames[0].pattern_idx].lines.ToArray(); to.user_credits = userTO.credits; to.user_bonus = userTO.bonus; to.user_prize = userTO.prize; BetInfoTO bet = ReservedTicketsBingo.GetBetInfo(nextGames[0].id); to.prize = bet.total_bet * (cfg.bingo_percent_prize / 100.0f); List <ReservedTicketsBingoTO> user_reservedListTO = ReservedTicketsBingo.GetTicketsList(nextGames[0].id, userTO.id, true); if (user_reservedListTO != null && user_reservedListTO.Count > 0) { to.user_ticketsCount = user_reservedListTO[0].tickets; } else { to.user_ticketsCount = 0; } return(to); }
/// <summary> /// Usuário entrou no bingo ou pediu atualização das informações /// </summary> public BingoInfoTO EnterAndGetInformation(string session) { DateTime currentTime = DateTime.Now; // atualiza o timeout timeoutDate = currentTime.AddMinutes(70); WebLoggedUser webUser = Global.GetRegisteredBySession(session); if (webUser == null) { return(null); } Common.Data.UserTO userTO = Global.GetUserTOBySession(session); if (webUser.bingo == null) { Global.EnterBingo(session, this); Global.ChatAddLine(null, "<b>" + userTO.nick + "</b> entrou."); } BingoInfoTO info = new BingoInfoTO(); info.currentGame = currentGame; info.currentGameTotals = currentGameTotals; info.currentGamePattern = Global.patterns[currentGamePatternIdx].lines.ToArray(); // determina as datas dos próximos jogos info.nextGames = ResultsBingo.GetNextResults(false, true); info.nextGamesTotals.Clear(); foreach (ResultsBingoTO res in info.nextGames) { info.nextGamesTotals.Add(ReservedTicketsBingo.GetBetInfo(res.id)); } // várias informações da rodada info.timeToNext = SecondsToDate(info.nextGames[0].date); DateTime serverNow = currentTime; info.serverTime = (UInt32)serverNow.TimeOfDay.TotalSeconds; info.turn_prize = currentGameTotals.total_bet * (cfg.bingo_percent_prize / 100.0f); info.turn_accum = cfg.bingo_accum; info.user_id = userTO.id; info.user_access_level = (short)userTO.access_level; info.user_nick = userTO.nick; info.user_credits = userTO.credits; info.user_bonus = userTO.bonus; info.user_prize = userTO.prize; // localiza as cartelas do jogador nessa rodada int idx = FindBingoTurnPlayerIdx(userTO.id); if (currentGame.turn_type == BingoGameType.none || idx == -1) { info.user_tickets = null; } else { info.user_tickets = currentPlayers[idx].tickets; } // determina quantas cartelas o jogador tem em cada uma das próximas rodadas for (int i = 0; i < info.nextGames.Count; i++) { List <ReservedTicketsBingoTO> user_reservedListTO = ReservedTicketsBingo.GetTicketsList(info.nextGames[i].id, userTO.id, true); if (user_reservedListTO != null && user_reservedListTO.Count > 0) { info.user_nextTicketsCount.Add(user_reservedListTO[0].tickets); } else { info.user_nextTicketsCount.Add(0); } } // retorna as bolas da rodada e o índice da última bola já sorteada info.serverBalls = serverBalls; info.currentBallIdx = currentBallIdx; GC.Collect(); return(info); }