mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-16 00:02:23 +02:00
Add Gold save-editor support, rearrange the launcher, and ship a patch-notes modal.
The save editor now routes Gold vs RBY through a generation adapter so boxes, items, events, and maps write the right fields. The launcher layout is shuffled a bit, and patch notes can come from the updater, a packed file, or the iOS sidecar.
This commit is contained in:
@@ -4,23 +4,40 @@ local Growth = require("src.pokemon.Growth")
|
||||
|
||||
local MonOps = {}
|
||||
|
||||
function MonOps.create(data, species, level)
|
||||
function MonOps.create(data, species, level, gen)
|
||||
if gen == 2 then
|
||||
local Mon = require("src.battle.gen2.Mon")
|
||||
local mon = Mon.new(data, species, level)
|
||||
assert(mon, "unknown species " .. tostring(species))
|
||||
return mon
|
||||
end
|
||||
return Pokemon.new(data, species, level)
|
||||
end
|
||||
|
||||
function MonOps.recalc(data, mon)
|
||||
function MonOps.recalc(data, mon, gen)
|
||||
if gen == 2 or (mon.stats and mon.stats.specialAttack) or mon.experience then
|
||||
require("src.battle.gen2.Mon").refreshStats(mon, data)
|
||||
return
|
||||
end
|
||||
local def = data.pokemon[mon.species]
|
||||
assert(def, "unknown species")
|
||||
mon.stats = Stats.calc(def, mon.level, mon.dvs, mon.statExp)
|
||||
mon.hp = math.max(0, math.min(mon.hp or mon.stats.hp, mon.stats.hp))
|
||||
end
|
||||
|
||||
function MonOps.setLevel(data, mon, level)
|
||||
function MonOps.setLevel(data, mon, level, gen)
|
||||
level = math.max(1, math.min(100, math.floor(level)))
|
||||
local def = data.pokemon[mon.species]
|
||||
mon.level = level
|
||||
if gen == 2 or mon.experience ~= nil then
|
||||
local Mon = require("src.battle.gen2.Mon")
|
||||
local growth = Mon.growthFor(data, def.growthRate)
|
||||
mon.experience = Mon.experienceForLevel(growth, level)
|
||||
Mon.refreshStats(mon, data)
|
||||
return
|
||||
end
|
||||
mon.exp = Growth.expForLevel(def.growthRate, level)
|
||||
MonOps.recalc(data, mon)
|
||||
MonOps.recalc(data, mon, gen)
|
||||
end
|
||||
|
||||
function MonOps.setMove(data, mon, slot, moveId)
|
||||
@@ -32,6 +49,7 @@ function MonOps.setMove(data, mon, slot, moveId)
|
||||
id = moveId,
|
||||
pp = mdef.pp + ((mon.moves[slot] and mon.moves[slot].ppUps) or 0) * math.floor(mdef.pp / 5),
|
||||
ppUps = mon.moves[slot] and mon.moves[slot].ppUps or nil,
|
||||
maxPp = mdef.pp,
|
||||
}
|
||||
end
|
||||
|
||||
@@ -42,19 +60,38 @@ function MonOps.syncHpDv(dvs)
|
||||
return dvs
|
||||
end
|
||||
|
||||
function MonOps.setDv(data, mon, key, value)
|
||||
function MonOps.setDv(data, mon, key, value, gen)
|
||||
mon.dvs[key] = math.max(0, math.min(15, math.floor(value)))
|
||||
if key ~= "hp" then
|
||||
MonOps.syncHpDv(mon.dvs)
|
||||
end
|
||||
MonOps.recalc(data, mon)
|
||||
if gen == 2 or (mon.stats and mon.stats.specialAttack) then
|
||||
local Mon = require("src.battle.gen2.Mon")
|
||||
mon.dvs.hp = Mon.hpDV(mon.dvs)
|
||||
local def = data.pokemon[mon.species]
|
||||
if def then
|
||||
mon.gender = Mon.gender(def, mon.dvs, { species = mon.species, level = mon.level })
|
||||
mon.shiny = Mon.isShiny(mon.dvs, { species = mon.species, def = def, level = mon.level })
|
||||
local Unown = require("src.core.gen2.Unown")
|
||||
if mon.species == Unown.SPECIES then
|
||||
mon.unownLetter = Unown.letterFromDVs(mon.dvs)
|
||||
end
|
||||
end
|
||||
end
|
||||
MonOps.recalc(data, mon, gen)
|
||||
end
|
||||
|
||||
-- Keep level; resync exp to the species growth curve (species changes).
|
||||
function MonOps.setSpecies(data, mon, species)
|
||||
-- Gold also copies def.name onto mon.name: the party list and SUMMARY print
|
||||
-- that field when nickname is nil, so leaving the previous species' name
|
||||
-- made a swapped mon still read as ABRA (or whoever was added first).
|
||||
function MonOps.setSpecies(data, mon, species, gen)
|
||||
assert(data.pokemon[species], "unknown species")
|
||||
mon.species = species
|
||||
MonOps.setLevel(data, mon, mon.level)
|
||||
MonOps.setLevel(data, mon, mon.level, gen)
|
||||
if gen == 2 or mon.experience ~= nil or (mon.stats and mon.stats.specialAttack) then
|
||||
require("src.battle.gen2.Mon").syncIdentity(mon, data)
|
||||
end
|
||||
end
|
||||
|
||||
return MonOps
|
||||
|
||||
Reference in New Issue
Block a user