Added class GameData::Stat

This commit is contained in:
Maruno17
2021-03-04 22:59:48 +00:00
parent 934e38662a
commit ff0c2f00c8
46 changed files with 1301 additions and 1202 deletions

View File

@@ -250,7 +250,6 @@ PokemonDebugMenuCommands.register("hiddenvalues", {
"name" => _INTL("EV/IV/pID..."),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
numstats = 6
cmd = 0
loop do
persid = sprintf("0x%08X", pkmn.personalID)
@@ -265,9 +264,11 @@ PokemonDebugMenuCommands.register("hiddenvalues", {
loop do
totalev = 0
evcommands = []
for i in 0...numstats
evcommands.push(PBStats.getName(i) + " (#{pkmn.ev[i]})")
totalev += pkmn.ev[i]
ev_id = []
GameData::Stat.each_main do |s|
evcommands.push(s.name + " (#{pkmn.ev[s.id]})")
ev_id.push(s.id)
totalev += pkmn.ev[s.id]
end
evcommands.push(_INTL("Randomise all"))
evcommands.push(_INTL("Max randomise all"))
@@ -275,41 +276,37 @@ PokemonDebugMenuCommands.register("hiddenvalues", {
totalev, Pokemon::EV_LIMIT,
100 * totalev / Pokemon::EV_LIMIT), evcommands, cmd2)
break if cmd2 < 0
if cmd2 < numstats
if cmd2 < ev_id.length
params = ChooseNumberParams.new
upperLimit = 0
for i in 0...numstats
upperLimit += pkmn.ev[i] if i != cmd2
end
GameData::Stat.each_main { |s| upperLimit += pkmn.ev[s.id] if s.id != ev_id[cmd2] }
upperLimit = Pokemon::EV_LIMIT - upperLimit
upperLimit = [upperLimit, Pokemon::EV_STAT_LIMIT].min
thisValue = [pkmn.ev[cmd2], upperLimit].min
thisValue = [pkmn.ev[ev_id[cmd2]], upperLimit].min
params.setRange(0, upperLimit)
params.setDefaultValue(thisValue)
params.setCancelValue(thisValue)
f = pbMessageChooseNumber(_INTL("Set the EV for {1} (max. {2}).",
PBStats.getName(cmd2), upperLimit), params) { screen.pbUpdate }
if f != pkmn.ev[cmd2]
pkmn.ev[cmd2] = f
GameData::Stat.get(ev_id[cmd2]).name, upperLimit), params) { screen.pbUpdate }
if f != pkmn.ev[ev_id[cmd2]]
pkmn.ev[ev_id[cmd2]] = f
pkmn.calcStats
screen.pbRefreshSingle(pkmnid)
end
elsif cmd2 < evcommands.length # Randomise
else # (Max) Randomise all
evTotalTarget = Pokemon::EV_LIMIT
if cmd2 == evcommands.length - 2
if cmd2 == evcommands.length - 2 # Randomize all (not max)
evTotalTarget = rand(Pokemon::EV_LIMIT)
end
for i in 0...numstats
pkmn.ev[i] = 0
end
GameData::Stat.each_main { |s| pkmn.ev[s.id] = 0 }
while evTotalTarget > 0
r = rand(numstats)
next if pkmn.ev[r] >= Pokemon::EV_STAT_LIMIT
addVal = 1 + rand(Pokemon::EV_STAT_LIMIT/4)
addVal = evTotalTarget if addVal > evTotalTarget
addVal = [addVal, Pokemon::EV_STAT_LIMIT - pkmn.ev[r]].min
r = rand(ev_id.length)
next if pkmn.ev[ev_id[r]] >= Pokemon::EV_STAT_LIMIT
addVal = 1 + rand(Pokemon::EV_STAT_LIMIT / 4)
addVal = addVal.clamp(0, evTotalTarget)
addVal = addVal.clamp(0, Pokemon::EV_STAT_LIMIT - pkmn.ev[ev_id[r]])
next if addVal == 0
pkmn.ev[r] += addVal
pkmn.ev[ev_id[r]] += addVal
evTotalTarget -= addVal
end
pkmn.calcStats
@@ -322,32 +319,32 @@ PokemonDebugMenuCommands.register("hiddenvalues", {
hiddenpower = pbHiddenPower(pkmn)
totaliv = 0
ivcommands = []
for i in 0...numstats
ivcommands.push(PBStats.getName(i) + " (#{pkmn.iv[i]})")
totaliv += pkmn.iv[i]
iv_id = []
GameData::Stat.each_main do |s|
ivcommands.push(s.name + " (#{pkmn.iv[s.id]})")
iv_id.push(s.id)
totaliv += pkmn.iv[s.id]
end
msg = _INTL("Change which IV?\nHidden Power:\n{1}, power {2}\nTotal: {3}/{4} ({5}%)",
GameData::Type.get(hiddenpower[0]).name, hiddenpower[1], totaliv, numstats * 31,
100 * totaliv / (numstats * 31))
GameData::Type.get(hiddenpower[0]).name, hiddenpower[1], totaliv,
iv_id.length * Pokemon::IV_STAT_LIMIT, 100 * totaliv / (iv_id.length * Pokemon::IV_STAT_LIMIT))
ivcommands.push(_INTL("Randomise all"))
cmd2 = screen.pbShowCommands(msg, ivcommands, cmd2)
break if cmd2 < 0
if cmd2 < numstats
if cmd2 < iv_id.length
params = ChooseNumberParams.new
params.setRange(0, 31)
params.setDefaultValue(pkmn.iv[cmd2])
params.setCancelValue(pkmn.iv[cmd2])
params.setRange(0, Pokemon::IV_STAT_LIMIT)
params.setDefaultValue(pkmn.iv[iv_id[cmd2]])
params.setCancelValue(pkmn.iv[iv_id[cmd2]])
f = pbMessageChooseNumber(_INTL("Set the IV for {1} (max. 31).",
PBStats.getName(cmd2)), params) { screen.pbUpdate }
if f != pkmn.iv[cmd2]
pkmn.iv[cmd2] = f
GameData::Stat.get(iv_id[cmd2]).name), params) { screen.pbUpdate }
if f != pkmn.iv[iv_id[cmd2]]
pkmn.iv[iv_id[cmd2]] = f
pkmn.calcStats
screen.pbRefreshSingle(pkmnid)
end
elsif cmd2 == ivcommands.length - 1 # Randomise
for i in 0...numstats
pkmn.iv[i] = rand(Pokemon::IV_STAT_LIMIT + 1)
end
else # Randomise all
GameData::Stat.each_main { |s| pkmn.iv[s.id] = rand(Pokemon::IV_STAT_LIMIT + 1) }
pkmn.calcStats
screen.pbRefreshSingle(pkmnid)
end
@@ -667,10 +664,10 @@ PokemonDebugMenuCommands.register("setnature", {
nature.stat_changes.each do |change|
if change[1] > 0
plus_text += "/" if !plus_text.empty?
plus_text += PBStats.getNameBrief(change[0])
plus_text += GameData::Stat.get(change[0]).name_brief
elsif change[1] < 0
minus_text += "/" if !minus_text.empty?
minus_text += PBStats.getNameBrief(change[0])
minus_text += GameData::Stat.get(change[0]).name_brief
end
end
commands.push(_INTL("{1} (+{2}, -{3})", nature.real_name, plus_text, minus_text))

View File

@@ -1021,8 +1021,8 @@ def pbPokemonEditor
spec.real_pokedex_entry,
spec.type1,
(spec.type2 == spec.type1) ? nil : spec.type2,
spec.base_stats.clone,
spec.evs.clone,
spec.base_stats,
spec.evs,
spec.base_exp,
spec.growth_rate,
spec.gender_ratio,

View File

@@ -456,35 +456,38 @@ class IVsProperty
end
def set(settingname, oldsetting)
oldsetting = [nil] if !oldsetting
for i in 0...6
oldsetting[i] = oldsetting[0] if !oldsetting[i]
end
oldsetting = {} if !oldsetting
properties = []
properties[PBStats::HP] = [_INTL("HP"), LimitProperty2.new(@limit), _INTL("Individual values for the Pokémon's HP stat (0-{1}).", @limit)]
properties[PBStats::ATTACK] = [_INTL("Attack"), LimitProperty2.new(@limit), _INTL("Individual values for the Pokémon's Attack stat (0-{1}).", @limit)]
properties[PBStats::DEFENSE] = [_INTL("Defense"), LimitProperty2.new(@limit), _INTL("Individual values for the Pokémon's Defense stat (0-{1}).", @limit)]
properties[PBStats::SPATK] = [_INTL("Sp. Atk"), LimitProperty2.new(@limit), _INTL("Individual values for the Pokémon's Sp. Atk stat (0-{1}).", @limit)]
properties[PBStats::SPDEF] = [_INTL("Sp. Def"), LimitProperty2.new(@limit), _INTL("Individual values for the Pokémon's Sp. Def stat (0-{1}).", @limit)]
properties[PBStats::SPEED] = [_INTL("Speed"), LimitProperty2.new(@limit), _INTL("Individual values for the Pokémon's Speed stat (0-{1}).", @limit)]
pbPropertyList(settingname, oldsetting, properties, false)
hasNonNil = false
firstVal = oldsetting[0] || 0
for i in 0...6
(oldsetting[i]) ? hasNonNil = true : oldsetting[i] = firstVal
data = []
stat_ids = []
GameData::Stat.each_main do |s|
oldsetting[s.pbs_order] = 0 if !oldsetting[s.pbs_order]
properties[s.pbs_order] = [s.name, LimitProperty2.new(@limit),
_INTL("Individual values for the Pokémon's {1} stat (0-{2}).", s.name, @limit)]
data[s.pbs_order] = oldsetting[s.id]
stat_ids[s.pbs_order] = s.id
end
return (hasNonNil) ? oldsetting : nil
pbPropertyList(settingname, data, properties, false)
allZeroes = true
data.each_with_index do |value, i|
data[i] ||= 0
allZeroes = false if value && value != 0
end
return nil if allZeroes
ret = {}
stat_ids.each_with_index { |s, i| ret[s] = data[i] }
return ret
end
def defaultValue
return nil
return 0
end
def format(value)
return "-" if !value
return value[0].to_s if value.uniq.length == 1
ret = ""
for i in 0...6
for i in 0...value.length
ret.concat(",") if i > 0
ret.concat((value[i] || 0).to_s)
end
@@ -500,46 +503,44 @@ class EVsProperty
end
def set(settingname, oldsetting)
oldsetting = [nil] if !oldsetting
for i in 0...6
oldsetting[i] = oldsetting[0] if !oldsetting[i]
end
oldsetting = {} if !oldsetting
properties = []
properties[PBStats::HP] = [_INTL("HP"), LimitProperty2.new(@limit), _INTL("Effort values for the Pokémon's HP stat (0-{1}).", @limit)]
properties[PBStats::ATTACK] = [_INTL("Attack"), LimitProperty2.new(@limit), _INTL("Effort values for the Pokémon's Attack stat (0-{1}).", @limit)]
properties[PBStats::DEFENSE] = [_INTL("Defense"), LimitProperty2.new(@limit), _INTL("Effort values for the Pokémon's Defense stat (0-{1}).", @limit)]
properties[PBStats::SPATK] = [_INTL("Sp. Atk"), LimitProperty2.new(@limit), _INTL("Effort values for the Pokémon's Sp. Atk stat (0-{1}).", @limit)]
properties[PBStats::SPDEF] = [_INTL("Sp. Def"), LimitProperty2.new(@limit), _INTL("Effort values for the Pokémon's Sp. Def stat (0-{1}).", @limit)]
properties[PBStats::SPEED] = [_INTL("Speed"), LimitProperty2.new(@limit), _INTL("Effort values for the Pokémon's Speed stat (0-{1}).", @limit)]
data = []
stat_ids = []
GameData::Stat.each_main do |s|
oldsetting[s.pbs_order] = 0 if !oldsetting[s.pbs_order]
properties[s.pbs_order] = [s.name, LimitProperty2.new(@limit),
_INTL("Effort values for the Pokémon's {1} stat (0-{2}).", s.name, @limit)]
data[s.pbs_order] = oldsetting[s.id]
stat_ids[s.pbs_order] = s.id
end
loop do
pbPropertyList(settingname, oldsetting, properties, false)
pbPropertyList(settingname,data,properties,true)
evtotal = 0
for i in 0...6
evtotal += oldsetting[i] if oldsetting[i]
end
if evtotal > Pokemon::EV_LIMIT
pbMessage(_INTL("Total EVs ({1}) are greater than allowed ({2}). Please reduce them.", evtotal, Pokemon::EV_LIMIT))
else
break
end
data.each { |value| evtotal += value if value }
break if evtotal <= Pokemon::EV_LIMIT
pbMessage(_INTL("Total EVs ({1}) are greater than allowed ({2}). Please reduce them.", evtotal, Pokemon::EV_LIMIT))
end
hasNonNil = false
firstVal = oldsetting[0] || 0
for i in 0...6
(oldsetting[i]) ? hasNonNil = true : oldsetting[i] = firstVal
allZeroes = true
data.each_with_index do |value, i|
data[i] ||= 0
allZeroes = false if value && value != 0
end
return (hasNonNil) ? oldsetting : nil
return nil if allZeroes
ret = {}
stat_ids.each_with_index { |s, i| ret[s] = data[i] }
return ret
end
def defaultValue
return nil
return 0
end
def format(value)
return "-" if !value
return value[0].to_s if value.uniq.length == 1
ret = ""
for i in 0...6
for i in 0...value.length
ret.concat(",") if i > 0
ret.concat((value[i] || 0).to_s)
end
@@ -827,16 +828,18 @@ module BaseStatsProperty
def self.set(settingname,oldsetting)
return oldsetting if !oldsetting
properties = []
properties[PBStats::HP] = _INTL("Base HP"), NonzeroLimitProperty.new(255), _INTL("Base HP stat of the Pokémon.")
properties[PBStats::ATTACK] = _INTL("Base Attack"), NonzeroLimitProperty.new(255), _INTL("Base Attack stat of the Pokémon.")
properties[PBStats::DEFENSE] = _INTL("Base Defense"), NonzeroLimitProperty.new(255), _INTL("Base Defense stat of the Pokémon.")
properties[PBStats::SPATK] = _INTL("Base Sp. Attack"), NonzeroLimitProperty.new(255), _INTL("Base Special Attack stat of the Pokémon.")
properties[PBStats::SPDEF] = _INTL("Base Sp. Defense"), NonzeroLimitProperty.new(255), _INTL("Base Special Defense stat of the Pokémon.")
properties[PBStats::SPEED] = _INTL("Base Speed"), NonzeroLimitProperty.new(255), _INTL("Base Speed stat of the Pokémon.")
if !pbPropertyList(settingname,oldsetting,properties,true)
oldsetting = nil
else
oldsetting = nil if !oldsetting[0] || oldsetting[0]==0
data = []
stat_ids = []
GameData::Stat.each_main do |s|
properties[s.pbs_order] = [_INTL("Base {1}", s.name), NonzeroLimitProperty.new(255),
_INTL("Base {1} stat of the Pokémon.", s.name)]
data[s.pbs_order] = oldsetting[s.id]
stat_ids[s.pbs_order] = s.id
end
if pbPropertyList(settingname,data,properties,true)
ret = {}
stat_ids.each_with_index { |s, i| ret[s] = data[i] }
oldsetting = ret
end
return oldsetting
end
@@ -856,16 +859,18 @@ module EffortValuesProperty
def self.set(settingname,oldsetting)
return oldsetting if !oldsetting
properties = []
properties[PBStats::HP] = [_INTL("HP EVs"), LimitProperty.new(255), _INTL("Number of HP Effort Value points gained from the Pokémon.")]
properties[PBStats::ATTACK] = [_INTL("Attack EVs"), LimitProperty.new(255), _INTL("Number of Attack Effort Value points gained from the Pokémon.")]
properties[PBStats::DEFENSE] = [_INTL("Defense EVs"), LimitProperty.new(255), _INTL("Number of Defense Effort Value points gained from the Pokémon.")]
properties[PBStats::SPATK] = [_INTL("Sp. Attack EVs"), LimitProperty.new(255), _INTL("Number of Special Attack Effort Value points gained from the Pokémon.")]
properties[PBStats::SPDEF] = [_INTL("Sp. Defense EVs"), LimitProperty.new(255), _INTL("Number of Special Defense Effort Value points gained from the Pokémon.")]
properties[PBStats::SPEED] = [_INTL("Speed EVs"), LimitProperty.new(255), _INTL("Number of Speed Effort Value points gained from the Pokémon.")]
if !pbPropertyList(settingname,oldsetting,properties,true)
oldsetting = nil
else
oldsetting = nil if !oldsetting[0] || oldsetting[0]==0
data = []
stat_ids = []
GameData::Stat.each_main do |s|
properties[s.pbs_order] = [_INTL("{1} EVs", s.name), LimitProperty.new(255),
_INTL("Number of {1} Effort Value points gained from the Pokémon.", s.name)]
data[s.pbs_order] = oldsetting[s.id]
stat_ids[s.pbs_order] = s.id
end
if pbPropertyList(settingname,oldsetting,properties,true)
ret = {}
stat_ids.each_with_index { |s, i| ret[s] = data[i] }
oldsetting = ret
end
return oldsetting
end