Example #1
0
        public void Setup()
        {
            _p = new Player("Player 1");
            List <Player> playerlist = new List <Player>();

            playerlist.Add(_p);
            GameConfiguration config = testUtils.GetDefaultGameConfiguration(playerlist);

            config.MapConfiguration.OutpostsPerPlayer = 12;
            _game   = new Game(config);
            _tm     = _game.TimeMachine;
            _o1     = _tm.GetState().GetPlayerOutposts(_p)[0];
            _o2     = _tm.GetState().GetPlayerOutposts(_p)[1];
            _model1 = new GameEventModel()
            {
                EventData = new DrillMineEventData()
                {
                    SourceId = _o1.GetComponent <IdentityManager>().GetId()
                }.ToByteString(),
                Id           = Guid.NewGuid().ToString(),
                EventType    = EventType.DrillMineEvent,
                OccursAtTick = 10
            };
            _model2 = new GameEventModel()
            {
                EventData = new DrillMineEventData()
                {
                    SourceId = _o2.GetComponent <IdentityManager>().GetId()
                }.ToByteString(),
                Id           = Guid.NewGuid().ToString(),
                EventType    = EventType.DrillMineEvent,
                OccursAtTick = 20
            };
        }
Example #2
0
        /// <summary>
        /// Determines if the game is in a game over state. In Mining, ties are broken by
        /// whoever happens to be first in the list of players.
        /// </summary>
        /// <returns>null if the game is not over, or the Player who has won if it is over.</returns>
        public Player IsGameOver()
        {
            switch (GameMode)
            {
            case GameMode.Mining:
                foreach (Player p in TimeMachine.GetState().GetPlayers())
                {
                    if (!p.IsEliminated() && p.GetNeptunium() >= Constants.MiningNeptuniumToWin)
                    {
                        return(p);
                    }
                }

                return(null);

            case GameMode.Domination:
                foreach (Player p in TimeMachine.GetState().GetPlayers())
                {
                    if (!p.IsEliminated() && TimeMachine.GetState().GetPlayerOutposts(p).Count >
                        TimeMachine.GetState().GetOutposts().Count / 2)
                    {
                        return(p);
                    }
                }

                return(null);

            // Other cases to be implemented

            default:
                return(null);
            }
        }
Example #3
0
        public void ExtractFromGameEventModel()
        {
            DrillMineEvent drillMine  = new DrillMineEvent(_model1);
            IEntity        combatable = _tm.GetState().GetEntity(drillMine.GetEventData().SourceId);

            Assert.IsNotNull(combatable);
            Assert.IsTrue(combatable is Outpost);
            Assert.IsFalse(combatable is Mine);
        }
        public void Setup()
        {
            List <Player> playerlist = new List <Player>();
            Player        player     = new Player("Player 1");

            playerlist.Add(player);
            GameConfiguration config = testUtils.GetDefaultGameConfiguration(playerlist);

            config.MapConfiguration.OutpostsPerPlayer = 10;
            _game = new Game(config);
            _tm   = _game.TimeMachine;
            foreach (Outpost o in _tm.GetState().GetPlayerOutposts(player))
            {
                if (isFactory(o))
                {
                    _f = (Factory)o;
                    break;
                }
            }
            Assert.IsNotNull(_f);
        }