Exemplo n.º 1
0
        private ResourceYield _getYield()
        {
            MutableResourceYield yield = new MutableResourceYield();

            foreach (PlanetType type in this.planetCounts.Keys)
            {
                yield.combineDirty(type.getYield(this.planetCounts[type]));
            }
            return(clusterType.modifyYield(yield.readOnly()));
        }
Exemplo n.º 2
0
        public void addition()
        {
            GameResourceType type1 = GameResourceTest.getTestGameResourceType(id: 1);
            GameResourceType type2 = GameResourceTest.getTestGameResourceType(id: 2);
            GameResourceType typeN = null;

            SingularYield singleYield1 = getTestSingularGameResourceYield(type1, 100);
            SingularYield singleYield2 = getTestSingularGameResourceYield(type1, 200);
            SingularYield singleYield3 = getTestSingularGameResourceYield(type1, -300);
            SingularYield singleYield4 = getTestSingularGameResourceYield(type2, 400);

            ResourceYield yield1 = GetTestFinishedGameResourceYield(
                singleYield1
                );
            ResourceYield yield2 = GetTestFinishedGameResourceYield(
                singleYield2,
                singleYield4
                );
            ResourceYield yield3 = GetTestFinishedGameResourceYield(
                singleYield3
                );

            MutableResourceYield yieldU1 = new MutableResourceYield();
            MutableResourceYield yieldU2 = yield1.cloneUnlocked();

            ResourceYield sumI = yield1.combinePure(NOTHING_CONST);

            Assert.That(sumI.Count, Is.EqualTo(1));
            Assert.That(sumI, Contains.Key(type1));
            Assert.That(sumI[type1], Is.EqualTo(100));

            ResourceYield sum1 = yield1.combinePure(yield2);

            Assert.That(sum1.Count, Is.EqualTo(2));
            Assert.That(sum1, Contains.Key(type1));
            Assert.That(sum1, Contains.Key(type2));
            Assert.That(sum1[type1], Is.EqualTo(300));
            Assert.That(sum1[type2], Is.EqualTo(400));
            //Purity (A)
            Assert.That(yield1.Count, Is.EqualTo(1));
            Assert.That(yield1, Contains.Key(type1));
            Assert.That(yield1[type1], Is.EqualTo(100));

            ResourceYield sum2 = yield1.combinePure(yield3);

            Assert.That(sum2.Count, Is.EqualTo(1));
            Assert.That(sum2, Contains.Key(type1));
            Assert.That(sum2[type1], Is.EqualTo(-200));
            //Purity (B)
            Assert.That(yield3.Count, Is.EqualTo(1));
            Assert.That(yield3, Contains.Key(type1));
            Assert.That(yield3[type1], Is.EqualTo(-300));


            Assert.That(yieldU1.Count, Is.EqualTo(0));
            Assert.That(yieldU1, Does.Not.ContainKey(type1));
            ResourceYield sumU1 = yieldU1.combineDirty(yield1);

            Assert.That(yieldU1.Count, Is.EqualTo(1));
            Assert.That(yieldU1, Contains.Key(type1));
            Assert.That(yieldU1[type1], Is.EqualTo(100));
            Assert.That(yieldU1, Is.EqualTo(sumU1));


            Assert.That(yieldU2.Count, Is.EqualTo(1));
            Assert.That(yieldU2, Contains.Key(type1));
            Assert.That(yieldU2[type1], Is.EqualTo(100));
            ResourceYield sumU2 = yieldU2.combineDirty(yield2);

            Assert.That(yieldU2.Count, Is.EqualTo(2));
            Assert.That(yieldU2, Contains.Key(type1));
            Assert.That(yieldU2, Contains.Key(type2));
            Assert.That(yieldU2[type1], Is.EqualTo(300));
            Assert.That(yieldU2[type2], Is.EqualTo(400));
            Assert.That(yieldU2, Is.EqualTo(sumU2));
        }