Reworked points to be based on item price

This commit is contained in:
stjn
2021-11-10 16:58:47 +01:00
parent 7584df32f4
commit 99d8a5007e
5 changed files with 104 additions and 21 deletions
+18 -2
View File
@@ -1,10 +1,25 @@
package com.alttd.objects;
import com.alttd.config.Config;
import com.alttd.util.Utilities;
public record Price(double price, int points) {
public final class Price {
private final double price;
private final int points;
public Price(double price) {
this.price = price;
for (int key : Config.pointsRangeMap.keySet()) {
if (Config.pointsRangeMap.get(key).contains(price)) {
points = key;
return;
}
}
points = -1; //TODO check for if points is -1
}
public static Price addPrice(Price one, Price two) {
return (new Price(Utilities.round(one.price() + two.price(), 2), one.points() + two.points()));
return (new Price(Utilities.round(one.getPrice(1) + two.getPrice(1), 2)));
}
public double getPrice(int multiplier) {
@@ -14,4 +29,5 @@ public record Price(double price, int points) {
public int getPoints() {
return (points);
}
}