java.lang.Object
java.util.EventObject
be.belegkarnil.game.board.spectrangle.event.TurnEvent
All Implemented Interfaces:
Serializable

public class TurnEvent extends EventObject
This event is used to notify interested parties that the turn state is changed during a Game.
Author:
Belegkarnil
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Action
    is the chosen {#link Action}, what the current Player's strategy plays
    final Player
    is the first {link @Player} when the turn will start, the event is related to this player
    final Game
    is the {link @Game} related to this event (i.e.
    static final Action
    is the static constant that represents there are no action (null)
    final Player
    is the second/other/opponent {link @Player} when turn round will start
    final int
    is the identifier (counter) of the related round.
    final int
    is the identifier (counter) of the related turn.

    Fields inherited from class java.util.EventObject

    source
  • Constructor Summary

    Constructors
    Constructor
    Description
    TurnEvent(Game game, Player current, Player opponent, int round, int turn)
    Constructor that does not define a winner (GameEvent.NO_WINNER), designed for begin events.
    TurnEvent(Game game, Player current, Player opponent, int round, int turn, Action action)
    Constructor requires an action (NO_ACTION), designed for end events.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Know if the current action represents piece to play on the board (i.e.
    boolean
    Know if the current action represents a replace/swap action
    boolean
    Know if the current action represents a skip action

    Methods inherited from class java.util.EventObject

    getSource, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • NO_ACTION

      public static final Action NO_ACTION
      is the static constant that represents there are no action (null)
    • current

      public final Player current
      is the first {link @Player} when the turn will start, the event is related to this player
    • opponent

      public final Player opponent
      is the second/other/opponent {link @Player} when turn round will start
    • round

      public final int round
      is the identifier (counter) of the related round.
    • turn

      public final int turn
      is the identifier (counter) of the related turn.
    • action

      public final Action action
      is the chosen {#link Action}, what the current Player's strategy plays
    • game

      public final Game game
      is the {link @Game} related to this event (i.e. the Game that generates the event)
  • Constructor Details

    • TurnEvent

      public TurnEvent(Game game, Player current, Player opponent, int round, int turn)
      Constructor that does not define a winner (GameEvent.NO_WINNER), designed for begin events.
      Parameters:
      game - the game related to the event, it's the source of the event
      current - is the current player related to this event
      opponent - is the second/other/opponent player
      round - is the round identifier related to the event
      turn - is the turn identifier related to the event
      Throws:
      IllegalArgumentException - if source is null
    • TurnEvent

      public TurnEvent(Game game, Player current, Player opponent, int round, int turn, Action action)
      Constructor requires an action (NO_ACTION), designed for end events.
      Parameters:
      game - the game related to the event, it's the source of the event
      current - is the current player related to this event
      opponent - is the second/other/opponent player
      round - is the round identifier related to the event
      turn - is the turn identifier related to the event
      action - is the action taken by the current player or NO_ACTION
      Throws:
      IllegalArgumentException - if source is null
  • Method Details

    • isSkipAction

      public boolean isSkipAction()
      Know if the current action represents a skip action
      Returns:
      if the current event represents a skip action (excluding a replace/swap action)
    • isReplaceAction

      public boolean isReplaceAction()
      Know if the current action represents a replace/swap action
      Returns:
      if the current event represents a replace/swap action
    • isPiecePlayed

      public boolean isPiecePlayed()
      Know if the current action represents piece to play on the board (i.e. not a skip, nor a swap/replace action)
      Returns:
      if the current event represents an action with a piece (not null)