mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-14 11:48:16 +00:00
added tests for experience tracking module
refactored some things in experience tracking changed the paging behaviour for leader board and added check for negative numbers fixed rank not being correct for further pages added test-common module to have some common code für tests fixed command creation
This commit is contained in:
@@ -10,6 +10,10 @@ import java.util.List;
|
||||
@Component
|
||||
public class ExperienceFeatureConfig implements FeatureConfig {
|
||||
|
||||
public static final String MIN_EXP_KEY = "minExp";
|
||||
public static final String MAX_EXP_KEY = "maxExp";
|
||||
public static final String EXP_MULTIPLIER_KEY = "expMultiplier";
|
||||
|
||||
@Override
|
||||
public FeatureEnum getFeature() {
|
||||
return ExperienceFeature.EXPERIENCE;
|
||||
@@ -17,6 +21,6 @@ public class ExperienceFeatureConfig implements FeatureConfig {
|
||||
|
||||
@Override
|
||||
public List<String> getRequiredSystemConfigKeys() {
|
||||
return Arrays.asList("expMultiplier", "minExp", "maxExp");
|
||||
return Arrays.asList(EXP_MULTIPLIER_KEY, MIN_EXP_KEY, MAX_EXP_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import dev.sheldan.abstracto.experience.models.database.AExperienceLevel;
|
||||
import dev.sheldan.abstracto.experience.models.database.AExperienceRole;
|
||||
import dev.sheldan.abstracto.experience.models.database.AUserExperience;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -27,20 +27,21 @@ public interface AUserExperienceService {
|
||||
void addExperience(AUserInAServer userInAServer);
|
||||
|
||||
/**
|
||||
* The current representation of the run time epxerience. Basically a HashMap of minutes to a list of {@link AServer}
|
||||
* The current representation of the run time experience. Basically a HashMap of minutes to a list of {@link AServer}
|
||||
* containing a list of {@link AUserInAServer} which should gain experience in the minute used as key in the HashMap
|
||||
* @return
|
||||
*/
|
||||
HashMap<Long, List<AServer>> getRuntimeExperience();
|
||||
Map<Long, List<AServer>> getRuntimeExperience();
|
||||
|
||||
/**
|
||||
* Calculates the appropriate level of the given {@link AUserExperience} according to the given {@link AExperienceLevel}
|
||||
* configuration.
|
||||
* @param experience The {@link AUserExperience} to calculate the level for
|
||||
* @param levels The list of {@link AExperienceLevel} representing the level configuration
|
||||
* @param levels The list of {@link AExperienceLevel} representing the level configuration, this must include the initial level 0
|
||||
* This level will be taken as the initial value, and if no other level qualifies, this will be taken. The levels must be ordered.
|
||||
* @return The appropriate level of {@link AUserExperience} according to the provided {@link AExperienceLevel} configuration
|
||||
*/
|
||||
Integer calculateLevel(AUserExperience experience, List<AExperienceLevel> levels);
|
||||
AExperienceLevel calculateLevel(AUserExperience experience, List<AExperienceLevel> levels);
|
||||
|
||||
/**
|
||||
* Increases the experience of the provided {@link AUserExperience} object and and calculates the new level according
|
||||
@@ -49,7 +50,7 @@ public interface AUserExperienceService {
|
||||
* @param levels The list of {@link AExperienceLevel} to be used as level configuration
|
||||
* @return Whether or not the user changed level
|
||||
*/
|
||||
boolean updateUserlevel(AUserExperience userExperience, List<AExperienceLevel> levels);
|
||||
boolean updateUserLevel(AUserExperience userExperience, List<AExperienceLevel> levels);
|
||||
|
||||
/**
|
||||
* Iterates through the given list of {@link AServer} and increases the experience of the users contained in the
|
||||
|
||||
@@ -20,4 +20,12 @@ public interface ExperienceLevelService {
|
||||
* @return The amount of experience required necessary to get to one level higher as currently.
|
||||
*/
|
||||
Long calculateExperienceToNextLevel(Integer level, Long currentExperience);
|
||||
|
||||
/**
|
||||
* Calculates the required experience to reach this level. This calculated experience is relative, in the sense
|
||||
* the returned experience is the increment from the experience requirement from the level before.
|
||||
* @param level The level to calculate the experience amount for
|
||||
* @return The needed experience to reach this level, if the user already has the level below the passed one
|
||||
*/
|
||||
Long calculateExperienceForLevel(Integer level);
|
||||
}
|
||||
|
||||
@@ -17,18 +17,16 @@ public interface ExperienceRoleService {
|
||||
* Creates an {@link dev.sheldan.abstracto.experience.models.database.AExperienceRole} according to the given
|
||||
* parameters
|
||||
* @param role The {@link ARole} to set the level to
|
||||
* @param level The level the {@link ARole} should be awareded at
|
||||
* @param server The {@link AServer} for which this configuration should be done
|
||||
* @param level The level the {@link ARole} should be awarded at
|
||||
*/
|
||||
void setRoleToLevel(ARole role, Integer level, AServer server, AChannel channel);
|
||||
void setRoleToLevel(ARole role, Integer level, AChannel channel);
|
||||
|
||||
/**
|
||||
* Removes the role from the {@link dev.sheldan.abstracto.experience.models.database.AExperienceRole} configuration
|
||||
* @param role The {@link ARole} to remove from the {@link dev.sheldan.abstracto.experience.models.database.AExperienceRole}
|
||||
* configuration
|
||||
* @param server The {@link AServer} for which the {@link ARole} should be removed from the configuration
|
||||
*/
|
||||
void unsetRole(ARole role, AServer server, AChannel feedbackChannel);
|
||||
void unsetRole(ARole role, AChannel feedbackChannel);
|
||||
|
||||
/**
|
||||
* Calculates the appropriate {@link AExperienceRole} based on the provided list of {@link AExperienceRole}
|
||||
|
||||
@@ -19,9 +19,9 @@ public interface ExperienceRoleManagementService {
|
||||
* the new level.
|
||||
* @param level The {@link AExperienceLevel} to set the role for
|
||||
* @param role The {@link ARole} to set to
|
||||
* @param server The {@link AServer} in which this should happen.
|
||||
* @return the created or updated {@link AExperienceRole}
|
||||
*/
|
||||
void setLevelToRole(AExperienceLevel level, ARole role, AServer server);
|
||||
AExperienceRole setLevelToRole(AExperienceLevel level, ARole role);
|
||||
|
||||
/**
|
||||
* Deletes *all* (if there are multiple by some chance) roles which were set to be given at the provided {@link AExperienceLevel} in the {@link AServer}
|
||||
@@ -39,10 +39,9 @@ public interface ExperienceRoleManagementService {
|
||||
/**
|
||||
* Retrieves the {@link AExperienceRole} which uses the given {@link ARole} in the {@link AServer}
|
||||
* @param role The {@link ARole} to search for
|
||||
* @param server The {@link AServer} in which to search in
|
||||
* @return
|
||||
* @return the {@link AExperienceRole} which uses the given {@link ARole}
|
||||
*/
|
||||
AExperienceRole getRoleInServer(ARole role, AServer server);
|
||||
AExperienceRole getRoleInServer(ARole role);
|
||||
|
||||
/**
|
||||
* Retrives all {@link AExperienceRole} configured in the given {@link AServer}
|
||||
|
||||
@@ -63,6 +63,7 @@ public interface UserExperienceManagementService {
|
||||
/**
|
||||
* Persists the {@link AUserExperience} in the database. Required when creating it
|
||||
* @param userExperience The {@link AUserExperience} to persist
|
||||
* @return The persisted {@link AUserExperience} instance
|
||||
*/
|
||||
void saveUser(AUserExperience userExperience);
|
||||
AUserExperience saveUser(AUserExperience userExperience);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user