Esempio n. 1
0
        public void EntityTestAddResource()
        {
            MockEntity       ent     = new MockEntity(Engine);
            ResourceTemplate resTemp = new ResourceTemplate();

            resTemp.Formula       = new MeNode(100);
            resTemp.RegenFormula  = new MeNode(0);
            resTemp.RegenInterval = new MeNode(0);
            resTemp.StartMod      = new MeNode(0);
            resTemp.Key           = "TEST_RES";
            resTemp.Name          = "Test Resource";
            resTemp.Description   = "";

            ent.AddResource(resTemp);
            ent.Key = "TEST_KEY";
            Assert.AreEqual(0, ent.GetProperty(resTemp.Key).Value);
            long amount = 50;

            Engine.AddPlayer(ent);
            string fromula = $"{LConstants.ADD_TO_RESOURCE_F}({ent.Key},{resTemp.Key},{amount})";

            TreeConverter.Build(fromula, Engine).Resolve();
            Assert.AreEqual(amount, ent.GetProperty(resTemp.Key).Value);
        }