Пример #1
0
        public void Test_MoneyStacking()
        {
            var world = new World();
            var room  = new Room("SomeRoom", world, 'f');
            var you   = new You("Dave", room);

            world.Map.Add(new Point3(0, 0, 0), room);

            var money = new ItemStack("Money", 10).With(Stat.Value, 1);

            room.Items.Add(money);

            Assert.AreEqual(10, money.GetFinalStats(you)[Stat.Value], "Money has worth depending on stack size");
            Assert.AreEqual(0, money.GetFinalStats(you)[Stat.Fight], "Money doesn't help you fight");

            var money2 = new ItemStack("Money", 10).With(Stat.Value, 1);

            room.Items.Add(money2);

            //pick both up
            world.RunRound(new FixedChoiceUI((IItem)money), you.GetFinalActions().OfType <PickUpAction>().First());
            world.RunRound(new FixedChoiceUI((IItem)money2), you.GetFinalActions().OfType <PickUpAction>().First());

            // you only have 1 item which has all the Money
            Assert.AreSame(money, you.Items.Single());
            Assert.AreEqual(20, money.StackSize);
            Assert.AreEqual(20, money.GetFinalStats(you)[Stat.Value]);
        }
Пример #2
0
        public void TestCreatingRoomFromBlueprint_WithDialogue()
        {
            var yaml = @"- Name: Gun Bay
  Dialogue:
    Next: 193506ab-11bc-4de2-963e-e2f55a38d006";

            var roomFactory = new RoomFactory {
                Blueprints = Compiler.Instance.Deserializer.Deserialize <List <RoomBlueprint> >(yaml)
            };

            var w = new World();

            w.Dialogue.AllDialogues.Add(new DialogueNode()
            {
                Identifier = new Guid("193506ab-11bc-4de2-963e-e2f55a38d006"),
                Body       = new List <TextBlock> {
                    new TextBlock("This room is rank"),
                }
            });

            var room = roomFactory.Create(w, roomFactory.Blueprints.Single());

            w.Map.Add(new Point3(0, 0, 0), room);

            var you = new You("Wanderer", room);

            var ui = GetUI("look:Gun Bay");

            w.RunRound(ui, you.GetFinalActions().OfType <DialogueAction>().Single());

            Assert.Contains("This room is rank", ui.MessagesShown);
        }