Class: GamePlay::Pokemon_Shop

Inherits:
Shop show all
Includes:
UI::Shop
Defined in:
scripts/01450 Systems/00203 Shop/00003 GamePlay/00200 Pokemon_Shop.rb,
scripts/01450 Systems/00203 Shop/00003 GamePlay/00240 Pokemon_Shop_Mouse.rb,
scripts/01450 Systems/00203 Shop/00003 GamePlay/00220 Pokemon_Shop_Inputs.rb,
scripts/01450 Systems/00203 Shop/00003 GamePlay/00230 Pokemon_Shop_Actions.rb,
scripts/01450 Systems/00203 Shop/00003 GamePlay/00210 Pokemon_Shop_Graphics.rb

Constant Summary collapse

MOUSE_OVER_ENABLED =

Tell if the mouse over is enabled

false

Constants inherited from BaseCleanUpdate

BaseCleanUpdate::AIU_KEY2METHOD

Constants inherited from Base

Base::DEFAULT_TRANSITION, Base::DEFAULT_TRANSITION_PARAMETER

Constants included from Input

Input::ALIAS_KEYS, Input::AXIS_MAPPING, Input::AXIS_SENSITIVITY, Input::DEAD_ZONE, Input::Keyboard, Input::Keys, Input::NON_TRIGGER_ZONE, Input::REPEAT_COOLDOWN, Input::REPEAT_SPACE

Constants included from DisplayMessage

DisplayMessage::MESSAGE_ERROR, DisplayMessage::MESSAGE_PROCESS_ERROR

Instance Attribute Summary

Attributes inherited from Base

#__last_scene, #__result_process, #running, #viewport

Attributes included from DisplayMessage

#message_window

Instance Method Summary collapse

Methods inherited from Shop

#create_arrow, #create_base_ui, #create_graphics, #create_money_window, #create_shop_banner, #update_arrow, #update_inputs, #update_money_text, #update_mouse, #update_nb_item, #update_scrollbar

Methods inherited from BaseCleanUpdate::FrameBalanced

#update

Methods included from Graphics::FPSBalancer::Marker

#frame_balanced?

Methods inherited from BaseCleanUpdate

#automatic_input_update, #update

Methods inherited from Base

#add_disposable, #call_scene, #dispose, #find_parent, #main, #return_to_scene, #snap_to_bitmap, #update, #visible, #visible=

Methods included from Input

dir4, dir8, get_text, joy_axis_position, press?, register_events, released?, repeat?, swap_states, trigger?

Methods included from DisplayMessage

#can_display_message_be_called?, #close_message_window, #display_message, #display_message_and_wait, #message_class, #message_processing?, #message_visible, #message_visible=

Constructor Details

#initialize(symbol_shop) ⇒ Pokemon_Shop #initialize(symbol_shop, prices) ⇒ Pokemon_Shop #initialize(list_id_pokemon, prices, parameters) ⇒ Pokemon_Shop

Create a new Pokemon Shop

Examples:

Opening an already defined shop with limited Pokemon

GamePlay::Pokemon_Shop.new(:pkm_shop_celadon) # Will open the Shop with symbol :pkm_shop_celadon (the shop must be already defined beforehand)

Opening an already defined shop with limited pokemon but with temporarily overwritten price

GamePlay::Pokemon_Shop.new(:pkm_shop_celadon, {17: 300, 25: 3000}) # Will open the Shop with symbol :pkm_shop_celadon while overwritting the price for pokemon with ID 17 or 25

Opening a simple pokemon shop

GamePlay::Pokemon_Shop.new([25, 52], [2500, 500], [50, { level: 15, form: 1 }]) # Will open a Shop selling Pikachu lvl 50 at 2500 P$ and Alolan Meowth lvl 15 at 500 P$

Overloads:

  • #initialize(symbol_shop) ⇒ Pokemon_Shop

    Parameters:

    • symbol_shop (Symbol)

      the symbol of the pokemon shop to open

  • #initialize(symbol_shop, prices) ⇒ Pokemon_Shop

    Parameters:

    • symbol_shop (Symbol)

      the symbol of the pokemon shop to open

    • prices (Hash)

      the hash containing the new price (value) of a pokemon id (key)

  • #initialize(list_id_pokemon, prices, parameters) ⇒ Pokemon_Shop

    Parameters:

    • list_id_pkm (Array)

      the array containing the id of the pokemon to sell

    • prices (Array)

      the array containing the price of each pokemon



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00200 Pokemon_Shop.rb', line 18

def initialize(symbol_or_list, prices = {}, parameters = [], show_background: true)
  super(false)
  validate_param(:initialize, :symbol_or_list, symbol_or_list => [Symbol, Array])
  validate_param(:initialize, :symbol_or_list, symbol_or_list => { Array => Integer }) if symbol_or_list.class == Array
  if symbol_or_list.is_a?(Symbol)
    validate_param(:initialize, :prices, prices => Hash)
  else
    validate_param(:initialize, :prices, prices => Array)
  end
  validate_param(:initialize, :params, parameters => Array) if symbol_or_list.class == Array
  @force_close = nil
  @shop = PFM.game_state.shop
  @show_background = :show_background
  @symbol_or_list = symbol_or_list
  @prices = prices
  @parameters = parameters
  @what_was_buyed = []
  load_item_list
  unless @force_close == true
    @index = @index.clamp(0, @last_index)
    @running = true
  end
end

Instance Method Details

#create_item_desc_window

Create the item description window



27
28
29
30
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00210 Pokemon_Shop_Graphics.rb', line 27

def create_item_desc_window
  @item_desc_window = PkmDesc.new(@viewport)
  update_item_desc
end

#create_item_list

Create the item list for the items to sell



15
16
17
18
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00210 Pokemon_Shop_Graphics.rb', line 15

def create_item_list
  @item_list = PkmList.new(@viewport)
  update_item_button_list
end

#create_scrollbar

Create the scrollbar



60
61
62
63
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00210 Pokemon_Shop_Graphics.rb', line 60

def create_scrollbar
  @scroll_bar = PkmScrollBar.new(@viewport)
  update_scrollbar
end

#update_graphics

Update the graphics every frame



6
7
8
9
10
11
12
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00210 Pokemon_Shop_Graphics.rb', line 6

def update_graphics
  unless @force_close
    @base_ui.update_background_animation if @show_background
    @animation&.call
    update_arrow
  end
end

#update_in_stock_item(nb)

Update the number of the actual item currently in stock



55
56
57
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00210 Pokemon_Shop_Graphics.rb', line 55

def update_in_stock_item(nb)
  @item_desc_window.nb_in_stock = nb
end

#update_item_button_list

Update the item list



21
22
23
24
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00210 Pokemon_Shop_Graphics.rb', line 21

def update_item_button_list
  @item_list.item_list = @item_list.item_price = @list_item
  @item_list.index = @index
end

#update_item_desc

Method that calls all the informations updating method of the description window



33
34
35
36
37
38
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00210 Pokemon_Shop_Graphics.rb', line 33

def update_item_desc
  update_item_desc_name(data_creature(@list_item[@index][:id]).name)
  update_item_desc_text(@list_item[@index][:level])
  update_pkm_specie_text(data_creature(@list_item[@index][:id]).species)
  update_in_stock_item(@list_item[@index][:quantity]) if @symbol_or_list.class == Symbol
end

#update_item_desc_name(name)

Update the name of the item currently shown



41
42
43
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00210 Pokemon_Shop_Graphics.rb', line 41

def update_item_desc_name(name)
  @item_desc_window.name = name
end

#update_item_desc_text(text)

Update the description of the item currently shown



46
47
48
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00210 Pokemon_Shop_Graphics.rb', line 46

def update_item_desc_text(text)
  @item_desc_window.text = text
end

#update_pkm_specie_text(species)



50
51
52
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00210 Pokemon_Shop_Graphics.rb', line 50

def update_pkm_specie_text(species)
  @item_desc_window.species = species
end