コード例 #1
0
 private GameContext(string name)
 {
     Name = name;
     Id = Guid.NewGuid();
     UncommittedActions = new List<GameActionBase>();
     Players = new List<Player>();
     Systems = new List<PlanetarySystem>();
     ExplorationMap = new ExplorationMap();
     Turn = 1;
 }
コード例 #2
0
        public void TestCriticalWrap()
        {
            bool[,] map = new bool[5, 5];
            ExplorationMap.Configuration config = defaultConfig;
            config.visibilityCheck = v => map[v.x, v.y];
            ExplorationMap dut = new ExplorationMap(config);

            dut.SetCriticalZone(new Vector2i(2, 0), 1);

            Assert.IsTrue(dut.map[2, 4].isCritical);
            Assert.IsTrue(dut.map[2, 0].isCritical);
        }
コード例 #3
0
        public void TestBasicExploration()
        {
            bool[,] map = new bool[5, 5];
            ExplorationMap.Configuration config = defaultConfig;
            config.visibilityCheck = v => map[v.y, v.x];
            ExplorationMap dut = new ExplorationMap(config);

            Copy(new bool[5, 5]
            {
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
            }, map, 5, 5);


            dut.Update();
            Assert.IsTrue(dut.map[2, 2].needsVisit);

            Copy(new bool[5, 5]
            {
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, v, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
            }, map, 5, 5);


            dut.Update();
            Assert.IsFalse(dut.map[2, 2].needsVisit);

            Copy(new bool[5, 5]
            {
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
            }, map, 5, 5);


            for (int i = 0; i < 10; i++)
            {
                dut.Update();
                Assert.IsFalse(dut.map[2, 2].needsVisit);
            }

            dut.Update();
            Assert.IsTrue(dut.map[2, 2].needsVisit);
        }
コード例 #4
0
        public void TestCritical()
        {
            bool[,] map = new bool[5, 5];
            ExplorationMap.Configuration config = defaultConfig;
            config.visibilityCheck = v => map[v.y, v.x];
            ExplorationMap dut = new ExplorationMap(config);

            dut.SetCriticalZone(new Vector2i(3, 2), 1);

            Copy(new bool[5, 5]
            {
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
            }, map, 5, 5);

            dut.Update();
            Assert.IsTrue(dut.map[3, 2].needsVisit);
            Assert.IsTrue(dut.map[3, 1].needsVisit);
            Assert.IsTrue(dut.map[1, 1].needsVisit);


            Copy(new bool[5, 5]
            {
                { _, _, _, _, _ },
                { _, v, _, v, _ },
                { _, _, _, v, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
            }, map, 5, 5);

            dut.Update();
            Assert.IsFalse(dut.map[3, 2].needsVisit);
            Assert.IsFalse(dut.map[3, 1].needsVisit);
            Assert.IsFalse(dut.map[1, 1].needsVisit);

            Copy(new bool[5, 5]
            {
                { _, _, _, _, _ },
                { _, v, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
            }, map, 5, 5);

            dut.Update();
            Assert.IsFalse(dut.map[3, 2].needsVisit);
            Assert.IsFalse(dut.map[3, 1].needsVisit);
            Assert.IsFalse(dut.map[1, 1].needsVisit);


            for (int i = 0; i < 2; i++)
            {
                dut.Update();
            }

            //
            //      CRITICAL ZONE ACTIVATES HERE
            //

            Copy(new bool[5, 5]
            {
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
            }, map, 5, 5);

            dut.Update();
            Assert.IsTrue(dut.map[3, 2].needsVisit);
            Assert.IsTrue(dut.map[3, 1].needsVisit);
            Assert.IsFalse(dut.map[1, 1].needsVisit);


            Copy(new bool[5, 5]
            {
                { _, _, _, _, _ },
                { _, v, _, v, _ },
                { _, _, _, v, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
            }, map, 5, 5);

            dut.Update();
            Assert.IsFalse(dut.map[3, 2].needsVisit);
            Assert.IsFalse(dut.map[3, 1].needsVisit);
            Assert.IsFalse(dut.map[1, 1].needsVisit);

            Copy(new bool[5, 5]
            {
                { _, _, _, _, _ },
                { _, v, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
                { _, _, _, _, _ },
            }, map, 5, 5);

            dut.Update();
            Assert.IsTrue(dut.map[3, 2].needsVisit);
            Assert.IsTrue(dut.map[3, 1].needsVisit);
            Assert.IsFalse(dut.map[1, 1].needsVisit);


            for (int i = 0; i < 2; i++)
            {
                dut.Update();
            }
        }