示例#1
0
    public void OneMarketTest()
    {
        var province = new Province("test", 1, Color.black, null);
        var country  = new Country("test", null, Color.black, province, 10f);

        var world = new MockWorld();

        world.RegisterCountry(country);

        var market = country.market;

        market.Initialize(country);

        var factory = new Factory(province, null, ProductionType.Orchard, new MoneyView(20));

        factory.SendToMarket(new Storage(Product.Fruit, 10f));

        var buyer = new MockAristocrats(1000, null, province);

        buyer.Cash = new Money(1000000);

        buyer.Buy(new Storage(Product.Fruit, 10f), null);

        //force DSB recalculation
        World.AllMarkets().PerformAction(x => x.getDemandSupplyBalance(null, true));

        Market.GiveMoneyForSoldProduct(factory);

        World.getAllExistingCountries().PerformAction(x => Debug.Log(x + "\n"));
        Assert.AreEqual(new MoneyView(10).Get(), factory.Cash.Get());
    }
        public void WorldSelector_ActiveWorld_will_be_non_null_if_spatial_worlds()
        {
            using (var mockWorld = MockWorld.Create(new MockWorld.Options()))
            {
                var element = new WorldSelector();
                element.UpdateWorldSelection();

                Assert.IsNotNull(element.ActiveWorld);
                Assert.AreEqual(mockWorld.Worker.World, element.ActiveWorld);
            }
        }
示例#3
0
        public void Disposed_world_cleans_provider()
        {
            using (var mockWorld = MockWorld.Create(new MockWorld.Options()))
            {
                mockWorld.Step(world =>
                {
                    world.Connection.CreateEntity(entityId, GetTemplate());
                });

                Assert.AreEqual(1, ReferenceProvider <string> .Count);
            }

            Assert.AreEqual(0, ReferenceProvider <string> .Count);
        }
        public void WorldSelector_OnWorldChanged_called_when_world_changed()
        {
            using (MockWorld.Create(new MockWorld.Options()))
            {
                var element = new WorldSelector();

                var changed = false;
                element.OnWorldChanged += world => changed = true;

                element.UpdateWorldSelection();

                Assert.IsTrue(changed);
            }
        }
示例#5
0
        public void Removed_component_disposes_reference()
        {
            var template = GetTemplate();

            using (var mockWorld = MockWorld.Create(new MockWorld.Options()))
            {
                mockWorld
                .Step(world =>
                {
                    world.Connection.CreateEntity(entityId, template);
                })
                .Step(world =>
                {
                    Assert.AreEqual(1, ReferenceProvider <string> .Count);
                    world.Connection.RemoveEntityAndComponents(entityId, template);
                });

                Assert.AreEqual(0, ReferenceProvider <string> .Count);
            }
        }
示例#6
0
        public void SetUp()
        {
            this.world  = MockWorld.Generate();
            this.entity = this.world.CreateEntity();

            this.interpreter = new Interpreter(Assembly.GetAssembly(typeof(ReverieGame)));

            Container inventory = new Container(10);

            this.entity.AddComponent(inventory);

            EntityDataCache entityDatas = WorldCache.GetCache(this.world).EntityDatas;

            Entity itemStack = this.world.CreateEntity();

            itemStack.AddComponent(new EntityStack(3, 3));
            itemStack.AddComponent(entityDatas[EntityType.Consumable]);

            Entity itemSingle = this.world.CreateEntity();

            itemSingle.AddComponent(entityDatas[EntityType.Consumable]);

            Entity     bag           = this.world.CreateEntity();
            Container  container     = new Container(3);
            EntityData bagEntityData = new EntityData(
                Guid.NewGuid(),
                "Bag",
                "Just a bag.",
                null,
                EntityType.Container);

            bag.AddComponent(bagEntityData);
            bag.AddComponent(container);
            container.AddEntity(itemStack);

            inventory.AddEntity(bag);
            inventory.AddEntity(itemSingle);
        }
 public ReverieGame()
 {
     this.gameWorld   = MockWorld.Generate();
     this.interpreter = new CommandParser.Interpreter(Assembly.GetAssembly(typeof(ReverieGame)));
 }