Added class GameData::Habitat

This commit is contained in:
Maruno17
2021-02-06 22:06:55 +00:00
parent 033434807d
commit a5af35beb1
9 changed files with 183 additions and 103 deletions

View File

@@ -667,7 +667,7 @@ module TrainerPokemonProperty
pkmn_properties.concat([
[_INTL("Ability"), LimitProperty2.new(99), _INTL("Ability flag. 0=first ability, 1=second ability, 2-5=hidden ability.")],
[_INTL("Held item"), ItemProperty, _INTL("Item held by the Pokémon.")],
[_INTL("Nature"), NatureProperty, _INTL("Nature of the Pokémon.")],
[_INTL("Nature"), GameDataProperty.new(:Nature), _INTL("Nature of the Pokémon.")],
[_INTL("IVs"), IVsProperty.new(Pokemon::IV_STAT_LIMIT), _INTL("Individual values for each of the Pokémon's stats.")],
[_INTL("EVs"), EVsProperty.new(Pokemon::EV_STAT_LIMIT), _INTL("Effort values for each of the Pokémon's stats.")],
[_INTL("Happiness"), LimitProperty2.new(255), _INTL("Happiness of the Pokémon (0-255).")],
@@ -974,8 +974,8 @@ def pbPokemonEditor
[_INTL("WildItemCommon"), ItemProperty, _INTL("Item commonly held by wild Pokémon of this species.")],
[_INTL("WildItemUncommon"), ItemProperty, _INTL("Item uncommonly held by wild Pokémon of this species.")],
[_INTL("WildItemRare"), ItemProperty, _INTL("Item rarely held by wild Pokémon of this species.")],
[_INTL("Compat1"), EggGroupProperty, _INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("Compat2"), EggGroupProperty, _INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("Compat1"), GameDataProperty.new(:EggGroup), _INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("Compat2"), GameDataProperty.new(:EggGroup), _INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("StepsToHatch"), LimitProperty.new(99999), _INTL("Number of steps until an egg of this species hatches.")],
[_INTL("Incense"), ItemProperty, _INTL("Item needed to be held by a parent to produce an egg of this species.")],
[_INTL("Evolutions"), EvolutionsProperty.new, _INTL("Evolution paths of this species.")],
@@ -983,7 +983,7 @@ def pbPokemonEditor
[_INTL("Weight"), NonzeroLimitProperty.new(9999), _INTL("Weight of the Pokémon in 0.1 kilograms (e.g. 42 = 4.2kg).")],
[_INTL("Color"), EnumProperty2.new(PBColors), _INTL("Pokémon's body color.")],
[_INTL("Shape"), LimitProperty.new(14), _INTL("Body shape of this species (0-14).")],
[_INTL("Habitat"), EnumProperty2.new(PBHabitats), _INTL("The habitat of this species.")],
[_INTL("Habitat"), GameDataProperty.new(:Habitat), _INTL("The habitat of this species.")],
[_INTL("Generation"), LimitProperty.new(99999), _INTL("The number of the generation the Pokémon debuted in.")],
[_INTL("BattlerPlayerX"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerPlayerY"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],

View File

@@ -235,6 +235,37 @@ end
class GameDataProperty
def initialize(value)
raise _INTL("Couldn't find class {1} in module GameData.", value.to_s) if !GameData.const_defined?(value.to_sym)
@module = GameData.const_get(value.to_sym)
end
def set(settingname, oldsetting)
commands = []
i = 0
@module.each do |data|
if data.respond_to?("id_number")
commands.push([data.id_number, data.name, data.id])
else
commands.push([i, data.name, data.id])
end
i += 1
end
return pbChooseList(commands, oldsetting, nil, -1)
end
def defaultValue
return nil
end
def format(value)
return (value && @module.exists?(value)) ? @module.get(value).real_name : "-"
end
end
module BGMProperty
def self.set(settingname,oldsetting)
chosenmap = pbListScreen(settingname,MusicFileLister.new(true,oldsetting))
@@ -402,23 +433,6 @@ end
module NatureProperty
def self.set(_settingname, oldsetting)
ret = pbChooseNatureList((oldsetting) ? oldsetting : nil)
return ret || oldsetting
end
def self.defaultValue
return nil
end
def self.format(value)
return (value && GameData::Nature.exists?(value)) ? GameData::Nature.get(value).real_name : "-"
end
end
module ItemProperty
def self.set(_settingname, oldsetting)
ret = pbChooseItemList((oldsetting) ? oldsetting : nil)
@@ -436,23 +450,6 @@ end
module EggGroupProperty
def self.set(_settingname, oldsetting)
ret = pbChooseEggGroupList((oldsetting) ? oldsetting : nil)
return ret || oldsetting
end
def self.defaultValue
return nil
end
def self.format(value)
return (value && GameData::EggGroup.exists?(value)) ? GameData::EggGroup.get(value).real_name : "-"
end
end
class IVsProperty
def initialize(limit)
@limit = limit
@@ -614,8 +611,8 @@ module MapSizeProperty
def self.set(settingname,oldsetting)
oldsetting = [0,""] if !oldsetting
properties = [
[_INTL("Width"),NonzeroLimitProperty.new(30),_INTL("The width of this map in Region Map squares.")],
[_INTL("Valid Squares"),StringProperty,_INTL("A series of 1s and 0s marking which squares are part of this map (1=part, 0=not part).")],
[_INTL("Width"), NonzeroLimitProperty.new(30), _INTL("The width of this map in Region Map squares.")],
[_INTL("Valid Squares"), StringProperty, _INTL("A series of 1s and 0s marking which squares are part of this map (1=part, 0=not part).")],
]
pbPropertyList(settingname,oldsetting,properties,false)
return oldsetting

View File

@@ -206,22 +206,6 @@ def pbChooseAbilityList(default = nil)
return pbChooseList(commands, default, nil, -1)
end
def pbChooseNatureList(default = nil)
commands = []
GameData::Nature.each { |n| commands.push([n.id_number, n.name, n.id]) }
return pbChooseList(commands, default, nil, -1)
end
def pbChooseEggGroupList(default = nil)
commands = []
i = 0
GameData::EggGroup.each do |g|
commands.push([i, g.name, g.id])
i += 1
end
return pbChooseList(commands, default, nil, -1)
end
def pbChooseBallList(defaultMoveID = -1)
cmdwin = pbListWindow([], 200)
commands = []