mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-09-30 07:22:37 -04:00
@@ -185,9 +185,12 @@ local function protocol()
|
||||
return require("src.link.Protocol")
|
||||
end
|
||||
|
||||
LB.LINK_LEVEL = 50
|
||||
|
||||
function LB.unpackOpts()
|
||||
local spec = LB._arena or (LB._spec and LB._spec.spec)
|
||||
local rule = spec and spec.profile and spec.profile.rule
|
||||
if not spec then return { strict = true, forceLevel = LB.LINK_LEVEL } end
|
||||
return { strict = true, forceLevel = rule and tonumber(rule.forceLevel) or nil }
|
||||
end
|
||||
|
||||
@@ -276,15 +279,6 @@ local function hasEnigmaBerry(s)
|
||||
return false
|
||||
end
|
||||
|
||||
-- pokefirered/src/union_room.c:4565 HasAtLeastTwoMonsOfLevel30OrLower
|
||||
local function twoUnderCap(s, cap)
|
||||
local n = 0
|
||||
for _, mon in ipairs(partyOf(s)) do
|
||||
if LB.eligible(mon) and (tonumber(mon.level) or 0) <= cap then n = n + 1 end
|
||||
end
|
||||
return n >= 2
|
||||
end
|
||||
|
||||
function LB.validateParty(s, mode, opts)
|
||||
opts = opts or {}
|
||||
s = s or session()
|
||||
@@ -297,9 +291,6 @@ function LB.validateParty(s, mode, opts)
|
||||
if opts.unionRoom then
|
||||
-- pokefirered/data/scripts/cable_club.inc:806
|
||||
if hasEnigmaBerry(s) then return false, "enigma_berry" end
|
||||
if not twoUnderCap(s, (union() and union().MAX_LEVEL) or 30) then
|
||||
return false, "level_cap"
|
||||
end
|
||||
return true, nil
|
||||
end
|
||||
local L = link()
|
||||
|
||||
@@ -303,9 +303,7 @@ function Link.doLinkRoomExit(ctx, adapters)
|
||||
ctx, adapters = Link.vmCtx()
|
||||
end
|
||||
Link.cleanupLinkRoomState(ctx, adapters)
|
||||
local warped = Link.returnFromLinkRoom(ctx, adapters)
|
||||
Link.setVar(ctx, Link.VAR_CABLE_CLUB_STATE, 0)
|
||||
return warped
|
||||
return Link.returnFromLinkRoom(ctx, adapters)
|
||||
end
|
||||
|
||||
-- pokefirered/src/cable_club.c:821 ExitLinkRoom
|
||||
|
||||
@@ -31,8 +31,6 @@ Union.ACTIVITY = {
|
||||
Union.IN_UNION_ROOM = 0x40
|
||||
-- pokefirered/include/constants/union_room.h:8
|
||||
Union.MAX_LEADERS = 8
|
||||
-- pokefirered/include/constants/union_room.h:15
|
||||
Union.MAX_LEVEL = 30
|
||||
|
||||
-- pokefirered/include/constants/union_room.h:51
|
||||
Union.LINK_GROUP = {
|
||||
@@ -839,21 +837,6 @@ local function chooserOpen()
|
||||
return s and s.isOpen and s.isOpen() and s.mode == "activity"
|
||||
end
|
||||
|
||||
-- pokefirered/src/union_room.c:4565 HasAtLeastTwoMonsOfLevel30OrLower
|
||||
function Union.hasTwoMonsUnderLevelCap()
|
||||
local s = link().session()
|
||||
local party = (s and s.party) or {}
|
||||
local n = 0
|
||||
for i = 1, 6 do
|
||||
local mon = party[i]
|
||||
local species = mon and (tonumber(mon.species) or 0) or 0
|
||||
if species ~= 0 and not mon.isEgg and (tonumber(mon.level) or 0) <= Union.MAX_LEVEL then
|
||||
n = n + 1
|
||||
end
|
||||
end
|
||||
return n >= 2
|
||||
end
|
||||
|
||||
local function sendRequest(activity)
|
||||
if Union.relay then return Union.sendInvite(activity) end
|
||||
local lk = link().link
|
||||
@@ -883,22 +866,6 @@ function Union.chooseActivity(index)
|
||||
return true
|
||||
end
|
||||
local activity = item.union and (item.activity + Union.IN_UNION_ROOM) or item.activity
|
||||
if activity == (Union.ACTIVITY.BATTLE_SINGLE + Union.IN_UNION_ROOM)
|
||||
and not Union.hasTwoMonsUnderLevelCap() then
|
||||
Union.activity = nil
|
||||
Union.lastResult = "need_two_mons"
|
||||
if Union.relay and M and M.show then
|
||||
return Union.runFlow({
|
||||
Union.sayStep(RomText.ascii("gText_UR_NeedTwoMonsOfLevel30OrLower1")),
|
||||
Union.doStep(function() Union.doSomethingPrompt(false) end),
|
||||
}, "do_something_prompt")
|
||||
end
|
||||
Union.state = "do_something_prompt"
|
||||
if M and M.show then
|
||||
M.show(RomText.ascii("gText_UR_NeedTwoMonsOfLevel30OrLower1"))
|
||||
end
|
||||
return false
|
||||
end
|
||||
Union.activity = activity
|
||||
Union._role = "child"
|
||||
local sent = sendRequest(activity)
|
||||
@@ -1711,16 +1678,6 @@ function Union.answerRequest(accept)
|
||||
local raw = math.floor(tonumber(Union.activity) or 0) % Union.IN_UNION_ROOM
|
||||
local M = message()
|
||||
local shown = inv and M and M.show and type(love) == "table" and love.graphics
|
||||
-- pokefirered/src/union_room.c:3178
|
||||
if accept and raw == Union.ACTIVITY.BATTLE_SINGLE and Union.activity >= Union.IN_UNION_ROOM
|
||||
and not Union.hasTwoMonsUnderLevelCap() then
|
||||
if inv then link().clientCall("replyInvite", inv.id, false) end
|
||||
Union.lastResult = "need_two_mons"
|
||||
Union.activity = nil
|
||||
if shown then return Union.printAndExit(RomText.ascii("gText_UR_NeedTwoMonsOfLevel30OrLower2")) end
|
||||
Union.state = "main"
|
||||
return true
|
||||
end
|
||||
if inv then link().clientCall("replyInvite", inv.id, accept and true or false) end
|
||||
Union.lastResult = accept and "accepted" or "declined"
|
||||
if accept and inv then
|
||||
|
||||
@@ -190,9 +190,8 @@ session.party = { charizard(), blastoise() }
|
||||
ok = LB.validateParty(session, Link.USING.DOUBLE_BATTLE)
|
||||
check(ok, "two usable mons pass the double battle check")
|
||||
|
||||
ok, reason = LB.validateParty(session, Link.USING.SINGLE_BATTLE, { unionRoom = true })
|
||||
check(not ok, "two level 60 mons cannot enter a union room battle")
|
||||
eq(reason, "level_cap", "UNION_ROOM_MAX_LEVEL refuses them")
|
||||
ok = LB.validateParty(session, Link.USING.SINGLE_BATTLE, { unionRoom = true })
|
||||
check(ok, "two level 60 mons can enter a union room battle")
|
||||
|
||||
session.party = {
|
||||
{ species = 1, level = 12, hp = 30, maxHp = 30, moves = { 33 }, pp = { 35 }, maxPp = { 35 } },
|
||||
@@ -521,15 +520,6 @@ pumpLink(host, guest)
|
||||
Link.attach(host)
|
||||
LB.headless = true
|
||||
LB.fade = false
|
||||
Union.state = "start_activity"
|
||||
Union.activity = Union.ACTIVITY.BATTLE_SINGLE + Union.IN_UNION_ROOM
|
||||
Union.partnerId = 1
|
||||
Union.update(0)
|
||||
eq(Union.state, "print_and_exit", "an over-level party cannot start the union room battle")
|
||||
Union.update(0)
|
||||
eq(Union.state, "main", "and the room goes back to its main loop")
|
||||
eq(Union.activity, nil, "with no pending activity")
|
||||
|
||||
session.party = {
|
||||
legal({ species = 1, level = 12, hp = 30, maxHp = 30, moves = { 33 }, pp = { 35 }, maxPp = { 35 } }),
|
||||
legal({ species = 4, level = 9, hp = 25, maxHp = 25, moves = { 10 }, pp = { 35 }, maxPp = { 35 } }),
|
||||
@@ -549,6 +539,9 @@ guest:send({ type = LB.MSG.SETUP, seed = urSetup and urSetup.seed,
|
||||
host:update(0)
|
||||
Union.update(0)
|
||||
check(Battle.isActive(), "the union room battle started")
|
||||
eq(LB.myParty()[1].level, LB.LINK_LEVEL, "our level 12 mon battles at level 50")
|
||||
eq(LB.myParty()[2].level, LB.LINK_LEVEL, "and so does the level 9 one")
|
||||
eq(session.party[1].level, 12, "while the party itself keeps its real level")
|
||||
eq(Battle.getState().link, true, "with BATTLE_TYPE_LINK")
|
||||
local urClasses = LB.unionRoomClasses()
|
||||
eq(Battle.getState().trainerPicId, urClasses.trainerPic[0x2222 % 8],
|
||||
|
||||
@@ -284,8 +284,9 @@ eq(#mapLoads, 1, "the player was warped back")
|
||||
eq(mapLoads[1] and mapLoads[1].map, COUNTER_MAP, "to the cable club counter map")
|
||||
eq(mapLoads[1] and mapLoads[1].x, 9, "onto the link room door x")
|
||||
eq(mapLoads[1] and mapLoads[1].y, 1, "onto the link room door y")
|
||||
eq(tonumber(Flags.getVar(store, ctx, Link.VAR_CABLE_CLUB_STATE)), 0,
|
||||
"VAR_CABLE_CLUB_STATE is cleared")
|
||||
-- pokefirered/data/scripts/cable_club.inc:106 the 2F's OnFrame exit script clears it
|
||||
check(tonumber(Flags.getVar(store, ctx, Link.VAR_CABLE_CLUB_STATE)) ~= 0,
|
||||
"VAR_CABLE_CLUB_STATE stays set for the Pokemon Center's exit script")
|
||||
|
||||
print("[test] 10. CleanupLinkRoomState restores the bag and asks for the saved party")
|
||||
Link.reset()
|
||||
@@ -323,8 +324,9 @@ mapLoads = {}
|
||||
Natives.special(ctx, NativesLink.SPECIAL.ExitLinkRoom, adapters)
|
||||
eq(#mapLoads, 1, "the player left the link room")
|
||||
eq(mapLoads[1] and mapLoads[1].map, COUNTER_MAP, "back to the counter")
|
||||
eq(tonumber(Flags.getVar(store, ctx, Link.VAR_CABLE_CLUB_STATE)), 0,
|
||||
"VAR_CABLE_CLUB_STATE is cleared")
|
||||
-- pokefirered/data/scripts/cable_club.inc:106 the 2F's OnFrame exit script clears it
|
||||
check(tonumber(Flags.getVar(store, ctx, Link.VAR_CABLE_CLUB_STATE)) ~= 0,
|
||||
"VAR_CABLE_CLUB_STATE stays set for the Pokemon Center's exit script")
|
||||
|
||||
print("[test] 12. the real Pokemon Center 2F door is a dynamic warp back to the counter")
|
||||
local Cache = require("tests.game3_cache")
|
||||
|
||||
@@ -203,17 +203,8 @@ eq(#Screen.items, 4, "with the four pret entries")
|
||||
teq(Screen.labelFor(Screen.items[1]), "GREETINGS", "GREETINGS first")
|
||||
teq(Screen.labelFor(Screen.items[4]), "EXIT", "EXIT last")
|
||||
|
||||
print("[test] 7. BATTLE needs two mons at or below level 30")
|
||||
session.party = { { species = 1, level = 42 } }
|
||||
Screen.cursor = 2
|
||||
Screen.confirm()
|
||||
check(not Screen.isOpen(), "the chooser closed")
|
||||
eq(Union.activity, nil, "an over-level party cannot start a union room battle")
|
||||
|
||||
session.party = { { species = 1, level = 12 }, { species = 4, level = 9 } }
|
||||
Union.state = "do_something_prompt"
|
||||
Union.partnerId = 1
|
||||
Union.update(0)
|
||||
print("[test] 7. BATTLE has no level limit")
|
||||
session.party = { { species = 1, level = 42 }, { species = 4, level = 60 } }
|
||||
Screen.cursor = 2
|
||||
Screen.confirm()
|
||||
eq(Union.activity, Union.ACTIVITY.BATTLE_SINGLE + Union.IN_UNION_ROOM,
|
||||
|
||||
Reference in New Issue
Block a user