Created and implemented GameData::Species

This commit is contained in:
Maruno17
2020-12-24 21:25:16 +00:00
parent 1ffeddc41c
commit ad21fc92cb
91 changed files with 6733 additions and 7963 deletions

View File

@@ -153,14 +153,9 @@ class PokeBattle_Trainer
def pokedexSeen(region = -1) # Number of Pokémon seen
ret = 0
if region == -1
for i in 1..PBSpecies.maxValue
ret += 1 if @seen[i]
end
GameData::Species.each { |s| ret += 1 if s.form == 0 && @seen[s.species] }
else
regionlist = pbAllRegionalSpecies(region)
for i in regionlist
ret += 1 if i > 0 && @seen[i]
end
pbAllRegionalSpecies(region).each { |s| ret += 1 if s && @seen[s] }
end
return ret
end
@@ -168,22 +163,19 @@ class PokeBattle_Trainer
def pokedexOwned(region = -1) # Number of Pokémon owned
ret = 0
if region == -1
for i in 0..PBSpecies.maxValue
ret += 1 if @owned[i]
end
GameData::Species.each { |s| ret += 1 if s.form == 0 && @owned[s.species] }
else
regionlist = pbAllRegionalSpecies(region)
for i in regionlist
ret += 1 if @owned[i]
end
pbAllRegionalSpecies(region).each { |s| ret += 1 if s && @owned[s] }
end
return ret
end
def numFormsSeen(species)
species = getID(PBSpecies, species)
return 0 if species <= 0
species_data = GameData::Species.try_get(species)
return 0 if !species_data
species = species_data.species
ret = 0
@formseen[species] = [[], []] if !@formseen[species]
array = @formseen[species]
for i in 0...[array[0].length, array[1].length].max
ret += 1 if array[0][i] || array[1][i]
@@ -192,38 +184,32 @@ class PokeBattle_Trainer
end
def seen?(species)
species = getID(PBSpecies, species)
return species > 0 ? @seen[species] : false
species_data = GameData::Species.try_get(species)
return (species_data) ? @seen[species_data.species] : false
end
alias hasSeen? seen?
def owned?(species)
species = getID(PBSpecies, species)
return species > 0 ? @owned[species] : false
species_data = GameData::Species.try_get(species)
return (species_data) ? @owned[species_data.species] : false
end
alias hasOwned? owned?
def setSeen(species)
species = getID(PBSpecies, species)
@seen[species] = true if species > 0
species_data = GameData::Species.try_get(species)
@seen[species_data.species] = true if species_data
end
def setOwned(species)
species = getID(PBSpecies, species)
@owned[species] = true if species > 0
species_data = GameData::Species.try_get(species)
@owned[species_data.species] = true if species_data
end
def clearPokedex
@seen = []
@owned = []
@formseen = []
@formlastseen = []
for i in 1..PBSpecies.maxValue
@seen[i] = false
@owned[i] = false
@formlastseen[i] = []
@formseen[i] = [[], []]
end
@seen = {}
@owned = {}
@formseen = {}
@formlastseen = {}
end
#=============================================================================
@@ -239,10 +225,7 @@ class PokeBattle_Trainer
@pokegear = false
@pokedex = false
clearPokedex
@shadowcaught = []
for i in 1..PBSpecies.maxValue
@shadowcaught[i] = false
end
@shadowcaught = {}
@badges = []
for i in 0...8
@badges[i] = false

View File

@@ -22,7 +22,7 @@ module TrainerData
SCHEMA = {
"Items" => [0, "eEEEEEEE", :Item, :Item, :Item, :Item,
:Item, :Item, :Item, :Item],
"Pokemon" => [SPECIES, "ev", :PBSpecies, nil], # Species, level
"Pokemon" => [SPECIES, "ev", :Species, nil], # Species, level
"Item" => [ITEM, "e", :Item],
"Moves" => [MOVES, "eEEE", :Move, :Move, :Move, :Move],
"Ability" => [ABILITY, "u"],
@@ -69,7 +69,7 @@ def pbLoadTrainer(tr_type, tr_name, tr_id = 0)
opponent.setForeignID($Trainer)
# Load up each Pokémon in the trainer's party
for poke in trainer[3]
species = pbGetSpeciesFromFSpecies(poke[TrainerData::SPECIES])[0]
species = GameData::Species.get(poke[TrainerData::SPECIES]).species
level = poke[TrainerData::LEVEL]
pokemon = Pokemon.new(species,level,opponent,false)
if poke[TrainerData::FORM]
@@ -84,14 +84,15 @@ def pbLoadTrainer(tr_type, tr_name, tr_id = 0)
else
pokemon.resetMoves
end
pokemon.setAbility(poke[TrainerData::ABILITY] || 0)
pokemon.setAbility(poke[TrainerData::ABILITY])
g = (poke[TrainerData::GENDER]) ? poke[TrainerData::GENDER] : (opponent.female?) ? 1 : 0
pokemon.setGender(g)
(poke[TrainerData::SHINY]) ? pokemon.makeShiny : pokemon.makeNotShiny
if poke[TrainerData::NATURE]
n = poke[TrainerData::NATURE]
else
n = (pokemon.species + GameData::TrainerType.get(opponent.trainertype).id_number) % (PBNatures.maxValue + 1)
n = pokemon.species_data.id_number + GameData::TrainerType.get(opponent.trainertype).id_number
n = n % (PBNatures.maxValue + 1)
end
pokemon.setNature(n)
for i in 0...6
@@ -143,17 +144,17 @@ def pbNewTrainer(tr_type, tr_name, tr_id, savechanges = true)
end
loop do
species = pbChooseSpeciesList
if species<=0
break if i>0
pbMessage(_INTL("This trainer must have at least 1 Pokémon!"))
else
if species
params = ChooseNumberParams.new
params.setRange(1,PBExperience.maxLevel)
params.setDefaultValue(10)
level = pbMessageChooseNumber(_INTL("Set the level for {1} (max. #{PBExperience.maxLevel}).",
PBSpecies.getName(species)),params)
GameData::Species.get(species).name),params)
pokemon.push([species,level])
break
else
break if i>0
pbMessage(_INTL("This trainer must have at least 1 Pokémon!"))
end
end
end