public void SubLaunchCreatesCombatEvents() { Outpost outpost1 = Game.TimeMachine.GetState().GetOutposts()[0]; Outpost outpost2 = Game.TimeMachine.GetState().GetOutposts()[2]; int outpostOneInitial = outpost1.GetDrillerCount(); int outpostTwoInitial = outpost2.GetDrillerCount(); LaunchEvent launch1 = new LaunchEvent(new GameTick(), outpost1, 1, outpost2); LaunchEvent launch2 = new LaunchEvent(new GameTick(), outpost2, 1, outpost1); Assert.AreEqual(true, launch1.ForwardAction()); Assert.AreEqual(true, launch2.ForwardAction()); // Ensure the sub was launched, outpost lost drillers, etc. Assert.AreEqual(2, Game.TimeMachine.GetState().GetSubList().Count); Assert.AreEqual(outpostOneInitial - 1, outpost1.GetDrillerCount()); Assert.AreEqual(outpostTwoInitial - 1, outpost2.GetDrillerCount()); // Ensure a combat event has been added that includes both subs. int subToSubBattles = 0; int subToOutpostBattles = 0; GameEvent arriveEvent = null; CombatEvent combatEvent = null; foreach (GameEvent gameEvent in Game.TimeMachine.GetQueuedEvents()) { if (gameEvent is CombatEvent) { combatEvent = (CombatEvent)gameEvent; if (combatEvent.GetCombatants()[0] is Sub && combatEvent.GetCombatants()[1] is Sub) { subToSubBattles++; } else { subToOutpostBattles++; arriveEvent = gameEvent; } } } // There should be 3 combats, one on each outpost, one on both subs. Assert.AreEqual(1, subToSubBattles); Assert.AreEqual(2, subToOutpostBattles); }
public void SubLaunchCreatesCombatEvents() { Outpost outpost1 = new Outpost("0", new RftVector(new Rft(300, 300), 0, 0)); Outpost outpost2 = new Outpost("1", new RftVector(new Rft(300, 300), 0, 0)); outpost1.SetDrillerCount(10); outpost2.SetDrillerCount(10); outpost1.SetOwner(_game.TimeMachine.GetState().GetPlayers()[0]); outpost2.SetOwner(_game.TimeMachine.GetState().GetPlayers()[1]); int outpostOneInitial = outpost1.GetDrillerCount(); int outpostTwoInitial = outpost2.GetDrillerCount(); _game.TimeMachine.GetState().GetOutposts().Add(outpost1); _game.TimeMachine.GetState().GetOutposts().Add(outpost2); LaunchEvent launch1 = new LaunchEvent(new GameEventModel() { EventData = new LaunchEventData() { DestinationId = outpost2.GetId(), DrillerCount = 1, SourceId = outpost1.GetId(), }.ToByteString(), EventId = "a", EventType = EventType.LaunchEvent, OccursAtTick = 1, }); LaunchEvent launch2 = new LaunchEvent(new GameEventModel() { EventData = new LaunchEventData() { DestinationId = outpost1.GetId(), DrillerCount = 1, SourceId = outpost2.GetId(), }.ToByteString(), EventId = "a", EventType = EventType.LaunchEvent, OccursAtTick = 1, }); Assert.AreEqual(true, launch1.ForwardAction(_game.TimeMachine, _game.TimeMachine.GetState())); Assert.AreEqual(true, launch2.ForwardAction(_game.TimeMachine, _game.TimeMachine.GetState())); // Ensure the sub was launched, outpost lost drillers, etc. Assert.AreEqual(2, _game.TimeMachine.GetState().GetSubList().Count); Assert.AreEqual(outpostOneInitial - 1, outpost1.GetDrillerCount()); Assert.AreEqual(outpostTwoInitial - 1, outpost2.GetDrillerCount()); // Ensure a combat event has been added that includes both subs. int subToSubBattles = 0; int subToOutpostBattles = 0; GameEvent arriveEvent = null; CombatEvent combatEvent = null; foreach (GameEvent gameEvent in _game.TimeMachine.GetQueuedEvents()) { if (gameEvent is CombatEvent) { combatEvent = (CombatEvent)gameEvent; if (combatEvent.GetCombatants()[0] is Sub && combatEvent.GetCombatants()[1] is Sub) { subToSubBattles++; } else { subToOutpostBattles++; arriveEvent = gameEvent; } } } // There should be 3 combats, one on each outpost, one on both subs. Assert.AreEqual(1, subToSubBattles); Assert.AreEqual(2, subToOutpostBattles); }