Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                DeserializeMatch lobbyData = JsonConvert.DeserializeObject <DeserializeMatch>(MatchDataJsonString());



                PointsResult     pointsResult = new PointsResult();
                RemyngtonGeneral match        = new RemyngtonGeneral();

                if (Tournament.CustomTeams)
                {
                    string jsonString = GetJsonStringFromFile(Tournament.TeamlistLink);
                    match.teamList = JsonConvert.DeserializeObject <DeserializeTeams>(jsonString);
                }

                Console.WriteLine(match.teamList);

                int teamType = Convert.ToInt32(lobbyData.games[0].team_type);
                if (teamType == 0) // Head to head = 0, Tag Co-op = 1, Team vs = 2, Tag Team vs = 3
                {
                    teamVS = false;
                }
                else
                {
                    teamVS = true;
                }

                match.ReadTotalPlayers(MatchDataJsonString());
                match.CalculateAccuracies(lobbyData);
                match.CalculateMaxcombo(lobbyData);
                match.CalculateMisscount(lobbyData);
                match.CalculateScore(lobbyData);
                Console.WriteLine(PlayerTracker);
                DisplaySimplyfiedPoints(match.GetSimplifiedPoints(RemyngtonGeneral.pointHistory));

                Console.WriteLine(PlayerTracker);
                if (lobbyData.match.end_time != null) //if the match has ended
                {
                    ArchiveMatch(RemyngtonGeneral.pointHistory, lobbyData.match.match_id, lobbyData.match.name);
                }

                PlayerTracker = new Dictionary <string, double>(); //clears values from playertracker
            }
            catch (JsonSerializationException)
            {
                Response.Redirect("Default.aspx");
            }
        }
Ejemplo n.º 2
0
        private void ArchiveMatch(PointsResult pointHistory, string matchNumber, string matchName)
        {
            var jsonString = JsonConvert.SerializeObject(pointHistory);
            var test       = jsonString.Replace(@"\", "");
            //JObject jsonObject = new JObject(pointHistory);


            JsonSerializer serializer = new JsonSerializer();

            serializer.NullValueHandling = NullValueHandling.Ignore;

            using (StreamWriter sw = new StreamWriter(Server.MapPath($"~/Past Matches/{ matchNumber } {matchName}.json")))
                using (JsonWriter writer = new JsonTextWriter(sw))
                {
                    serializer.Serialize(writer, pointHistory);
                }

            Console.WriteLine();
        }
Ejemplo n.º 3
0
        public SimplifiedPoints GetSimplifiedPoints(PointsResult detailedPoints)
        {
            SimplifiedPoints simplifiedPoints = new SimplifiedPoints();

            for (int map = 0; map < detailedPoints.map.Count; map++)
            {
                Beatmap beatmap = new Beatmap();

                beatmap.beatmapName = getMapName(detailedPoints.map[map].beatmap_id);
                for (int participant = 0; participant < detailedPoints.map[map].users.Count; participant++)
                {
                    Participant p = new Participant();

                    //the userlist contains all userIDs + usernames of the players in this match, detailedPoints has the userID and with that the username can be found in the userlist dictionary
                    if (Tournament.CustomTeams)
                    {
                        p.name = detailedPoints.map[map].users[participant].user_id; //in customteams the teamname is set as user_id
                    }
                    else
                    {
                        p.name = userList[detailedPoints.map[map].users[participant].user_id];
                    }

                    int scorePoints     = Convert.ToInt32(detailedPoints.map[map].users[participant].scorePoints);
                    int maxcomboPoints  = Convert.ToInt32(detailedPoints.map[map].users[participant].maxcomboPoints);
                    int countmissPoints = Convert.ToInt32(detailedPoints.map[map].users[participant].countmissPoints);
                    int accPoints       = Convert.ToInt32(detailedPoints.map[map].users[participant].accPoints);

                    p.totalPoints = (scorePoints + maxcomboPoints + countmissPoints + accPoints).ToString();

                    beatmap.Participant.Add(p);
                }
                simplifiedPoints.beatmap.Add(beatmap);
            }

            return(simplifiedPoints);
        }