Atavism Version 2018.1AGIS API

atavism.agis.arenas
Class Arena

java.lang.Object
  extended by atavism.agis.arenas.Arena
All Implemented Interfaces:
MessageCallback, java.io.Serializable
Direct Known Subclasses:
CaptureTheFlagArena, DeathmatchArena

public abstract class Arena
extends java.lang.Object
implements java.io.Serializable, MessageCallback

The Arena class handles an arena instance. It has numerous scheduled executors and a state variable to control the flow of the arena from setup to the end. This class is complete, it relies on no other class to perform it's duties.

Author:
Andrew Harrison
See Also:
Serialized Form

Nested Class Summary
 class Arena.ArenaCleanup
          Teleports all players out and then sends out a message to remove this arena instance from the Map stored in the ArenaPlugin.
 class Arena.ArenaEnd
          The class to handle when the arenas timer has expired.
 class Arena.ArenaStart
          Starts the arena.
 
Field Summary
protected  int arenaDatabaseID
           
protected  int arenaGameType
           
protected  int arenaID
           
protected  java.lang.String arenaName
           
protected  java.util.HashMap<java.lang.Integer,java.util.HashMap<java.lang.Integer,ArenaObject>> arenaObjects
           
protected  int category
           
protected static int centreX
           
protected static int centreY
           
protected static int centreZ
           
protected  java.util.HashMap<java.lang.Integer,java.lang.Integer> defeatPayment
           
protected  int defeatXP
           
protected  int goalType
           
protected static int gridSize
           
protected  OID instanceOid
           
protected  int instanceTemplateID
           
protected  int length
           
protected  int numTeams
           
protected static int PLAYER_IMMUNE
           
protected static int PLAYER_INACTIVE
           
static java.lang.String PROP_HEALTH
           
protected static java.lang.String PROP_MAX_HEALTH
           
static java.lang.String PROP_WEAPON
           
protected  java.util.concurrent.ScheduledFuture<?> scheduledExecutioner
           
protected  int startTime
           
protected  int state
          Status of the arena 0: Not yet set 1: Starting 2: Running 3: Ending
protected static int STATE_END
           
protected static int STATE_RUNNING
           
protected static int STATE_SETUP
           
protected static int STATE_UNSET
           
protected  ArenaTeam[] teams
           
protected  boolean useWeapons
           
protected  int victoryCondition
           
protected  java.util.HashMap<java.lang.Integer,java.lang.Integer> victoryPayment
           
protected  int victoryXP
           
 
Fields inherited from interface atavism.msgsys.MessageCallback
NO_FLAGS, RESPONSE_EXPECTED
 
Constructor Summary
Arena()
           
Arena(int numTeams)
          The default constructor.
Arena(int numTeams, java.util.ArrayList<ArenaQueue.QueueMember>[] members, int arenaGameType, int arenaDatabaseID, java.lang.String arenaName, int category, int dur, int[] goals, java.lang.String[] teamNames, Point[] spawnPoints, int condition, int id, int[] minPlayers, int instanceTemplateID, java.util.HashMap<java.lang.Integer,java.lang.Integer> victoryPayment, java.util.HashMap<java.lang.Integer,java.lang.Integer> defeatPayment, int victoryExp, int defeatExp, boolean useWeapons)
          Constructor that takes in two lists that contain the oids of the players on each team.
 
Method Summary
abstract  void activateAbility(OID playerOid, OID targetOid, int slot)
           
 void activateMachine(OID oid, int machineID)
           
protected abstract  boolean addAbility(OID playerOid, int team)
           
 void addArenaObject(ArenaObject aObject)
           
protected  boolean addHealth(ArenaMember member)
           
protected  void addIndividualDeath(int team, OID oid, int adjustment)
          Add the score to the players individual score.
protected  void addIndividualKill(int team, OID oid, int adjustment)
          Add the score to the players individual score.
protected  void addIndividualScore(int team, OID oid, int score)
          Add the score to the players individual score.
 void addKillScore(OID attackerOid, OID victimOid)
          This will be called whenever one player kills another.
protected  boolean addWeapon(ArenaMember member, java.lang.String objectType)
           
protected abstract  void alterTeamScore(int team, int score)
          Add the score to the teams score.
protected  void changePlayerRace(ArenaMember member, java.lang.String race, boolean temporary)
           
abstract  void completeTutorial(OID oid)
           
protected  void createSubs()
          Creates a subscription for each player so we can catch their damage messages.
protected  void despawnGates()
           
 int getArenaCategory()
           
 int getArenaID()
           
 OID getArenaInstanceOid()
           
 ArenaMember getArenaPlayer(OID oid)
           
 int getArenaType()
           
 int getInstanceTemplateID()
           
 int getLength()
           
 java.util.LinkedList<java.lang.Integer> getOpposingTeams(int team)
           
 int getPlayerTeam(OID oid)
          Searches the target team for the index of the player
 int getState()
           
 ArenaTeam getTeam(int team)
           
 ArenaTeam[] getTeams()
           
protected  java.util.ArrayList<java.lang.String> getUsableSkins()
          Gets the list of skins the member can use.
 void handleDeath(OID attackerOid, OID victimOid)
           
 void handleMessage(Message msg, int flags)
          process network messages
protected  void logArenaResult(int winningTeam)
           
abstract  void releaseRequest(OID playerOid)
           
 void removePlayer(OID oid, boolean teleport)
          Removes a player from the arena.
 void sendAbilities(OID playerOid)
           
protected  void sendChatMessageAll(java.lang.String msg)
          Calls sendChatMessageTeam for each team in the arena.
protected  void sendChatMessageSingle(java.lang.String msg, OID oid)
          Sends the specified chat message to the specified player
protected  void sendChatMessageTeam(java.lang.String msg, int team)
          Calls sendChatMessageSingle for each player in the specified team.
 void sendMessageAll(java.lang.String msgType, java.io.Serializable data)
          Calls sendMessageTeam for each team in the arena.
 boolean sendMessageSingle(java.lang.String msgType, OID oid, java.io.Serializable data)
          Sends an extension message of the specified type to the specified player
 void sendMessageTeam(java.lang.String msgType, int team, java.io.Serializable data)
          Calls sendMessageSingle for each member in the specified team.
protected  void sendStatMessageAll(java.lang.String msgType, int team, OID oid, java.lang.String stat, int score)
          Calls sendStateMessageSingle for each player in the arena.
protected  void sendStatMessageSingle(java.lang.String msgType, OID oid, int team, OID scoreOid, java.lang.String stat, int score)
          Sends a stat update extension message to the specified player.
 void setArenaCategory(int category)
           
 void setArenaID(int arenaID)
           
 void setArenaInstanceOid(OID instanceOid)
           
 void setArenaType(int arenaGameType)
           
 void setInstanceTemplateID(int instanceTemplateID)
           
 void setLength(int length)
           
 void setPlayerProperty(OID oid, java.lang.String prop, java.io.Serializable value)
          Sends a property message with the given properties for the player.
 void setPlayerSkin(OID oid, java.lang.String race)
           
protected  void setPlayerTeamColour(OID oid, int teamColour)
           
 void setState(int state)
           
 void setTeams(ArenaTeam[] teams)
           
 void setup()
          This is run once the Arena object is created.
protected  void teleportAllBase()
          Teleports all players back to their bases.
protected  void teleportAllOut()
          Goes through all the players in the arena and calls teleportOut.
protected  void teleportOut(OID oid)
          Teleports the specified player out of the instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numTeams

protected int numTeams

arenaID

protected int arenaID

arenaDatabaseID

protected int arenaDatabaseID

arenaGameType

protected int arenaGameType

category

protected int category

arenaName

protected java.lang.String arenaName

instanceOid

protected OID instanceOid

length

protected int length

startTime

protected int startTime

instanceTemplateID

protected int instanceTemplateID

victoryPayment

protected java.util.HashMap<java.lang.Integer,java.lang.Integer> victoryPayment

defeatPayment

protected java.util.HashMap<java.lang.Integer,java.lang.Integer> defeatPayment

victoryXP

protected int victoryXP

defeatXP

protected int defeatXP

useWeapons

protected boolean useWeapons

scheduledExecutioner

protected java.util.concurrent.ScheduledFuture<?> scheduledExecutioner

state

protected int state
Status of the arena 0: Not yet set 1: Starting 2: Running 3: Ending


teams

protected ArenaTeam[] teams

victoryCondition

protected int victoryCondition

goalType

protected int goalType

arenaObjects

protected java.util.HashMap<java.lang.Integer,java.util.HashMap<java.lang.Integer,ArenaObject>> arenaObjects

gridSize

protected static int gridSize

centreX

protected static int centreX

centreY

protected static int centreY

centreZ

protected static int centreZ

STATE_UNSET

protected static final int STATE_UNSET
See Also:
Constant Field Values

STATE_SETUP

protected static final int STATE_SETUP
See Also:
Constant Field Values

STATE_RUNNING

protected static final int STATE_RUNNING
See Also:
Constant Field Values

STATE_END

protected static final int STATE_END
See Also:
Constant Field Values

PLAYER_INACTIVE

protected static final int PLAYER_INACTIVE
See Also:
Constant Field Values

PLAYER_IMMUNE

protected static final int PLAYER_IMMUNE
See Also:
Constant Field Values

PROP_HEALTH

public static final java.lang.String PROP_HEALTH
See Also:
Constant Field Values

PROP_MAX_HEALTH

protected static final java.lang.String PROP_MAX_HEALTH
See Also:
Constant Field Values

PROP_WEAPON

public static final java.lang.String PROP_WEAPON
See Also:
Constant Field Values
Constructor Detail

Arena

public Arena()

Arena

public Arena(int numTeams)
The default constructor. This creates the Arrays and ArrayLists. This needs to be called by the other constructors.

Parameters:
numTeams: - the number of teams in the arena

Arena

public Arena(int numTeams,
             java.util.ArrayList<ArenaQueue.QueueMember>[] members,
             int arenaGameType,
             int arenaDatabaseID,
             java.lang.String arenaName,
             int category,
             int dur,
             int[] goals,
             java.lang.String[] teamNames,
             Point[] spawnPoints,
             int condition,
             int id,
             int[] minPlayers,
             int instanceTemplateID,
             java.util.HashMap<java.lang.Integer,java.lang.Integer> victoryPayment,
             java.util.HashMap<java.lang.Integer,java.lang.Integer> defeatPayment,
             int victoryExp,
             int defeatExp,
             boolean useWeapons)
Constructor that takes in two lists that contain the oids of the players on each team.

Parameters:
one: - the list of oids for players on team one
two: - the list of oids for players on team two
type: - the arena type
dur: - the duration of the arena
goals: - the goal score for the teams
loc: - the centre point of the arena
id: - the identification number of the arena
minPlayers: - the minimum number of players in each team
Method Detail

setup

public void setup()
This is run once the Arena object is created. It will be responsible for teleporting players to their bases, sending the setup extension message to all players and then getting arenaStart() to be activated in 30 seconds.


getUsableSkins

protected java.util.ArrayList<java.lang.String> getUsableSkins()
Gets the list of skins the member can use. This is determined by the arena category skins and the list of skins the user has purchased.

Parameters:
member -

setPlayerSkin

public void setPlayerSkin(OID oid,
                          java.lang.String race)

setPlayerTeamColour

protected void setPlayerTeamColour(OID oid,
                                   int teamColour)

changePlayerRace

protected void changePlayerRace(ArenaMember member,
                                java.lang.String race,
                                boolean temporary)

getOpposingTeams

public java.util.LinkedList<java.lang.Integer> getOpposingTeams(int team)

createSubs

protected void createSubs()
Creates a subscription for each player so we can catch their damage messages.


addArenaObject

public void addArenaObject(ArenaObject aObject)

handleMessage

public void handleMessage(Message msg,
                          int flags)
process network messages

Specified by:
handleMessage in interface MessageCallback
Parameters:
msg - Message sent from other agent.
flags - Bitwise OR of MessageCallback.NO_FLAGS, MessageCallback.RESPONSE_EXPECTED.

despawnGates

protected void despawnGates()

addAbility

protected abstract boolean addAbility(OID playerOid,
                                      int team)

sendAbilities

public void sendAbilities(OID playerOid)

addHealth

protected boolean addHealth(ArenaMember member)

addWeapon

protected boolean addWeapon(ArenaMember member,
                            java.lang.String objectType)

teleportAllBase

protected void teleportAllBase()
Teleports all players back to their bases. While this is not currently used it will probably have a use at a later date


teleportAllOut

protected void teleportAllOut()
Goes through all the players in the arena and calls teleportOut. This will also delete the instance, so do not use this unless the instance has finished.


teleportOut

protected void teleportOut(OID oid)
Teleports the specified player out of the instance.

Parameters:
oid: - The oid of the player being teleported out

activateMachine

public void activateMachine(OID oid,
                            int machineID)

removePlayer

public void removePlayer(OID oid,
                         boolean teleport)
Removes a player from the arena.

Parameters:
oid: - The player being removed from the arena

handleDeath

public void handleDeath(OID attackerOid,
                        OID victimOid)

addKillScore

public void addKillScore(OID attackerOid,
                         OID victimOid)
This will be called whenever one player kills another. This function is called from the ArenaPlugin which has a hook to catch the kill message.

Parameters:
attackerOid: - the oid of the attacker
victimOid: - the oid of the victim

activateAbility

public abstract void activateAbility(OID playerOid,
                                     OID targetOid,
                                     int slot)

completeTutorial

public abstract void completeTutorial(OID oid)

alterTeamScore

protected abstract void alterTeamScore(int team,
                                       int score)
Add the score to the teams score.

Parameters:
team: - Which team to add score to.
score: - Score value to add. Can be negative.

releaseRequest

public abstract void releaseRequest(OID playerOid)

addIndividualScore

protected void addIndividualScore(int team,
                                  OID oid,
                                  int score)
Add the score to the players individual score.

Parameters:
team: - the team the player belongs to
oid: - the oid of the player
score: - the score value to add. Can be negative.

addIndividualKill

protected void addIndividualKill(int team,
                                 OID oid,
                                 int adjustment)
Add the score to the players individual score.

Parameters:
team: - the team the player belongs to
oid: - the oid of the player
adjustment: - the value to adjustment the kill variable by

addIndividualDeath

protected void addIndividualDeath(int team,
                                  OID oid,
                                  int adjustment)
Add the score to the players individual score.

Parameters:
team: - the team the player belongs to
oid: - the oid of the player
adjustment: - the value to adjustment the death variable by

getPlayerTeam

public int getPlayerTeam(OID oid)
Searches the target team for the index of the player

Parameters:
oid: - Player object id
team: - Which team to search
Returns:
Index:the position of the player within the team list. Returns -1 if the player doesn't exist in that team.

getArenaPlayer

public ArenaMember getArenaPlayer(OID oid)

sendMessageAll

public void sendMessageAll(java.lang.String msgType,
                           java.io.Serializable data)
Calls sendMessageTeam for each team in the arena.

Parameters:
msgType: - the message type
data: - some form of data to be sent

sendMessageTeam

public void sendMessageTeam(java.lang.String msgType,
                            int team,
                            java.io.Serializable data)
Calls sendMessageSingle for each member in the specified team.

Parameters:
msgType: - the message type
team: - the team to send the message to
data: - some form of data to be sent

sendMessageSingle

public boolean sendMessageSingle(java.lang.String msgType,
                                 OID oid,
                                 java.io.Serializable data)
Sends an extension message of the specified type to the specified player

Parameters:
msgType: - the message type
oid: - the oid to send the message to
data: - some form of data to be sent

sendStatMessageAll

protected void sendStatMessageAll(java.lang.String msgType,
                                  int team,
                                  OID oid,
                                  java.lang.String stat,
                                  int score)
Calls sendStateMessageSingle for each player in the arena.

Parameters:
msgType: - the message type
team: - the team which the player whose stat is being updated is from
oid: - the oid of the player whose stat was changed
stat: - the type of stat that was changed
score: - the value of the stat that was changed

sendStatMessageSingle

protected void sendStatMessageSingle(java.lang.String msgType,
                                     OID oid,
                                     int team,
                                     OID scoreOid,
                                     java.lang.String stat,
                                     int score)
Sends a stat update extension message to the specified player.

Parameters:
msgType: - the message type
oid: - the oid of the player the message is being sent to
team: - the team which the player whose stat is being updated is from
scoreOid: - the oid of the player whose stat was changed
stat: - the type of stat that was changed
score: - the value of the stat that was changed

sendChatMessageAll

protected void sendChatMessageAll(java.lang.String msg)
Calls sendChatMessageTeam for each team in the arena.

Parameters:
msg: - the chat message to send

sendChatMessageTeam

protected void sendChatMessageTeam(java.lang.String msg,
                                   int team)
Calls sendChatMessageSingle for each player in the specified team.

Parameters:
msg: - the chat message to send
team: - the team to send the chat message to

sendChatMessageSingle

protected void sendChatMessageSingle(java.lang.String msg,
                                     OID oid)
Sends the specified chat message to the specified player

Parameters:
msg: - the chat message to send
oid: - the oid of the player to send the message to

setPlayerProperty

public void setPlayerProperty(OID oid,
                              java.lang.String prop,
                              java.io.Serializable value)
Sends a property message with the given properties for the player. This allows everyone in the arena to receive the property while not storing it permanently.

Parameters:
oid -
props -

logArenaResult

protected void logArenaResult(int winningTeam)

getArenaID

public int getArenaID()

setArenaID

public void setArenaID(int arenaID)

getArenaInstanceOid

public OID getArenaInstanceOid()

setArenaInstanceOid

public void setArenaInstanceOid(OID instanceOid)

getArenaType

public int getArenaType()

setArenaType

public void setArenaType(int arenaGameType)

getArenaCategory

public int getArenaCategory()

setArenaCategory

public void setArenaCategory(int category)

getLength

public int getLength()

setLength

public void setLength(int length)

getInstanceTemplateID

public int getInstanceTemplateID()

setInstanceTemplateID

public void setInstanceTemplateID(int instanceTemplateID)

getState

public int getState()

setState

public void setState(int state)

getTeams

public ArenaTeam[] getTeams()

setTeams

public void setTeams(ArenaTeam[] teams)

getTeam

public ArenaTeam getTeam(int team)


Copyright © 2018 Dragonsan Studios Sp. z o.o.