... | ... | @@ -3,7 +3,8 @@ |
|
|
Here is the description of the Ability/Effect module of the game, to allow everyone to create new abilities for the game.
|
|
|
|
|
|
**Typographical convention**: As the same word can have different meanings, I'll try to use some convention to distinguish these meanings. For example, "Ability" means the Ability class of the java code (or maybe an instance of this class) while "ability" is the ability as seen from the game design point of view (the word in the common language and not in the programming meaning).
|
|
|
## 1) Overview
|
|
|
## I) Overview
|
|
|
### 1) How things work (roughly)
|
|
|
Each character has abilities. This is represented by each Character having a List of instances of Ability.
|
|
|
These instances are "owned" by the Character, and not shared with other Characters.
|
|
|
But the code of the class Ability only contains the cast/cooldown mechanism and, it does not contain the actual "effects" of the ability. This is where the Effect class comes in.
|
... | ... | @@ -13,9 +14,11 @@ By design, and due to the fact that anonymous lambda functions are not serialisa |
|
|
Several enums are used as keys in the factory patterns implemented in the Ability/Effect modules, here is a list of them, and the concepts they are bound to:
|
|
|
* AbilityKey: represent an ability (from game design perspective). They are bound to Supplier<Ability> (the type of functions that can generate instances of Ability by calling their "get" method) in the AbilityFactory.
|
|
|
* EffectKey: bound to EffectGenerators (see below) in EffectFactory.
|
|
|
|
|
|
## 2) Effects
|
|
|
### a) Definition
|
|
|
## 2) The plan of this page
|
|
|
**TO BE COMPLETED**
|
|
|
## II) Definition of the concepts
|
|
|
### 1) Effects
|
|
|
#### a) Definition
|
|
|
Here is the main method of an Effect, which defines a modification of the gameContent:
|
|
|
```
|
|
|
/**
|
... | ... | @@ -27,7 +30,7 @@ Here is the main method of an Effect, which defines a modification of the gameCo |
|
|
abstract public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID);
|
|
|
```
|
|
|
For example a damage effect will query the gameContent for for the Characters that have the ID stored in targetCharacterIDList and remove let's say 5 HP to each of them.
|
|
|
### b) How to design new Effects
|
|
|
#### b) How Effects can be defined/created
|
|
|
Effects are built using the methods from EffectBuilder and composing them. There are "base case" methods, that just produce an Effect that does something to the gameContent, and there are "induction" methods, that takes an existing Effect, plug something before it and create a new Effect whose effect method does this. To illustrate this, here is an extract of the documentation of the "randomTest" method:
|
|
|
```
|
|
|
* Take an instance of Effect and return another instance of Effect that, for each Character it receives as input,
|
... | ... | @@ -36,7 +39,7 @@ Effects are built using the methods from EffectBuilder and composing them. There |
|
|
```
|
|
|
So
|
|
|
|
|
|
## 3) EffectDescriptors
|
|
|
### 2) EffectDescriptors
|
|
|
Here is the doc on them:
|
|
|
```
|
|
|
* Contains an EffectKey and an array of int. The EffectKey defines an Effect (basic or composed), and the array of int
|
... | ... | @@ -44,19 +47,28 @@ Here is the doc on them: |
|
|
```
|
|
|
Each EffectDescriptor
|
|
|
|
|
|
## 4) EffectGenerators
|
|
|
### 3) EffectGenerators
|
|
|
Here is the doc on them:
|
|
|
```
|
|
|
* The type of functions able to generate instances of Effect out of the ID of the character that cast the ability triggering this effect,
|
|
|
* and a given number (this number depends on the actual EffectGenerator instance) of int values, provided in an array.
|
|
|
```
|
|
|
## 5) Abilities
|
|
|
|
|
|
### 4) Abilities
|
|
|
The Ability class essentially contains:
|
|
|
* The cast/cooldown mechanism
|
|
|
* A key (a member of the AbilityIconKeys enum) to define which icon should be displayed on the player's screen to represent the ability
|
|
|
* A member of the Action enum (used to animate the character when she casts the ability)
|
|
|
* A list of instances of EffectDescriptor
|
|
|
|
|
|
## 2) How to add an ability to the game
|
|
|
## III) These concepts in action
|
|
|
So, here is what happens under the hood where the player presses the 'A' keys on his keyboard.
|
|
|
The "Followed Character" (and by extension the "Followed Relayer") corresponds to the Character the player is playing.
|
|
|
**Client**
|
|
|
* Client: Player presses key 'A'
|
|
|
* Client: The signal goes through the gui modules, which calls the "tryToCastAbility(0)" method of the followed Relayer. The '0' is the number (in the list of Abilities of the followed Character) of the ability being potentially cast. The '0' corresponds to the first weapon ability (which is mapped to 'A' by default).
|
|
|
* Through processes I won't describe here, the followed Relayer sends a new AbilityEvent(CasterCharacterID, 0) to the server (note that there wasn't a cooldown check, this will be done on the server)
|
|
|
**Server**
|
|
|
* Server: Execute the received AbilityEvent: Gets the local instance of Ability corresponding to the ability cast by the followed Character and call its "cast" method.
|
|
|
|
|
|
`AbilityKey` is an enum whose members correspond to particular abilities. |
|
|
\ No newline at end of file |
|
|
## IV) How to design new abilities |
|
|
\ No newline at end of file |