VillagerShopUI/src/main/java/com/alttd/objects/Price.java

36 lines
937 B
Java
Raw Normal View History

package com.alttd.objects;
import com.alttd.config.Config;
import com.alttd.util.Logger;
import com.alttd.util.Utilities;
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;
}
}
Logger.severe("Points set to -1 for a price: %", String.valueOf(price));
points = -1; //TODO check for if points is -1
}
public static Price addPrice(Price one, Price two) {
return (new Price(Utilities.round(one.getPrice(1) + two.getPrice(1), 2)));
}
public double getPrice(int multiplier) {
return (Utilities.round(price * multiplier, 2));
}
2021-11-08 19:28:25 +00:00
public int getPoints() {
return (points);
}
}