Class: Action

Inherits:
Object
  • Object
show all
Defined in:
lib/software_challenge_client/action.rb

Overview

An action is a part of a move. A move can have multiple actions. The specific actions are inherited from this Action class which should be considered abstract/interface.

Direct Known Subclasses

Acceleration, Advance, Push, Turn

Instance Method Summary collapse

Instance Method Details

#==(_other) ⇒ Object



12
13
14
# File 'lib/software_challenge_client/action.rb', line 12

def ==(_other)
  raise 'must be overridden'
end

#invalid(message) ⇒ Object

Helper to make raising InvalidMoveExceptions easier. It is defined in the Action class instead of the Move class because performing individual actions normally trigger invalid moves, not the move itself.

Parameters:

  • message (String)

    Message why the move is invalid.

Returns:

  • Nothing. Raises an exception.

Raises:



26
27
28
# File 'lib/software_challenge_client/action.rb', line 26

def invalid(message)
  raise InvalidMoveException.new(message, self)
end

#perform!(_gamestate, _current_player) ⇒ Object



16
17
18
# File 'lib/software_challenge_client/action.rb', line 16

def perform!(_gamestate, _current_player)
  raise 'must be overridden'
end

#typeActionType

Returns Type of the action.

Returns:

  • (ActionType)

    Type of the action.



8
9
10
# File 'lib/software_challenge_client/action.rb', line 8

def type
  raise 'must be overridden'
end