Class: PFM::MiningGame::GridHandler

Inherits:
Object
  • Object
show all
Defined in:
docs/4_Systems_801_Mining_Game.rb

Overview

Class handling the grid for the mining game

Constant Summary collapse

MIN_ITEM_COUNT =

Constant telling the minimum amount of item possible on a grid

2
MAX_ITEM_COUNT =

Constant telling the maximum amount of item possible on a grid

5
SWITCH_METHOD_TRIES =

Constant telling at how many unsuccessful tries the system switched from full randomness to semi-randomness A lower number means the system will switch to a more mechanical way earlier Might yield unexpected result, !!! Change with caution !!!

Returns:

  • (Integer)
25
MAX_TRIES_ALLOWED =

Constant telling the max number of tries the system has to randomly place an item or an iron A higher number means a better probability of success but also means a higher loading time !!! Change with caution !!!

Returns:

  • (Integer)
50

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wanted_items, item_count, grid_width, grid_height) ⇒ GridHandler

Create a new grid handler

Parameters:

  • wanted_items (Array<Symbol>, nil)

    list of wanted items

  • item_count (Integer, nil)

    maximum number of items

  • grid_width (Integer)

    width of the grid

  • grid_height (Integer)

    height of the grid



177
178
# File 'docs/4_Systems_801_Mining_Game.rb', line 177

def initialize(wanted_items, item_count, grid_width, grid_height)
end

Instance Attribute Details

#arr_ironsArray<Diggable> (readonly)

Get the list of irons

Returns:



171
172
173
# File 'docs/4_Systems_801_Mining_Game.rb', line 171

def arr_irons
  @arr_irons
end

#arr_itemsArray<Diggable> (readonly)

Get the list of diggable items

Returns:



168
169
170
# File 'docs/4_Systems_801_Mining_Game.rb', line 168

def arr_items
  @arr_items
end

#arr_tiles_stateArray<Array<Integer>> (readonly)

Get the tile states

Returns:

  • (Array<Array<Integer>>)


165
166
167
# File 'docs/4_Systems_801_Mining_Game.rb', line 165

def arr_tiles_state
  @arr_tiles_state
end

#heightInteger (readonly)

Get the grid height

Returns:

  • (Integer)


162
163
164
# File 'docs/4_Systems_801_Mining_Game.rb', line 162

def height
  @height
end

#widthInteger (readonly)

Get the grid width

Returns:

  • (Integer)


159
160
161
# File 'docs/4_Systems_801_Mining_Game.rb', line 159

def width
  @width
end

Instance Method Details

#check_presence_of_diggable(x, y) ⇒ Diggable, Boolean

Check if a diggable is present at the said coordinate and return it if it’s an item

Parameters:

  • x (Integer)

    x coordinate where we went to find the diggable

  • y (Integer)

    y coordinate where we went to find the diggable

Returns:

  • (Diggable, Boolean)

    Diggable instance if item, true if iron, false if nothing



187
188
# File 'docs/4_Systems_801_Mining_Game.rb', line 187

def check_presence_of_diggable(x, y)
end

#ready?Boolean

Tell if the mining game grid is ready

Returns:

  • (Boolean)


181
182
# File 'docs/4_Systems_801_Mining_Game.rb', line 181

def ready?
end