Added current multiplier to points command
This commit is contained in:
parent
168cb55b51
commit
ac0f050071
|
|
@ -3,6 +3,7 @@ package com.alttd.commands.subcommands;
|
||||||
import com.alttd.commands.SubCommand;
|
import com.alttd.commands.SubCommand;
|
||||||
import com.alttd.config.Config;
|
import com.alttd.config.Config;
|
||||||
import com.alttd.objects.EconUser;
|
import com.alttd.objects.EconUser;
|
||||||
|
import com.alttd.objects.Price;
|
||||||
import com.alttd.objects.VillagerType;
|
import com.alttd.objects.VillagerType;
|
||||||
import com.alttd.util.Logger;
|
import com.alttd.util.Logger;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||||
|
|
@ -40,10 +41,13 @@ public class CommandPoints extends SubCommand {
|
||||||
Logger.warning("Player % has unused villager type % in their point list.", player.getName(), key);
|
Logger.warning("Player % has unused villager type % in their point list.", player.getName(), key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int currentPoints = pointsMap.getOrDefault(key, 0);
|
||||||
ref.message = ref.message.append(miniMessage.deserialize("\n", TemplateResolver.resolving()));
|
ref.message = ref.message.append(miniMessage.deserialize("\n", TemplateResolver.resolving()));
|
||||||
ref.message = ref.message.append(miniMessage.deserialize(Config.POINTS_CONTENT, TemplateResolver.resolving(
|
ref.message = ref.message.append(miniMessage.deserialize(Config.POINTS_CONTENT, TemplateResolver.resolving(
|
||||||
Template.template("villager_type", VillagerType.getVillagerType(key).getDisplayName()),
|
Template.template("villager_type", VillagerType.getVillagerType(key).getDisplayName()),
|
||||||
Template.template("points", String.valueOf(pointsMap.getOrDefault(key, 0)))
|
Template.template("points", String.valueOf(currentPoints)),
|
||||||
|
Template.template("buy_multiplier", String.valueOf(Price.getCurrentMultiplier(currentPoints, true))),
|
||||||
|
Template.template("sell_multiplier", String.valueOf(Price.getCurrentMultiplier(currentPoints, true)))
|
||||||
)));
|
)));
|
||||||
});
|
});
|
||||||
} else if (args.length == 2){
|
} else if (args.length == 2){
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,9 @@ public final class Config extends AbstractConfig {
|
||||||
"<total_points> for <villager_name>!</green>";
|
"<total_points> for <villager_name>!</green>";
|
||||||
public static String REMOVED_VILLAGER = "<green>Removed villager with uuid <uuid></green>";
|
public static String REMOVED_VILLAGER = "<green>Removed villager with uuid <uuid></green>";
|
||||||
public static String POINTS_HEADER = "<gold>Villager points for <player>: ";
|
public static String POINTS_HEADER = "<gold>Villager points for <player>: ";
|
||||||
public static String POINTS_CONTENT = "<gold><villager_type>: <dark_aqua><points></dark_aqua></gold>";
|
public static String POINTS_CONTENT = "<gold><villager_type>: points:<dark_aqua><points></dark_aqua> " +
|
||||||
|
"buy:<dark_aqua><buy_multiplier>x</dark_aqua> " +
|
||||||
|
"sell:<dark_aqua><sell_multiplier>x</dark_aqua></gold>";
|
||||||
public static String BUY_ITEM_MESSAGE = "<green><material> can be bought at spawn at the <villager_type> villager for $<price> and <points> points per item " +
|
public static String BUY_ITEM_MESSAGE = "<green><material> can be bought at spawn at the <villager_type> villager for $<price> and <points> points per item " +
|
||||||
"at your current amount of points (<current_points>).</green>";
|
"at your current amount of points (<current_points>).</green>";
|
||||||
public static String NO_BUY_AT_SPAWN = "<red><material> can not be bought at spawn, try a player shop!</red>";
|
public static String NO_BUY_AT_SPAWN = "<red><material> can not be bought at spawn, try a player shop!</red>";
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ public final class Price {
|
||||||
private final double price;
|
private final double price;
|
||||||
private final int points;
|
private final int points;
|
||||||
|
|
||||||
private static final double[] xMult = {Integer.MIN_VALUE, -4000, -2000, -500, 500, 2000, 4000, Integer.MAX_VALUE};
|
private static final double[] xMult = {Integer.MIN_VALUE, -6000, -4000, -2000, -500, 500, 2000, 4000, 6000, Integer.MAX_VALUE};
|
||||||
private static final double[] yMultBuy = {0.6, 0.75, 0.9, 1, 1.5, 2.5, 5};
|
private static final double[] yMultBuy = {0.5, 0.6, 0.75, 0.9, 1, 1.5, 2.5, 5, 10};
|
||||||
private static final double[] yMultSell = {0.2, 0.4, 0.7, 1, 1.25, 1.75, 2.5};
|
private static final double[] yMultSell = {0.1, 0.2, 0.4, 0.7, 1, 1.25, 1.75, 2.5, 3};
|
||||||
|
|
||||||
public Price(double price) {
|
public Price(double price) {
|
||||||
this.price = price;
|
this.price = price;
|
||||||
|
|
@ -20,6 +20,14 @@ public final class Price {
|
||||||
return (new Price(Utilities.round(one.getPrice(1) + two.getPrice(1), 2)));
|
return (new Price(Utilities.round(one.getPrice(1) + two.getPrice(1), 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double getCurrentMultiplier(int points, boolean buy) {
|
||||||
|
for (int i = 1; i < xMult.length; i++) {
|
||||||
|
if (points <= xMult[i])
|
||||||
|
return buy ? yMultBuy[i - 1] : yMultSell[i - 1];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public double getPrice(int multiplier) {
|
public double getPrice(int multiplier) {
|
||||||
return (Utilities.round(price * multiplier, 2));
|
return (Utilities.round(price * multiplier, 2));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user