Пример #1
0
        public void GainLevel_HasNoRewardForLevel_NoRewardsGiven()
        {
            int[] xplevels = new int[] { 0, 100 };
            LevelRewarder levelReward = new LevelRewarder(xplevels);
            Player player = new Player(null, null, null, levelReward);
            this.Engine.AddActor(player);
            this.Engine.Update();
            player.AddXP(100);

            Assert.AreEqual(2, levelReward.CurrentLevel);
        }
Пример #2
0
        public void GainLevel_ZeroXPRequriedForLevelUp_RewardGiven()
        {
            bool rewardGiven = false;
            int[] xplevels = new int[]{0};
            LevelRewarder levelReward = new LevelRewarder(xplevels);
            Player player = new Player(null, null, null, levelReward);
            levelReward.SetReward(1,rw => rewardGiven = true);
            this.Engine.AddActor(player);
            this.Engine.Update();

            Assert.IsTrue(rewardGiven);
        }
Пример #3
0
        public void GainLevel_HasAReward_RewardGiven()
        {
            bool rewardGiven = false;
            int[] xplevels = new int[] { 0, 100 };
            LevelRewarder levelReward = new LevelRewarder(xplevels);
            Player player = new Player(null, null, null, levelReward);
            levelReward.SetReward(2, rw => rewardGiven = true);
            this.Engine.AddActor(player);
            this.Engine.Update();
            player.AddXP(100);

            Assert.IsTrue(rewardGiven);
        }
Пример #4
0
 public Player(GameLibrary lib, Hand hand, ManaStorage manaStorage,LevelRewarder rewarder)
 {
     this.CurrentXP = 0;
     this.Rewarder = rewarder;
     if (this.Rewarder != null)
         Rewarder.Owner = this;
     Library = lib;
     if(lib!=null)
         Library.Owner = this;
     Hand = hand;
     ManaStorage = manaStorage;
     if(manaStorage != null)
         ManaStorage.Owner = this;
 }
Пример #5
0
        public void GainLevel_GetsXpForMultipleLevels_RewardsForAllLevelsGiven()
        {
            bool FirstRewardGiven = false;
            bool SecondRewardGiven = false;
            int[] xplevels = new int[] { 0, 100, 200 };
            LevelRewarder levelReward = new LevelRewarder(xplevels);
            Player player = new Player(null, null, null, levelReward);
            levelReward.SetReward(2, rw => FirstRewardGiven = true);
            levelReward.SetReward(3, rw => SecondRewardGiven = true);
            this.Engine.AddActor(player);
            this.Engine.Update();
            player.AddXP(200);

            Assert.IsTrue(FirstRewardGiven);
            Assert.IsTrue(SecondRewardGiven);
        }
Пример #6
0
 public Player(GameLibrary lib, Hand hand, ManaStorage manaStorage, LevelRewarder rewarder)
 {
     this.CurrentXP = 0;
     this.Rewarder  = rewarder;
     if (this.Rewarder != null)
     {
         Rewarder.Owner = this;
     }
     Library = lib;
     if (lib != null)
     {
         Library.Owner = this;
     }
     Hand        = hand;
     ManaStorage = manaStorage;
     if (manaStorage != null)
     {
         ManaStorage.Owner = this;
     }
 }