Exemplo n.º 1
0
        private static async Task GetLockedAndUnlockedFeatures(IProgressionSystem <FeatureFlag> xpSys, int currentUserXp)
        {
            var t = Log.MethodEntered();

            {
                var lockedFeatures = await xpSys.GetLockedFeatures();

                var unlockedFeatures = await xpSys.GetUnlockedFeatures();

                Assert.NotEmpty(lockedFeatures);
                Assert.NotEmpty(unlockedFeatures);
                Assert.Empty(lockedFeatures.Intersect(unlockedFeatures)); // There should be no features in both lists

                foreach (var feature in lockedFeatures)
                {
                    Assert.True(currentUserXp < feature.requiredXp);
                    Assert.False(await xpSys.IsFeatureUnlocked(feature));
                }
                foreach (var feature in unlockedFeatures)
                {
                    Assert.True(currentUserXp >= feature.requiredXp);
                    Assert.True(await xpSys.IsFeatureUnlocked(feature));
                }

                var nextAvailableFeature = lockedFeatures.OrderBy(f => f.requiredXp).First();
                Log.d("The next unlocked feature will be " + JsonWriter.AsPrettyString(nextAvailableFeature));
            }
            Log.MethodDone(t);
        }
Exemplo n.º 2
0
        public static async Task <bool> IsFeatureUnlocked <T>(this T self) where T : IFeatureFlag
        {
            var tt  = "" + typeof(T);
            var key = IoC.inject.GetEventKey <IProgressionSystem <T> >();
            IProgressionSystem <T> progrSys = IoC.inject.Get <IProgressionSystem <T> >(self);

            if (progrSys == null)
            {
                return(true);
            } // No progr. system in place
            return(await progrSys.IsFeatureUnlocked(self));
        }
Exemplo n.º 3
0
 public Domain.IBattleBuilder WithProgressionSystem()
 {
     ProgressionSystem = new LevelBasedProgression();
     return(this);
 }
Exemplo n.º 4
0
 public Domain.IBattleBuilder WithProgressionSystem()
 {
     ProgressionSystem = new SphereGrid();
     return(this);
 }