Exemplo n.º 1
0
        private Night parse(string[] lines)
        {
            Night night = new Night();          
            Game game = null;
            int contPartidas = 0;

            foreach (string line in lines)
            {
                if (line.Contains("InitGame"))
                {
                    string[] words = line.Split('\\');

                    int gameNameIndex = Array.IndexOf(words, "mapname") + 1;
                    int gameModeIndex = Array.IndexOf(words, "g_gametype") + 1;
                    game = new Game() { Id = (++contPartidas).ToString(), GameMap = new Map() { Name = words[gameNameIndex], Mode = words[gameModeIndex] } };
                    continue;
                }
                else if (line.Contains("ShutdownGame"))
                {
                    night.AddGame(game);
                    game = null;
                }

                if (game != null)
                {
                    string[] words = line.Split(';');
                    if (words[0] != string.Empty)
                    {
                        switch (words[0][words[0].Length - 1])
                        {
                            case 'J':
                                joinEvent(game, words);
                                break;
                            case 'D':
                                damageEvent(game, words);
                                break;
                            case 'K':
                                killEvent(game, words);
                                break;
                        }
                    }
                }
            }
            return night;
        }
Exemplo n.º 2
0
 private void joinEvent(Game game, string[] words)
 {
     Player player = new Player() { Id = words[1], Name = words[3] };
     game.AddPlayer(player);
 }
Exemplo n.º 3
0
 private void damageEvent(Game game, string[] words)
 {
     game.AddAction(words[1], words[5], ActionType.Damage, getModifier(words[11]), getWeapon(words[9]), getWhere(words[12]), getArmy(words[3]), getArmy(words[7]));
 }
Exemplo n.º 4
0
 public void AddGame(Game game)
 {
     listGames.Add(game);
 }