Base longest fish's length on time remaining
This commit is contained in:
parent
68304098fb
commit
67bd8ce8d0
|
|
@ -3,6 +3,7 @@ package com.alttd.fishingevent.fish;
|
|||
import com.alttd.fishingevent.FishingEvent;
|
||||
import com.alttd.fishingevent.config.Fishes;
|
||||
import com.alttd.fishingevent.objects.Rarity;
|
||||
import com.alttd.fishingevent.timer.EventManager;
|
||||
import com.alttd.fishingevent.util.Logger;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
|
@ -93,15 +94,26 @@ public class Fish {
|
|||
* @return a random length for this fish
|
||||
*/
|
||||
public float generateLength(int luckLevel) {
|
||||
float modifiedMaxLength = limitMaxLengthBasedOnTime();
|
||||
|
||||
float modifiedMinLength = minLength;
|
||||
if (luckLevel >= 1 && luckLevel <= 5) {
|
||||
float improvement = luckLevel * 0.1f * (maxLength - minLength);
|
||||
float availableSpace = maxLength - minLength - 1;
|
||||
float improvement = luckLevel * 0.1f * (modifiedMaxLength - minLength);
|
||||
float availableSpace = modifiedMaxLength - minLength - 1;
|
||||
|
||||
modifiedMinLength += Math.min(improvement, availableSpace);
|
||||
}
|
||||
|
||||
return new Random().nextFloat(modifiedMinLength, maxLength);
|
||||
return new Random().nextFloat(modifiedMinLength, modifiedMaxLength);
|
||||
}
|
||||
|
||||
private float limitMaxLengthBasedOnTime() {
|
||||
if (maxLength <= 6000)
|
||||
return maxLength;
|
||||
long secondsRemaining = EventManager.getInstance().getTimeRemaining().toSeconds();
|
||||
if ((maxLength - minLength) < 2000)
|
||||
return maxLength;
|
||||
return Math.max(minLength + 2000, maxLength - secondsRemaining);
|
||||
}
|
||||
|
||||
public net.kyori.adventure.text.@NotNull Component fishName() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user