Esempio n. 1
0
        private void WriteLog()
        {
            int proposerIndex = 0;
            int aiIndex       = -1;

            PlayerRoundInfo[] priPlayers  = roundsInfo[currentRound].playersRoundInfo.Values.ToArray();
            String[]          playersHash = roundsInfo[currentRound].playersRoundInfo.Keys.ToArray();

            int[]    weights   = new int[priPlayers.Length];
            int[]    shares    = new int[priPlayers.Length];
            string[] decisions = new string[priPlayers.Length];
            int[]    timeouts  = new int[priPlayers.Length];
            for (int i = 0; i < priPlayers.Length; i++)
            {
                if (priPlayers[i].isAI)
                {
                    aiIndex = i;
                }
                if (priPlayers[i].isProposer)
                {
                    proposerIndex = i;
                }
                weights[i]   = (int)priPlayers[i].weight;
                shares[i]    = (int)priPlayers[i].playerOffer;
                decisions[i] = priPlayers[i].playerResponse.ToString();
                timeouts[i]  = priPlayers[i].responseTime;
            }

            WriteToDB.WriteProposalToDB(playersHash, currentRound, roomHash, numberOfPlayers, proposerIndex, aiIndex, weights, shares, decisions, timeouts);
        }
Esempio n. 2
0
        public enum Status { Home, WaitingRoom, WaitingForJoinResponse, Ready, EnteringRoom, Proposing, FinishedRespondingWaiting, GameFinishedCoalitionNotFormed, GameFinishedCoalitionFormedInc, GameFinishedCoalitionFormedNotInc, EndGameScreen, WaitingNotGivenOffer, ProposalInspection, ProposerWaitingForAnswer, WaitingForProposal, None, ExitingGame }; // divs

        internal static void WriteToFile(string hashPlayer)
        {
            try
            {
                changeLock.WaitOne();
            }
            catch (AbandonedMutexException)
            {
                changeLock.ReleaseMutex();
                changeLock.WaitOne();
            }
            bool answer = false;

            var online = HttpContext.Current.Application["OnlinePlayers"];

            if (online == null)
            {
                online = new Dictionary <string, Player>();
            }

            Dictionary <string, Player> onlinePlayers = (Dictionary <string, Player>)online;

            foreach (var item in onlinePlayers)
            {
                if (item.Value.HashPlayer == hashPlayer)
                {
                    WriteToDB.WriteFinishedPlayer(((Dictionary <string, Player>)HttpContext.Current.Application["OnlinePlayers"])[item.Key]);
                    break;
                }
            }
            changeLock.ReleaseMutex();
        }