Browse Source

Arena System

lakebane2
FatBoy-DOTC 2 weeks ago
parent
commit
2ac3ce5bc8
  1. 27
      src/engine/gameManager/ArenaManager.java
  2. 5
      src/engine/gameManager/SimulationManager.java
  3. 8
      src/engine/objects/Arena.java
  4. 30
      src/engine/objects/Contract.java

27
src/engine/gameManager/ArenaManager.java

@ -1,22 +1,25 @@
package engine.gameManager; package engine.gameManager;
import engine.InterestManagement.WorldGrid;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.objects.Arena; import engine.objects.*;
import engine.objects.PlayerCharacter; import engine.server.MBServerStatics;
import engine.objects.Regions;
import engine.objects.Zone;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.ArrayList; import java.util.*;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
public class ArenaManager { public class ArenaManager {
private static final List<Arena> activeArenas = new ArrayList<>(); private static final List<Arena> activeArenas = new ArrayList<>();
public static final List<PlayerCharacter> playerQueue = new ArrayList<>(); public static final List<PlayerCharacter> playerQueue = new ArrayList<>();
public static Long pulseDelay = 180000L;
public static Long lastExecution = 0L;
public static void pulseArenas() { public static void pulseArenas() {
if(lastExecution == 0L){
lastExecution = System.currentTimeMillis();
}
Iterator<Arena> iterator = activeArenas.iterator(); Iterator<Arena> iterator = activeArenas.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -26,6 +29,11 @@ public class ArenaManager {
} }
} }
if(lastExecution + pulseDelay < System.currentTimeMillis())
return;
lastExecution = System.currentTimeMillis();
while (playerQueue.size() > 1) { while (playerQueue.size() > 1) {
createArena(); createArena();
} }
@ -43,6 +51,7 @@ public class ArenaManager {
private static void createArena() { private static void createArena() {
if (playerQueue.size() > 1) { if (playerQueue.size() > 1) {
Collections.shuffle(playerQueue);
Arena newArena = new Arena(); Arena newArena = new Arena();
//decide an arena location //decide an arena location
@ -87,7 +96,9 @@ public class ArenaManager {
loc = new Vector3fImmutable(x, y, z); loc = new Vector3fImmutable(x, y, z);
Zone zone = ZoneManager.findSmallestZone(loc); Zone zone = ZoneManager.findSmallestZone(loc);
if (zone.isContinent() && !ZoneManager.getSeaFloor().equals(zone)) { 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){ }catch(Exception e){

5
src/engine/gameManager/SimulationManager.java

@ -113,9 +113,10 @@ public enum SimulationManager {
} }
try { try {
if ((_cityPulseTime != 0) if ((_cityPulseTime != 0) && (System.currentTimeMillis() > _cityPulseTime)) {
&& (System.currentTimeMillis() > _cityPulseTime))
pulseCities(); pulseCities();
ArenaManager.pulseArenas();
}
} catch (Exception e) { } catch (Exception e) {
Logger.error( Logger.error(
"Fatal error in City Pulse: DISABLED. Error Message : " "Fatal error in City Pulse: DISABLED. Error Message : "

8
src/engine/objects/Arena.java

@ -2,6 +2,7 @@ package engine.objects;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.gameManager.ArenaManager; import engine.gameManager.ArenaManager;
import engine.gameManager.ChatManager;
import engine.gameManager.MovementManager; import engine.gameManager.MovementManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
@ -19,7 +20,14 @@ public class Arena {
} }
public Boolean disqualify() { public Boolean disqualify() {
HashSet<AbstractWorldObject> inRange = WorldGrid.getObjectsInRangePartial(this.loc, 250f, MBServerStatics.MASK_PLAYER); 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 //boot out all non competitors
for(AbstractWorldObject obj : inRange){ for(AbstractWorldObject obj : inRange){
if(obj.equals(this.player1)) if(obj.equals(this.player1))

30
src/engine/objects/Contract.java

@ -202,23 +202,31 @@ public class Contract extends AbstractGameObject {
vd.getOptions().clear(); vd.getOptions().clear();
switch(optionId){ 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: case 15020431:
ArenaManager.joinQueue(pc); if(pc.isBoxed){
ChatManager.chatSystemInfo(pc, "You Have Joined The Arena Que"); 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; break;
case 15020432: case 15020432:
if(ArenaManager.playerQueue.contains(pc)) if(ArenaManager.playerQueue.contains(pc)) {
ArenaManager.leaveQueue(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; 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; return vd;
} }
public static VendorDialog HandleEnrollmentOfficer(int optionId, NPC npc, PlayerCharacter pc){ public static VendorDialog HandleEnrollmentOfficer(int optionId, NPC npc, PlayerCharacter pc){

Loading…
Cancel
Save