Add double plant generation and fix life reduction bug

This commit is contained in:
Thanos Paravantis 2016-05-30 12:46:04 +03:00
parent 8ee53c935b
commit a918f9067d
2 changed files with 58 additions and 26 deletions

View File

@ -169,7 +169,9 @@ public abstract class Challenge implements Listener
if (alive <= Settings.getMaxCompletedCount())
{
for (Player player : players)
{
setCompleted(player);
}
return true;
}
@ -236,12 +238,9 @@ public abstract class Challenge implements Listener
int alive = Host.getPlayersWithRemainingLives();
int lives = loseLife(player);
if (lives <= 0)
if (lives <= 0 && alive <= 3)
{
if (alive <= 3)
{
Host.getWinners().add(player);
}
Host.getWinners().add(player);
}
if (lives <= 0 && alive > 2)
@ -281,9 +280,9 @@ public abstract class Challenge implements Listener
{
if (Data.hasAnyoneCompleted() && !Data.isCompleted(player))
{
int lives = loseLife(player);
int lives = Host.lives(player);
if (lives > 0)
if (lives > 1)
{
setLost(player);
}
@ -535,39 +534,71 @@ public abstract class Challenge implements Listener
}
}
@SuppressWarnings("deprecation")
protected Block generateGrass(Block block)
{
return generateGrass(block, false);
}
protected Block generateGrass(Block block, boolean bushes)
{
if (UtilMath.r(4) == 0)
{
if (UtilMath.r(8) == 0)
{
Material flower = Material.YELLOW_FLOWER;
byte data = 0;
if (UtilMath.random.nextBoolean())
{
flower = Material.RED_ROSE;
if (UtilMath.random.nextBoolean())
{
data = (byte) (UtilMath.r(7) + 1);
}
}
block.setType(flower);
block.setData(data);
makeFlower(block);
}
else
{
block.setType(Material.LONG_GRASS);
block.setData((byte) 1);
makeGrass(block, bushes);
}
}
return block;
}
@SuppressWarnings("deprecation")
private void makeFlower(Block block)
{
Material flower = Material.YELLOW_FLOWER;
byte data = 0;
if (UtilMath.random.nextBoolean())
{
flower = Material.RED_ROSE;
if (UtilMath.random.nextBoolean())
{
data = (byte) (UtilMath.r(7) + 1);
}
}
block.setType(flower);
block.setData(data);
}
@SuppressWarnings("deprecation")
private void makeGrass(Block block, boolean bushes)
{
if (bushes && UtilMath.r(3) == 0)
{
Block above = block.getRelative(BlockFace.UP);
byte plantData = (byte) UtilMath.r(5);
block.setType(Material.DOUBLE_PLANT);
block.setData(plantData);
above.setType(Material.DOUBLE_PLANT);
above.setData((byte) 8);
addBlock(above);
}
else
{
block.setType(Material.LONG_GRASS);
block.setData((byte) 1);
}
}
public boolean isChallengeValid()
{
return Host.IsLive() && Host.getSettings().isChallengeStarted();

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.mineware.challenge;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@ -19,7 +20,7 @@ public class ChallengeData
{
private List<Location> _spawns = new ArrayList<>();
private Set<Player> _invisible = new HashSet<>();
private Set<Block> _modifiedBlocks = new HashSet<>();
private Set<Block> _modifiedBlocks = new LinkedHashSet<>();
private Set<Player> _completed = new HashSet<>();
private Set<Player> _lost = new HashSet<>();