Fix bugs with kit sorting + cost of kits
This commit is contained in:
parent
e4662ab563
commit
0edb0d74a7
@ -27,7 +27,7 @@ public class KitBlaze extends SmashKit
|
||||
{
|
||||
public KitBlaze(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Blaze", KitAvailability.Green, 5000,
|
||||
super(manager, "Blaze", KitAvailability.Green, 6000,
|
||||
|
||||
new String[]
|
||||
{
|
||||
@ -106,10 +106,4 @@ public class KitBlaze extends SmashKit
|
||||
Manager.GetCondition().Factory().FireItemImmunity(GetName(), player, player, 1.9, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetCost()
|
||||
{
|
||||
return 6000;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class KitCreeper extends SmashKit
|
||||
{
|
||||
public KitCreeper(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Creeper", KitAvailability.Green,
|
||||
super(manager, "Creeper", KitAvailability.Green, 4000,
|
||||
|
||||
new String[]
|
||||
{
|
||||
@ -95,10 +95,4 @@ public class KitCreeper extends SmashKit
|
||||
disguise.SetCustomNameVisible(true);
|
||||
Manager.GetDisguise().disguise(disguise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetCost()
|
||||
{
|
||||
return 4000;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class KitEnderman extends SmashKit
|
||||
|
||||
public KitEnderman(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Enderman", KitAvailability.Green,
|
||||
super(manager, "Enderman", KitAvailability.Green, 4000,
|
||||
|
||||
new String[]
|
||||
{
|
||||
@ -147,10 +147,4 @@ public class KitEnderman extends SmashKit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetCost()
|
||||
{
|
||||
return 4000;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class KitSnowman extends SmashKit
|
||||
{
|
||||
public KitSnowman(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Snowman", KitAvailability.Green,
|
||||
super(manager, "Snowman", KitAvailability.Green, 5000,
|
||||
|
||||
new String[]
|
||||
{
|
||||
@ -94,10 +94,4 @@ public class KitSnowman extends SmashKit
|
||||
disguise.SetCustomNameVisible(true);
|
||||
Manager.GetDisguise().disguise(disguise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetCost()
|
||||
{
|
||||
return 5000;
|
||||
}
|
||||
}
|
||||
|
@ -101,10 +101,4 @@ public class KitSpider extends SmashKit
|
||||
disguise.SetCustomNameVisible(true);
|
||||
Manager.GetDisguise().disguise(disguise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetCost()
|
||||
{
|
||||
return 2000;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class KitWitherSkeleton extends SmashKit
|
||||
{
|
||||
public KitWitherSkeleton(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Wither Skeleton", KitAvailability.Green, 5000,
|
||||
super(manager, "Wither Skeleton", KitAvailability.Green, 6000,
|
||||
|
||||
new String[]
|
||||
{
|
||||
@ -83,10 +83,4 @@ public class KitWitherSkeleton extends SmashKit
|
||||
disguise.hideArmor();
|
||||
Manager.GetDisguise().disguise(disguise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetCost()
|
||||
{
|
||||
return 6000;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package nautilus.game.arcade.kit;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/4/2014.
|
||||
*/
|
||||
public class KitSorter implements Comparator<Kit>
|
||||
{
|
||||
@Override
|
||||
public int compare(Kit kit1, Kit kit2)
|
||||
{
|
||||
if (kit1.GetAvailability() == KitAvailability.Free && kit2.GetAvailability() == KitAvailability.Green)
|
||||
return -1;
|
||||
else if (kit1.GetAvailability() == KitAvailability.Green && kit2.GetAvailability() == KitAvailability.Free)
|
||||
return 1;
|
||||
else
|
||||
return kit1.GetCost() - kit2.GetCost();
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ public abstract class SmashKit extends Kit
|
||||
KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks,
|
||||
EntityType entityType, ItemStack itemInHand)
|
||||
{
|
||||
super(manager, name, kitAvailability, kitDesc, kitPerks, entityType, itemInHand);
|
||||
super(manager, name, kitAvailability, 3000, kitDesc, kitPerks, entityType, itemInHand);
|
||||
}
|
||||
|
||||
public SmashKit(ArcadeManager manager, String name,
|
||||
@ -55,10 +55,4 @@ public abstract class SmashKit extends Kit
|
||||
UtilPlayer.message(player, ArcadeFormat.Line);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetCost()
|
||||
{
|
||||
return 3000;
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.KitAvailability;
|
||||
import nautilus.game.arcade.kit.KitSorter;
|
||||
import net.minecraft.server.v1_7_R3.DataWatcher;
|
||||
import net.minecraft.server.v1_7_R3.Packet;
|
||||
import net.minecraft.server.v1_7_R3.PacketPlayOutEntityMetadata;
|
||||
@ -455,6 +456,9 @@ public class GameLobbyManager implements IPacketRunnable, Listener
|
||||
kits.add(kit);
|
||||
}
|
||||
|
||||
// Sort kits by price
|
||||
Collections.sort(kits, new KitSorter());
|
||||
|
||||
//Smash
|
||||
if (game.GetType() == GameType.Smash || game.GetType() == GameType.SurvivalGames)
|
||||
{
|
||||
@ -466,22 +470,11 @@ public class GameLobbyManager implements IPacketRunnable, Listener
|
||||
|
||||
for (int i=0 ; i<kits.size() ; i++)
|
||||
{
|
||||
kitsA.add(kits.get(i));
|
||||
// if (kits.get(i).GetAvailability() != KitAvailability.Blue) kitsA.add(kits.get(i));
|
||||
// else kitsB.add(kits.get(i));
|
||||
if (kits.get(i).GetCost() < 5000) kitsA.add(kits.get(i));
|
||||
else kitsB.add(kits.get(i));
|
||||
}
|
||||
|
||||
{
|
||||
// Sort kits by price
|
||||
Collections.sort(kitsA, new Comparator<Kit>()
|
||||
{
|
||||
@Override
|
||||
public int compare(Kit o1, Kit o2)
|
||||
{
|
||||
return o1.GetCost() - o2.GetCost();
|
||||
}
|
||||
});
|
||||
|
||||
//Positions
|
||||
double space = 4;
|
||||
double offset = (kitsA.size()-1)*space/2d;
|
||||
|
Loading…
Reference in New Issue
Block a user