feat: some new artifacts and cards

This commit is contained in:
Daniel Schmidt 2024-09-02 12:13:53 +02:00
parent efbc74077a
commit 4bce308ef5
7 changed files with 139 additions and 28 deletions

View File

@ -16,9 +16,11 @@ register_artifact("ARM_MOUNTED_GUN", {
register_card("ARM_MOUNTED_GUN", {
name = l("cards.ARM_MOUNTED_GUN.name", "Arm Mounted Gun"),
description = l("cards.ARM_MOUNTED_GUN.description", "Exhaust. Use your arm mounted gun to deal 15 (+3 for each upgrade) damage."),
description = l("cards.ARM_MOUNTED_GUN.description",
"Exhaust. Use your arm mounted gun to deal 15 (+3 for each upgrade) damage."),
state = function(ctx)
return string.format(l("cards.ARM_MOUNTED_GUN.state", "Use your arm mounted gun to deal %s damage."), highlight(7 + ctx.level * 3))
return string.format(l("cards.ARM_MOUNTED_GUN.state", "%s. Use your arm mounted gun to deal %s damage."),
highlight("Exhaust"), highlight(7 + ctx.level * 3))
end,
tags = { "ATK", "R", "T", "ARM" },
max_level = 1,
@ -33,7 +35,7 @@ register_card("ARM_MOUNTED_GUN", {
return nil
end
},
test = function ()
test = function()
return assert_cast_damage("ARM_MOUNTED_GUN", 7)
end
})
})

View File

@ -0,0 +1,25 @@
register_artifact("BIO_RECYCLER", {
name = "Bio Recycler",
description = "Heal 1 on kill.",
tags = { "_ACT_0" },
price = 200,
order = 0,
callbacks = {
on_actor_die = function(ctx)
if ctx.source == PLAYER_ID then
heal(PLAYER_ID, PLAYER_ID, 1)
end
return nil
end
},
test = function()
local dummy = add_actor_by_enemy("DUMMY")
deal_damage(dummy, PLAYER_ID, 1, true)
local hp_before = get_player().hp
deal_damage(PLAYER_ID, dummy, 100)
local hp_after = get_player().hp
if hp_after - hp_before ~= 1 then
return "Expected 1 HP heal, got " .. (hp_after - hp_before)
end
end
})

View File

@ -0,0 +1,22 @@
register_artifact("GOLD_SCRAPPER", {
name = "Gold Scrapper",
description = "Gain 15 gold on kill.",
tags = { "_ACT_0" },
price = 200,
order = 0,
callbacks = {
on_actor_die = function(ctx)
if ctx.source == PLAYER_ID then
give_player_gold(15)
end
return nil
end
},
test = function()
local dummy = add_actor_by_enemy("DUMMY")
deal_damage(PLAYER_ID, dummy, 100)
if get_player().gold ~= 15 then
return "Expected 15 gold, got " .. get_player().gold
end
end
})

View File

@ -0,0 +1,23 @@
register_artifact("HEADBUT_HELMET", {
name = "Headbut Helmet",
description = "Gain 1 Knock Out card.",
tags = { "_ACT_0" },
price = 200,
order = 0,
callbacks = {
on_pick_up = function(ctx)
give_card("KNOCK_OUT", PLAYER_ID)
return nil
end
},
test = function()
local cards = get_cards(PLAYER_ID)
for _, card_guid in ipairs(cards) do
local card = get_card_instance(card_guid)
if card.type_id == "KNOCK_OUT" then
return nil
end
end
return "Expected to find KNOCK_OUT card, but did not."
end
})

View File

@ -0,0 +1,52 @@
register_card("NULLIFY", {
name = l("cards.NULLIFY.name", "Nullify"),
description = string.format(
l("cards.NULLIFY.description", "%s\n\nDeploy a temporary damage nullifier. %s all damage this round."),
highlight("Exhaust"), highlight("Negates")
),
tags = { "DEF", "_ACT_0" },
max_level = 0,
color = COLOR_BLUE,
need_target = false,
does_exhaust = true,
point_cost = 3,
price = 200,
callbacks = {
on_cast = function(ctx)
give_status_effect("NULLIFY", ctx.caster, 1 + ctx.level)
return nil
end
}
})
register_status_effect("NULLIFY", {
name = l("status_effects.NULLIFY.name", "Nullify Field"),
description = l("status_effects.NULLIFY.description", "Negates all damage this round."),
look = "NF",
foreground = COLOR_BLUE,
can_stack = false,
decay = DECAY_ALL,
rounds = 1,
order = 100,
callbacks = {
on_damage_calc = function(ctx)
if ctx.target == ctx.owner then
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("NULLIFY", 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
end
})
end
})

View File

@ -92,9 +92,9 @@ You found a chest with a strange symbol on it. The chest is protected by a stran
})
register_event("GAIN_GOLD_ACT_0", {
name = "",
name = "Old Gold Cache",
description = [[
...
You find an old chest filled with gold. You can either take it or leave.
]],
tags = { "_ACT_0" },
choices = {

View File

@ -19,42 +19,29 @@ register_story_teller("_ACT_0", {
possible = find_events_by_tags({ "_ACT_0_FIGHT" })
end
print(#get_event_history())
print("[ACT_0 ST] history:", get_event_history())
-- filter out events by id that have already been played
possible = fun.iter(possible):filter(function(event)
return event == "MERCHANT" or not table.contains(history, event.id)
return event.id == "MERCHANT" or not table.contains(history, event.id)
end):totable()
print("[ACT_0 ST] possible:", fun.iter(possible):map(function(e) return e.id end):totable())
-- fallback for now
if #possible == 0 then
possible = find_events_by_tags({ "_ACT_0_FIGHT" })
end
local choosen = possible[random_int(0, #possible)]
local choosen_id = random_int(0, #possible);
print("[ACT_0 ST] choosen_id:", choosen_id)
local choosen = possible[1 + choosen_id]
if choosen ~= nil then
print("[ACT_0 ST] choosen:", choosen.id)
set_event(choosen.id)
end
-- if we cleared a stage, give the player a random artifact
local last_stage_count = fetch("last_stage_count")
local current_stage_count = get_stages_cleared()
if last_stage_count ~= current_stage_count then
local gets_random_artifact = random() < 0.25
if gets_random_artifact then
local player_artifacts = fun.iter(get_actor(PLAYER_ID).artifacts):map(function(id)
return get_artifact(id).id
end):totable()
local artifacts = find_artifacts_by_tags({ "_ACT_0" })
if #artifacts > 0 then
local artifact = choose_weighted_by_price(artifacts)
if not table.contains(player_artifacts, artifact) then
give_artifact(PLAYER_ID, artifact)
end
end
end
end
return GAME_STATE_EVENT
end