コード例 #1
0
ファイル: Analysis.cs プロジェクト: BuloZB/BeRated
        void ProcessLine(string line)
        {
            var kill = LogParser.ReadPlayerKill(line);

            if (kill == null)
            {
                return;
            }
            if (kill.Killer.SteamId == LogParser.BotId || kill.Victim.SteamId == LogParser.BotId || kill.Killer.SteamId == kill.Victim.SteamId)
            {
                return;
            }
            var killerInformation = GetPlayerInformation(kill.Killer);

            killerInformation.Kills.Add(kill);
            killerInformation.KillCount++;
            var victimInformation = GetPlayerInformation(kill.Victim);

            victimInformation.DeathCount++;
            var killerPerformance = GetPeformanceEntry(kill.Killer.SteamId, kill.Victim.SteamId);

            killerPerformance.Kills++;
            var victimPerformance = GetPeformanceEntry(kill.Victim.SteamId, kill.Killer.SteamId);

            victimPerformance.Deaths++;
        }
コード例 #2
0
        void ProcessLine(string line, int lineCounter)
        {
            var kill = LogParser.ReadPlayerKill(line);

            if (kill != null)
            {
                if (kill.Killer.SteamId == LogParser.BotId || kill.Victim.SteamId == LogParser.BotId)
                {
                    return;
                }
                var parameters = new []
                {
                    new CommandParameter("kill_time", kill.Time),
                    new CommandParameter("killer_steam_id", kill.Killer.SteamId),
                    new CommandParameter("killer_team", kill.KillerTeam),
                    new CommandParameter("killer_x", kill.KillerPosition.X),
                    new CommandParameter("killer_y", kill.KillerPosition.Y),
                    new CommandParameter("killer_z", kill.KillerPosition.Z),
                    new CommandParameter("victim_steam_id", kill.Victim.SteamId),
                    new CommandParameter("victim_team", kill.VictimTeam),
                    new CommandParameter("victim_x", kill.VictimPosition.X),
                    new CommandParameter("victim_y", kill.VictimPosition.Y),
                    new CommandParameter("victim_z", kill.VictimPosition.Z),
                    new CommandParameter("weapon", kill.Weapon),
                    new CommandParameter("headshot", kill.Headshot),
                };
                _Database.NonQueryFunction("process_kill", parameters);
                return;
            }
            int?maxRounds = LogParser.ReadMaxRounds(line);

            if (maxRounds != null)
            {
                _MaxRounds = maxRounds.Value;
                return;
            }
            var teamSwitch = LogParser.ReadTeamSwitch(line);

            if (teamSwitch != null)
            {
                string steamId = teamSwitch.Player.SteamId;
                string team    = teamSwitch.CurrentTeam;
                if (steamId == LogParser.BotId || (team != LogParser.TerroristTeam && team != LogParser.CounterTerroristTeam))
                {
                    return;
                }
                _Players[steamId] = team;
                var parameters = new[]
                {
                    new CommandParameter("name", teamSwitch.Player.Name),
                    new CommandParameter("steam_id", steamId),
                };
                _Database.NonQueryFunction("update_player", parameters);
                return;
            }
            var disconnect = LogParser.ReadDisconnect(line);

            if (disconnect != null)
            {
                string steamId = disconnect.Player.SteamId;
                if (steamId == LogParser.BotId)
                {
                    return;
                }
                _Players.Remove(steamId);
            }
            var endOfRound = LogParser.ReadEndOfRound(line);

            if (endOfRound != null)
            {
                if (endOfRound.TerroristScore == 0 && endOfRound.CounterTerroristScore == 0)
                {
                    return;
                }
                string terroristIds        = GetSteamIdsString(LogParser.TerroristTeam);
                string counterTerroristIds = GetSteamIdsString(LogParser.CounterTerroristTeam);
                var    parameters          = new[]
                {
                    new CommandParameter("end_of_round_time", endOfRound.Time),
                    new CommandParameter("triggering_team", endOfRound.TriggeringTeam),
                    new CommandParameter("sfui_notice", endOfRound.SfuiNotice),
                    new CommandParameter("terrorist_score", endOfRound.TerroristScore),
                    new CommandParameter("counter_terrorist_score", endOfRound.CounterTerroristScore),
                    new CommandParameter("max_rounds", _MaxRounds),
                    new CommandParameter("terrorist_steam_ids", terroristIds),
                    new CommandParameter("counter_terrorist_steam_ids", counterTerroristIds),
                };
                _Database.NonQueryFunction("process_end_of_round", parameters);
                return;
            }
            var purchase = LogParser.ReadPurchase(line);

            if (purchase != null)
            {
                string steamId = purchase.Player.SteamId;
                if (steamId == LogParser.BotId)
                {
                    return;
                }
                string team       = _Players[steamId];
                var    parameters = new[]
                {
                    new CommandParameter("steam_id", steamId),
                    new CommandParameter("line", lineCounter),
                    new CommandParameter("purchase_time", purchase.Time),
                    new CommandParameter("team", team),
                    new CommandParameter("item", purchase.Item),
                };
                _Database.NonQueryFunction("process_purchase", parameters);
                return;
            }
        }
コード例 #3
0
        void ProcessLine(string line)
        {
            var kill = LogParser.ReadPlayerKill(line);

            if (kill == null)
            {
                return;
            }
            if (kill.Killer.SteamId == LogParser.BotId || kill.Victim.SteamId == LogParser.BotId || kill.Killer.SteamId == kill.Victim.SteamId)
            {
                return;
            }
            string query =
                @"insert into player_kill (
					time,
					killer_name,
					killer_steam_id,
					killer_team,
					killer_x,
					killer_y,
					killer_z,
					victim_name,
					victim_steam_id,
					victim_team,
					victim_x,
					victim_y,
					victim_z,
					headshot,
					weapon
				)
				values (
					@time,
					@killerName,
					@killerSteamId,
					@killerTeam,
					@killerX,
					@killerY,
					@killerZ,
					@victimName,
					@victimSteamId,
					@victimTeam,
					@victimX,
					@victimY,
					@victimZ,
					@headshot,
					@weapon
				)"                ;

            using (var command = new SqlCommand(query, _Connection))
            {
                command.Parameters.AddRange(new SqlParameter[]
                {
                    new SqlParameter("@time", kill.Time),
                    new SqlParameter("@killerName", kill.Killer.Name),
                    new SqlParameter("@killerSteamId", kill.Killer.SteamId),
                    new SqlParameter("@killerTeam", kill.KillerTeam),
                    new SqlParameter("@killerX", kill.KillerPosition.X),
                    new SqlParameter("@killerY", kill.KillerPosition.Y),
                    new SqlParameter("@killerZ", kill.KillerPosition.Z),
                    new SqlParameter("@victimName", kill.Victim.Name),
                    new SqlParameter("@victimSteamId", kill.Victim.SteamId),
                    new SqlParameter("@victimTeam", kill.VictimTeam),
                    new SqlParameter("@victimX", kill.VictimPosition.X),
                    new SqlParameter("@victimY", kill.VictimPosition.Y),
                    new SqlParameter("@victimZ", kill.VictimPosition.Z),
                    new SqlParameter("@headshot", kill.Headshot),
                    new SqlParameter("@weapon", kill.Weapon),
                }
                                            );
                try
                {
                    command.ExecuteNonQuery();
                }
                catch (SqlException)
                {
                }
            }
        }