Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* #1899 training recalculation recovers deleted skill ups
  • Loading branch information
wsbrenk authored Jul 29, 2023
1 parent c691b2e commit 7e1a27a
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 26 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ test {
// Version ============================================================
// Development_stage (DEV:0 BETA:1 STABLE:2)
def major = '7'
def minor = '2'
def development_stage = 2
def minor = '3'
def development_stage = 1
def releaseArtefacts = true
def development_tag = ["dev", "beta", "tag_stable"]
def version_type = ["-DEV", "-BETA", ""]
Expand Down Expand Up @@ -309,9 +309,9 @@ task pushmd(dependsOn: preparingBuild) {
// list the contributors that don't want to be mentioned in release notes
def contributorFilter = ["Che"]

def commitCount = callGit('git rev-list 7.1..HEAD --count')
def diff = callGit('git diff --shortstat 7.1..HEAD')
def contributors = filter(callGit('git shortlog -s -n 7.1..HEAD'), contributorFilter)
def commitCount = callGit('git rev-list 7.2..HEAD --count')
def diff = callGit('git diff --shortstat 7.2..HEAD')
def contributors = filter(callGit('git shortlog -s -n 7.2..HEAD'), contributorFilter)
def latestCommit = callGit('git log -1 --pretty=format:"%s"')

println("create release-notes")
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/core/db/AbstractTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected String getTableType() {
}

/**
* derived table class has to create the colums array
* derived table class has to create the columns array
*/
protected abstract void initColumns();

Expand Down Expand Up @@ -91,7 +91,7 @@ protected String[] getConstraintStatements() {
* stores the given object.
* if the object is already stored in database, update is called otherwise insert
* @param object that should be stored
* @param <T> Storable class (extends Abstract.Storable)
* @param <T> Storable class (extends AbstractStorable)
*/
public <T extends Storable> void store(T object){
if (object.isStored()) {
Expand All @@ -104,7 +104,7 @@ public <T extends Storable> void store(T object){
/**
* create a new record of the storable object
* @param object that should be created
* @param <T> Storable class (extends Abstract.Starable)
* @param <T> Storable class (extends AbstractStorable)
* @return 1 on success, 0 on error
*/
private <T extends Storable> int insert(T object) {
Expand All @@ -118,7 +118,7 @@ private <T extends Storable> int insert(T object) {
* The first columns of the table are used in the where clause, the remaining as set values.
* Count of id columns is defined by field idcolumns.
* @param object that should be updated
* @param <T> Storable class (extends Abstract.Stobable)
* @param <T> Storable class (extends AbstractStorable)
* @return 1 on success, 0 on error
*/
private <T extends Storable> int update(T object) {
Expand All @@ -134,7 +134,7 @@ private <T extends Storable> int update(T object) {
* the specified where values must match the first id columns of the table.
* The count of where values is defined by idColumns
* @param tClass Storable class (extends Abstract.Storable)
* @param whereValues variable arguments descibing the where values (count must match idColumns)
* @param whereValues variable arguments describing the where values (count must match idColumns)
* @param <T> the object class to create
* @return one Object of type T
*/
Expand All @@ -144,7 +144,7 @@ public <T extends Storable> T loadOne(Class<T> tClass, Object ... whereValues) {

/**
* load one object of an externally created result set.
* @param tClass Storable class (extends Abstract.Storable)
* @param tClass Storable class (extends AbstractStorable)
* @param rs result set
* @param <T> the object class to create
* @return one object of type T
Expand All @@ -159,8 +159,8 @@ public <T extends Storable> T loadOne(Class<T> tClass, ResultSet rs) {

/**
* load a list of records
* @param tClass Storable class (extends Abstract.Storable)
* @param whereValues variable arguments descibing the where values (count must match idColumns)
* @param tClass Storable class (extends AbstractStorable)
* @param whereValues variable arguments describing the where values (count must match idColumns)
* @param <T> the object class to create
* @return List of objects of type T
*/
Expand All @@ -170,7 +170,7 @@ public <T extends Storable> List<T> load(Class<T> tClass, Object ... whereValues

/**
* load a list of records of an externally created result set
* @param tClass Storable class (extends Abstract.Storable)
* @param tClass Storable class (extends AbstractStorable)
* @param rs result set
* @param <T> the object class to create
* @return List of objects of type T
Expand All @@ -181,7 +181,7 @@ public <T extends Storable> List<T> load(Class<T> tClass, ResultSet rs) {

/**
* load a list of records
* @param tClass Storable class (extends Abstract.Storable)
* @param tClass Storable class (extends AbstractStorable)
* @param rs result set
* @param max 1 to load one object, -1 to load all objects
* @param <T> the object class to create
Expand Down Expand Up @@ -374,9 +374,9 @@ protected int executePreparedInsert(Object ... values){


/**
* create sql string of the standard update statment.
* the first colums of table are used in the where clause, the remaining columns in the SET part.
* The count of where values if given by the field idcolumns
* create sql string of the standard update statement.
* the first columns of table are used in the where clause, the remaining columns in the SET part.
* The count of where values if given by the field id columns
* @return sql string of the prepared statement
*/
private String createUpdateStatement() {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/core/db/DBManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ public void checkSkillup(HOModel homodel) {
.importNewSkillup(homodel);
}

public void storeSkillup(Skillup skillup){
getTable(SpielerSkillupTable.TABLENAME)
.store(skillup);
}

// ------------------------------- SpielerTable
// -------------------------------------------------

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/core/model/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -2359,6 +2359,21 @@ public void calcSubskills(int previousID, List<TrainingPerWeek> trainingWeeks) {
var valueAfterTraining = this.getValue4Skill(skill);

if (trainingWeeks.size() > 0) {
if ( valueAfterTraining > valueBeforeTraining) {
// Check if skill up is available
var skillUps = this.getAllLevelUp(skill);
var isAvailable = skillUps.stream().anyMatch(i -> i.getValue() == valueAfterTraining);
if (!isAvailable) {
var skillUp = new Skillup();
skillUp.setPlayerId(this.getPlayerID());
skillUp.setSkill(skill);
skillUp.setDate(trainingWeeks.get(0).getTrainingDate());
skillUp.setValue(valueAfterTraining);
skillUp.setHrfId(this.getHrfId());
DBManager.instance().storeSkillup(skillUp);
resetSkillUpInformation();
}
}
for (var training : trainingWeeks) {

var trainingPerPlayer = calculateWeeklyTraining(training);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/module/training/EffectDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static void reload() {
}
while (tDateset.next()) {
var trainDate = HODateTime.fromDbTimestamp(tDateset.getTimestamp(3));
var htWeek =trainDate.toHTWeek();
var htWeek =trainDate.toLocaleHTWeek();
trainingDates.add(new TrainWeekEffect(htWeek.week, htWeek.season, tDateset.getInt(1), first_in_week));
first_in_week = tDateset.getInt(1);
}
Expand Down
24 changes: 24 additions & 0 deletions src/main/resources/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# Changelist HO! 7.2

## Some numbers
* 2 commits
* 8 files changed, 90 insertions(+), 31 deletions(-)
* Contributors:
* 2 wsbrenk

## Highlights
* bug fixes

## [Detailed Changelog](https://github.com/akasolace/HO/issues?q=milestone%3A7.2)

### Training
* handle new trainer types which are no longer listed as player (#1889)

## Translations
Reports by Contributors - June 24, 2023 - July 22, 2023

* Moorhuhninho 4
* Miccoli17 1
* wsbrenk 1
Total 6

# Changelist HO! 7.1

## Some numbers
Expand Down
11 changes: 4 additions & 7 deletions src/main/resources/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

bug fixes

## [Detailed Changelog](https://github.com/akasolace/HO/issues?q=milestone%3A7.2)
## [Detailed Changelog](https://github.com/akasolace/HO/issues?q=milestone%3A7.3)

### Database

Expand All @@ -23,7 +23,7 @@ bug fixes
### Transfer

### Training
* handle new trainer types which are no longer listed as player (#1889)
* reset skill ups when hrfs were deleted (#1899)

### League

Expand All @@ -33,9 +33,6 @@ bug fixes

## Translations

Reports by Contributors - June 24, 2023 - July 22, 2023
* Moorhuhninho 4
* Miccoli17 1
* wsbrenk 1
Reports by Contributors - July 22, 2023 - July 29, 2023

Total 6
Total 0

0 comments on commit 7e1a27a

Please sign in to comment.