public void NestedInventoriesSerializeAndDeserializeCorrectly()
        {
            var outerInventory = InventoryComponent.Create(20);

            var waterskin = Entity.Create("waterskinId", "waterskinName");

            waterskin.AddComponent(StorableComponent.Create());
            var waterskinInventory = InventoryComponent.Create(10);

            var nested = Entity.Create("nestedId", "nestedName");

            nested.AddComponent(StorableComponent.Create());

            waterskinInventory.AddEntity(nested);
            waterskin.AddComponent(waterskinInventory);

            outerInventory.AddEntity(waterskin);

            string saved        = outerInventory.Save();
            var    newComponent = InventoryComponent.Create(saved);

            Assert.Equal("waterskinId", newComponent._StoredEntities[0].EntityId);
            Assert.Equal("waterskinName", newComponent._StoredEntities[0].EntityName);
            Assert.NotNull(newComponent._StoredEntities[0].GetComponent <StorableComponent>());
            Assert.Equal("nestedId", newComponent._StoredEntities[0].GetComponent <InventoryComponent>()._StoredEntities[0].EntityId);
            Assert.Equal("nestedName", newComponent._StoredEntities[0].GetComponent <InventoryComponent>()._StoredEntities[0].EntityName);
        }
        public void IncludesEntityGroup()
        {
            var         component    = StorableComponent.Create(0);
            JsonElement deserialized = JsonSerializer.Deserialize <JsonElement>(component.Save());

            Assert.Equal(StorableComponent.ENTITY_GROUP, deserialized.GetProperty("EntityGroup").GetString());
        }
        public void SerializesAndDeserializesCorrectly()
        {
            var    component = StorableComponent.Create(4);
            string saved     = component.Save();

            var newComponent = StorableComponent.Create(saved);

            Assert.Equal(component.Size, newComponent.Size);
        }
Example #4
0
        public static Entity CreateIntelEntity(int targetDungeonLevel)
        {
            var e = CreateEntity(Guid.NewGuid().ToString(), "intel for sector " + targetDungeonLevel);

            e.AddComponent(DisplayComponent.Create(_texIntelPath, "Intel! Gives you zone information for the next sector. You want this.", true, ITEM_Z_INDEX));
            e.AddComponent(StorableComponent.Create());
            e.AddComponent(UsableComponent.Create(useOnGet: true));
            e.AddComponent(UseEffectAddIntelComponent.Create(targetDungeonLevel));

            return(e);
        }
Example #5
0
        private static Entity CreateRedPaintEntity()
        {
            var e = CreateEntity(Guid.NewGuid().ToString(), "red paint");

            e.AddComponent(DisplayComponent.Create(_texRedPaintPath, "Reduces turn time by 75 for 300 ticks (minimum time is 1).", true, ITEM_Z_INDEX));
            e.AddComponent(StorableComponent.Create());
            e.AddComponent(UsableComponent.Create(useOnGet: false));
            e.AddComponent(UseEffectBoostSpeedComponent.Create(boostPower: 75, duration: 300));

            return(e);
        }
Example #6
0
        private static Entity CreateDuctTapeEntity()
        {
            var e = CreateEntity(Guid.NewGuid().ToString(), "duct tape");

            e.AddComponent(DisplayComponent.Create(_texDuctTapePath, "Some duct tape. Heals 10 HP.", true, ITEM_Z_INDEX));
            e.AddComponent(StorableComponent.Create());
            e.AddComponent(UsableComponent.Create(useOnGet: false));
            e.AddComponent(UseEffectHealComponent.Create(healpower: 10));

            return(e);
        }
Example #7
0
        private static Entity CreateExtraBatteryEntity()
        {
            var e = CreateEntity(Guid.NewGuid().ToString(), "extra battery");

            e.AddComponent(DisplayComponent.Create(_texBatteryPath, "An extra battery for your weapons. Gives 20 power for 450 ticks.", true, ITEM_Z_INDEX));
            e.AddComponent(StorableComponent.Create());
            e.AddComponent(UsableComponent.Create(useOnGet: false));
            e.AddComponent(UseEffectBoostPowerComponent.Create(boostPower: 20, duration: 450));

            return(e);
        }
Example #8
0
        private static Entity CreateEMPEntity()
        {
            var e = CreateEntity(Guid.NewGuid().ToString(), "EMP");

            e.AddComponent(DisplayComponent.Create(_texEMPPath, "An EMP burst. Disables enemies for 10 turns in radius 20.", true, ITEM_Z_INDEX));
            e.AddComponent(StorableComponent.Create());
            e.AddComponent(UsableComponent.Create(useOnGet: false));
            // I seriously put 20 radius 10 turns? That's enough time to mop up an entire encounter!
            e.AddComponent(UseEffectEMPComponent.Create(radius: 20, disableTurns: 10));

            return(e);
        }