Moving the power configuration from MConf to UConf.
This commit is contained in:
parent
9a324d572e
commit
e30c652759
@ -30,30 +30,6 @@ public class ConfServer extends SimpleConfig
|
|||||||
public static double autoLeaveRoutineRunsEveryXMinutes = 5.0;
|
public static double autoLeaveRoutineRunsEveryXMinutes = 5.0;
|
||||||
public static boolean removePlayerDataWhenBanned = true;
|
public static boolean removePlayerDataWhenBanned = true;
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// POWER
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static double powerMax = 10.0;
|
|
||||||
public static double powerMin = -10.0;
|
|
||||||
public static double powerStarting = 10.0; // New players start out with this power level
|
|
||||||
|
|
||||||
public static double powerPerDeath = -4.0; // A death makes you lose 4 power
|
|
||||||
|
|
||||||
public static double powerPerHourOnline = 10.0;
|
|
||||||
public static double powerPerHourOffline = 0.0;
|
|
||||||
|
|
||||||
// players will no longer lose power from being offline once their power drops to this amount or less
|
|
||||||
public static double powerLimitGainOnline = 10.0;
|
|
||||||
public static double powerLimitGainOffline = 0.0;
|
|
||||||
public static double powerLimitLossOnline = -10.0;
|
|
||||||
public static double powerLimitLossOffline = 0.0;
|
|
||||||
|
|
||||||
public static boolean scaleNegativePower = false; // Power regeneration rate increase as power decreases
|
|
||||||
public static double scaleNegativeDivisor = 40.0; // Divisor for inverse power regeneration curve
|
|
||||||
|
|
||||||
public static double powerFactionMax = 0.0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts)
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// HOMES
|
// HOMES
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -29,6 +29,7 @@ import com.massivecraft.mcore.mixin.Mixin;
|
|||||||
import com.massivecraft.mcore.money.Money;
|
import com.massivecraft.mcore.money.Money;
|
||||||
import com.massivecraft.mcore.ps.PS;
|
import com.massivecraft.mcore.ps.PS;
|
||||||
import com.massivecraft.mcore.store.SenderEntity;
|
import com.massivecraft.mcore.store.SenderEntity;
|
||||||
|
import com.massivecraft.mcore.util.MUtil;
|
||||||
import com.massivecraft.mcore.util.TimeUnit;
|
import com.massivecraft.mcore.util.TimeUnit;
|
||||||
import com.massivecraft.mcore.util.Txt;
|
import com.massivecraft.mcore.util.Txt;
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
// Note: we do not check role or title here since they mean nothing without a faction.
|
// Note: we do not check role or title here since they mean nothing without a faction.
|
||||||
|
|
||||||
// TODO: This line looks obnoxious, investigate it.
|
// TODO: This line looks obnoxious, investigate it.
|
||||||
if (this.getPowerRounded() != this.getPowerMaxRounded() && this.getPowerRounded() != (int) Math.round(ConfServer.powerStarting)) return false;
|
if (this.getPowerRounded() != this.getPowerMaxRounded() && this.getPowerRounded() != (int) Math.round(UConf.get(this).powerStarting)) return false;
|
||||||
|
|
||||||
if (this.hasPowerBoost()) return false;
|
if (this.hasPowerBoost()) return false;
|
||||||
|
|
||||||
@ -354,7 +355,9 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
public double getPower()
|
public double getPower()
|
||||||
{
|
{
|
||||||
this.recalculatePower();
|
this.recalculatePower();
|
||||||
return this.power;
|
Double ret = this.power;
|
||||||
|
if (ret == null) ret = UConf.get(this).powerStarting;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPower(double power)
|
public void setPower(double power)
|
||||||
@ -368,7 +371,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
power = Math.max(power, this.getPowerMin());
|
power = Math.max(power, this.getPowerMin());
|
||||||
|
|
||||||
// Nochange
|
// Nochange
|
||||||
if (this.power == power) return;
|
if (MUtil.equals(this.power, Double.valueOf(power))) return;
|
||||||
|
|
||||||
this.power = power;
|
this.power = power;
|
||||||
this.setLastPowerUpdateTime(now);
|
this.setLastPowerUpdateTime(now);
|
||||||
@ -377,12 +380,12 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
|
|
||||||
public double getPowerMax()
|
public double getPowerMax()
|
||||||
{
|
{
|
||||||
return ConfServer.powerMax + this.getPowerBoost();
|
return UConf.get(this).powerMax + this.getPowerBoost();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPowerMin()
|
public double getPowerMin()
|
||||||
{
|
{
|
||||||
return ConfServer.powerMin + this.getPowerBoost();
|
return UConf.get(this).powerMin + this.getPowerBoost();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recalculatePower()
|
public void recalculatePower()
|
||||||
@ -411,30 +414,39 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
// Note that we updated
|
// Note that we updated
|
||||||
this.setLastPowerUpdateTime(now);
|
this.setLastPowerUpdateTime(now);
|
||||||
|
|
||||||
// We consider dead players to be offline.
|
// We consider dead players and players in other universes offline.
|
||||||
if (online)
|
if (online)
|
||||||
{
|
{
|
||||||
Player thisPlayer = this.getPlayer();
|
Player thisPlayer = this.getPlayer();
|
||||||
if (thisPlayer != null && thisPlayer.isDead())
|
online = (thisPlayer != null && !thisPlayer.isDead() && FPlayer.get(thisPlayer) == this);
|
||||||
{
|
|
||||||
online = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cache and prepare
|
||||||
|
UConf uconf = UConf.get(this);
|
||||||
|
double powerCurrent;
|
||||||
|
if (this.power != null)
|
||||||
|
{
|
||||||
|
powerCurrent = this.power;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
powerCurrent = uconf.powerStarting;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Depending on online state pick the config values
|
// Depending on online state pick the config values
|
||||||
double powerPerHour = online ? ConfServer.powerPerHourOnline : ConfServer.powerPerHourOffline;
|
double powerPerHour = online ? uconf.powerPerHourOnline : uconf.powerPerHourOffline;
|
||||||
double powerLimitGain = online ? ConfServer.powerLimitGainOnline : ConfServer.powerLimitGainOffline;
|
double powerLimitGain = online ? uconf.powerLimitGainOnline : uconf.powerLimitGainOffline;
|
||||||
double powerLimitLoss = online ? ConfServer.powerLimitLossOnline : ConfServer.powerLimitLossOffline;
|
double powerLimitLoss = online ? uconf.powerLimitLossOnline : uconf.powerLimitLossOffline;
|
||||||
|
|
||||||
// Apply the negative divisor thingy
|
// Apply the negative divisor thingy
|
||||||
if (ConfServer.scaleNegativePower && this.power < 0)
|
if (uconf.scaleNegativePower && powerCurrent < 0)
|
||||||
{
|
{
|
||||||
powerPerHour += (Math.sqrt(Math.abs(this.power)) * Math.abs(this.power)) / ConfServer.scaleNegativeDivisor;
|
powerPerHour += (Math.sqrt(Math.abs(powerCurrent)) * Math.abs(powerCurrent)) / uconf.scaleNegativeDivisor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate delta and target
|
// Calculate delta and target
|
||||||
double powerDelta = powerPerHour * millisPassed / TimeUnit.MILLIS_PER_HOUR;
|
double powerDelta = powerPerHour * millisPassed / TimeUnit.MILLIS_PER_HOUR;
|
||||||
double powerTarget = this.power + powerDelta;
|
double powerTarget = powerCurrent + powerDelta;
|
||||||
|
|
||||||
// Check Gain and Loss limits
|
// Check Gain and Loss limits
|
||||||
if (powerDelta >= 0)
|
if (powerDelta >= 0)
|
||||||
@ -442,10 +454,10 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
// Gain
|
// Gain
|
||||||
if (powerTarget > powerLimitGain)
|
if (powerTarget > powerLimitGain)
|
||||||
{
|
{
|
||||||
if (this.power > powerLimitGain)
|
if (powerCurrent > powerLimitGain)
|
||||||
{
|
{
|
||||||
// Did already cross --> Just freeze
|
// Did already cross --> Just freeze
|
||||||
powerTarget = this.power;
|
powerTarget = powerCurrent;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -459,10 +471,10 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
// Loss
|
// Loss
|
||||||
if (powerTarget < powerLimitLoss)
|
if (powerTarget < powerLimitLoss)
|
||||||
{
|
{
|
||||||
if (this.power < powerLimitLoss)
|
if (powerCurrent < powerLimitLoss)
|
||||||
{
|
{
|
||||||
// Did already cross --> Just freeze
|
// Did already cross --> Just freeze
|
||||||
powerTarget = this.power;
|
powerTarget = powerCurrent;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -677,10 +677,12 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
{
|
{
|
||||||
ret += fplayer.getPower();
|
ret += fplayer.getPower();
|
||||||
}
|
}
|
||||||
if (ConfServer.powerFactionMax > 0 && ret > ConfServer.powerFactionMax)
|
|
||||||
|
if (UConf.get(this).powerFactionMax > 0 && ret > UConf.get(this).powerFactionMax)
|
||||||
{
|
{
|
||||||
ret = ConfServer.powerFactionMax;
|
ret = UConf.get(this).powerFactionMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret + this.getPowerBoost();
|
return ret + this.getPowerBoost();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -696,10 +698,12 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
{
|
{
|
||||||
ret += fplayer.getPowerMax();
|
ret += fplayer.getPowerMax();
|
||||||
}
|
}
|
||||||
if (ConfServer.powerFactionMax > 0 && ret > ConfServer.powerFactionMax)
|
|
||||||
|
if (UConf.get(this).powerFactionMax > 0 && ret > UConf.get(this).powerFactionMax)
|
||||||
{
|
{
|
||||||
ret = ConfServer.powerFactionMax;
|
ret = UConf.get(this).powerFactionMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret + this.getPowerBoost();
|
return ret + this.getPowerBoost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,4 +40,28 @@ public class UConf extends Entity<UConf>
|
|||||||
|
|
||||||
public int factionMemberLimit = 0;
|
public int factionMemberLimit = 0;
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// POWER
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public double powerMax = 10.0;
|
||||||
|
public double powerMin = -10.0;
|
||||||
|
public double powerStarting = 10.0; // New players start out with this power level
|
||||||
|
|
||||||
|
public double powerPerDeath = -4.0; // A death makes you lose 4 power
|
||||||
|
|
||||||
|
public double powerPerHourOnline = 10.0;
|
||||||
|
public double powerPerHourOffline = 0.0;
|
||||||
|
|
||||||
|
// players will no longer lose power from being offline once their power drops to this amount or less
|
||||||
|
public double powerLimitGainOnline = 10.0;
|
||||||
|
public double powerLimitGainOffline = 0.0;
|
||||||
|
public double powerLimitLossOnline = -10.0;
|
||||||
|
public double powerLimitLossOffline = 0.0;
|
||||||
|
|
||||||
|
public boolean scaleNegativePower = false; // Power regeneration rate increase as power decreases
|
||||||
|
public double scaleNegativeDivisor = 40.0; // Divisor for inverse power regeneration curve
|
||||||
|
|
||||||
|
public double powerFactionMax = 0.0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ import com.massivecraft.factions.entity.BoardColls;
|
|||||||
import com.massivecraft.factions.entity.FPlayer;
|
import com.massivecraft.factions.entity.FPlayer;
|
||||||
import com.massivecraft.factions.entity.Faction;
|
import com.massivecraft.factions.entity.Faction;
|
||||||
import com.massivecraft.factions.entity.MConf;
|
import com.massivecraft.factions.entity.MConf;
|
||||||
|
import com.massivecraft.factions.entity.UConf;
|
||||||
import com.massivecraft.factions.event.FactionsEventPowerChange;
|
import com.massivecraft.factions.event.FactionsEventPowerChange;
|
||||||
import com.massivecraft.factions.event.FactionsEventPowerChange.PowerChangeReason;
|
import com.massivecraft.factions.event.FactionsEventPowerChange.PowerChangeReason;
|
||||||
import com.massivecraft.factions.util.VisualizeUtil;
|
import com.massivecraft.factions.util.VisualizeUtil;
|
||||||
@ -106,7 +107,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ... Event ...
|
// ... Event ...
|
||||||
double newPower = fplayer.getPower() + ConfServer.powerPerDeath;
|
double newPower = fplayer.getPower() + UConf.get(fplayer).powerPerDeath;
|
||||||
FactionsEventPowerChange powerChangeEvent = new FactionsEventPowerChange(null, fplayer, PowerChangeReason.DEATH, newPower);
|
FactionsEventPowerChange powerChangeEvent = new FactionsEventPowerChange(null, fplayer, PowerChangeReason.DEATH, newPower);
|
||||||
powerChangeEvent.run();
|
powerChangeEvent.run();
|
||||||
if (powerChangeEvent.isCancelled()) return;
|
if (powerChangeEvent.isCancelled()) return;
|
||||||
|
Loading…
Reference in New Issue
Block a user