|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.starhope.appius.game.ZoneSpawner
public class ZoneSpawner
Thread to manage automated zone spawn/retirement
Field Summary | |
---|---|
private static Lock |
lock
a lock for zone spawning |
static String |
myServer
the server to which this Zone Spawner belongs |
private long |
nextCheck
Time to next check zones for spawning |
private static Set<Zone> |
retiredZones
Zones which have been Retired may still be in play (there are probably users in them), but new users cannot see them or join them. |
private static int |
USER_ROOM_MAX_USERS
Max users allowed into one room of an user's house at a time |
private static double |
ZONE_FULL_RATIO
Get the percentage of "full" at which we consider a zone to be full enough to warrant spawning new ones. |
(package private) static double |
ZONE_LIGHT_RATIO
Get the percentage of "full" at which we consider a zone to be light enough that it's almost empty |
private static int |
ZONE_MAX_USERS
The max. |
private static int |
ZONE_SPAWN_SECONDS
Time (in seconds) between spawning new zones |
Constructor Summary | |
---|---|
ZoneSpawner(String server)
create a ZoneSpawner object for a given server |
Method Summary | |
---|---|
static void |
checkZonesForSpawn()
See if enough zones are full to warrant spawning a new one; or, if zones are empty and can be deallocated. |
int |
compareTo(AcceptsMetronomeTicks o)
|
static void |
configUpdated()
When the configuration is updated, update some “constants” used by the Zone Spawn system from the values in the configuration file (or in-core configuration overrides) |
boolean |
equals(Object obj)
|
(package private) static AbstractZone |
findLightZone()
Deprecated. Use TheZones.findLightZone() instead |
(package private) boolean |
freeInDB(String zoneName)
mark a zone as being free in the database |
private String |
genZoneName()
Generate the name for a new zone based upon this one's name |
String |
getName()
Return a user-visible, unique name for this class. |
private static int |
getNumberOfZonesNeeded(ConcurrentLinkedQueue<AbstractZone> zones)
This is a breakout from checkZonesForSpawn() to
determine the number of zones that need to be spawned or removed
ignoring hidden zones |
static int |
getUserRoomMaxUsers()
|
private static double |
getZoneFullRatio()
|
static double |
getZoneLightRatio()
|
static int |
getZoneMaxUsers()
|
static int |
getZoneSpawnSeconds()
Get the number of seconds between checking for zone spawning |
int |
hashCode()
|
private static void |
retireUnneededZones(ConcurrentLinkedQueue<AbstractZone> zones,
int numZonesToRemove)
retire any zones which are unneeded, due to population drop |
private static void |
spawnNeededZones(int needZones)
spawn the number of zones needed (in parallel) |
static String |
spawnNewZone()
|
private static void |
spawnZone_addRooms(Zone zone)
While spawning a new zone, add rooms to it. |
static Zone |
spawnZone()
spawn a single new zone, and return that Zone |
static Zone |
spawnZone(String zoneName)
Create a new, empty zone, and attach the default properties to it. |
static Zone |
spawnZone(String zoneName,
String image)
Create a new, empty zone, and attach the default properties to it. |
void |
tick(long currentTime,
long deltaTime)
This method is called periodically from the metronome thread. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static Lock lock
public static String myServer
private static final Set<Zone> retiredZones
private static int USER_ROOM_MAX_USERS
private static double ZONE_FULL_RATIO
static double ZONE_LIGHT_RATIO
private static int ZONE_MAX_USERS
private static int ZONE_SPAWN_SECONDS
private long nextCheck
Constructor Detail |
---|
public ZoneSpawner(String server)
server
- the hostname of the serverMethod Detail |
---|
public static void checkZonesForSpawn()
public static void configUpdated()
@Deprecated static AbstractZone findLightZone()
TheZones.findLightZone()
instead
private static int getNumberOfZonesNeeded(ConcurrentLinkedQueue<AbstractZone> zones)
checkZonesForSpawn()
to
determine the number of zones that need to be spawned or removed
ignoring hidden zones
zones
- The set of all Zones in the multiverse
public static int getUserRoomMaxUsers()
private static double getZoneFullRatio()
public static double getZoneLightRatio()
public static int getZoneMaxUsers()
public static int getZoneSpawnSeconds()
private static void retireUnneededZones(ConcurrentLinkedQueue<AbstractZone> zones, int numZonesToRemove)
zones
- the set of zones to be considered for retirementnumZonesToRemove
- the number of zones to be removedprivate static void spawnNeededZones(int needZones)
needZones
- the number of new zones to be spawnedpublic static String spawnNewZone()
public static Zone spawnZone()
public static Zone spawnZone(String zoneName)
zoneName
- the name of the new zone
public static Zone spawnZone(String zoneName, String image)
zoneName
- the name of the new zoneimage
- the background nugget icon
private static void spawnZone_addRooms(Zone zone)
zone
- the Zone to which rooms should be addedpublic int compareTo(AcceptsMetronomeTicks o)
compareTo
in interface Comparable<AcceptsMetronomeTicks>
Comparable.compareTo(java.lang.Object)
public boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
boolean freeInDB(String zoneName)
XXX: contains SQL
zoneName
- the new zone's name
private String genZoneName()
public String getName()
HasName
getName
in interface HasName
HasName.getName()
public int hashCode()
hashCode
in class Object
Object.hashCode()
public void tick(long currentTime, long deltaTime) throws UserDeadException
AcceptsMetronomeTicks
tick
in interface AcceptsMetronomeTicks
currentTime
- Time since epoch at the start of the global
metronome propagation, as per
System.currentTimeMillis()deltaTime
- Delta-time in milliseconds since the prior
global metronome tick
UserDeadException
- if a user has died during this tickAcceptsMetronomeTicks.tick(long,
long)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |