Methods
broadcastMessage(type, data, debugMessage)
Broadcasts a message to a all websocket clients.
Parameters:
| Name | Type | Description |
|---|---|---|
type |
messageTypeEnum | The type of the message. |
data |
Object | The data to send. |
debugMessage |
String | The debug message to send. |
damageCharacter(character, damage, poison)
Adds damage to a character in respect to their properties. (Decreases hp)
Parameters:
| Name | Type | Description |
|---|---|---|
character |
Character | The character to damage. |
damage |
Integer | The amaount of damage. |
poison |
Boolean | If cause of damage is a poisoned cocktail. |
doOperation(player, operation) → {Boolean}
Perfoms actions which a character can do with certain properties.
Parameters:
| Name | Type | Description |
|---|---|---|
player |
Player | The player. |
operation |
Operation | The operation. |
Returns:
If operation was valid.
- Type
- Boolean
endGame()
Ends the game.
getChance(character, chance) → {Boolean}
Returns true or false for a character with a specific chance in respect to their properties.
Parameters:
| Name | Type | Description |
|---|---|---|
character |
Character | The character. |
chance |
Double | The chance. |
Returns:
Random boolean.
- Type
- Boolean
getCharacterByPosition(coordinates) → {Character}
Returns a character (if on field) by position.
Parameters:
| Name | Type | Description |
|---|---|---|
coordinates |
Point | The position. |
Returns:
The character. (null if no character on that position)
- Type
- Character
getDistance(pos1, pos2) → {Integer}
Returns the distance of to points.
Parameters:
| Name | Type | Description |
|---|---|---|
pos1 |
Point | The first point. |
pos2 |
Point | The second point. |
Returns:
The distance of those two points.
- Type
- Integer
getGadget(character, gadget) → {Gadget}
Returns specific gadget of a character.
Parameters:
| Name | Type | Description |
|---|---|---|
character |
Character | The character. |
gadget |
gadgetEnum | The gadget type. |
Returns:
The gadget if. (Can be null if not found).
- Type
- Gadget
getGameState(ws) → {Object}
Returns the current game state in respect to a specific client.
Parameters:
| Name | Type | Description |
|---|---|---|
ws |
Websocket | The websocket client. |
Returns:
The game state.
- Type
- Object
getNearestCharacter(coordinates, maxDist) → {Character}
Returns the nearest character to a specific point.
Parameters:
| Name | Type | Description |
|---|---|---|
coordinates |
Point | The point. |
maxDist |
Integer | The maximum distance. |
Returns:
The nearest character.
- Type
- Character
getNeighbors(coordinates, rangeopt) → {Array.<Point>}
Returns all neighbors for a specific point.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
coordinates |
Point | The position. | ||
range |
Integer |
<optional> |
1 | The range of neighborhood. |
Returns:
Array of neighbors.
- Type
- Array.<Point>
getRandomCharacter() → {Character}
Returns a random character on the map.
Returns:
Random character.
- Type
- Character
getRandomFreeNeighbor(coordinates, rangeopt) → {Point}
Returns a random free neighbor for a specific point.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
coordinates |
Point | The position. | ||
range |
Integer |
<optional> |
1 | The range of neighborhood. |
Returns:
Random free neighbor.
- Type
- Point
getRandomNeighborCharacter(coordinates, rangeopt, sightopt) → {Character}
Returns a random neighbor character for a specific point.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
coordinates |
Point | The position. | ||
range |
Integer |
<optional> |
1 | The range of neighborhood. |
sight |
Boolean |
<optional> |
false | If character has to be in sight (important for range > 1). |
Returns:
Random neighbor character.
- Type
- Character
giveCharIP(character, ip)
Adds intelligence points to a character.
Parameters:
| Name | Type | Description |
|---|---|---|
character |
Character | The character to damage. |
ip |
Integer | The amaount of intelligence points. |
isCoordinatesValid(coordinates) → {Boolean}
If point is on the map.
Parameters:
| Name | Type | Description |
|---|---|---|
coordinates |
Point | The coordinates. |
Returns:
If is on map.
- Type
- Boolean
isInSight(position, target, chars) → {Boolean}
Return if two points are in sight.
Parameters:
| Name | Type | Description |
|---|---|---|
position |
Point | The position. |
target |
Point | The target position. |
chars |
Boolean | If character block the sight. |
Returns:
If in sight.
- Type
- Boolean
isNeighbor(position, target, rangeopt) → {Boolean}
Returns if one point is a neighbor of the other.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
position |
Point | The position. | ||
target |
Point | The target position. | ||
range |
Integer |
<optional> |
1 | The range of neighborhood. |
Returns:
If they are neighbors.
- Type
- Boolean
nextTurn()
Starts the next turn or next round if all characters had their turn.
pauseGame()
Pauses the game.
prepareTurn(characterId)
Prepares a characters turn and sets their mps and aps in respect to their properties.
Parameters:
| Name | Type | Description |
|---|---|---|
characterId |
String | The id of the character. |
removeGadget(character, type)
Removes a specific gadget from a character.
Parameters:
| Name | Type | Description |
|---|---|---|
character |
Character | The character to damage. |
type |
gadgetEnum | The gadget type. |
removeProperty(character, type)
Removes a specific property from a character.
Parameters:
| Name | Type | Description |
|---|---|---|
character |
Character | The character to damage. |
type |
propertyEnum | The property type. |
resumeGame()
Resumes the game.
sendGameStatusMessage()
Broadcasts the current game state.
sendMessage(ws, type, data, debugMessage)
Sends a message to a websocket client.
Parameters:
| Name | Type | Description |
|---|---|---|
ws |
Websocket | The receiving websocket client. |
type |
messageTypeEnum | The type of the message. |
data |
Object | The data to send. |
debugMessage |
String | The debug message to send. |
setCharacterOrder()
Sets the order of all characters.
setGameCharacters(player, freeFields)
Initiates the characters of a player.
Parameters:
| Name | Type | Description |
|---|---|---|
player |
Player | The player. |
freeFields |
Array.<Field> | The remaining free fields on the map. |
startGame()
Sarts the game.
startRound()
Starts a new round
startTurn(characterId)
Starts a new turn for a specific character.
Parameters:
| Name | Type | Description |
|---|---|---|
characterId |
String | The id of the character. |