Module: GTS

Defined in:
scripts/01450 Systems/09000 GTS/09000 GTS.rb

Overview

require 'net/http' ENV = './lib/cert.pem'

Defined Under Namespace

Modules: Core, Settings Classes: Button, LoadingScreen, Scene, SearchMethod, SummarySelect, SummaryWanted, Summary_Memo_GTS, WantedDataScene

Class Method Summary collapse

Class Method Details

.finish_trade(my_pokemon, new_poke, searching, choice = nil, id = nil)

Finishes the GTS trade

Parameters:

  • my_pokemon (PFM::Pokemon)

    the player's Pokemon

  • new_poke (PFM::Pokemon)

    the traded Pokemon

  • choice (Integer, nil) (defaults to: nil)

    the choice made in the Box in order to correctly remove the Pokemon

  • searching (Boolean)

    if the Pokemon was got from searching (implying choice to be Integer)

  • id (Integer) (defaults to: nil)

    online ID



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'scripts/01450 Systems/09000 GTS/09000 GTS.rb', line 95

def finish_trade(my_pokemon, new_poke, searching, choice = nil, id = nil)
  $pokedex.mark_seen(new_poke.id, new_poke.form)
  $pokedex.mark_captured(new_poke.id)
=begin TODO
  pbFadeOutInWithMusic(99999){
    evo = PokemonTradeScene.new
    evo.pbStartScreen(my_pokemon, new_poke, $Trainer.name, new_poke.ot)
    evo.pbTrade
    evo.pbEndScreen
  }
=end
  elv_id, elv_form = new_poke.evolve_check(:trade, my_pokemon)
  GamePlay.make_pokemon_evolve(new_poke, elv_id, elv_form, true) if elv_id

  if !new_poke.game_code || new_poke.game_code != Settings::GAME_CODE
    new_poke.flags = 0x00E9_0000 # 9 = base2 : 1,0,0,1 = ?, !FromThisGame, !CapturedByPlayer, FromPresentTime
  else
    new_poke.flags = 0x00ED_0000 # D = base2 : 1,1,0,1 = ?, FromThisGame, !CapturedByPlayer, FromPresentTime
  end

  return finish_trade_from_searching(my_pokemon, new_poke, choice, id) if searching

  GamePlay::Save.save
  return Core.delete_pokemon(false)
end

.finish_trade_from_searching(my_pokemon, new_poke, choice, id)

Finishes the GTS trade (delete pokemon from data & insert traded Pokemon in party)

Parameters:

  • my_pokemon (PFM::Pokemon)

    the player's Pokemon

  • new_poke (PFM::Pokemon)

    the traded Pokemon

  • choice (Integer, nil)

    the choice made in the Box in order to correctly remove the Pokemon

  • id (Integer)

    online ID



126
127
128
129
130
131
132
133
134
# File 'scripts/01450 Systems/09000 GTS/09000 GTS.rb', line 126

def finish_trade_from_searching(my_pokemon, new_poke, choice, id)
  if Core.take_pokemon(id) && Core.upload_new_pokemon(id, my_pokemon)
    choice >= 31 ? PFM.game_state.remove_pokemon(choice - 31) : $storage.remove(choice - 1)
    PFM.game_state.add_pokemon(new_poke)
    GamePlay::Save.save
    return true
  end
  return false
end

.genders



184
185
186
# File 'scripts/01450 Systems/09000 GTS/09000 GTS.rb', line 184

def genders
  return %w[Either Male Female]
end

.loading_screenLoadingScreen

Return the loading screen

Returns:



85
86
87
# File 'scripts/01450 Systems/09000 GTS/09000 GTS.rb', line 85

def loading_screen
  @loading_screen
end

.open

Main Method



71
72
73
74
75
76
77
78
79
80
81
# File 'scripts/01450 Systems/09000 GTS/09000 GTS.rb', line 71

def open
  Core.update_uri
  loading_viewport = Viewport.create(:main, 10_001)
  @loading_screen = LoadingScreen.new(loading_viewport)
  Audio.bgm_play(Settings::BGM) unless Settings::BGM.empty?
  Scene.new.main
  loading_viewport.dispose
  @loading_screen = nil
  $game_system.bgm_play($game_system.playing_bgm)
  Graphics.transition
end

.order_species(index)

Brings up all species of pokemon of the given index of the given sort mode



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'scripts/01450 Systems/09000 GTS/09000 GTS.rb', line 137

def order_species(index)
  commands = [ext_text(8997, 2)]

  # Retreive the list of Pokemon we can see
  species_list = species_list_from_criteria

  if Settings::SORT_MODE == 'Alphabetical'
    letter = index.is_a?(String) ? index : (0x40 + index).chr # index >= 1, A = 0x41
    # Select the Pokemon that start with the right letter
    species_list.select! { |i| data_creature(i).name.start_with?(letter) }
  elsif Settings::SORT_MODE == 'Regional'
    # /!\ PSDK has no multi-regional Dex
    real_index = index == 1 && -1 # TODO: Regional Dex in Studio $pokedex.national? ? -1 : 0
    if real_index != -1
      # Reject non-national Pokemon
      species_list.reject! { |i| data_creature(i).id_bis == 0 }
      # Sort Pokemon by their Regional ID
      species_list.sort! { |a, b| data_creature(a).id_bis <=> data_creature(b).id_bis }
    end
  end

  to_id = proc { |i| i } # TODO: Regional Dex in Studio $pokedex.national? ? i : data_creature(i).id_bis }

  commands.concat(species_list.collect { |i| format('%03d : %0s', to_id.call(i), data_creature(i).name) })
  if commands.size <= 1
    $scene.display_message(ext_text(8997, 0))
    return 0
  end

  c = $scene.display_message(ext_text(8997, 1), 1, *commands)
  return c == 0 ? 0 : species_list[c - 1]
end

.species_list_from_criteriaArray<Integer>

Return the specie list filtered with the criteria (seen, got, black_list)

Returns:



172
173
174
175
176
177
178
179
180
181
182
# File 'scripts/01450 Systems/09000 GTS/09000 GTS.rb', line 172

def species_list_from_criteria
  show_seen = Settings::SPECIES_SHOWN == 'Seen'
  show_captured = Settings::SPECIES_SHOWN == 'Owned'
  return each_data_creature.map(&:id).select do |i|
    next(false) if show_seen && !$pokedex.has_seen?(i)
    next(false) if show_captured && !$pokedex.has_captured?(i)
    next(false) if Settings::BLACK_LIST.include?(i) || Settings::BLACK_LIST.include?(data_creature(i).db_symbol)

    next(true)
  end
end