Home Reference Source Repository
import GraphicalViewSharedData from 'roguelike/app/controllers/GraphicalViewSharedData.js'
public class | source

GraphicalViewSharedData

Extends:

Observable → GraphicalViewSharedData

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

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

Stores the coordinates of a tile that the user has selected.

public

Stores a reference to a targetted ability that the user has considered using.

public

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#constructor

Params:

NameTypeAttributeDescription
dungeon Dungeon
  • optional

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:

NameTypeAttributeDescription
dx *
dy *

public dispatchUIEvent(event: *) source

Dispatches an event to observers

Params:

NameTypeAttributeDescription
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 getDungeon(): Dungeon source

Gets the currently held Dungeon

Return:

Dungeon

public getInspectedTile(): object source

Gets the tile set by setInspectedTile

Return:

object

An object with x and y properties

public getItemTarget(): Tile source

Gets the currently focused legal item target for the currently selected targetted item, if any

Return:

Tile

A tile that is a legal target for the targetted item, or null if no item is selected

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 null if none has been selected

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 null if none has been selected

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:

NameTypeAttributeDescription
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

Params:

NameTypeAttributeDescription
x number

The x-coordinate of the tile

y number

The y-coordinate of the tile

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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
index number

The position of the chosen item within the player's inventory slots.

public unsetAttackMode() source

Returns this controller to the default mode (movement mode)

public unsetTargettedAbility() source

Forgets which targetted ability the user was considering using

public unsetTargettedItem() source

Forgets which targetted item the user was considering using