Moved trainer data constants into module TrainerData

This commit is contained in:
Maruno17
2020-10-17 00:45:39 +01:00
parent c30e302ccf
commit 2b4f1e1aba
5 changed files with 113 additions and 113 deletions

View File

@@ -458,7 +458,7 @@ def pbTrainerBattleEditor
data[0],
data[1],
[data[10],data[11],data[12],data[13],data[14],data[15],data[16],data[17]].find_all { |i| i && i!=0 }, # Item list
[data[4],data[5],data[6],data[7],data[8],data[9]].find_all { |i| i && i[TPSPECIES]!=0 }, # Pokémon list
[data[4],data[5],data[6],data[7],data[8],data[9]].find_all { |i| i && i[TrainerData::SPECIES]!=0 }, # Pokémon list
data[2],
data[3]
]
@@ -491,10 +491,10 @@ module TrainerPokemonProperty
def self.set(settingname,initsetting)
initsetting = [0,10] if !initsetting
oldsetting = []
for i in 0...TPEV
if i==TPMOVES
for i in 0...TrainerData::EV
if i==TrainerData::MOVES
for j in 0...4
oldsetting.push((initsetting[TPMOVES]) ? initsetting[TPMOVES][j] : nil)
oldsetting.push((initsetting[TrainerData::MOVES]) ? initsetting[TrainerData::MOVES][j] : nil)
end
else
oldsetting.push(initsetting[i])
@@ -522,27 +522,27 @@ module TrainerPokemonProperty
[_INTL("EVs"), EVsProperty.new(Pokemon::EV_STAT_LIMIT), _INTL("Effort values for each of the Pokémon's stats.")]
]
pbPropertyList(settingname,oldsetting,properties,false)
return nil if !oldsetting[TPSPECIES] || oldsetting[TPSPECIES]==0
return nil if !oldsetting[TrainerData::SPECIES] || oldsetting[TrainerData::SPECIES]==0
ret = []
moves = []
for i in 0...oldsetting.length
if i>=TPMOVES && i<TPMOVES+4
ret.push(nil) if i==TPMOVES
if i>=TrainerData::MOVES && i<TrainerData::MOVES+4
ret.push(nil) if i==TrainerData::MOVES
moves.push(oldsetting[i])
else
ret.push(oldsetting[i])
end
end
moves.compact!
ret[TPMOVES] = moves if moves.length>0
ret[TrainerData::MOVES] = moves if moves.length>0
# Remove unnecessarily nils from the end of ret
ret.pop while ret.last.nil? && ret.size>0
return ret
end
def self.format(value)
return "-" if !value || !value[TPSPECIES] || value[TPSPECIES]<=0
return sprintf("%s,%d",PBSpecies.getName(value[TPSPECIES]),value[TPLEVEL])
return "-" if !value || !value[TrainerData::SPECIES] || value[TrainerData::SPECIES]<=0
return sprintf("%s,%d",PBSpecies.getName(value[TrainerData::SPECIES]),value[TrainerData::LEVEL])
end
end

View File

@@ -467,67 +467,67 @@ def pbSaveTrainerBattles
end
# Pokémon
for poke in trainer[3]
species = getConstantName(PBSpecies,poke[TPSPECIES]) rescue pbGetSpeciesConst(poke[TPSPECIES]) rescue ""
f.write(sprintf("Pokemon = %s,%d\r\n",species,poke[TPLEVEL]))
if poke[TPNAME] && poke[TPNAME]!=""
f.write(sprintf(" Name = %s\r\n",poke[TPNAME]))
species = getConstantName(PBSpecies,poke[TrainerData::SPECIES]) rescue pbGetSpeciesConst(poke[TrainerData::SPECIES]) rescue ""
f.write(sprintf("Pokemon = %s,%d\r\n",species,poke[TrainerData::LEVEL]))
if poke[TrainerData::NAME] && poke[TrainerData::NAME]!=""
f.write(sprintf(" Name = %s\r\n",poke[TrainerData::NAME]))
end
if poke[TPFORM]
f.write(sprintf(" Form = %d\r\n",poke[TPFORM]))
if poke[TrainerData::FORM]
f.write(sprintf(" Form = %d\r\n",poke[TrainerData::FORM]))
end
if poke[TPGENDER]
f.write(sprintf(" Gender = %s\r\n",(poke[TPGENDER]==1) ? "female" : "male"))
if poke[TrainerData::GENDER]
f.write(sprintf(" Gender = %s\r\n",(poke[TrainerData::GENDER]==1) ? "female" : "male"))
end
if poke[TPSHINY]
if poke[TrainerData::SHINY]
f.write(" Shiny = yes\r\n")
end
if poke[TPSHADOW]
if poke[TrainerData::SHADOW]
f.write(" Shadow = yes\r\n")
end
if poke[TPMOVES] && poke[TPMOVES].length>0
if poke[TrainerData::MOVES] && poke[TrainerData::MOVES].length>0
movestring = ""
for i in 0...poke[TPMOVES].length
movename = getConstantName(PBMoves,poke[TPMOVES][i]) rescue pbGetMoveConst(poke[TPMOVES][i]) rescue nil
for i in 0...poke[TrainerData::MOVES].length
movename = getConstantName(PBMoves,poke[TrainerData::MOVES][i]) rescue pbGetMoveConst(poke[TrainerData::MOVES][i]) rescue nil
next if !movename
movestring.concat(",") if i>0
movestring.concat(movename)
end
f.write(sprintf(" Moves = %s\r\n",movestring)) if movestring!=""
end
if poke[TPABILITY]
f.write(sprintf(" Ability = %d\r\n",poke[TPABILITY]))
if poke[TrainerData::ABILITY]
f.write(sprintf(" Ability = %d\r\n",poke[TrainerData::ABILITY]))
end
if poke[TPITEM] && poke[TPITEM]>0
item = getConstantName(PBItems,poke[TPITEM]) rescue pbGetItemConst(poke[TPITEM]) rescue nil
if poke[TrainerData::ITEM] && poke[TrainerData::ITEM]>0
item = getConstantName(PBItems,poke[TrainerData::ITEM]) rescue pbGetItemConst(poke[TrainerData::ITEM]) rescue nil
f.write(sprintf(" Item = %s\r\n",item)) if item
end
if poke[TPNATURE]
nature = getConstantName(PBNatures,poke[TPNATURE]) rescue nil
if poke[TrainerData::NATURE]
nature = getConstantName(PBNatures,poke[TrainerData::NATURE]) rescue nil
f.write(sprintf(" Nature = %s\r\n",nature)) if nature
end
if poke[TPIV] && poke[TPIV].length>0
f.write(sprintf(" IV = %d",poke[TPIV][0]))
if poke[TPIV].length>1
if poke[TrainerData::IV] && poke[TrainerData::IV].length>0
f.write(sprintf(" IV = %d",poke[TrainerData::IV][0]))
if poke[TrainerData::IV].length>1
for i in 1...6
f.write(sprintf(",%d",(i<poke[TPIV].length) ? poke[TPIV][i] : poke[TPIV][0]))
f.write(sprintf(",%d",(i<poke[TrainerData::IV].length) ? poke[TrainerData::IV][i] : poke[TrainerData::IV][0]))
end
end
f.write("\r\n")
end
if poke[TPEV] && poke[TPEV].length>0
f.write(sprintf(" EV = %d",poke[TPEV][0]))
if poke[TPEV].length>1
if poke[TrainerData::EV] && poke[TrainerData::EV].length>0
f.write(sprintf(" EV = %d",poke[TrainerData::EV][0]))
if poke[TrainerData::EV].length>1
for i in 1...6
f.write(sprintf(",%d",(i<poke[TPEV].length) ? poke[TPEV][i] : poke[TPEV][0]))
f.write(sprintf(",%d",(i<poke[TrainerData::EV].length) ? poke[TrainerData::EV][i] : poke[TrainerData::EV][0]))
end
end
f.write("\r\n")
end
if poke[TPHAPPINESS]
f.write(sprintf(" Happiness = %d\r\n",poke[TPHAPPINESS]))
if poke[TrainerData::HAPPINESS]
f.write(sprintf(" Happiness = %d\r\n",poke[TrainerData::HAPPINESS]))
end
if poke[TPBALL]
f.write(sprintf(" Ball = %d\r\n",poke[TPBALL]))
if poke[TrainerData::BALL]
f.write(sprintf(" Ball = %d\r\n",poke[TrainerData::BALL]))
end
end
end

View File

@@ -605,7 +605,7 @@ class TrainerBattleLister
if !@includeNew || index>0
@trainers[(@includeNew) ? index-1 : index][3].each_with_index do |p,i|
text += "\r\n" if i>0
text += sprintf("%s Lv.%d",PBSpecies.getName(p[TPSPECIES]),p[TPLEVEL])
text += sprintf("%s Lv.%d",PBSpecies.getName(p[TrainerData::SPECIES]),p[TrainerData::LEVEL])
end
end
@pkmnList.text = text