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