Arena System
This commit is contained in:
@@ -1,22 +1,25 @@
|
||||
package engine.gameManager;
|
||||
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.Arena;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.Regions;
|
||||
import engine.objects.Zone;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class ArenaManager {
|
||||
private static final List<Arena> activeArenas = new ArrayList<>();
|
||||
public static final List<PlayerCharacter> playerQueue = new ArrayList<>();
|
||||
public static Long pulseDelay = 180000L;
|
||||
public static Long lastExecution = 0L;
|
||||
|
||||
public static void pulseArenas() {
|
||||
if(lastExecution == 0L){
|
||||
lastExecution = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
Iterator<Arena> iterator = activeArenas.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -26,6 +29,11 @@ public class ArenaManager {
|
||||
}
|
||||
}
|
||||
|
||||
if(lastExecution + pulseDelay < System.currentTimeMillis())
|
||||
return;
|
||||
|
||||
lastExecution = System.currentTimeMillis();
|
||||
|
||||
while (playerQueue.size() > 1) {
|
||||
createArena();
|
||||
}
|
||||
@@ -43,6 +51,7 @@ public class ArenaManager {
|
||||
|
||||
private static void createArena() {
|
||||
if (playerQueue.size() > 1) {
|
||||
Collections.shuffle(playerQueue);
|
||||
Arena newArena = new Arena();
|
||||
|
||||
//decide an arena location
|
||||
@@ -87,7 +96,9 @@ public class ArenaManager {
|
||||
loc = new Vector3fImmutable(x, y, z);
|
||||
Zone zone = ZoneManager.findSmallestZone(loc);
|
||||
if (zone.isContinent() && !ZoneManager.getSeaFloor().equals(zone)) {
|
||||
locSet = true;
|
||||
HashSet<AbstractWorldObject> inRange = WorldGrid.getObjectsInRangePartial(loc,250f, MBServerStatics.MASK_PLAYER);
|
||||
if(inRange.isEmpty())
|
||||
locSet = true;
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
||||
|
||||
@@ -113,9 +113,10 @@ public enum SimulationManager {
|
||||
}
|
||||
|
||||
try {
|
||||
if ((_cityPulseTime != 0)
|
||||
&& (System.currentTimeMillis() > _cityPulseTime))
|
||||
if ((_cityPulseTime != 0) && (System.currentTimeMillis() > _cityPulseTime)) {
|
||||
pulseCities();
|
||||
ArenaManager.pulseArenas();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error(
|
||||
"Fatal error in City Pulse: DISABLED. Error Message : "
|
||||
|
||||
@@ -2,6 +2,7 @@ package engine.objects;
|
||||
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.gameManager.ArenaManager;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.MovementManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.server.MBServerStatics;
|
||||
@@ -19,7 +20,14 @@ public class Arena {
|
||||
}
|
||||
public Boolean disqualify() {
|
||||
HashSet<AbstractWorldObject> inRange = WorldGrid.getObjectsInRangePartial(this.loc, 250f, MBServerStatics.MASK_PLAYER);
|
||||
HashSet<AbstractWorldObject> warningRange = WorldGrid.getObjectsInRangePartial(this.loc, 500f, MBServerStatics.MASK_PLAYER);
|
||||
for(AbstractWorldObject obj : warningRange){
|
||||
PlayerCharacter pc = (PlayerCharacter)obj;
|
||||
if(pc.equals(this.player1) || pc.equals(this.player2))
|
||||
continue;
|
||||
|
||||
ChatManager.chatSystemInfo(pc, "WARNING!! You are entering an arena zone!");
|
||||
}
|
||||
//boot out all non competitors
|
||||
for(AbstractWorldObject obj : inRange){
|
||||
if(obj.equals(this.player1))
|
||||
|
||||
@@ -202,23 +202,31 @@ public class Contract extends AbstractGameObject {
|
||||
vd.getOptions().clear();
|
||||
|
||||
switch(optionId){
|
||||
default:
|
||||
MenuOption option1 = new MenuOption(15020431, "Join Arena Que", 15020431);
|
||||
vd.getOptions().add(option1);
|
||||
MenuOption option2 = new MenuOption(15020432, "Leave Arena Que", 15020432);
|
||||
vd.getOptions().add(option2);
|
||||
break;
|
||||
case 15020431:
|
||||
ArenaManager.joinQueue(pc);
|
||||
ChatManager.chatSystemInfo(pc, "You Have Joined The Arena Que");
|
||||
if(pc.isBoxed){
|
||||
ChatManager.chatSystemInfo(pc, "You Cannot Join The Que, You Are Boxed");
|
||||
}else {
|
||||
if (ArenaManager.playerQueue.contains(pc)) {
|
||||
ChatManager.chatSystemInfo(pc, "You Are Already In The Arena Que");
|
||||
} else {
|
||||
ArenaManager.joinQueue(pc);
|
||||
ChatManager.chatSystemInfo(pc, "You Have Joined The Arena Que");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 15020432:
|
||||
if(ArenaManager.playerQueue.contains(pc))
|
||||
if(ArenaManager.playerQueue.contains(pc)) {
|
||||
ArenaManager.leaveQueue(pc);
|
||||
ChatManager.chatSystemInfo(pc, "You Have Left The Arena Que");
|
||||
ChatManager.chatSystemInfo(pc, "You Have Left The Arena Que");
|
||||
}else{
|
||||
ChatManager.chatSystemInfo(pc, "You Are Not In The Arena Que");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
MenuOption option1 = new MenuOption(15020431, "Join Arena Que", 15020431);
|
||||
vd.getOptions().add(option1);
|
||||
MenuOption option2 = new MenuOption(15020432, "Leave Arena Que", 15020432);
|
||||
vd.getOptions().add(option2);
|
||||
return vd;
|
||||
}
|
||||
public static VendorDialog HandleEnrollmentOfficer(int optionId, NPC npc, PlayerCharacter pc){
|
||||
|
||||
Reference in New Issue
Block a user