Class: PFM::Shop

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

Overview

Class describing the shop logic

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(game_state = PFM.game_state) ⇒ Shop

Create a new shop handler

Parameters:

  • game_state (PFM::GameState) (defaults to: PFM.game_state)

    variable responsive of containing the whole game state for easier access



15
16
# File 'docs/4_Systems_203_Shop.rb', line 15

def initialize(game_state = PFM.game_state)
end

Instance Attribute Details

#game_statePFM::GameState

Get the game state responsive of the whole game state

Returns:



12
13
14
# File 'docs/4_Systems_203_Shop.rb', line 12

def game_state
  @game_state
end

#pokemon_shop_listHash{Symbol => Array}

Hash containing the defined Pokemon shops

Returns:

  • (Hash{Symbol => Array})


9
10
11
# File 'docs/4_Systems_203_Shop.rb', line 9

def pokemon_shop_list
  @pokemon_shop_list
end

#shop_listHash{Symbol => Hash{Symbol => Integer}}

Hash containing the defined shops

Returns:

  • (Hash{Symbol => Hash{Symbol => Integer}})


6
7
8
# File 'docs/4_Systems_203_Shop.rb', line 6

def shop_list
  @shop_list
end

Instance Method Details

#create_new_limited_shop(symbol_of_shop, items_sym = [], items_quantity = [], shop_rewrite: false)

Create a new limited Shop

Parameters:

  • symbol_of_shop (Symbol)

    the symbol to link to the new shop

  • items_sym (Array<Symbol, Integer>) (defaults to: [])

    the array containing the symbols/id of the items to sell

  • items_quantity (Array<Integer>) (defaults to: [])

    the array containing the quantity of the items to sell

  • shop_rewrite (Boolean) (defaults to: false)

    if the system must completely overwrite an already existing shop



22
23
# File 'docs/4_Systems_203_Shop.rb', line 22

def create_new_limited_shop(symbol_of_shop, items_sym = [], items_quantity = [], shop_rewrite: false)
end

#create_new_pokemon_shop(sym_new_shop, list_id, list_price, list_param, list_quantity = [], shop_rewrite: false)

Create a new Pokemon Shop

Parameters:

  • sym_new_shop (Symbol)

    the symbol to link to the new shop

  • list_id (Array<Integer>)

    the array containing the id of the Pokemon to sell

  • list_price (Array<Integer>)

    the array containing the prices of the Pokemon to sell

  • list_param (Array)

    the array containing the infos of the Pokemon to sell

  • list_quantity (Array<Integer>) (defaults to: [])

    the array containing the quantity of the Pokemon to sell

  • shop_rewrite (Boolean) (defaults to: false)

    if the system must completely overwrite an already existing shop



43
44
# File 'docs/4_Systems_203_Shop.rb', line 43

def create_new_pokemon_shop(sym_new_shop, list_id, list_price, list_param, list_quantity = [], shop_rewrite: false)
end

#migrate_ids_to_symbols

Ensure every ids stocked for every available shop is converted to a db_symbol



75
76
# File 'docs/4_Systems_203_Shop.rb', line 75

def migrate_ids_to_symbols
end

#refill_limited_shop(symbol_of_shop, items_to_refill = [], quantities_to_refill = [])

Refill an already existing shop with items (Create the shop if it does not exist)

Parameters:

  • symbol_of_shop (Symbol)

    the symbol of the existing shop

  • items_to_refill (Array<Symbol, Integer>) (defaults to: [])

    the array of the items’ db_symbol/id

  • quantities_to_refill (Array<Integer>) (defaults to: [])

    the array of the quantity to refill



28
29
# File 'docs/4_Systems_203_Shop.rb', line 28

def refill_limited_shop(symbol_of_shop, items_to_refill = [], quantities_to_refill = [])
end

#refill_pokemon_shop(symbol_of_shop, list_id, list_price = [], list_param = [], list_quantity = [], pkm_rewrite: false)

Refill an already existing Pokemon Shop (create it if it does not exist)

Parameters:

  • symbol_of_shop (Symbol)

    the symbol of the shop

  • list_id (Array<Integer>)

    the array containing the id of the Pokemon to sell

  • list_price (Array<Integer>) (defaults to: [])

    the array containing the prices of the Pokemon to sell

  • list_param (Array) (defaults to: [])

    the array containing the infos of the Pokemon to sell

  • list_quantity (Array<Integer>) (defaults to: [])

    the array containing the quantity of the Pokemon to sell

  • pkm_rewrite (Boolean) (defaults to: false)

    if the system must completely overwrite the existing Pokemon



52
53
# File 'docs/4_Systems_203_Shop.rb', line 52

def refill_pokemon_shop(symbol_of_shop, list_id, list_price = [], list_param = [], list_quantity = [], pkm_rewrite: false)
end

#register_new_pokemon_in_shop(sym_shop, id, price, param, quantity, rewrite: false)

Register the Pokemon into the Array under certain conditions

Parameters:

  • sym_shop (Symbol)

    the symbol of the shop

  • id (Integer)

    the ID of the Pokemon to register

  • price (Integer)

    the price of the Pokemon

  • param (Hash)

    the hash of the Pokemon (might be a single Integer)

  • quantity (Integer)

    the quantity of the Pokemon to register

  • rewrite (Boolean) (defaults to: false)

    if an existing Pokemon should be rewritten or not



68
69
# File 'docs/4_Systems_203_Shop.rb', line 68

def register_new_pokemon_in_shop(sym_shop, id, price, param, quantity, rewrite: false)
end

#remove_from_limited_shop(symbol_of_shop, items_to_remove, quantities_to_remove)

Remove items from an already existing shop (return if do not exist)

Parameters:

  • symbol_of_shop (Symbol)

    the symbol of the existing shop

  • items_to_remove (Array<Symbol, Integer>)

    the array of the items’ db_symbol/id

  • quantities_to_remove (Array<Integer>)

    the array of the quantity to remove



34
35
# File 'docs/4_Systems_203_Shop.rb', line 34

def remove_from_limited_shop(symbol_of_shop, items_to_remove, quantities_to_remove)
end

#remove_from_pokemon_shop(symbol_of_shop, remove_list_mon, param_form = [], quantities_to_remove = [])

Remove Pokemon from an already existing shop (return if do not exist)

Parameters:

  • symbol_of_shop (Symbol)

    the symbol of the existing shop

  • remove_list_mon (Array<Integer>)

    the array of the Pokemon id

  • param_form (Array<Hash>) (defaults to: [])

    the form of the Pokemon to delete (only if there is more than one form of a Pokemon in the list)

  • quantities_to_remove (Array<Integer>) (defaults to: [])

    the array of the quantity to remove



59
60
# File 'docs/4_Systems_203_Shop.rb', line 59

def remove_from_pokemon_shop(symbol_of_shop, remove_list_mon, param_form = [], quantities_to_remove = [])
end

#sort_pokemon_shop(symbol_of_shop)

Sort the Pokemon Shop list

Parameters:

  • symbol_of_shop (Symbol)

    the symbol of the shop to sort



72
73
# File 'docs/4_Systems_203_Shop.rb', line 72

def sort_pokemon_shop(symbol_of_shop)
end