コード例 #1
0
        public async Task SetProficiencyAsync_SetFalse_ReturnSuccess()
        {
            // Arrange
            var charProvider = new MockCharacterProvider();
            var statProvider = new MockStatisticProvider();

            var statOptions = new StatisticOptions
            {
                InitialAttributeMin         = 1,
                InitialAttributeMax         = 10,
                InitialAttributePoints      = 40,
                InitialAttributesAtMax      = 7,
                InitialAttributesProficient = 0
            };

            var controller = new StatisticController(charProvider, statProvider, new GenericProgressionStrategy(statProvider, statOptions));
            var character  = await charProvider.GetActiveCharacterAsync(1);

            await controller.SetStatisticAsync(1, "strength", 10);

            // Act
            var result = await controller.SetProficiencyAsync(1, "strength", false);

            // Assert
            Assert.Equal(StatisticResult.StatisticSetSucessfully(), result);
        }
コード例 #2
0
        public async Task SetStatisticAsync_LevelTooHighButAttributesUnset_ReturnSuccess()
        {
            // Arrange
            var charProvider = new MockCharacterProvider();
            var character    = await charProvider.CreateCharacterAsync(100, "TooHigh");

            // the important bit
            character.Experience = 50000;

            var statProvider = new MockStatisticProvider();
            var statOptions  = new StatisticOptions
            {
                InitialAttributeMin    = 1,
                InitialAttributeMax    = 10,
                InitialAttributePoints = 10,
                InitialSetupMaxLevel   = 1
            };

            var controller = new StatisticController(charProvider, statProvider, new GenericProgressionStrategy(statProvider, statOptions));

            // Act
            var result = await controller.SetStatisticAsync(100, "strength", 3);

            // Assert
            Assert.Equal(StatisticResult.StatisticSetSucessfully(), result);
        }
コード例 #3
0
        public async Task SetProficiencyAsync_ValidInput_ReturnSuccess()
        {
            // Arrange
            var charProvider = new MockCharacterProvider();
            var statProvider = new MockStatisticProvider();

            var statOptions = new StatisticOptions
            {
                InitialAttributeMin         = 1,
                InitialAttributeMax         = 10,
                InitialAttributePoints      = 40,
                InitialAttributesAtMax      = 7,
                InitialAttributesProficient = 1
            };

            var controller = new StatisticController(charProvider, statProvider, new GenericProgressionStrategy(statProvider, statOptions));
            var character  = await charProvider.GetActiveCharacterAsync(1);

            Statistic str = await statProvider.GetStatisticAsync("strength");

            await controller.SetStatisticAsync(1, "strength", 10);

            // Act
            await controller.SetProficiencyAsync(1, "strength", true);

            // Assert
            Assert.True(character.GetStatistic(str).IsProficient);
        }
コード例 #4
0
        public async Task SetStatisticAsync_InvalidStatisticName_ReturnStatisticNotFound()
        {
            // Arrange
            var charProvider             = new MockCharacterProvider();
            var statProvider             = new MockStatisticProvider();
            StatisticOptions statOptions = new StatisticOptions();

            var controller = new StatisticController(charProvider, statProvider, new GenericProgressionStrategy(statProvider, statOptions));

            // Act
            var result = await controller.SetStatisticAsync(1, "invalid", 5);

            // Assert
            Assert.Equal(StatisticResult.StatisticNotFound(), result);
        }
コード例 #5
0
        public async Task SetStatisticAsync_InvalidCharacterId_ReturnCharacterNotFound()
        {
            // Arrange
            var charProvider             = new MockCharacterProvider();
            var statProvider             = new MockStatisticProvider();
            StatisticOptions statOptions = new StatisticOptions();

            var controller = new StatisticController(charProvider, statProvider, new GenericProgressionStrategy(statProvider, statOptions));

            // Act
            var result = await controller.SetStatisticAsync(ulong.MaxValue, "strength", 5);

            // Assert
            Assert.Equal(CharacterResult.CharacterNotFound(), result);
        }
コード例 #6
0
        public async Task SetStatisticAsync_TooManyAtMax_ReturnTooManyAtMax()
        {
            // Arrange
            var charProvider = new MockCharacterProvider();
            var statProvider = new MockStatisticProvider();
            var statOptions  = new StatisticOptions
            {
                InitialAttributeMax    = 2,
                InitialAttributePoints = 6,
                InitialAttributesAtMax = 2
            };

            var controller = new StatisticController(charProvider, statProvider, new GenericProgressionStrategy(statProvider, statOptions));

            // Act
            await controller.SetStatisticAsync(1, "strength", 2);

            await controller.SetStatisticAsync(1, "perception", 2);

            var result = await controller.SetStatisticAsync(1, "endurance", 2);

            // Assert
            Assert.Equal(StatisticResult.TooManyAtMax(2), result);
        }
コード例 #7
0
        public async Task SetStatisticAsync_LevelTooHigh_ReturnLevelTooHigh()
        {
            // Arrange
            var charProvider = new MockCharacterProvider();
            var character    = await charProvider.CreateCharacterAsync(100, "TooHigh");

            var statProvider = new MockStatisticProvider();
            var statOptions  = new StatisticOptions
            {
                InitialAttributeMin      = 1,
                InitialAttributeMax      = 10,
                InitialAttributePoints   = 40,
                InitialSkillPoints       = 1,
                InitialSetupMaxLevel     = 1,
                AttributePointsOnLevelUp = 0
            };

            var controller = new StatisticController(charProvider, statProvider, new GenericProgressionStrategy(statProvider, statOptions));

            // Act

            // Set initial special
            await controller.SetStatisticAsync(100, "strength", 10);

            await controller.SetStatisticAsync(100, "perception", 2);

            await controller.SetStatisticAsync(100, "endurance", 6);

            await controller.SetStatisticAsync(100, "charisma", 6);

            await controller.SetStatisticAsync(100, "intelligence", 6);

            await controller.SetStatisticAsync(100, "agility", 5);

            await controller.SetStatisticAsync(100, "luck", 5);

            character.Experience = 50000;
            await charProvider.UpdateCharacterAsync(character);

            // Attempt to set initial special again after going past InitialSetupMaxLevel
            var result = await controller.SetStatisticAsync(100, "strength", 4);

            // Assert
            Assert.Equal(CharacterResult.LevelTooHigh(), result);
        }
コード例 #8
0
        public async Task SetStatisticAsync_ValidInput_ReturnSuccess()
        {
            // Arrange
            var charProvider = new MockCharacterProvider();
            var statProvider = new MockStatisticProvider();

            var statOptions = new StatisticOptions
            {
                InitialAttributeMin    = 1,
                InitialAttributeMax    = 10,
                InitialAttributePoints = 40,
                InitialAttributesAtMax = 7
            };

            var controller = new StatisticController(charProvider, statProvider, new GenericProgressionStrategy(statProvider, statOptions));
            var character  = await charProvider.GetActiveCharacterAsync(1);

            // Act
            await controller.SetStatisticAsync(1, "strength", 10);

            await controller.SetStatisticAsync(1, "perception", 2);

            await controller.SetStatisticAsync(1, "endurance", 6);

            await controller.SetStatisticAsync(1, "charisma", 6);

            await controller.SetStatisticAsync(1, "intelligence", 6);

            await controller.SetStatisticAsync(1, "agility", 5);

            await controller.SetStatisticAsync(1, "luck", 5);

            // Assert
            Statistic str  = await statProvider.GetStatisticAsync("strength"),
                      per  = await statProvider.GetStatisticAsync("perception"),
                      end  = await statProvider.GetStatisticAsync("endurance"),
                      cha  = await statProvider.GetStatisticAsync("charisma"),
                      inte = await statProvider.GetStatisticAsync("intelligence"),
                      agi  = await statProvider.GetStatisticAsync("agility"),
                      lck  = await statProvider.GetStatisticAsync("luck");

            Assert.True(character.GetStatistic(str).Value.Equals(10) &&
                        character.GetStatistic(per).Value.Equals(2) &&
                        character.GetStatistic(end).Value.Equals(6) &&
                        character.GetStatistic(cha).Value.Equals(6) &&
                        character.GetStatistic(inte).Value.Equals(6) &&
                        character.GetStatistic(agi).Value.Equals(5) &&
                        character.GetStatistic(lck).Value.Equals(5));
        }
コード例 #9
0
        public async Task SetStatisticAsync_NewValueLowerThanCurrent_ReturnInvalidInput()
        {
            // Arrange
            var charProvider = new MockCharacterProvider();
            var character    = await charProvider.CreateCharacterAsync(100, "TooHigh");

            var statProvider = new MockStatisticProvider();
            var statOptions  = new StatisticOptions
            {
                InitialAttributeMin      = 1,
                InitialAttributeMax      = 10,
                InitialAttributePoints   = 40,
                InitialSetupMaxLevel     = 1,
                AttributePointsOnLevelUp = 0
            };

            var controller = new StatisticController(charProvider, statProvider, new GenericProgressionStrategy(statProvider, statOptions));

            // Act
            // Set initial special
            await controller.SetStatisticAsync(100, "strength", 10);

            await controller.SetStatisticAsync(100, "perception", 2);

            await controller.SetStatisticAsync(100, "endurance", 6);

            await controller.SetStatisticAsync(100, "charisma", 6);

            await controller.SetStatisticAsync(100, "intelligence", 6);

            await controller.SetStatisticAsync(100, "agility", 5);

            await controller.SetStatisticAsync(100, "luck", 5);

            character.Experience = 50000;
            await charProvider.UpdateCharacterAsync(character);

            // Attempt to set special lower than current value
            var result = await controller.SetStatisticAsync(100, "strength", 4);

            // Assert
            Assert.Equal(Messages.INVALID_INPUT, result.Message);
        }
コード例 #10
0
        public async Task SetStatisticAsync_AboveMaximum_ReturnTooHigh()
        {
            // Arrange
            var charProvider = new MockCharacterProvider();
            var statProvider = new MockStatisticProvider();
            var statOptions  = new StatisticOptions
            {
                InitialAttributeMax    = 10,
                InitialAttributePoints = 12,
            };

            var controller = new StatisticController(charProvider, statProvider, new GenericProgressionStrategy(statProvider, statOptions));

            // Act
            var result = await controller.SetStatisticAsync(1, "strength", 11);

            // Assert
            Assert.Equal(GenericResult.ValueTooHigh(), result);
        }
コード例 #11
0
        public async Task SetStatisticAsync_NotEnoughPoints_ReturnNotEnoughPoints()
        {
            // Arrange
            int points    = 1;
            int luckScore = 2;

            var charProvider = new MockCharacterProvider();
            var statProvider = new MockStatisticProvider();
            var statOptions  = new StatisticOptions
            {
                InitialAttributeMax    = 10,
                InitialAttributePoints = points
            };

            var controller = new StatisticController(charProvider, statProvider, new GenericProgressionStrategy(statProvider, statOptions));

            // Act
            var result = await controller.SetStatisticAsync(1, "luck", 2);

            // Assert
            // TODO: update unit tests to match new result
            Assert.Equal(GenericResult.Failure(
                             string.Format(Messages.STAT_NOT_ENOUGH_POINTS, luckScore, points)), result);
        }
コード例 #12
0
ファイル: StatisticModule.cs プロジェクト: MickMelon/FRAGS
        public async Task SetStatisticAsync(string statName, int?newValue = null)
        {
            var result = await _statController.SetStatisticAsync(Context.User.Id, statName, newValue);

            await ReplyAsync(result.Message);
        }