-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
11 deletions.
There are no files selected for viewing
36 changes: 35 additions & 1 deletion
36
src/api/java/de/teamlapen/vampirism/api/difficulty/Difficulty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,48 @@ | ||
package de.teamlapen.vampirism.api.difficulty; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import static net.minecraft.util.Mth.clamp; | ||
|
||
/** | ||
* Represents a calculated difficulty level. | ||
* The used difficulty levels are in percentage of the max reachable level. | ||
* So a level 5 in a faction which has a max level of 10 would be represented by 5/10*100=50 | ||
*/ | ||
public record Difficulty(int minPercLevel, int maxPercLevel, int avgPercLevel) { | ||
public class Difficulty { | ||
|
||
/** | ||
* Percentage between 0 and 100 | ||
*/ | ||
public final int minPercLevel, maxPercLevel, avgPercLevel; | ||
|
||
public Difficulty(int mil, int mal, int al) { | ||
mal = clamp(mal, 0, 100); | ||
mil = clamp(mil, 0, mal); | ||
al = clamp(al, mil, mal); | ||
this.minPercLevel = mil; | ||
this.maxPercLevel = mal; | ||
this.avgPercLevel = al; | ||
} | ||
|
||
public int minPercLevel() { | ||
return minPercLevel; | ||
} | ||
|
||
public int maxPercLevel() { | ||
return maxPercLevel; | ||
} | ||
|
||
public int avgPercLevel() { | ||
return avgPercLevel; | ||
} | ||
|
||
public boolean isZero() { | ||
return (this.minPercLevel == 0 && this.maxPercLevel == 0); | ||
} | ||
|
||
@Override | ||
public @NotNull String toString() { | ||
return "Difficulty: min_" + minPercLevel + " max_" + maxPercLevel + " avg_" + avgPercLevel; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters