Esempio n. 1
0
        public void Nature_does_not_strike_the_rot_via_other_sources()
        {
            GameState gs = new GameState();
            var       cm = new CompoundMap();

            cm.RotMap = new RotMap();
            gs.Map    = cm;

            //var asys = new AttackSystem();
            var asys = SourceMe.The <AttackSystem>();

            asys.GameState = gs;

            var    flameRat = BeingCreator.CreateBeing("flame rat");
            var    am       = new AttackMethod("physical.impact.blunt", "1d3 +2");
            var    rot      = new AreaRot();
            Attack attack   = new Attack
            {
                Attacker      = flameRat,
                AttackMethod  = am,
                Defender      = rot,
                DefenseMethod = rot.GetDefenseMethod(am)
            };

            Assert.That(asys.AttackQueue.Count, Is.EqualTo(0));

            asys.CheckForSpecials(attack);

            Assert.That(asys.AttackQueue.Count, Is.EqualTo(1));
        }
Esempio n. 2
0
        public CompoundMap MapFromYAML(string mapYaml)
        {
            CompoundMapBridge bridge = BridgeFromYAML(mapYaml);
            CompoundMap       map    = MapFromBridge(bridge);

            return(map);
        }
Esempio n. 3
0
 protected void Assert_Map_isRoundRoom(CompoundMap map)
 {
     Assert.That(map.Name, Is.EqualTo("Round Room"));
     Assert.That(map.Height, Is.EqualTo(5));
     Assert.That(map.Width, Is.EqualTo(7));
     Assert.That(map.SpaceMap.GetItem((1, 0)).Terrain.Name, Is.EqualTo("soil"));
     Assert.That(map.SpaceMap.GetItem((1, 1)).Terrain.Name, Is.EqualTo("stone wall"));
     Assert.That(map.SpaceMap.GetItem((5, 2)).Terrain.Name, Is.EqualTo("closed door"));
 }
Esempio n. 4
0
        internal CompoundMap FarmhouseMap()
        {
            if (farmhouseMap == null)
            {
                farmhouseMap = MapFromYAML(rootCellarYaml);
                //_farmhouseMap.PlayerStartsAt = new Point(2, 7);
            }

            return(farmhouseMap);
        }
Esempio n. 5
0
        public void Nature_strikes_neighboring_rot_through_our_hero()
        {
            var    player = BeingCreator.CreateBeing("Suvail");
            var    am     = new AttackMethod("physical.impact.blunt", "1d3 +2");
            var    rot    = new AreaRot();
            Attack attack = new Attack
            {
                Attacker      = player,
                AttackMethod  = am,
                Defender      = rot,
                DefenseMethod = rot.GetDefenseMethod(am)
            };

            RotMap rotMap = new RotMap();
            //...add two neighbor ABs, and one further away
            var nbor_1   = new AreaRot();
            var nbor_2   = new AreaRot();
            var stranger = new AreaRot();

            rotMap.Add(rot, (2, 2));
            rotMap.Add(nbor_1, (2, 3));
            rotMap.Add(nbor_2, (3, 1));
            rotMap.Add(stranger, (8, 2));

            GameState gs = new GameState();
            var       cm = new CompoundMap();

            cm.RotMap = rotMap;
            gs.Map    = cm;

            var asys = new AttackSystem {
                GameState = gs
            };

            SourceMe.InjectProperties(asys);

            Assert.That(asys.AttackQueue.Count, Is.EqualTo(0));

            asys.CheckForSpecials(attack);

            Assert.That(asys.AttackQueue.Count, Is.EqualTo(4));

            var splashBack = asys.AttackQueue.Dequeue();

            Assert.NotNull(splashBack);

            var newAttack = asys.AttackQueue.Dequeue();

            Assert.That(newAttack.Defender, Is.EqualTo(rot));

            newAttack = asys.AttackQueue.Dequeue();
            Assert.That(newAttack.Defender, Is.EqualTo(nbor_2));
            newAttack = asys.AttackQueue.Dequeue();
            Assert.That(newAttack.Defender, Is.EqualTo(nbor_1));
        }
Esempio n. 6
0
        public void Nature_strikes_the_rot_through_our_hero()
        {
            GameState gs = new GameState();
            var       cm = new CompoundMap();

            cm.RotMap = new RotMap();
            gs.Map    = cm;

            var asys = new AttackSystem();

            asys.GameState = gs;
            SourceMe.InjectProperties(asys);

            var    player = BeingCreator.CreateBeing("Suvail");
            var    am     = new AttackMethod("physical.impact.blunt", "1d3 +2");
            var    rot    = new AreaRot();
            Attack attack = new Attack
            {
                Attacker      = player,
                AttackMethod  = am,
                Defender      = rot,
                DefenseMethod = rot.GetDefenseMethod(am)
            };

            Assert.That(asys.AttackQueue.Count, Is.EqualTo(0));

            asys.CheckForSpecials(attack);

            Assert.That(asys.AttackQueue.Count, Is.EqualTo(2));

            var splashBack = asys.AttackQueue.Dequeue();

            Assert.NotNull(splashBack);

            var newAttack = asys.AttackQueue.Dequeue();
            var newAM     = newAttack.AttackMethod;
            var newAE     = newAM.AttackEffects[0];

            Assert.That(newAE.Type, Is.EqualTo("vital.nature.itself"));
            Assert.That(newAttack.Defender, Is.EqualTo(rot));
            Assert.That(newAttack.Attacker, Is.EqualTo(player));
        }
Esempio n. 7
0
        internal CompoundMap FarmMap()
        {
            if (farmMap == null)
            {
                farmMap = MapFromYAML(farmMapYaml);
                farmMap.SpaceMap.PlayerStartPoint = (23, 21);  //0.1.MAP  get start location from map
                Coord shedCoord = (28, 4);
                var   gear      = Equipper.BuildItem("hoe");
                farmMap.ItemMap.Add(gear, shedCoord);
                gear = Equipper.BuildItem("gloves");
                farmMap.ItemMap.Add(gear, shedCoord);

                var rots = new List <string> {
                    "..1221",
                    "...1211",
                    "....121",
                    ".1112211",
                    "11122221111...11",
                    ".1111232221111111",
                    ".11113332221111",
                    "111111333221111",
                    "11111333221111",
                    ".1111333111.11",
                    ".1133221111.11",
                    ".1123232111",
                    ".112111331111",
                    ".112111122111",
                    ".1111 111111",
                    "..1........1",
                    "..11......11",
                    "..11......1",
                    "..........111",
                    "...........111",
                    "..........11",
                    ".....1....1",
                    "...1111..11",
                    "....111111",
                    "...1123211",
                    ".111..111",
                    ".......1",
                };
                AddRotsFromTextList(farmMap.RotMap, (6, 0), rots);

                //  Obscure point on the edge to test map transitions
                //_farmMap.AddEventAtLocation(new Point(41, 1), new CommandEntry(GameCommand.GoToFarmhouse, null));

                //  Barrier in front of the gate out
                var noLeave = new Trigger
                {
                    Name       = "Not Ready to Leave",
                    Categories = TriggerCategories.PlayerLocation,
                    Condition  = "(5, 16) to (5, 18)",
                    Script     = new List <string>
                    {
                        "message",
                        "Something needs doing here, first.",
                        "end message",
                        "move player: (6, 17)",
                    },
                };
                farmMap.AddTrigger(noLeave);
            }

            log.Debug("Loaded the farmyard map");
            return(farmMap);
        }
Esempio n. 8
0
        public CompoundMap MapFromBridge(CompoundMapBridge bridge)
        {
            var width  = bridge.Terrain.Max(t => t.Length);
            var height = bridge.Terrain.Count;

            if (bridge.Width != width)
            {
                log.Error($"Map {bridge.Name} declares width {bridge.Width} but has terrain {width} wide.");
            }
            if (bridge.Height != height)
            {
                log.Error($"Map {bridge.Name} declares height {bridge.Height} but has terrain {height} high.");
            }

            var map = new CompoundMap
            {
                Name     = bridge.Name,
                Width    = width,
                Height   = height,
                SpaceMap = new SpaceMap(width, height),
                BeingMap = new BeingMap(),
                ItemMap  = new ItemMap(),
                RotMap   = new RotMap(),
            };

            var tilledSoil = Atlas.Legend[TerrainEnum.SoilTilled];

            for (int y = 0; y < height; y++)
            {
                string row = bridge.Terrain[y];
                for (int x = 0; x < width; x++)
                {
                    var symbol = (x < row.Length)
                        ? row.Substring(x, 1)
                        : "???";
                    var name = bridge.Legend[symbol];

                    var   type  = TerrainFrom(name);
                    Space space = new Space
                    {
                        Terrain  = type,
                        IsTilled = (type == tilledSoil),
                    };
                    map.SpaceMap.Add(space, (x, y));
                }
            }

            foreach (var coord in bridge.AreaRots.Keys)
            {
                map.RotMap.Add(bridge.AreaRots[coord], coord);
            }

            foreach (var pair in bridge.AreaRots)
            {
                map.RotMap.Add(pair.Value, pair.Key);
            }

            map.Triggers.AddRange(bridge.Triggers);

            return(map);
        }