mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-09-26 13:33:27 -04:00
a9ce423bdc
CLOSES #1275, CLOSES #1295, CLOSES #1384, CLOSES #1628, CLOSES #1677, CLOSES #1682, CLOSES #1691, CLOSES #1813, CLOSES #1822, CLOSES #1861, CLOSES #1867, CLOSES #1868, CLOSES #1869, CLOSES #1870, CLOSES #1871, CLOSES #1872, CLOSES #1874, CLOSES #1876, CLOSES #1878, CLOSES #1880, CLOSES #1881, CLOSES #1882, CLOSES #1884, CLOSES #1885, CLOSES #1886, CLOSES #1887, CLOSES #1888, CLOSES #1889, CLOSES #1890, CLOSES #1891, CLOSES #1892, CLOSES #1893, CLOSES #1894, CLOSES #1895, CLOSES #1896, CLOSES #1899, CLOSES #1900, CLOSES #1901
106 lines
3.4 KiB
Lua
106 lines
3.4 KiB
Lua
-- pokered engine/items/item_effects.asm:1-3 (#1882)
|
|
|
|
package.path = "./?.lua;./?/init.lua;" .. package.path
|
|
|
|
local T = require("tests.harness")
|
|
local check, eq = T.check, T.eq
|
|
love = love or require("tests.love_stub")
|
|
|
|
local ItemEffects = require("src.inventory.ItemEffects")
|
|
|
|
local data = {
|
|
items = { POKE_FLUTE = { id = "POKE_FLUTE", index = 49, name = "POKé FLUTE" },
|
|
POTION = { id = "POTION", index = 1, name = "POTION", price = 300 } },
|
|
text = {},
|
|
}
|
|
|
|
local function newSave(status)
|
|
return {
|
|
party = { { species = "CHARMANDER", hp = 20, stats = { hp = 20 },
|
|
level = 12, status = status } },
|
|
player = { name = "RED" },
|
|
inventory = { POKE_FLUTE = 1, POTION = 1 },
|
|
options = {}, flags = {},
|
|
}
|
|
end
|
|
|
|
local function newBattle(save, enemyStatus)
|
|
return {
|
|
player = { mon = save.party[1] },
|
|
enemy = { mon = { species = "PIDGEY", hp = 15, stats = { hp = 15 },
|
|
level = 8, status = enemyStatus } },
|
|
enemyParty = {},
|
|
}
|
|
end
|
|
|
|
do
|
|
local save = newSave(nil)
|
|
local battle = newBattle(save, nil)
|
|
local result, msgs = ItemEffects.use(data, save, "POKE_FLUTE", nil, battle)
|
|
eq(result, "kept", "nothing asleep still takes the turn")
|
|
check(msgs and msgs[1] and msgs[1]:find("catchy"),
|
|
"and prints PlayedFluteNoEffectText")
|
|
eq(save.inventory.POKE_FLUTE, 1, "the flute is a key item, never consumed")
|
|
end
|
|
|
|
do
|
|
local save = newSave("SLP")
|
|
local battle = newBattle(save, nil)
|
|
local result = ItemEffects.use(data, save, "POKE_FLUTE", nil, battle)
|
|
eq(result, "flute", "a sleeping party mon is the had-effect arm")
|
|
eq(save.party[1].status, nil, "WakeUpEntireParty cleared the sleep")
|
|
end
|
|
|
|
do
|
|
local save = newSave(nil)
|
|
local battle = newBattle(save, "SLP")
|
|
local result = ItemEffects.use(data, save, "POKE_FLUTE", nil, battle)
|
|
eq(result, "flute", "a sleeping active enemy is the had-effect arm too")
|
|
end
|
|
|
|
do
|
|
local save = newSave(nil)
|
|
local battle = newBattle(save, nil)
|
|
local result = ItemEffects.use(data, save, "POTION", save.party[1], battle)
|
|
eq(result, "failed", "a POTION on a full-HP mon still costs no turn")
|
|
end
|
|
|
|
package.loaded["src.render.TextBox"] = {
|
|
new = function(_, text, done) return { textBox = true, text = text, done = done } end,
|
|
soundOpts = function(_, _, opts) return opts end,
|
|
}
|
|
package.loaded["src.ui.BagMenu"] = nil
|
|
local BagMenu = require("src.ui.BagMenu")
|
|
|
|
do
|
|
local save = newSave(nil)
|
|
local battle = newBattle(save, nil)
|
|
local turns = 0
|
|
battle.itemUsed = function() turns = turns + 1 end
|
|
local game = { data = data, save = save }
|
|
game.stack = { states = {},
|
|
push = function(self, s) table.insert(self.states, s) end,
|
|
pop = function(self) return table.remove(self.states) end,
|
|
top = function(self) return self.states[#self.states] end }
|
|
local list = BagMenu.new(game, { battle = battle })
|
|
game.stack:push(list)
|
|
local row
|
|
for i, item in ipairs(list.items) do
|
|
if item.value == "POKE_FLUTE" then row = i end
|
|
end
|
|
if check(row ~= nil, "the flute is in the battle bag") then
|
|
list.index = row
|
|
list.onChoose(list.items[row], list)
|
|
local box = game.stack:top()
|
|
if check(box and box.textBox, "the no-effect line is up") then
|
|
eq(turns, 0, "the turn waits on the message")
|
|
game.stack:pop()
|
|
box.done()
|
|
eq(turns, 1, "dismissing it spends the turn")
|
|
eq(game.stack:top(), nil, "and the bag is gone, not back on ITEMS")
|
|
end
|
|
end
|
|
end
|
|
|
|
T.finish("poke_flute_battle_turn_bug1882")
|