Skip to content

Commit

Permalink
feat: 3 new items
Browse files Browse the repository at this point in the history
  • Loading branch information
BigJk committed Jan 12, 2024
1 parent b1546c5 commit ccaf515
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 5 deletions.
21 changes: 21 additions & 0 deletions assets/scripts/_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ function assert_cast_damage(id, dmg)
end
end

function assert_cast_heal(id, heal)
local cards = get_cards(PLAYER_ID)

if not cards[1] then
return "Card not in hand"
end

local card = get_card_instance(cards[1])
if card.type_id ~= id then
return "Card has wrong type: " .. card.type_id
end

deal_damage(PLAYER_ID, PLAYER_ID, 5, true)
local hp_before = get_actor(PLAYER_ID).hp
cast_card(cards[1], PLAYER_ID)

if get_actor(PLAYER_ID).hp ~= hp_before + heal then
return "Expected " .. tostring(hp_before + heal) .. " health, got " .. get_actor(PLAYER_ID).hp
end
end

---assert_status_effect_count asserts that the player has a certain number of status effects, returning an error message if not
---@param count number
---@return string|nil
Expand Down
1 change: 1 addition & 0 deletions assets/scripts/definitions/card.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
---@field point_cost number
---@field max_level number
---@field does_exhaust? boolean
---@field does_consume? boolean
---@field need_target boolean
---@field price number
---@field callbacks callbacks
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/definitions/status_effect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
---@field id? type_id
---@field name string
---@field description string
---@field state fun(ctx:status_effect_state_ctx):nil
---@field state? fun(ctx:status_effect_state_ctx):nil
---@field look string
---@field foreground string
---@field order? number
Expand Down
4 changes: 2 additions & 2 deletions assets/scripts/equipment/flash_bang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ register_card("FLASH_BANG", {
})

register_status_effect("FLASH_BANG", {
name = l("cards.FLASH_BANG.name", "Blinded"),
description = l("cards.FLASH_BANG.description", "Causing " .. highlight("25%") .. " less damage."),
name = l("status_effects.FLASH_BANG.name", "Blinded"),
description = l("status_effects.FLASH_BANG.description", "Causing " .. highlight("25%") .. " less damage."),
look = "FL",
foreground = COLOR_PURPLE,
state = function(ctx) return nil end,
Expand Down
62 changes: 62 additions & 0 deletions assets/scripts/equipment/flash_shield.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
register_card("FLASH_SHIELD", {
name = l("cards.FLASH_SHIELD.name", "Flash Shield"),
description = string.format(
l("cards.FLASH_SHIELD.description","%s\n\nDeploy a temporary shield. %s the next attack."),
highlight("One-Time"), highlight("Negates")
),
tags = { "DEF" },
max_level = 0,
color = COLOR_BLUE,
need_target = false,
does_consume = true,
point_cost = 0,
price = 180,
callbacks = {
on_cast = function(ctx)
give_status_effect("FLASH_SHIELD", ctx.caster, 1 + ctx.level)
return nil
end
}
})

register_status_effect("FLASH_SHIELD", {
name = l("status_effects.FLASH_SHIELD.name", "Flash Shield"),
description = l("status_effects.FLASH_SHIELD.description", "Negates the next attack."),
look = "Fsh",
foreground = COLOR_BLUE,
can_stack = false,
decay = DECAY_ALL,
rounds = 1,
order = 100,
callbacks = {
on_damage_calc = function(ctx)
if ctx.simulated then
return ctx.damage
end

if ctx.target == ctx.owner then
add_status_effect_stacks(ctx.guid, -1)
return 0
end
return ctx.damage
end,
},
test = function()
return assert_chain({
function() return assert_status_effect_count(1) end,
function() return assert_status_effect("FLASH_SHIELD", 1) end,
function ()
local dummy = add_actor_by_enemy("DUMMY")
local damage = deal_damage(dummy, PLAYER_ID, 100)
if damage ~= 0 then
return "Expected 0 damage, got " .. damage
end

damage = deal_damage(dummy, PLAYER_ID, 2)
if damage ~= 2 then
return "Expected 2 damage, got " .. damage
end
end
})
end
})
20 changes: 20 additions & 0 deletions assets/scripts/equipment/stim_pack.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
register_card("STIM_PACK", {
name = l("cards.STIM_PACK.name", "Stim Pack"),
description = l("cards.STIM_PACK.description", highlight("One-Time") .. "\n\nRestores " .. highlight(5) .. " HP."),
tags = { "HEAL" },
max_level = 0,
color = COLOR_BLUE,
need_target = false,
does_consume = true,
point_cost = 0,
price = -1,
callbacks = {
on_cast = function(ctx)
heal(ctx.caster, ctx.caster, 5)
return nil
end
},
test = function ()
return assert_cast_heal("STIM_PACK", 5)
end
})
11 changes: 9 additions & 2 deletions assets/scripts/events/act_0/enemies.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
register_event("RUST_MITE", {
name = "Tasty metals...",
description = [[
You come across a strange being. It seems to be eating the metal from the walls. It looks at you and after a few seconds it rushes towards you. It seems to be hostile.
You are walking through the facility hoping to find a way out. After a few turns you hear a strange noise. You look around and come across a strange being.
It seems to be eating the metal from the walls. It looks at you and after a few seconds it rushes towards you.
**It seems to be hostile!**
]],
tags = {"ACT_0"},
choices = {
Expand All @@ -18,7 +21,11 @@ register_event("RUST_MITE", {
register_event("CLEAN_BOT", {
name = "Corpse. Clean. Engage.",
description = [[
You come across a strange robot. It seems to be cleaning up the area. It looks at you and says "Corpse. Clean. Engage.". You're not sure what it means, but it doesn't seem to be friendly.
While exploring the facility you hear a strange noise. Suddenly a strange robot appears from one of the corridors.
It seems to be cleaning up the area, but it's not working properly anymore and you can see small sparks coming out of it.
It looks at you and says "Corpse. Clean. Engage.".
**You're not sure what it means, but it doesn't seem to be friendly!**
]],
tags = {"ACT_0"},
choices = {
Expand Down

0 comments on commit ccaf515

Please sign in to comment.