Rename files to match challenge name, change kit description, refactor color change challenge.

This commit is contained in:
Thanos paravantis 2016-03-18 18:36:32 +02:00
parent 2f96325f0c
commit dd6d128b44
13 changed files with 311 additions and 286 deletions

View File

@ -93,13 +93,13 @@ import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeFastFood
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeFishingDay;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeInfestation;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeKangarooJump;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeKingOfTheHill;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeKingOfTheLadder;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeLavaRun;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeMilkACow;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeMineADiamond;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeMinecartDance;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeMiniOneInTheQuiver;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeNavigateMaze;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeNavigationMaze;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengePickASide;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengePunchThePig;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeRedLightGreenLight;
@ -107,8 +107,8 @@ import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeReverseT
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeRushPush;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeShootChickens;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeSmashOff;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeStandOnColor;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeTntLauncher;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeColorChange;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeDeadlyTnt;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeTreasureDigger;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeVolleyPig;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeWaterHorror;
@ -158,6 +158,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
// TODO: Do not trigger chicken attack if the game is about to end.
// TODO: Make players spawn with equal distance from target.
// TODO: Apply restriction to grass created in spawn locations.
// TODO: Do not crumble or make players invisible on challenge ending.
@SuppressWarnings("unchecked")
public BawkBawkBattles(ArcadeManager manager)
@ -212,40 +213,40 @@ public class BawkBawkBattles extends TeamGame implements IThrown
public void populateChallenges()
{
_list.add(
ChallengeAnvilDance.class, // Playable - Refactored
ChallengeArrowRampage.class, // Playable - Refactored
ChallengeBlockLobbers.class, // Playable - Refactored
ChallengeBouncingBlock.class, // Playable - Refactored
ChallengeBuildRace.class, // Playable - Refactored
ChallengeDiamondSeeker.class, // Playable - Refactored
ChallengeCloudFall.class, // Spawns - Refactored
ChallengeDogsVersusCats.class, // Playable - Refactored
ChallengeDragonEgg.class, // Playable - Refactored
ChallengeFallingBlocks.class, // Playable - Refactored
ChallengeFastFood.class, // Playable - Refactored
ChallengeFishingDay.class, // Playable - Refactored
ChallengeWaterHorror.class, // TNT not spawning - Refactored
ChallengeInfestation.class, // Playable - Refactored
ChallengeKangarooJump.class, // Playable - Refactored
ChallengeKingOfTheHill.class, // Playable - Refactored
ChallengeLavaRun.class, // Playable - Refactored
ChallengeMilkACow.class, // Playable - Refactored
ChallengeMineADiamond.class, // Playable - Refactored
ChallengeMinecartDance.class, // Playable - Refactored
ChallengeMiniOneInTheQuiver.class, // Playable - Refactored
ChallengeNavigateMaze.class, // Playable - Maze needs to be valid.
ChallengePickASide.class, // Never ends - Refactored
ChallengePunchThePig.class, // Playable - Refactored
ChallengeRedLightGreenLight.class, // Broken - Villager, Fireworks
ChallengeReverseTag.class, // Playable
ChallengeRushPush.class, // Testing Needed
ChallengeShootChickens.class, // Playable
ChallengeSmashOff.class, // Playable
ChallengeStandOnColor.class, // Playable
ChallengeTntLauncher.class, // Playable
ChallengeTreasureDigger.class, // Testing Needed
ChallengeVolleyPig.class, // Playable
ChallengeWaveCrush.class); // Broken
ChallengeAnvilDance.class,
ChallengeArrowRampage.class,
ChallengeBlockLobbers.class,
ChallengeBouncingBlock.class,
ChallengeBuildRace.class,
ChallengeDiamondSeeker.class,
ChallengeCloudFall.class,
ChallengeColorChange.class,
ChallengeDeadlyTnt.class,
ChallengeDogsVersusCats.class,
ChallengeDragonEgg.class,
ChallengeFallingBlocks.class,
ChallengeFastFood.class,
ChallengeFishingDay.class,
ChallengeWaterHorror.class,
ChallengeInfestation.class,
ChallengeKangarooJump.class,
ChallengeKingOfTheLadder.class,
ChallengeLavaRun.class,
ChallengeMilkACow.class,
ChallengeMineADiamond.class,
ChallengeMinecartDance.class,
ChallengeMiniOneInTheQuiver.class,
ChallengeNavigationMaze.class,
ChallengePickASide.class,
ChallengePunchThePig.class,
ChallengeRedLightGreenLight.class,
ChallengeReverseTag.class,
ChallengeRushPush.class,
ChallengeShootChickens.class,
ChallengeSmashOff.class,
ChallengeTreasureDigger.class,
ChallengeVolleyPig.class,
ChallengeWaveCrush.class);
}
@Override

View File

@ -119,6 +119,17 @@ public abstract class Challenge implements Listener
}
}
protected void fillItem(ItemStack item)
{
for (Player player : getChallengers())
{
for (int i = 0; i < 9; i++)
{
player.getInventory().setItem(i, item);
}
}
}
protected void removeItem(Material type, byte data)
{
for (Player player : getChallengers())

View File

@ -0,0 +1,233 @@
package nautilus.game.arcade.game.games.mineware.challenge.type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map.Entry;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
public class ChallengeColorChange extends Challenge
{
private ArrayList<Integer> _colors = new ArrayList<Integer>();
private int _currentColor;
private boolean _isFalling;
private long _lastSound;
private long _stageExpire;
private long _timeDelay = 3000;
public ChallengeColorChange(BawkBawkBattles host)
{
super(
host,
ChallengeType.LastStanding,
"Color Change",
"Stand on the correct color.");
Settings.setUseMapHeight();
populateColors();
}
@Override
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
for (int x = -7; x <= 7; x++)
{
for (int z = -7; z <= 7; z++)
{
if (x % 2 == 0 && z % 2 == 0)
{
spawns.add(getCenter().add(x + 0.5, 1.1, z + 0.5));
}
}
}
return spawns;
}
@Override
public void createMap()
{
ArrayList<Entry<Integer, Integer>> platforms = createPlatformCoordinates();
createPlatforms(platforms);
}
@Override
public void onStart()
{
setBorder(-20, 20, 0, 10, -20, 20);
_stageExpire = System.currentTimeMillis() + _timeDelay;
_currentColor = UtilMath.randomElement(_colors);
fillItem(new ItemStack(Material.STAINED_CLAY, 1, (short) _currentColor));
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!isChallengeValid())
return;
Player[] players = getChallengers().toArray(new Player[0]);
if (_stageExpire < System.currentTimeMillis())
{
UtilTextBottom.displayProgress(0, players);
if (_isFalling)
{
playFallSound();
_isFalling = false;
_timeDelay *= 0.8;
_stageExpire = System.currentTimeMillis() + _timeDelay;
_currentColor = UtilMath.randomElement(_colors);
createMap();
addCurrentColorToInventory();
}
else
{
_isFalling = true;
_stageExpire = System.currentTimeMillis() + 4000;
removeDifferentColorPlatforms();
}
}
else if (!_isFalling)
{
double amount = (_stageExpire - System.currentTimeMillis()) / (double) _timeDelay;
UtilTextBottom.displayProgress(amount, players);
playCountdownSound();
}
else
{
UtilTextBottom.displayProgress(0, players);
}
}
private void populateColors()
{
for (int i = 0; i <= 15; i++)
{
if (i != 2 && i != 6 && i != 7 && i != 9 && i != 12)
{
_colors.add(i);
}
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private ArrayList<Entry<Integer, Integer>> createPlatformCoordinates()
{
ArrayList<Entry<Integer, Integer>> platforms = new ArrayList<Entry<Integer, Integer>>();
for (int x = -4; x <= 4; x++)
{
for (int z = -4; z <= 4; z++)
{
platforms.add(new HashMap.SimpleEntry(x * 2, z * 2));
}
}
Collections.shuffle(platforms);
return platforms;
}
private void createPlatforms(ArrayList<Entry<Integer, Integer>> platforms)
{
int i = UtilMath.randomElement(_colors);
for (Entry<Integer, Integer> platform : platforms)
{
byte color = (byte) (int) _colors.get(i);
i++;
if (i >= _colors.size())
i = 0;
createPlatformPart(platform.getKey(), platform.getValue(), color);
}
}
@SuppressWarnings("deprecation")
private void createPlatformPart(int platformX, int platformZ, byte color)
{
for (int x = 0; x <= 1; x++)
{
for (int z = 0; z <= 1; z++)
{
Block block = getCenter().getBlock().getRelative(platformX + x, 0, platformZ + z);
block.setTypeIdAndData(Material.STAINED_CLAY.getId(), color, false);
addBlock(block);
}
}
}
private void playFallSound()
{
for (Player player : getChallengers())
{
player.playSound(player.getLocation(), Sound.NOTE_PIANO, 2.0F, 0.0F);
}
}
private void addCurrentColorToInventory()
{
fillItem(new ItemStack(Material.STAINED_CLAY, 1, (short) _currentColor));
}
@SuppressWarnings("deprecation")
private void removeDifferentColorPlatforms()
{
for (int x = -8; x <= 9; x++)
{
for (int z = -8; z <= 9; z++)
{
Block block = getCenter().getBlock().getRelative(x, 0, z);
if (block.getData() != _currentColor)
{
block.setTypeIdAndData(Material.AIR.getId(), (byte) 0, false);
addBlock(block);
}
}
}
}
private void playCountdownSound()
{
if (_lastSound < System.currentTimeMillis())
{
_lastSound = System.currentTimeMillis() + 1000;
for (Player player : getChallengers())
{
player.playSound(player.getLocation(), Sound.NOTE_STICKS, 1.0F, 1.0F);
}
}
}
}

View File

@ -28,12 +28,12 @@ import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
public class ChallengeTntLauncher extends Challenge
public class ChallengeDeadlyTnt extends Challenge
{
private ArrayList<Location> _spawns = new ArrayList<Location>();
private ArrayList<Entity> _tnt = new ArrayList<Entity>();
public ChallengeTntLauncher(BawkBawkBattles host)
public ChallengeDeadlyTnt(BawkBawkBattles host)
{
super(
host,

View File

@ -54,7 +54,7 @@ public class ChallengeFishingDay extends Challenge
ChallengeType.FirstComplete,
"Fishing Day",
"Be the first to catch 5 fish.",
"Watch out for TNT if you miss the fish!");
"Watch out for TNT if you miss one!");
Settings.setUseMapHeight();
Settings.setLockInventory(0);

View File

@ -23,17 +23,17 @@ import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
public class ChallengeKingOfTheHill extends Challenge
public class ChallengeKingOfTheLadder extends Challenge
{
private Location _winCornerA;
private Location _winCornerB;
public ChallengeKingOfTheHill(BawkBawkBattles host)
public ChallengeKingOfTheLadder(BawkBawkBattles host)
{
super(
host,
ChallengeType.FirstComplete,
"King Of The Ladder",
"King of the Ladder",
"Reach the top of the ladder.");
Settings.setUseMapHeight();

View File

@ -159,10 +159,10 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
if (!isChallengeValid())
return;
if (!(event.getDamager() instanceof Arrow)) // Damager = Arrow (player)
if (!(event.getDamager() instanceof Arrow))
return;
if (!(event.getEntity() instanceof Player)) // Damaged = player
if (!(event.getEntity() instanceof Player))
return;
Arrow arrow = (Arrow) event.getDamager();

View File

@ -16,11 +16,11 @@ import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
public class ChallengeNavigateMaze extends Challenge
public class ChallengeNavigationMaze extends Challenge
{
private HashMap<Player, Long> _completionTime = new HashMap<Player, Long>();
public ChallengeNavigateMaze(BawkBawkBattles host)
public ChallengeNavigationMaze(BawkBawkBattles host)
{
super(
host,

View File

@ -16,9 +16,9 @@ import org.bukkit.event.entity.EntityDeathEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -78,8 +78,6 @@ public class ChallengePunchThePig extends Challenge
if (y == 0)
{
double chance = UtilMath.random(1, 100);
if (UtilMath.random.nextDouble() * 100 < 20)
{
block.setType(Material.DIRT);
@ -134,11 +132,6 @@ public class ChallengePunchThePig extends Challenge
}
}
private Location getRandomPigSpawn()
{
return getCenter().add(UtilMath.r((getArenaSize() * 2) - 1) - (getArenaSize() - 1), 1, UtilMath.r((getArenaSize() * 2) - 1) - (getArenaSize() - 1));
}
@Override
public void onEnd()
{
@ -229,4 +222,8 @@ public class ChallengePunchThePig extends Challenge
}
}
private Location getRandomPigSpawn()
{
return getCenter().add(UtilMath.r((getArenaSize() * 2) - 1) - (getArenaSize() - 1), 1, UtilMath.r((getArenaSize() * 2) - 1) - (getArenaSize() - 1));
}
}

View File

@ -35,8 +35,8 @@ public class ChallengeRushPush extends Challenge
"Push them off the platform.");
Settings.setUseMapHeight();
Settings.setTeamBased();
Settings.setCanCruble();
Settings.setTeamBased();
}
@Override

View File

@ -1,220 +0,0 @@
package nautilus.game.arcade.game.games.mineware.challenge.type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map.Entry;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
public class ChallengeStandOnColor extends Challenge
{
private ArrayList<Integer> _colors = new ArrayList<Integer>();
private int _currentColor;
private boolean _isFalling;
private long _lastSound;
private long _stageExpires;
private long _timeDelay = 3000;
public ChallengeStandOnColor(BawkBawkBattles host)
{
super(
host,
ChallengeType.LastStanding,
"Color Change",
"Stand on the correct color.");
Settings.setUseMapHeight();
for (int i = 0; i <= 15; i++)
{
_colors.add(i);
}
_colors.remove(new Integer(2));
_colors.remove(new Integer(6));
_colors.remove(new Integer(7));
_colors.remove(new Integer(9));
_colors.remove(new Integer(12));
}
@Override
public void onEnd()
{
for (Player player : Host.GetPlayers(true))
{
UtilInv.Clear(player);
}
}
private void generateFloor()
{
ArrayList<Entry<Integer, Integer>> cords = new ArrayList<Entry<Integer, Integer>>();
int i = UtilMath.r(_colors.size());
for (int x = -4; x <= 4; x++)
{
for (int z = -4; z <= 4; z++)
{
cords.add(new HashMap.SimpleEntry(x * 2, z * 2));
}
}
Collections.shuffle(cords);
for (Entry<Integer, Integer> entry : cords)
{
byte color = (byte) (int) _colors.get(i++);
if (i >= _colors.size())
{
i = 0;
}
for (int x = 0; x <= 1; x++)
{
for (int z = 0; z <= 1; z++)
{
Block b = getCenter().getBlock().getRelative(entry.getKey() + x, 0, entry.getValue() + z);
b.setTypeIdAndData(Material.STAINED_CLAY.getId(), color, false);
addBlock(b);
}
}
}
}
@Override
public void createMap()
{
setBorder(-20, 20, 0, 10, -20, 20);
generateFloor();
}
@Override
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
for (int x = -7; x <= 7; x++)
{
for (int z = -7; z <= 7; z++)
{
if (x % 2 == 0 && z % 2 == 0)
{
spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5));
}
}
}
return spawns;
}
@EventHandler
public void OnTick(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
{
return;
}
if (!Host.IsLive())
{
return;
}
Player[] players = getChallengers().toArray(new Player[0]);
if (_stageExpires < System.currentTimeMillis())
{
UtilTextBottom.displayProgress(0, players);
if (_isFalling)
{
for (Player player : UtilServer.getPlayers())
player.playSound(player.getLocation(), Sound.NOTE_PIANO, 2f, 0f);
_timeDelay *= 0.8;
_isFalling = false;
_stageExpires = System.currentTimeMillis() + _timeDelay;
_currentColor = _colors.get(UtilMath.r(_colors.size()));
generateFloor();
for (Player player : getChallengers())
{
for (int i = 0; i < 9; i++)
{
player.getInventory().setItem(i, new ItemStack(Material.STAINED_CLAY, 1, (short) _currentColor));
}
}
}
else
{
_isFalling = true;
_stageExpires = System.currentTimeMillis() + 4000;
for (int x = -8; x <= 9; x++)
{
for (int z = -8; z <= 9; z++)
{
Block b = getCenter().getBlock().getRelative(x, 0, z);
if (b.getData() != _currentColor)
{
b.setTypeIdAndData(Material.AIR.getId(), (byte) 0, false);
addBlock(b);
}
}
}
}
}
else if (!_isFalling)
{
UtilTextBottom.displayProgress((_stageExpires - System.currentTimeMillis()) / (double) _timeDelay, players);
if (_lastSound < System.currentTimeMillis())
{
_lastSound = System.currentTimeMillis() + 1000;
for (Player player : UtilServer.getPlayers())
player.playSound(player.getLocation(), Sound.NOTE_STICKS, 1f, 1f);
}
}
else
{
UtilTextBottom.displayProgress(0, players);
}
}
@Override
public void onStart()
{
_stageExpires = System.currentTimeMillis() + _timeDelay;
_currentColor = _colors.get(UtilMath.r(_colors.size()));
for (Player player : Host.GetPlayers(true))
{
for (int i = 0; i < 9; i++)
{
player.getInventory().setItem(i, new ItemStack(Material.STAINED_CLAY, 1, (short) _currentColor));
}
}
}
}

View File

@ -23,11 +23,14 @@ public class KitBawksFood extends Kit
super(manager,
"Bawk's Food",
KitAvailability.Free,
new String[] { "You must listen to Bawk Bawk." },
new Perk[] { },
new String[] {
"Lord Bawk Bawk demands you follow his commands.",
"If you fail his tasks you will lose a life.",
"If you run out of lives Bawk Bawk's followers will eat you!"
},
new Perk[] {},
EntityType.SKELETON,
new ItemStack(Material.AIR)
);
new ItemStack(Material.AIR));
}
@Override

View File

@ -3,7 +3,7 @@ package nautilus.game.arcade.game.games.mineware.stats;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeNavigateMaze;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeNavigationMaze;
import nautilus.game.arcade.game.games.mineware.events.ChallengeEndEvent;
import nautilus.game.arcade.game.games.mineware.events.ChallengeStartEvent;
import nautilus.game.arcade.stats.StatTracker;
@ -30,7 +30,7 @@ public class MinewareLauraCraftTracker extends StatTracker<Game>
Challenge challenge = event.getStartedChallenge();
if (!(challenge instanceof ChallengeNavigateMaze))
if (!(challenge instanceof ChallengeNavigationMaze))
return;
_challengeStartTime = System.currentTimeMillis();
@ -44,10 +44,10 @@ public class MinewareLauraCraftTracker extends StatTracker<Game>
Challenge challenge = event.getEndedChallenge();
if (!(challenge instanceof ChallengeNavigateMaze))
if (!(challenge instanceof ChallengeNavigationMaze))
return;
ChallengeNavigateMaze challengeMaze = (ChallengeNavigateMaze) challenge;
ChallengeNavigationMaze challengeMaze = (ChallengeNavigationMaze) challenge;
for (Player player : challengeMaze.getPlayerTimes().keySet())
if (challengeMaze.getPlayerTimes().get(player) <= (_challengeStartTime + (_timeForCompletion * 1000)))