Beispiel #1
0
        /// <summary>
        /// jogador pede linhas de chat (o cliente informa qtas linhas já recebeu)
        /// </summary>
        /// <param name="session"></param>
        /// <param name="linesCount"></param>
        /// <returns></returns>
        public BingoChatInfoTO ChatGetLines(string session)
        {
            // localiza o registro do usuário
            WebLoggedUser user = Global.GetRegisteredBySession(session);

            // começa a montar a resposta
            BingoChatInfoTO to = new BingoChatInfoTO();

            // adiciona os usuários que estão atualmente online,
            // independente de terem cartelas na rodada ou não
            List <WebLoggedUser> loggedList = Global.GetNicksOnBingo(user.bingo);

            foreach (WebLoggedUser logged in loggedList)
            {
                BingoTurnChatPlayer chatPlayer = new BingoTurnChatPlayer();
                chatPlayer.access_level = logged.access_level;
                chatPlayer.nick         = logged.nick;
                chatPlayer.online       = true;
                chatPlayer.user_id      = logged.id;
                to.loggedNicks.Add(chatPlayer);
            }

            /*
             * // ### PRECISA REVER ISSO AQUI! ###
             * // buscar no banco seria MUITO LENTO, pois toda hora tem essa chamada.
             *
             * // adiciona também os usuários que estão offline
             * // mas que têm cartelas na rodada
             * foreach (BingoTurnPlayer player in currentPlayers)
             * {
             *  BingoTurnChatPlayer chatPlayer = new BingoTurnChatPlayer();
             *  UserTO usr = Common.Data.User.GetUserById(player.user_id);
             *  chatPlayer.access_level = usr.access_level;
             *  chatPlayer.nick = usr.nick;
             *  chatPlayer.online = false;
             *  chatPlayer.user_id = usr.id;
             *  to.loggedNicks.Add(chatPlayer);
             * }
             */

            to.lines.Clear();
            to.lines.AddRange(user.newChatLines);

            user.newChatLines.Clear();

            return(to);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        /// <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);
        }