Class: RSokoban::UI::BaseUI Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/rsokoban/ui/base_ui.rb

Overview

This class is abstract.

Subclass and override #get_action to implement a working UI.

Every concrete UI should inherits from me.

Direct Known Subclasses

Console, CursesConsole

Instance Method Summary collapse

Constructor Details

#initializeBaseUI

Returns a new instance of BaseUI.



7
8
9
# File 'lib/rsokoban/ui/base_ui.rb', line 7

def initialize
	@level_title = ''
end

Instance Method Details

#get_action(hash) ⇒ PlayerAction

TODO:

write some examples

Based on things found in the hash argument, I display the game to the user. Then he can tell what he wants to do. Whatever my childs permit the user to do, they can only return an ActionPlayer object.

Parameters:

  • hash (Hash)

    the options passed to the UI.

Options Hash (hash):

  • :type (:win|:start|:display|:end_of_set)

    The type of the message (always requiered)

  • :map (Map)

    The current map of the game (always requiered)

  • :title (String)

    The level’s title (requiered if type==:start)

  • :set (String)

    The set’s title (requiered if type==:start)

  • :number (Fixnum)

    The level’s number (requiered if type==:start)

  • :total (Fixnum)

    Number of level in this set (requiered if type==:start)

  • :move (Fixnum)

    The move’s number (requiered when type is :display or :win)

  • :error (String)

    An error message. Could happen when type is :display or :start

  • :record (Fixnum)

    The record for this level

Returns:

Since:

  • 0.73



29
30
31
# File 'lib/rsokoban/ui/base_ui.rb', line 29

def get_action(hash)
	raise "Please implement me !"
end