Ejemplo n.º 1
0
        public void AddCommandsGeneral_Test()
        {
            var server = EnvironmentGlobal.CreateGameServer("CommandsTests");

            var gameSession = EnvironmentGlobal.GetSession(server);

            var spaceship = gameSession.GetPlayerSpaceShip();

            var module = spaceship.GetPropulsionModules().First();

            server.Command(server.SessionId, ModuleCommand.ToJson(gameSession, module.Braking));

            Assert.AreEqual(1, server.Commands.Count);

            server.TurnCalculation(1);

            server.Command(server.SessionId, ModuleCommand.ToJson(gameSession, module.Braking));

            Assert.AreEqual(0, server.Commands.Count);

            server.TurnCalculation(5);

            Assert.AreEqual(0, server.Commands.Count);

            server.TurnCalculation(1);
            server.Wait(5);

            server.Command(server.SessionId, ModuleCommand.ToJson(gameSession, module.Braking));

            Assert.AreEqual(1, server.Commands.Count);

            server.TurnCalculation(1);
        }
Ejemplo n.º 2
0
        public void AutomaticExecuteScanningModule_Test()
        {
            var localServer = EnvironmentGlobal.CreateGameServer("ScanningModuleTest");

            var gameSession = localServer.RefreshGameSession();

            var scanners = gameSession.GetPlayerSpaceShip().ToSpaceship().GetScanningModules();

            Assert.AreEqual(1, scanners.Count);

            var scannerModule = scanners[0];

            Assert.AreEqual(scannerModule.ReloadTime, scannerModule.Reloading);

            localServer.ResumeSession();

            Assert.AreEqual(2, gameSession.SpaceMap.CelestialObjects.Count);

            localServer.TurnCalculation();

            var gameSessionTurn1 = localServer.RefreshGameSession();

            scannerModule = gameSessionTurn1.GetPlayerSpaceShip().ToSpaceship().GetScanningModules()[0];

            Assert.AreEqual(1, gameSessionTurn1.Turn);

            Assert.AreEqual(1, scannerModule.Reloading);

            Thread.Sleep(200);

            Assert.AreEqual(3, gameSessionTurn1.SpaceMap.CelestialObjects.Count);
        }
Ejemplo n.º 3
0
        public void LinearMovementCalculationTest()
        {
            var server = EnvironmentGlobal.CreateGameServer("Map_OneShip");

            var gameSession = EnvironmentGlobal.GetSession(server);

            var spaceShip = gameSession.GetCelestialObject(gameSession.GetCelestialObjects()[0].Id);

            var position = spaceShip.GetLocation();

            Assert.AreEqual(1, gameSession.GetCelestialObjects().Count);
            Assert.AreEqual(new PointF(10000, 10000), position);

            server.TurnCalculation();

            gameSession = EnvironmentGlobal.GetSession(server);

            position = gameSession.GetCelestialObject(gameSession.GetCelestialObjects()[0].Id).GetLocation();

            Assert.AreEqual(new PointF((float)10000.35, 10000), position);

            for (var i = 0; i < 19; i++)
            {
                server.TurnCalculation();
            }

            gameSession = EnvironmentGlobal.GetSession(server);

            position = gameSession.GetCelestialObject(gameSession.GetCelestialObjects()[0].Id).GetLocation();

            Assert.AreEqual(new PointF((float)10006.9922, 10000), position);
        }
Ejemplo n.º 4
0
        public void SessionId_Test()
        {
            var server = EnvironmentGlobal.CreateGameServer("General");

            server.TurnCalculation(1);

            var gameSession = EnvironmentGlobal.GetSessionServerSide(server);

            Assert.AreEqual(1005302115, gameSession.Id);

            server.TurnCalculation(5);

            gameSession = EnvironmentGlobal.GetSessionServerSide(server);

            Assert.AreEqual(1005302115, gameSession.Id);

            server = EnvironmentGlobal.CreateGameServer("Reloading");

            server.TurnCalculation(1);

            gameSession = EnvironmentGlobal.GetSessionServerSide(server);

            Assert.AreEqual(1005302116, gameSession.Id);

            server.TurnCalculation(5);

            gameSession = EnvironmentGlobal.GetSessionServerSide(server);

            Assert.AreEqual(1005302116, gameSession.Id);
        }
Ejemplo n.º 5
0
        public void Reloading_MicroWarpDrive_Test()
        {
            var server = EnvironmentGlobal.CreateGameServer("Reloading");

            var gameSession = EnvironmentGlobal.GetSession(server);

            var spaceship = gameSession.GetPlayerSpaceShip();

            var module = spaceship.GetPropulsionModules().First();

            Assert.AreEqual(2.0f, module.Reloading);

            server.Command(server.SessionId, ModuleCommand.ToJson(gameSession, module.Braking));

            Assert.AreEqual(1, server.Commands.Count);

            Assert.AreEqual(7, gameSession.GetCelestialObject(spaceship.Id).Speed);

            server.TurnCalculation(1);

            gameSession = EnvironmentGlobal.GetSession(server);

            spaceship = gameSession.GetPlayerSpaceShip();

            module = spaceship.GetPropulsionModules().First();

            Assert.AreEqual(0.05, module.Reloading);

            server.TurnCalculation(5);

            module = EnvironmentGlobal.GetSessionServerSide(server).GetPlayerSpaceShip().GetPropulsionModules().First();

            Assert.AreEqual(0.3, module.Reloading);
        }
Ejemplo n.º 6
0
        public void GetPropulsionModuleTest()
        {
            var localServer = EnvironmentGlobal.CreateGameServer("Map_005");

            var gameSession = localServer.RefreshGameSession();

            var propulsionModules = gameSession.GetPlayerSpaceShip().ToSpaceship().GetModules(Category.Propulsion);

            Assert.AreEqual(1, propulsionModules.Count);

            var propulsionModule = propulsionModules.FirstOrDefault() as MicroWarpDrive;

            Assert.AreEqual("Civilian Prototype Mk I", propulsionModule.Name);
            Assert.AreEqual(2000, propulsionModule.Power);
            Assert.AreEqual(5005, propulsionModule.OwnerId);
            Assert.AreEqual(100, propulsionModule.ActivationCost);

            var propulsionModulesCategory = gameSession.GetPlayerSpaceShip().ToSpaceship().GetPropulsionModules();

            Assert.AreEqual(1, propulsionModulesCategory.Count);

            var propModule = propulsionModulesCategory.FirstOrDefault();

            Assert.AreEqual("Civilian Prototype Mk I", propModule.Name);
            Assert.AreEqual(2000, propModule.Power);
            Assert.AreEqual(5005, propModule.OwnerId);
            Assert.AreEqual(100, propModule.ActivationCost);
        }
Ejemplo n.º 7
0
        public void SessionName_Test()
        {
            var server = EnvironmentGlobal.CreateGameServer("General");

            var gameSession = EnvironmentGlobal.GetSessionServerSide(server);

            Assert.AreEqual("General", gameSession.ScenarioName);
        }
Ejemplo n.º 8
0
        public void MovementLogEmptyTest()
        {
            var movementLog = new MovementLog(2);

            var localServer = EnvironmentGlobal.CreateGameServer("MovementLogTests");

            movementLog.Update(localServer.RefreshGameSession());

            Assert.IsTrue(movementLog.GetHistoryForCelestialObject(100).Count == 0);
        }
Ejemplo n.º 9
0
        public void GetDialogTest()
        {
            var localServer = EnvironmentGlobal.CreateGameServer("General");

            var gameSession = localServer.RefreshGameSession();

            var dialogRow = gameSession.GetDialogRow(637066561468000000);

            Assert.AreEqual(637066561468000000, dialogRow.Id);
            Assert.AreEqual(1, dialogRow.Exits.Count);
            Assert.AreEqual(637066561468000000, dialogRow.CharacterId);
        }
Ejemplo n.º 10
0
        public void LoadSettingsTest()
        {
            EnvironmentGlobal.Initialization();

            var settings = new Engine.Settings();

            var version = settings.Version;

            settings.WriteSettingsToLog();

            Assert.AreNotEqual(version, string.Empty);

            Assert.AreEqual(new Size(1920, 1080), settings.WindowSize);
        }
Ejemplo n.º 11
0
        public void GenerateAsteroidTest()
        {
            var localServer = EnvironmentGlobal.CreateGameServer("CelestialObjectsFactoryTests");

            var gameSession = localServer.RefreshGameSession();

            var asteroid = CelestialObjectsFactory.GenerateAsteroid(gameSession);

            Assert.IsNotNull(asteroid);

            Assert.IsTrue(asteroid.Direction > 0 && asteroid.Direction <= 360);

            Assert.IsTrue(asteroid.Speed > 0 && asteroid.Speed <= 30);
        }
Ejemplo n.º 12
0
        public void Missile_Test()
        {
            var settings = new EngineSettings {
                DebugProperties = new DebugProperties(true, true)
            };

            var server = EnvironmentGlobal.CreateGameServer("CommandsTests_Weapon", settings);

            var gameSession = EnvironmentGlobal.GetSession(server);

            var spaceship = gameSession.GetPlayerSpaceShip();

            Assert.AreEqual(2, spaceship.Modules[1].Skills.Count);
        }
Ejemplo n.º 13
0
        public void PropulsionModule_Braking_Test()
        {
            var server = EnvironmentGlobal.CreateGameServer("CommandsTests");

            var gameSession = EnvironmentGlobal.GetSession(server);

            var spaceship = gameSession.GetPlayerSpaceShip();

            var module = spaceship.GetPropulsionModules().First();

            server.Command(server.SessionId, ModuleCommand.ToJson(gameSession, module.Braking));

            Assert.AreEqual(1, server.Commands.Count);

            Assert.AreEqual(7, gameSession.GetCelestialObject(spaceship.Id).Speed);

            server.TurnCalculation(1);

            gameSession = EnvironmentGlobal.GetSession(server);

            Assert.AreEqual(6.975, Math.Round(gameSession.GetCelestialObject(spaceship.Id).Speed, 3));

            Assert.AreEqual(0, server.Commands.Count);

            Assert.AreEqual(1, server.GetHistoryCommands(server.SessionId, spaceship.Id).Count);

            server.TurnCalculation(1);

            // Add command for not reloaded module
            server.Command(server.SessionId, ModuleCommand.ToJson(gameSession, module.Braking));

            server.TurnCalculation(1);

            Assert.AreEqual(0, server.Commands.Count);

            server.Wait(5);

            server.Command(server.SessionId, ModuleCommand.ToJson(gameSession, module.Braking));

            Assert.AreEqual(1, server.Commands.Count);

            server.Wait(5);

            Assert.AreEqual(0, server.Commands.Count);

            Assert.AreEqual(2, server.GetHistoryCommands(server.SessionId, spaceship.Id).Count);

            Assert.AreEqual(CommandTypes.StopShip, server.GetHistoryCommands(server.SessionId, spaceship.Id)[0].Type);
        }
Ejemplo n.º 14
0
        public void TurnRecalculation_Test()
        {
            var server = EnvironmentGlobal.CreateGameServer("General");

            server.TurnCalculation(1);

            var gameSession = EnvironmentGlobal.GetSession(server);

            Assert.AreEqual(1, gameSession.Turn);

            server.TurnCalculation(5);

            gameSession = EnvironmentGlobal.GetSession(server);

            Assert.AreEqual(6, gameSession.Turn);
        }
        public void GenerateNpcShip_Test()
        {
            var settings = new EngineSettings {
                DebugProperties = new DebugProperties(true, true)
            };

            var server = EnvironmentGlobal.CreateGameServer("General", settings);

            server.EnableDebugMode();

            var gameSession = EnvironmentGlobal.GetSession(server);

            var result = CelestialObjectsFactory.GenerateNpcShip(gameSession, 12, 12, 1).ToSpaceship();

            Assert.IsTrue(result.Id > 0);
            Assert.AreEqual(4, result.Modules.Count);
            Assert.AreEqual(6, result.MaxSpeed);
        }
Ejemplo n.º 16
0
        public void ToClientTest()
        {
            var server = EnvironmentGlobal.CreateGameServer("ConvertTests");

            Assert.AreEqual(2, EnvironmentGlobal.GetSession(server).GetCelestialObjects().Count);

            var gameSession = EnvironmentGlobal.GetSession(server);

            Assert.AreEqual(2, gameSession.GetCelestialObjects().Count);

            server.TurnCalculation(2);

            Assert.AreEqual(1, EnvironmentGlobal.GetSessionServerSide(server).ScenarioEvents.Count);

            server.TurnCalculation(10);

            Assert.AreEqual(0, EnvironmentGlobal.GetSession(server).ScenarioEvents.Count);
        }
Ejemplo n.º 17
0
        public void DeepScanningModuleExistOnPlayerShip_Test()
        {
            var localServer = EnvironmentGlobal.CreateGameServer("Map_005");

            var gameSession = localServer.RefreshGameSession();

            var scanners = gameSession.GetPlayerSpaceShip().ToSpaceship().GetModules(Category.DeepScanner);

            Assert.AreEqual(1, scanners.Count);

            var scannerModule = (DeepScanner)scanners[0];

            Assert.AreEqual(300, scannerModule.ScanRange);
            Assert.AreEqual(60, scannerModule.Power);
            Assert.AreEqual(5005, scannerModule.OwnerId);
            Assert.AreEqual("DeepScanner Mk I", scannerModule.Name);
            Assert.AreEqual(false, scannerModule.IsEnabled);
        }
Ejemplo n.º 18
0
        public void GameSessionToSessionTransfer_Test()
        {
            var server = EnvironmentGlobal.CreateGameServer("General");

            var gameSession = EnvironmentGlobal.GetSessionServerSide(server);

            var sessionDto = gameSession.ToSessionTransfer();

            Assert.AreEqual(gameSession.IsPause, sessionDto.IsPause);
            Assert.AreEqual(gameSession.ScenarioName, sessionDto.ScenarioName);
            Assert.AreEqual(gameSession.Turn, sessionDto.Turn);
            Assert.AreEqual(gameSession.Rules.IsEventsEnabled, sessionDto.Rules.IsEventsEnabled);
            Assert.AreEqual(gameSession.Rules.Spawn.AsteroidSmallSize, sessionDto.Rules.Spawn.AsteroidSmallSize);
            Assert.AreEqual(gameSession.GetCelestialObjects().Count, sessionDto.CelestialObjects.Count);
            Assert.AreEqual(gameSession.GetCelestialObjects()[0].Id, sessionDto.CelestialObjects[0].Id);
            Assert.AreEqual(gameSession.GameEvents.Count, sessionDto.GameEvents.Count);
            Assert.AreEqual(gameSession.TurnHistory.Count, sessionDto.TurnHistory.Count);
        }
Ejemplo n.º 19
0
        public void Explosive_Integration_Test()
        {
            var settings = new EngineSettings {
                DebugProperties = new DebugProperties(true, true)
            };

            var server = EnvironmentGlobal.CreateGameServer("CommandsTests_Weapon", settings);

            server.EnableDebugMode();

            var gameSession = EnvironmentGlobal.GetSession(server);

            var spaceship = gameSession.GetPlayerSpaceShip();

            var targetSpacecraft = gameSession.GetCelestialObject(1000348945).ToSpaceship();

            var module = spaceship.GetWeaponModules().First();

            server.Command(server.SessionId, ModuleCommand.ToJson(gameSession, module.Shot, 1000348945, ((IModule)module).Id, 1));

            Assert.AreEqual(1, server.Commands.Count);
            Assert.AreEqual(200, targetSpacecraft.Shields);
            Assert.AreEqual(false, targetSpacecraft.IsDestroyed);

            server.TurnCalculation(1);

            gameSession = EnvironmentGlobal.GetSession(server);

            var explosives = gameSession.CelestialObjects.Where(obj => obj.OwnerId == 5005 && obj is Explosion).ToList();

            Assert.AreEqual(1, explosives.Count);

            server.TurnCalculation(1);

            explosives = gameSession.CelestialObjects.Where(obj => obj.OwnerId == 5005 && obj is Explosion).ToList();

            Assert.AreEqual(1, explosives.Count);

            gameSession = EnvironmentGlobal.Turn(20);

            explosives = gameSession.CelestialObjects.Where(obj => obj.OwnerId == 5005 && obj is Explosion).ToList();

            Assert.AreEqual(0, explosives.Count);
        }
Ejemplo n.º 20
0
        public void WeaponModuleReloading_Test()
        {
            var a = new AClass().GetData(100000);

            var localServer = EnvironmentGlobal.CreateGameServer("WeaponModuleReloading_Test");

            var gameSession = localServer.RefreshGameSession();

            var weaponModules = gameSession.GetPlayerSpaceShip().ToSpaceship().GetWeaponModules();

            Assert.AreEqual(1, weaponModules.Count);

            var weaponModule = weaponModules[0];

            Assert.AreEqual(weaponModule.ReloadTime, weaponModule.Reloading);

            localServer.ResumeSession();

            localServer.TurnCalculation();

            gameSession = localServer.RefreshGameSession();

            weaponModule = gameSession.GetPlayerSpaceShip().ToSpaceship().GetScanningModules()[0];

            Assert.AreEqual(1, gameSession.Turn);

            Assert.AreEqual(1, weaponModule.Reloading);

            for (var i = 1; i < weaponModule.ReloadTime; i++)
            {
                localServer.TurnCalculation();

                gameSession = localServer.RefreshGameSession();

                weaponModule = gameSession.GetPlayerSpaceShip().ToSpaceship().GetScanningModules()[0];
            }

            Assert.AreEqual(weaponModule.ReloadTime, weaponModule.Reloading);

            localServer.TurnCalculation();

            Assert.AreEqual(weaponModule.ReloadTime, weaponModule.Reloading);
        }
Ejemplo n.º 21
0
        public void GetCharacterTest()
        {
            var localServer = EnvironmentGlobal.CreateGameServer("General");

            var gameSession = localServer.RefreshGameSession();

            var character = gameSession.GetCharacter(637066561468099897);

            Assert.AreEqual(637066561468099897, character.Id);
            Assert.AreEqual("Joanna Benbow", character.Name);
            Assert.AreEqual(637066561468043700, character.CelestialId);
            Assert.AreEqual("DFS-800 Viking", character.CelestialName);

            character = gameSession.GetCharacter(637066561468099897);

            Assert.AreEqual(637066561468099897, character.Id);
            Assert.AreEqual("Joanna Benbow", character.Name);
            Assert.AreEqual(637066561468043700, character.CelestialId);
            Assert.AreEqual("DFS-800 Viking", character.CelestialName);
        }
Ejemplo n.º 22
0
        public void MouseClickOnObjectAndChangeSelectedObject_Test()
        {
            var server = EnvironmentGlobal.CreateGameServer("OuterSpace");

            var gameSession = EnvironmentGlobal.GetSession(server);

            var outerSpace = new OuterSpace();

            var isChangeSelectedObject = false;

            outerSpace.OnChangeSelectedObject += (e) =>
            {
                Assert.AreEqual(e, 5006);
                isChangeSelectedObject = true;
            };

            outerSpace.Refresh(gameSession, new System.Drawing.PointF(10101, 10201), MouseArguments.LeftClick);

            Assert.IsTrue(isChangeSelectedObject);
        }
Ejemplo n.º 23
0
        public void GetObjectsByDistanceTests()
        {
            var localServer = EnvironmentGlobal.CreateGameServer("Session_ObjectsByDistance");

            var gameSession = localServer.RefreshGameSession();

            Assert.AreEqual(4, gameSession.SpaceMap.CelestialObjects.Count);

            var objectsByDistance = gameSession.GetCelestialObjectsByDistance();

            Assert.AreEqual(3, objectsByDistance.Count);

            Assert.AreEqual("OBJ_01", objectsByDistance[0].Name);
            Assert.AreEqual("OBJ_03", objectsByDistance[1].Name);
            Assert.AreEqual("OBJ_02", objectsByDistance[2].Name);

            var closest = gameSession.GetCelestialObjectsByDistance().FirstOrDefault(o => o.IsScanned == false);

            Assert.AreEqual("OBJ_01", closest.Name);
        }
Ejemplo n.º 24
0
        public void PropulsionModule_TurnLeft_Test()
        {
            var server = EnvironmentGlobal.CreateGameServer("CommandsTests");

            var gameSession = EnvironmentGlobal.GetSession(server);

            var spaceship = gameSession.GetPlayerSpaceShip();

            var module = spaceship.GetPropulsionModules().First();

            double turnRotationSpeed = MobilityInDegrees / (new EngineSettings().UnitsPerSecond *module.ReloadTime);

            server.Command(server.SessionId, ModuleCommand.ToJson(gameSession, module.TurnLeft));

            Assert.AreEqual(1, server.Commands.Count);

            server.TurnCalculation(1);

            gameSession = EnvironmentGlobal.GetSession(server);

            spaceship = gameSession.GetPlayerSpaceShip();

            Assert.AreEqual(90 - turnRotationSpeed, spaceship.Direction);

            // Reloading time
            server.Wait(3);

            server.Command(server.SessionId, ModuleCommand.ToJson(gameSession, module.TurnLeft));

            server.TurnCalculation(1);

            spaceship = EnvironmentGlobal.GetSession(server).GetPlayerSpaceShip();

            Assert.AreEqual(80 - 1 * turnRotationSpeed, spaceship.Direction);

            server.TurnCalculation(1);

            spaceship = EnvironmentGlobal.GetSession(server).GetPlayerSpaceShip();

            Assert.AreEqual(80 - 2 * turnRotationSpeed, spaceship.Direction);
        }
Ejemplo n.º 25
0
        public void AddMessageTest()
        {
            var localServer = EnvironmentGlobal.CreateGameServer("MessageTest");

            var gameSession = localServer.RefreshGameSession();

            Assert.AreEqual(0, gameSession.GetCurrentTurnEvents().Count);

            localServer.ResumeSession();

            localServer.TurnCalculation();

            Assert.AreEqual(0, gameSession.GetCurrentTurnEvents().Count);

            gameSession = localServer.RefreshGameSession();

            gameSession.AddEvent(new GameEvent {
                CelestialObjectId = 1, IsOpenWindow = true, Type = GameEventTypes.AnomalyFound
            });

            localServer.TurnCalculation();

            gameSession = localServer.RefreshGameSession();

            gameSession.AddEvent(new GameEvent {
                CelestialObjectId = 2, IsOpenWindow = true, Type = GameEventTypes.AnomalyFound
            });

            gameSession.AddEvent(new GameEvent {
                CelestialObjectId = 3, IsOpenWindow = true, Type = GameEventTypes.AnomalyFound
            });

            Assert.AreEqual(1, gameSession.GetCurrentTurnEvents().Count);

            localServer.TurnCalculation();

            gameSession = localServer.RefreshGameSession();

            Assert.AreEqual(2, gameSession.GetTurnEvents(3).Count);
            Assert.AreEqual(1, gameSession.GetTurnEvents(2).Count);
        }
Ejemplo n.º 26
0
        public void LightMissileLauncherTest()
        {
            var settings = new EngineSettings {
                DebugProperties = new DebugProperties(true, true)
            };

            var server = EnvironmentGlobal.CreateGameServer("CommandsTests_Weapon", settings);

            server.EnableDebugMode();

            var gameSession = EnvironmentGlobal.GetSession(server);

            var spaceship = gameSession.GetPlayerSpaceShip();

            var lightMissile = spaceship.Modules[1] as LightMissileLauncher;

            Assert.IsFalse(lightMissile is null);

            Assert.AreEqual(500, lightMissile.Range);
            Assert.AreEqual(0.7, lightMissile.Efficiency);
        }
Ejemplo n.º 27
0
        public void UpdateTest()
        {
            var movementLog = new MovementLog(4);

            var localServer = EnvironmentGlobal.CreateGameServer("MovementLogTests");

            movementLog.Update(localServer.RefreshGameSession());

            Assert.IsTrue(movementLog.GetHistoryForCelestialObject(5005).Count == 2);

            Assert.AreEqual(movementLog.GetHistoryForCelestialObject(5005)[0].Coordinates, new PointF(8000, 10000));

            Assert.AreEqual(movementLog.GetHistoryForCelestialObject(5005)[1].Coordinates, new PointF(10000, 10000));

            localServer.TurnCalculation();

            movementLog.Update(localServer.RefreshGameSession());

            Assert.IsTrue(movementLog.GetHistoryForCelestialObject(5005).Count == 3);

            Assert.AreEqual(movementLog.GetHistoryForCelestialObject(5005)[0].Coordinates, new PointF(8000, 10000));

            Assert.AreEqual(movementLog.GetHistoryForCelestialObject(5005)[1].Coordinates, new PointF(10000, 10000));

            Assert.AreEqual(movementLog.GetHistoryForCelestialObject(5005)[2].Coordinates, new PointF(10005, 10000));

            localServer.TurnCalculation();

            movementLog.Update(localServer.RefreshGameSession());

            Assert.IsTrue(movementLog.GetHistoryForCelestialObject(5005).Count == 4);

            localServer.TurnCalculation();

            movementLog.Update(localServer.RefreshGameSession());

            Assert.IsTrue(movementLog.GetHistoryForCelestialObject(5005).Count == 4);

            //Assert.IsTrue(MovementLog.);
        }
Ejemplo n.º 28
0
        public void GameSession_GetCelestialObjectsByDistance_Test()
        {
            var server = EnvironmentGlobal.CreateGameServer("OuterSpace");

            var gameSession = EnvironmentGlobal.GetSession(server);

            var result = gameSession.GetCelestialObjectsByDistance(new System.Drawing.PointF(10030, 10030), 20);

            Assert.AreEqual(0, result.Count);

            result = gameSession.GetCelestialObjectsByDistance(new System.Drawing.PointF(10000, 10000), 20);

            Assert.AreEqual(1, result.Count);

            result = gameSession.GetCelestialObjectsByDistance(new System.Drawing.PointF(10030, 10030), 100);

            Assert.AreEqual(1, result.Count);

            result = gameSession.GetCelestialObjectsByDistance(new System.Drawing.PointF(10030, 10030), 800);

            Assert.AreEqual(2, result.Count);
        }
Ejemplo n.º 29
0
        public void MouseClickOnObjectAndChangeActiveObject_Negative_Test()
        {
            var server = EnvironmentGlobal.CreateGameServer("OuterSpace");

            var gameSession = EnvironmentGlobal.GetSession(server);

            var outerSpace = new OuterSpace();

            var isChangeActiveObject = false;

            outerSpace.OnChangeActiveObject += (e) =>
            {
                if (e > 0)
                {
                    isChangeActiveObject = true;
                }
            };

            outerSpace.Refresh(gameSession, new System.Drawing.PointF(9101, 9201), MouseArguments.Move);

            Assert.IsFalse(isChangeActiveObject);
        }
Ejemplo n.º 30
0
        public void LoadScenarioEventsTest()
        {
            var localServer = EnvironmentGlobal.CreateGameServer("LoadScenarioEvents");

            var gameSession = localServer.RefreshGameSession();

            Assert.AreEqual(1, gameSession.SpaceMap.CelestialObjects.Count);

            Assert.AreEqual(2, gameSession.ScenarioEvents.Count());

            Assert.AreEqual(10, gameSession.ScenarioEvents[0].Id);
            Assert.AreEqual(10, gameSession.ScenarioEvents[0].ToScenarioEventDialog().Id);
            Assert.AreEqual(7001, gameSession.ScenarioEvents[0].ToScenarioEventDialog().DialogId);


            localServer.ResumeSession();

            localServer.TurnCalculation();

            localServer.TurnCalculation();

            var gameSessionTurn1 = localServer.RefreshGameSession();

            Assert.AreEqual(1, gameSessionTurn1.GameEvents.Count);

            localServer.TurnCalculation();

            gameSessionTurn1 = localServer.RefreshGameSession();

            Assert.AreEqual(1, gameSessionTurn1.GameEvents.Count);

            localServer.TurnCalculation();

            gameSessionTurn1 = localServer.RefreshGameSession();

            Assert.AreEqual(2, gameSessionTurn1.GameEvents.Count);

            Assert.AreEqual(7001, gameSessionTurn1.GameEvents[1].DialogId);
        }