Champs update

This commit is contained in:
Chiss 2013-10-31 17:36:41 +11:00
parent 52ac670f3f
commit ae4bf75485
4 changed files with 156 additions and 36 deletions

View File

@ -5,20 +5,25 @@ import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ItemDespawnEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.classcombat.shop.ClassCombatCustomBuildShop;
import mineplex.minecraft.game.core.combat.CombatComponent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.champions.kits.*;
import nautilus.game.arcade.game.games.champions.map.*;
import nautilus.game.arcade.game.games.smash.kits.*;
import nautilus.game.arcade.kit.Kit;
@ -37,6 +42,7 @@ public class Champions extends TeamGame
private ArrayList<String> _lastScoreboard = new ArrayList<String>();
//Scores
private int _victoryScore = 15000;
private int _redScore = 0;
private int _blueScore = 0;
@ -56,9 +62,10 @@ public class Champions extends TeamGame
new String[]
{
"DOMMA DOMMA DOMMA",
"...?",
"DOMMA!"
"Capture Beacons for Points",
"+500 Points for Emerald Powerups",
"+200 Point for Kills",
"First team to 15000 Points wins"
});
@ -87,6 +94,25 @@ public class Champions extends TeamGame
{
_emerald.add(new Emerald(this, loc));
}
/* NPCs
for (Location loc : WorldData.GetDataLocs("GRAY")) //Knight
SpawnNPC(Knight, loc);
for (Location loc : WorldData.GetDataLocs("GREEN")) //Ranger
SpawnNPC(Ranger, loc);
for (Location loc : WorldData.GetDataLocs("BLUE")) //Brute
SpawnNPC(Brute, loc);
for (Location loc : WorldData.GetDataLocs("BLACK")) //Assassin
SpawnNPC(Assasin, loc);
for (Location loc : WorldData.GetDataLocs("ORANGE")) //Mage
SpawnNPC(Mage, loc);
*/
}
@EventHandler
@ -105,6 +131,9 @@ public class Champions extends TeamGame
@EventHandler
public void Updates(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() == UpdateType.FAST)
for (CapturePoint cur : _points)
cur.Update();
@ -112,6 +141,10 @@ public class Champions extends TeamGame
if (event.getType() == UpdateType.FAST)
for (Emerald cur : _emerald)
cur.Update();
if (event.getType() == UpdateType.FAST)
for (Resupply cur : _resupply)
cur.Update();
}
@EventHandler
@ -119,14 +152,51 @@ public class Champions extends TeamGame
{
for (Emerald cur : _emerald)
cur.Pickup(event.getPlayer(), event.getItem());
for (Resupply cur : _resupply)
cur.Pickup(event.getPlayer(), event.getItem());
}
@EventHandler
public void KillScore(CombatDeathEvent event)
{
if (!(event.GetEvent().getEntity() instanceof Player))
return;
Player killed = (Player)event.GetEvent().getEntity();
GameTeam killedTeam = GetTeam(killed);
if (killedTeam == null) return;
if (event.GetLog().GetKiller() == null)
return;
Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (killer == null)
return;
GameTeam killerTeam = GetTeam(killer);
if (killerTeam == null) return;
if (killerTeam.equals(killedTeam))
return;
AddScore(killerTeam, 200);
}
public void AddScore(GameTeam team, int score)
{
if (team.GetColor() == ChatColor.RED)
_redScore += score;
{
_redScore = Math.min(_victoryScore, _redScore + score);
}
else
_blueScore += score;
{
_blueScore = Math.min(_victoryScore, _blueScore + score);
}
EndCheckScore();
}
//Dont allow powerups to despawn
@ -143,6 +213,12 @@ public class Champions extends TeamGame
if (event.getType() != UpdateType.FAST)
return;
ScoreboardWrite();
}
private void ScoreboardWrite()
{
if (!InProgress())
return;
@ -180,5 +256,43 @@ public class Champions extends TeamGame
}
}
public void EndCheckScore()
{
GameTeam winner = null;
if (_redScore == _victoryScore)
winner = GetTeam(ChatColor.RED);
else if (_blueScore == _victoryScore)
winner = GetTeam(ChatColor.AQUA);
if (winner == null)
return;
ScoreboardWrite();
//Announce
AnnounceEnd(winner);
for (GameTeam team : GetTeamList())
{
if (WinnerTeam != null && team.equals(WinnerTeam))
{
for (Player player : team.GetPlayers(false))
AddGems(player, 10, "Winning Team", false);
}
for (Player player : team.GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false);
}
//End
SetState(GameState.End);
}
@Override
public double GetKillsGems(Player killer, Player killed, boolean assist)
{
return 1;
}
}

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.champions.map;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@ -96,10 +97,10 @@ public class CapturePoint
{
//Who's on the CP?
GameTeam teamA = null;
int countA = 0;
ArrayList<Player> playersA = new ArrayList<Player>();
GameTeam teamB = null;
int countB = 0;
ArrayList<Player> playersB = new ArrayList<Player>();
for (GameTeam team : Host.GetTeamList())
{
@ -120,12 +121,12 @@ public class CapturePoint
if (teamA == null || teamA.equals(team))
{
teamA = team;
countA += 1;
playersA.add(player);
}
else
{
teamB = team;
countB += 1;
playersB.add(player);
}
}
}
@ -142,13 +143,13 @@ public class CapturePoint
//Capture
if (teamB == null)
Capture(teamA, countA);
Capture(teamA, playersA.size(), playersA);
else if (countA > countB)
Capture(teamA, countA-countB);
else if (playersA.size() > playersB.size())
Capture(teamA, playersA.size()-playersB.size(), playersA);
else if (countB > countA)
Capture(teamB, countB-countA);
else if (playersB.size() > playersA.size())
Capture(teamB, playersB.size()-playersA.size(), playersB);
}
private void RegenDegen()
@ -216,14 +217,14 @@ public class CapturePoint
}
}
public void Capture(GameTeam team, int count)
public void Capture(GameTeam team, int count, Collection<Player> capturers)
{
//Decay Delay
_decayDelay = System.currentTimeMillis();
//Defend Score
if (_captured)
Host.AddScore(_owner, count);
//if (_captured)
// Host.AddScore(_owner, count);
//Color
Color color = Color.RED;
@ -266,6 +267,15 @@ public class CapturePoint
if (team.GetColor() == ChatColor.RED) block.setData((byte)14);
else block.setData((byte)11);
}
//Reward Gems
if (capturers != null)
{
for (Player player : capturers)
{
Host.AddGems(player, 3, "Control Point Capture", true);
}
}
}
}
//Count Down

View File

@ -2,7 +2,6 @@ package nautilus.game.arcade.game.games.champions.map;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.game.GameTeam;
@ -15,7 +14,6 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -100,5 +98,8 @@ public class Emerald
//Firework
UtilFirework.playFirework(_loc, FireworkEffect.builder().flicker(false).withColor(Color.GREEN).with(Type.BALL_LARGE).trail(true).build());
//Gems
Host.AddGems(player, 3, "Emerald Powerup", true);
}
}

View File

@ -2,7 +2,6 @@ package nautilus.game.arcade.game.games.champions.map;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.game.GameTeam;
@ -15,7 +14,6 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -92,9 +90,6 @@ public class Resupply
_time = System.currentTimeMillis();
_loc.getBlock().getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK);
//Give Points
Host.AddScore(team, 500);
//Inform
UtilPlayer.message(player, C.cYellow + C.Bold + "Your inventory was restocked!");