incremental claimblock prices
This commit is contained in:
parent
b784eea500
commit
bf1c4c38a2
|
|
@ -69,6 +69,7 @@ import java.util.Collection;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
@ -1868,7 +1869,7 @@ public class GriefPrevention extends JavaPlugin
|
||||||
|
|
||||||
//if the player can't afford his purchase, send error message
|
//if the player can't afford his purchase, send error message
|
||||||
double balance = economy.getBalance(player);
|
double balance = economy.getBalance(player);
|
||||||
double totalCost = blockCount * GriefPrevention.instance.config_economy_claimBlocksPurchaseCost;
|
double totalCost = claimBlockCost(playerData.getBonusClaimBlocks()+playerData.getAccruedClaimBlocks() , blockCount);
|
||||||
if (totalCost > balance)
|
if (totalCost > balance)
|
||||||
{
|
{
|
||||||
GriefPrevention.sendMessage(player, TextMode.Err, Messages.InsufficientFunds, String.valueOf(totalCost), String.valueOf(balance));
|
GriefPrevention.sendMessage(player, TextMode.Err, Messages.InsufficientFunds, String.valueOf(totalCost), String.valueOf(balance));
|
||||||
|
|
@ -3897,14 +3898,49 @@ public class GriefPrevention extends JavaPlugin
|
||||||
portalReturnTaskMap.put(player.getUniqueId(), task);
|
portalReturnTaskMap.put(player.getUniqueId(), task);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double claimBlockCost(int currentClaimBlocks, int blockCount) {
|
private static final double[] xMult = { 0, 500, 10000, 50000, 300000, 1000000};
|
||||||
|
private static final double[] yMultBuy = { 0.25, 0.5, 0.75, 1, 2, 5};
|
||||||
|
private double claimBlockCost(int oldPoints, int transPts) {
|
||||||
if (Config.claimBlockPrices.isEmpty())
|
if (Config.claimBlockPrices.isEmpty())
|
||||||
return blockCount * GriefPrevention.instance.config_economy_claimBlocksPurchaseCost;
|
return transPts * GriefPrevention.instance.config_economy_claimBlocksPurchaseCost;
|
||||||
|
|
||||||
double totalBlocks = currentClaimBlocks + blockCount;
|
double finalPrice = 0; //Initialize final price
|
||||||
double cost = 0;
|
int segment = 1; //Start segment at one
|
||||||
// TODO finish me
|
int high = oldPoints + transPts; //Will be the highest point value
|
||||||
return cost;
|
|
||||||
|
if (oldPoints > high) //If high is not the highest point value, swap it with oldPoints so it is
|
||||||
|
{
|
||||||
|
int temp = oldPoints;
|
||||||
|
oldPoints = high;
|
||||||
|
high = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (oldPoints > xMult[segment] && segment < xMult.length - 1) { //Calculate the start segment (first value smaller than lower)
|
||||||
|
segment++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = segment; i < xMult.length && high > xMult[i - 1]; i++)
|
||||||
|
finalPrice += getPricePerInterval(oldPoints, high, i);
|
||||||
|
|
||||||
|
return finalPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getPricePerInterval(int start_points, int end_points, int segment) {
|
||||||
|
double bottom = xMult[segment - 1];
|
||||||
|
double top = xMult[segment];
|
||||||
|
double priceMult = yMultBuy[segment - 1];
|
||||||
|
double pricePerPoint = 1;
|
||||||
|
|
||||||
|
if (start_points <= bottom && end_points <= top)// +_---+---
|
||||||
|
return (end_points - bottom) * pricePerPoint * priceMult;
|
||||||
|
else if (start_points <= bottom && end_points >= top) // +_---_+
|
||||||
|
return (top - bottom) * pricePerPoint * priceMult;
|
||||||
|
else if (start_points >= bottom && end_points <= top) // _--+--+--_
|
||||||
|
return (end_points - start_points) * pricePerPoint * priceMult;
|
||||||
|
else if (start_points >= bottom && end_points >= top) // _--+--_+
|
||||||
|
return (top - start_points) * pricePerPoint * priceMult;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user