import GraphicalViewSharedData from 'roguelike/app/controllers/GraphicalViewSharedData.js'
GraphicalViewSharedData
Extends:
An object for decoupling the Dungeon from views and controllers Holds the current Dungeon and acts as a proxy for the Dungeon's events. Observers are notified whenever the Dungeon fires an event or when the Dungeon itself switches. Additionally, this class stores information that needs to be shared between multiple views and controllers, such as the currently hovered tile
TODO:
- Consider renaming this to `UiSharedData` or similar
Constructor Summary
Public Constructor | ||
public |
constructor(dungeon: Dungeon) |
Member Summary
Public Members | ||
public |
[arrayName]: * |
Method Summary
Public Methods | ||
public |
cycleTarget(dx: *, dy: *) Cycles focus to the next ability, attack, or item target depending on what the user has selected |
|
public |
dispatchUIEvent(event: *) Dispatches an event to observers |
|
public |
Gets the currently focused legal ability target for the currently selected targetted ability, if any |
|
public |
Gets the currently focused legal attack target for the currently selected weapon, if any |
|
public |
Gets the currently held Dungeon |
|
public |
Gets the tile set by setInspectedTile |
|
public |
Gets the currently focused legal item target for the currently selected targetted item, if any |
|
public |
Gets the index of the selected targetted ability, if any |
|
public |
Gets the index of the selected targetted item, if any |
|
public |
Puts this controller in attack mode so that keyboard users can select a target for an attack |
|
public |
setDungeon(dungeon: Dungeon) Changes the contained dungeon. |
|
public |
setInspectedTile(x: number, y: number) Stores the coordinates of a tile that the user has selected. |
|
public |
setTargettedAbility(index: number) Stores a reference to a targetted ability that the user has considered using. |
|
public |
setTargettedItem(index: number) Stores a reference to a targetted item that the user has considered using. |
|
public |
Returns this controller to the default mode (movement mode) |
|
public |
Forgets which targetted ability the user was considering using |
|
public |
Forgets which targetted item the user was considering using |
Inherited Summary
From class Observable | ||
public |
addObserver(observer: *) |
|
public |
removeObserver(observer: *) |
Public Constructors
public constructor(dungeon: Dungeon) source
Override:
Observable#constructorParams:
Name | Type | Attribute | Description |
dungeon | Dungeon |
|
The initial dungeon for the views to show |
Public Members
public [arrayName]: * source
Public Methods
public cycleTarget(dx: *, dy: *) source
Cycles focus to the next ability, attack, or item target depending on what the user has selected
Params:
Name | Type | Attribute | Description |
dx | * | ||
dy | * |
public dispatchUIEvent(event: *) source
Dispatches an event to observers
Params:
Name | Type | Attribute | Description |
event | * |
public getAbilityTarget(): Tile source
Gets the currently focused legal ability target for the currently selected targetted ability, if any
Return:
Tile | A tile that is a legal target for the targetted ability, or null if no ability is selected |
public getAttackTarget(): Tile source
Gets the currently focused legal attack target for the currently selected weapon, if any
Return:
Tile | A tile that is a legal target for the targetted weapon, or null if no weapon is selected |
public getItemTarget(): Tile source
Gets the currently focused legal item target for the currently selected targetted item, if any
public getTargettedAbility(): number source
Gets the index of the selected targetted ability, if any
Return:
number | The index of the targetted ability the user is
considering, or |
public getTargettedItem(): number source
Gets the index of the selected targetted item, if any
Return:
number | The index of the targetted item the user is
considering, or |
public setAttackMode() source
Puts this controller in attack mode so that keyboard users can select a target for an attack
public setDungeon(dungeon: Dungeon) source
Changes the contained dungeon. Will notify observers of the change
Params:
Name | Type | Attribute | Description |
dungeon | Dungeon | The dungeon to replace the current dungeon |
public setInspectedTile(x: number, y: number) source
Stores the coordinates of a tile that the user has selected. Useful for changing views based on which tile the user is examining/hovering/ect
public setTargettedAbility(index: number) source
Stores a reference to a targetted ability that the user has considered using. This enables views to reference the selected move while the user considers targets.
Params:
Name | Type | Attribute | Description |
index | number | The position of the chosen ability within the player's ability list |
public setTargettedItem(index: number) source
Stores a reference to a targetted item that the user has considered using. This enables views to reference the selected item while the user considers targets.
Params:
Name | Type | Attribute | Description |
index | number | The position of the chosen item within the player's inventory slots. |
public unsetTargettedAbility() source
Forgets which targetted ability the user was considering using