Correctly (hopefully) calculate the amount based on a range based on quest completed this month
This commit is contained in:
parent
2cefdf8840
commit
bcf0a3adef
|
|
@ -3,8 +3,7 @@ package com.alttd.altitudequests.objects;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public abstract class Variant {
|
public abstract class Variant {
|
||||||
|
|
||||||
|
|
@ -41,7 +40,16 @@ public abstract class Variant {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int calculateAmount(int questsCompleted) {
|
public int calculateAmount(int questsCompleted) {
|
||||||
int difficultyOffset = ((rangeMax - rangeMin) / 40) * questsCompleted;
|
double difficultyOffset = ((rangeMax - rangeMin) / (double) getDaysInMonth());
|
||||||
return new Random().nextInt(Integer.min(rangeMax - 1, rangeMin + difficultyOffset), rangeMax);
|
int min = Math.max(rangeMin, rangeMin + (int) (difficultyOffset * (questsCompleted - 5)));
|
||||||
|
int max = Math.min(rangeMax, rangeMin + (int) (difficultyOffset * (questsCompleted + 5)));
|
||||||
|
return new Random().nextInt(min, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getDaysInMonth() {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(new Date());
|
||||||
|
|
||||||
|
return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user