Skip to content

Commit

Permalink
Implement sumTeamDeaths, maxDeaths and deathPenalty.
Browse files Browse the repository at this point in the history
Improved calculating death penalty. Death count now checks if it must include teamDeaths.
maxDeaths now is working, as deathHandicap will be set to minimal value from it and current deathCount.
Change level and pointsToNextLevel calculation. Now it will remove deathCount * deathPenalty points from rawBlockCount and use new value to calculate current level and points till next one.
  • Loading branch information
BONNe committed Jan 2, 2019
1 parent 4a73534 commit e7cc3c7
Showing 1 changed file with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.UUID;

import org.bukkit.Bukkit;
import org.bukkit.ChunkSnapshot;
Expand Down Expand Up @@ -214,12 +215,38 @@ private void tidyUp() {
task.cancel();
// Finalize calculations
result.rawBlockCount += (long)(result.underWaterBlockCount * addon.getSettings().getUnderWaterMultiplier());

// Set the death penalty
result.deathHandicap = addon.getPlayers().getDeaths(world, island.getOwner());
// Set final score
result.level = (result.rawBlockCount / addon.getSettings().getLevelCost()) - result.deathHandicap - island.getLevelHandicap();
if (this.addon.getSettings().isSumTeamDeaths())
{
for (UUID uuid : this.island.getMemberSet())
{
this.result.deathHandicap += this.addon.getPlayers().getDeaths(this.world, uuid);
}
}
else
{
this.result.deathHandicap =
this.addon.getPlayers().getDeaths(this.world, this.island.getOwner());
}

// Just lazy check for min death count.
this.result.deathHandicap = Math.min(this.result.deathHandicap, this.addon.getSettings().getMaxDeaths());

long blockAndDeathPoints = this.result.rawBlockCount;

if (this.addon.getSettings().getDeathPenalty() > 0)
{
// Proper death penalty calculation.
blockAndDeathPoints -= this.result.deathHandicap * this.addon.getSettings().getDeathPenalty();
}

this.result.level = blockAndDeathPoints / this.addon.getSettings().getLevelCost() - this.island.getLevelHandicap();

// Calculate how many points are required to get to the next level
result.pointsToNextLevel = addon.getSettings().getLevelCost() - (result.rawBlockCount % addon.getSettings().getLevelCost());
this.result.pointsToNextLevel = this.addon.getSettings().getLevelCost() -
(blockAndDeathPoints % this.addon.getSettings().getLevelCost());

// Report
result.report = getReport();
// All done.
Expand Down

0 comments on commit e7cc3c7

Please sign in to comment.