コード例 #1
0
ファイル: PowerReader.cs プロジェクト: bumjung/eraHS
        public override void parseLogLines(Json resultJson)
        {
            this.newGame();
            DateTime startDate = DateTime.Now;

            foreach (string line in this.CopyLogLines)
            {
                Match createGameMatch = RegexManager.createGameRegex.Match(line);
                Match heroMatch = RegexManager.heroIdRegex.Match(line);
                Match playerEntityMatch = RegexManager.playerEntityRegex.Match(line);
                Match playerIdMatch = RegexManager.playerIdRegex.Match(line);
                Match mulliganMatch = RegexManager.mulliganRegex.Match(line);
                Match gameResultMatch = RegexManager.gameResultRegex.Match(line);

                if (createGameMatch.Success)
                {
                    string strStartDate = createGameMatch.Groups["startTime"].Value;
                    startDate = strStartDate.ConvertStringToDateTime();
                }
                else if (heroMatch.Success)
                {
                    int entityId = Int32.Parse(heroMatch.Groups["entityId"].Value);
                    int heroId = Int32.Parse(heroMatch.Groups["heroId"].Value) - 1;
                    _heroEntityDict.Add(entityId, Hero.HeroIdList[heroId]);
                }
                else if (playerEntityMatch.Success)
                {
                    string username = playerEntityMatch.Groups["name"].Value;
                    int entityId = Int32.Parse(playerEntityMatch.Groups["entityId"].Value);
                    _playerEntityDict.Add(username.Simplify(), entityId);
                }
                else if (playerIdMatch.Success)
                {
                    string username = playerIdMatch.Groups["name"].Value;
                    int playerId = Int32.Parse(playerIdMatch.Groups["playerId"].Value);
                    _playerIdDict.Add(playerId, username.Simplify());
                }
                else if (mulliganMatch.Success)
                {
                    if (_myId < 0) _myId = Int32.Parse(mulliganMatch.Groups["playerId"].Value);
                }
                else if (gameResultMatch.Success)
                {
                    _gameResultMatchCount++;
                    string username = gameResultMatch.Groups["name"].Value;
                    string result = gameResultMatch.Groups["result"].Value;
                    string strEndDate = gameResultMatch.Groups["endTime"].Value;

                    this.populatePlayerOpponent(resultJson, username, result);

                    if (isGameEnded() && !resultJson.Empty())
                    {
                        resultJson["startDate"] = startDate.ToString().Replace("/", "-");
                        resultJson["endDate"] = strEndDate.ConvertStringToDateTime().ToString().Replace("/", "-");
                    }
                }
            }
        }
コード例 #2
0
ファイル: ModeReader.cs プロジェクト: bumjung/eraHS
 public override void parseLogLines(Json resultJson)
 {
     for (int i = this.CopyLogLines.Count - 1; i >= 0; i--)
     {
         Match gameModeMatch = RegexManager.gameModeRegex.Match(this.CopyLogLines[i]);
         if (gameModeMatch.Success)
         {
             resultJson["mode"] = this.convertMode(gameModeMatch.Groups["currMode"].Value);
             return;
         }
     }
 }
コード例 #3
0
ファイル: LogManager.cs プロジェクト: bumjung/eraHS
        private void parseAndSendResults()
        {
            Json resultJson = new Json();
            _powerReader.parseLogLines(resultJson);

            if (!resultJson.Empty())
            {
                Logger.log("Sending Request");

                _modeReader.parseLogLines(resultJson);
                Request.Post(resultJson.ToString());
            }

            _powerReader.CopyLogLines.Clear();
            _modeReader.CopyLogLines.Clear();
            barrier.SignalAndWait();
        }
コード例 #4
0
ファイル: PowerReader.cs プロジェクト: bumjung/eraHS
        private void populatePlayerOpponent(Json resultJson, string username, string result)
        {
            Json playerJson = new Json();
            Json opponentJson = new Json();

            if (_playerEntityDict.ContainsKey(username.Simplify()))
            {
                if (_playerIdDict[_myId] == username.Simplify())
                {
                    playerJson["name"] = username;
                    playerJson["hero"] = _heroEntityDict[_playerEntityDict[username.Simplify()]];
                    playerJson["result"] = GameResult.dictionary[result];

                    resultJson["player"] = playerJson;
                }
                else
                {
                    bool isComputer = !_heroEntityDict.ContainsKey(_playerEntityDict[username.Simplify()]);
                    opponentJson["name"] = isComputer ? "Computer" : username;
                    opponentJson["hero"] = isComputer ? username : _heroEntityDict[_playerEntityDict[username.Simplify()]];
                    opponentJson["result"] = GameResult.dictionary[result];

                    resultJson["opponent"] = opponentJson;
                }
            }
        }
コード例 #5
0
ファイル: BaseReader.cs プロジェクト: bumjung/eraHS
 public abstract void parseLogLines(Json resultJson);