예제 #1
0
        public static (RESTResult, string) RESTFight(string p1, string p2)
        {
            Player _player = new Player();

            _player.Name   = "Player#1";
            _player.Pos    = 1;
            _player.ID     = paxgame.GetPlayerID();
            _player.Race   = UnitRace.Terran;
            _player.inGame = true;
            _player.Units  = new List <Unit>(UnitPool.Units.Where(x => x.Race == _player.Race));

            Player _opp = new Player();

            _opp.Name   = "Player#2";
            _opp.Pos    = 4;
            _opp.ID     = paxgame.GetPlayerID();
            _opp.Race   = UnitRace.Terran;
            _opp.inGame = true;
            _opp.Units  = new List <Unit>(UnitPool.Units.Where(x => x.Race == _opp.Race));

            GameHistory game = new GameHistory();

            _player.Game    = game;
            _player.Game.ID = paxgame.GetGameID();
            _player.Game.Players.Add(_player);
            _player.Game.Players.Add(_opp);

            _opp.Game = _player.Game;


            //OppService.BPRandom(_player).GetAwaiter().GetResult();
            //OppService.BPRandom(_opp).GetAwaiter().GetResult();

            BBuild bplayer = new BBuild(_player);
            BBuild bopp    = new BBuild(_opp);

            bplayer.SetString(p1, _player);
            bopp.SetString(p2, _opp);

            GameService.GenFight(_player.Game).GetAwaiter().GetResult();
            StatsService.GenRoundStats(game, false).GetAwaiter().GetResult();
            Stats result    = new Stats();
            Stats oppresult = new Stats();

            result.DamageDone            = game.Stats.Last().Damage[1];
            result.MineralValueKilled    = game.Stats.Last().Killed[1];
            oppresult.DamageDone         = game.Stats.Last().Damage[0];
            oppresult.MineralValueKilled = game.Stats.Last().Killed[0];

            RESTResult rgame = new RESTResult();

            rgame.Result     = game.Stats.Last().winner;
            rgame.DamageP1   = oppresult.DamageDone;
            rgame.MinValueP1 = oppresult.MineralValueKilled;
            rgame.DamageP2   = result.DamageDone;
            rgame.MinValueP2 = result.MineralValueKilled;

            return(rgame, bopp.GetString(_opp));
        }
예제 #2
0
        public static RandomGame RandomFight(int minerals = 2000, bool save = false)
        {
            Player _player = new Player();

            _player.Name   = "Player#1";
            _player.Pos    = 1;
            _player.ID     = paxgame.GetPlayerID();
            _player.Race   = UnitRace.Terran;
            _player.inGame = true;
            _player.Units  = new List <Unit>(UnitPool.Units.Where(x => x.Race == _player.Race));

            Player _opp = new Player();

            _opp.Name   = "Player#2";
            _opp.Pos    = 4;
            _opp.ID     = paxgame.GetPlayerID();
            _opp.Race   = UnitRace.Terran;
            _opp.inGame = true;
            _opp.Units  = new List <Unit>(UnitPool.Units.Where(x => x.Race == _opp.Race));

            GameHistory game = new GameHistory();

            _player.Game    = game;
            _player.Game.ID = paxgame.GetGameID();
            _player.Game.Players.Add(_player);
            _player.Game.Players.Add(_opp);

            _opp.Game = _player.Game;

            _player.Units = new List <Unit>(UnitPool.Units.Where(x => x.Race == _player.Race && x.Cost > 0));
            _opp.Units    = new List <Unit>(UnitPool.Units.Where(x => x.Race == _opp.Race && x.Cost > 0));

            _player.MineralsCurrent = minerals;
            _opp.MineralsCurrent    = minerals;

            OppService.BPRandom(_player).GetAwaiter().GetResult();
            OppService.BPRandom(_opp).GetAwaiter().GetResult();

            BBuild bplayer = new BBuild(_player);
            BBuild bopp    = new BBuild(_opp);

            bplayer.SetBuild(_player);
            bopp.SetBuild(_opp);

            GameService.GenFight(_player.Game).GetAwaiter().GetResult();
            StatsService.GenRoundStats(game, false).GetAwaiter().GetResult();
            Stats result    = new Stats();
            Stats oppresult = new Stats();

            result.DamageDone            = game.Stats.Last().Damage[1];
            result.MineralValueKilled    = game.Stats.Last().Killed[1];
            oppresult.DamageDone         = game.Stats.Last().Damage[0];
            oppresult.MineralValueKilled = game.Stats.Last().Killed[0];

            RandomResult result1 = new RandomResult();

            result1.DamageDone         = oppresult.DamageDone;
            result1.MineralValueKilled = oppresult.MineralValueKilled;
            RandomResult result2 = new RandomResult();

            result2.DamageDone         = result.DamageDone;
            result2.MineralValueKilled = result.MineralValueKilled;

            RandomGame rgame = new RandomGame();

            rgame.player1 = bplayer;
            rgame.player2 = bopp;
            rgame.result1 = result1;
            rgame.result2 = result2;
            rgame.Result  = game.Stats.Last().winner;

            if (save == true)
            {
                SaveGame(rgame, _player, _opp);
            }

            return(rgame);
        }