Controller
The controller contains business logic. It holds a status which is updated through its methods executed by the observers. Upon a state update, all observers are notified. Observers can then read the status and reflect the changes. Methods which change
Attributes
- Graph
-
- Supertypes
- Known subtypes
-
class BaseController
Members list
Value members
Abstract methods
Should be called when an attacking player attacks with the specified card. It is not checked whether Controller.canAttack returns true. The exact update depends on the implementation, normally base.command.AttackCommand. The method assumes to be called in a valid context and will update all observers
Should be called when an attacking player attacks with the specified card. It is not checked whether Controller.canAttack returns true. The exact update depends on the implementation, normally base.command.AttackCommand. The method assumes to be called in a valid context and will update all observers
Value parameters
- card
-
The card to attack with.
Attributes
Returns the player who has the specified turn.
Returns the player who has the specified turn.
Attributes
- Returns
-
the player who has the specified turn. If multiple players have the same turn, the first one is returned.
Checks whether a card can be used to attack with.
Checks whether a card can be used to attack with.
Value parameters
- card
-
the card to attack with
Attributes
- Returns
-
true when either Status.used, Status.undefended or Status.defended contain the specified card. Otherwise, false.
Checks whether a card can be used to defend another.
Checks whether a card can be used to defend another.
Value parameters
- undefended
-
the undefended card to defend
- used
-
the card of the defending player
Attributes
- Returns
-
true when Card.beats, called on used with undefended as the argument, returns true or when used is a trump card and undefended is not. Otherwise, false.
Returns the player who has the current turn.
Returns the player who has the current turn.
Attributes
- Returns
-
the player who has the current turn. The current turn is determined by model.status.Status.turn.
Should be called when a defending player attacks an undefended card with one of their own. It is not checked whether controller.Controller.canDefend returns true. The exact update depends on the implementation, normally controller.base.command.DefendCommand. The method assumes to be called in a valid context and will update all observers
Should be called when a defending player attacks an undefended card with one of their own. It is not checked whether controller.Controller.canDefend returns true. The exact update depends on the implementation, normally controller.base.command.DefendCommand. The method assumes to be called in a valid context and will update all observers
Value parameters
- undefended
-
The undefended card to defend
- used
-
The card of the defending player
Attributes
Should be called when an attacking player denies their attack. The exact update depends on the implementation, normally base.command.DenyCommand. The method assumes to be called in a valid context and will update all observers
Should be called when an attacking player denies their attack. The exact update depends on the implementation, normally base.command.DenyCommand. The method assumes to be called in a valid context and will update all observers
Attributes
Initializes the status with the specified card amount and player names. The first attacking player is chosen randomly. The exact update depends on the implementation, normally base.command.InitializeCommand. The method assumes to be called in a valid context and will update all observers
Initializes the status with the specified card amount and player names. The first attacking player is chosen randomly. The exact update depends on the implementation, normally base.command.InitializeCommand. The method assumes to be called in a valid context and will update all observers
Value parameters
- amount
-
the card amount
- names
-
the player names
Attributes
Initializes the status with the specified card amount, player names and first attacking player. The exact update depends on the implementation, normally base.command.InitializeCommand. The method assumes to be called in a valid context and will update all observers
Initializes the status with the specified card amount, player names and first attacking player. The exact update depends on the implementation, normally base.command.InitializeCommand. The method assumes to be called in a valid context and will update all observers
Value parameters
- amount
-
the card amount
- attacking
-
the first attacking player
- names
-
the player names
Attributes
Returns whether the game is over.
Returns whether the game is over.
Attributes
- Returns
-
true when there is only one player whose turn is not model.Turn.Finished. Otherwise, false.
Loads the status from I/O, normally calling model.io.FileIo.load and thus might block. All exceptions will be caught. The method assumes to be called in a valid context and will update all observers
Loads the status from I/O, normally calling model.io.FileIo.load and thus might block. All exceptions will be caught. The method assumes to be called in a valid context and will update all observers
Attributes
Should be called when a defending player picks cards up, thus failing to defend. The exact update depends on the implementation, normally base.command.DefendCommand. The method assumes to be called in a valid context and will update all observers
Should be called when a defending player picks cards up, thus failing to defend. The exact update depends on the implementation, normally base.command.DefendCommand. The method assumes to be called in a valid context and will update all observers
Attributes
Redoes the last undone command. The method assumes to be called in a valid context and will update all observers
Redoes the last undone command. The method assumes to be called in a valid context and will update all observers
Attributes
Saves the status to I/O, normally calling model.io.FileIo.save and thus might block. All exceptions will be caught. The method assumes to be called in a valid context and will update all observers
Saves the status to I/O, normally calling model.io.FileIo.save and thus might block. All exceptions will be caught. The method assumes to be called in a valid context and will update all observers
Attributes
Unbinds any I/O, normally calling model.io.FileIo.unbind.
Undoes the last command. The method assumes to be called in a valid context and will update all observers
Undoes the last command. The method assumes to be called in a valid context and will update all observers
Attributes
Inherited methods
Adds an observer.
Adds an observer.
Value parameters
- observer
-
the observer to add
Attributes
- Inherited from:
- Observable
Notifies all added observers.
Removes an observer.
Removes an observer.
Value parameters
- observer
-
the observer to remove
Attributes
- Inherited from:
- Observable