From 4bce308ef5c6cf700652b2a55984b830cfa82cac Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Mon, 2 Sep 2024 12:13:53 +0200 Subject: [PATCH] feat: some new artifacts and cards --- .../equipment/permanents/arm_mounted_gun.lua | 10 ++-- .../equipment/permanents/bio_recycler.lua | 25 +++++++++ .../equipment/permanents/gold_scrapper.lua | 22 ++++++++ .../equipment/permanents/headbut_helmet.lua | 23 ++++++++ .../scripts/equipment/permanents/nullify.lua | 52 +++++++++++++++++++ assets/scripts/events/act_0/other.lua | 4 +- assets/scripts/story_teller/act_0.lua | 31 ++++------- 7 files changed, 139 insertions(+), 28 deletions(-) create mode 100644 assets/scripts/equipment/permanents/bio_recycler.lua create mode 100644 assets/scripts/equipment/permanents/gold_scrapper.lua create mode 100644 assets/scripts/equipment/permanents/headbut_helmet.lua create mode 100644 assets/scripts/equipment/permanents/nullify.lua diff --git a/assets/scripts/equipment/permanents/arm_mounted_gun.lua b/assets/scripts/equipment/permanents/arm_mounted_gun.lua index 7b0242e..66de404 100644 --- a/assets/scripts/equipment/permanents/arm_mounted_gun.lua +++ b/assets/scripts/equipment/permanents/arm_mounted_gun.lua @@ -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 -}) \ No newline at end of file +}) diff --git a/assets/scripts/equipment/permanents/bio_recycler.lua b/assets/scripts/equipment/permanents/bio_recycler.lua new file mode 100644 index 0000000..e4dd373 --- /dev/null +++ b/assets/scripts/equipment/permanents/bio_recycler.lua @@ -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 +}) diff --git a/assets/scripts/equipment/permanents/gold_scrapper.lua b/assets/scripts/equipment/permanents/gold_scrapper.lua new file mode 100644 index 0000000..c1682d3 --- /dev/null +++ b/assets/scripts/equipment/permanents/gold_scrapper.lua @@ -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 +}) diff --git a/assets/scripts/equipment/permanents/headbut_helmet.lua b/assets/scripts/equipment/permanents/headbut_helmet.lua new file mode 100644 index 0000000..40e823d --- /dev/null +++ b/assets/scripts/equipment/permanents/headbut_helmet.lua @@ -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 +}) diff --git a/assets/scripts/equipment/permanents/nullify.lua b/assets/scripts/equipment/permanents/nullify.lua new file mode 100644 index 0000000..ed7f9fd --- /dev/null +++ b/assets/scripts/equipment/permanents/nullify.lua @@ -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 +}) diff --git a/assets/scripts/events/act_0/other.lua b/assets/scripts/events/act_0/other.lua index f8d4750..ccf4f4b 100644 --- a/assets/scripts/events/act_0/other.lua +++ b/assets/scripts/events/act_0/other.lua @@ -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 = { diff --git a/assets/scripts/story_teller/act_0.lua b/assets/scripts/story_teller/act_0.lua index 63e60d7..d59b240 100644 --- a/assets/scripts/story_teller/act_0.lua +++ b/assets/scripts/story_teller/act_0.lua @@ -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