Skip to content

Commit

Permalink
feat: act_0 basic content
Browse files Browse the repository at this point in the history
  • Loading branch information
BigJk committed Jan 16, 2024
1 parent 68d9de1 commit d3afc3b
Show file tree
Hide file tree
Showing 32 changed files with 700 additions and 116 deletions.
2 changes: 1 addition & 1 deletion assets/scripts/_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function assert_cast_damage(id, dmg)
local cards = get_cards(PLAYER_ID)

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

local card = get_card_instance(cards[1])
Expand Down
16 changes: 15 additions & 1 deletion assets/scripts/_util.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
local function _escape_color(number)
local escapeString = string.char(27) .. '[%sm'
return escapeString:format(number)
end

---highlight some value
---@param val any
function highlight(val)
Expand All @@ -7,7 +12,13 @@ end
---highlight_warn some value with warning colors
---@param val any
function highlight_warn(val)
return text_underline(text_bold(text_red("[" .. tostring(val) .. "]")))
return text_underline(text_bold(_escape_color("38;5;161") .. "[" .. tostring(val) .. "]" .. string.char(27) .. "[0m"))
end

---highlight_success some value with success colors
---@param val any
function highlight_success(val)
return text_underline(text_bold(_escape_color("38;5;119") .. "[" .. tostring(val) .. "]" .. string.char(27) .. "[0m"))
end

---choose_weighted chooses an item from a list of choices, with a weight for each item.
Expand Down Expand Up @@ -35,6 +46,9 @@ end

---table.contains check if a table contains an element.
function table.contains(table, element)
if table == nil then
return false
end
for _, value in pairs(table) do
if value == element then
return true
Expand Down
14 changes: 9 additions & 5 deletions assets/scripts/definitions/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ function text_bold(value) end
---@return string
function text_italic(value) end

--- Makes the text colored red.
---@param value any
---@return string
function text_red(value) end

--- Makes the text underlined.
---@param value any
---@return string
Expand Down Expand Up @@ -342,6 +337,15 @@ function upgrade_random_card(actor_guid) end
---@return number
function deal_damage(source, target, damage, flat) end

--- Deal damage from one source to a target from a card. If flat is true the damage can't be modified by status effects or artifacts. Returns the damage that was dealt.
---@param source guid
---@param card guid
---@param target guid
---@param damage number
---@param flat? boolean
---@return number
function deal_damage_card(source, card, target, damage, flat) end

--- Deal damage to multiple enemies from one source. If flat is true the damage can't be modified by status effects or artifacts. Returns a array of damages for each actor hit.
---@param source guid
---@param targets guid[]
Expand Down
1 change: 1 addition & 0 deletions assets/scripts/definitions/callbacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
---@field type_id? type_id
---@field guid? guid
---@field source? guid
---@field card? guid
---@field target? guid
---@field owner? guid
---@field caster? guid
Expand Down
25 changes: 25 additions & 0 deletions assets/scripts/enemies/cyber_spider.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
register_enemy("CYBER_SPIDER", {
name = "CYBER Spider",
description = "It waits for its prey to come closer",
look = [[/\o^o/\]],
color = "#ff4d6d",
initial_hp = 8,
max_hp = 8,
gold = 15,
intend = function(ctx)
if ctx.round > 0 and ctx.round % 3 == 0 then
return "Deal " .. highlight(5) .. " damage"
end

return "Wait..."
end,
callbacks = {
on_turn = function(ctx)
if ctx.round > 0 and ctx.round % 3 == 0 then
deal_damage(ctx.guid, PLAYER_ID, 5)
end

return nil
end
}
})
3 changes: 2 additions & 1 deletion assets/scripts/equipment/_colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ COLOR_GRAY = "#2f3e46"
COLOR_BLUE = "#219ebc"
COLOR_PURPLE = "#725e9c"
COLOR_RED = "#c1121f"
COLOR_GREEN = "#a7c957"
COLOR_GREEN = "#a7c957"
COLOR_ORANGE = "#fb5607"
18 changes: 10 additions & 8 deletions assets/scripts/equipment/_util.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
function add_found_artifact_event(id, picture, description, choice_description)
function add_found_artifact_event(id, picture, description, choice_description, tags)
register_event(id, {
name = "Found: " .. registered.artifact[id].name,
description = string.format("!!%s\n\n**You found something!** %s", picture or "artifact_chest.jpg", description),
tags = tags,
choices = {
{
description_fn = function()
Expand All @@ -11,15 +12,16 @@ function add_found_artifact_event(id, picture, description, choice_description)
give_artifact(id, PLAYER_ID)
return nil
end
}, {
description = "Leave...",
callback = function()
return nil
end
}
},
{
description = "Leave...",
callback = function()
return nil
end
}
},
on_end = function()
return GAME_STATE_RANDOM
end
})
end
end
2 changes: 1 addition & 1 deletion assets/scripts/equipment/consumeable/bounce_shield.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ register_card("BOUNCE_SHIELD", {
l("cards.BOUNCE_SHIELD.description","%s\n\nDeploy a temporary shield. %s bounces the damage back, but still takes damage."),
highlight("One-Time"), highlight("Negates")
),
tags = { "DEF" },
tags = { "DEF", "_ACT_0" },
max_level = 0,
color = COLOR_BLUE,
need_target = false,
Expand Down
58 changes: 58 additions & 0 deletions assets/scripts/equipment/consumeable/energy_drink.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
local drinks = {
{
id = "ENERGY_DRINK",
name = "ENRGY Drink X91",
description = "Gain 1 action point.",
price = 150,
action_points = 1,
},
{
id = "ENERGY_DRINK_2",
name = "ENRGY Drink X92",
description = "Gain 2 action points.",
price = 250,
action_points = 2,
},
{
id = "ENERGY_DRINK_3",
name = "ENRGY Drink X93",
description = "Gain 3 action points.",
price = 350,
action_points = 3,
},
}

for _, drink in ipairs(drinks) do
register_card(drink.id, {
name = l("cards." .. drink.id .. ".name", drink.name),
description = string.format(
l("cards." .. drink.id .. ".description","%s\n\n%s"),
highlight("One-Time"),
drink.description
),
tags = { "UTIL", "_ACT_0" },
max_level = 0,
color = COLOR_ORANGE,
need_target = false,
does_consume = true,
point_cost = 0,
price = drink.price,
callbacks = {
on_cast = function(ctx)
player_give_action_points(drink.action_points)
return nil
end
},
test = function ()
return assert_chain({
function() return assert_card_present(drink.id) end,
function() return assert_cast_card(drink.id) end,
function()
if get_fight().current_points ~= 3 + drink.action_points then
return "Expected " .. tostring(3 + drink.action_points) .. " points, got " .. get_fight().current_points
end
end,
})
end
})
end
2 changes: 1 addition & 1 deletion assets/scripts/equipment/consumeable/flash_bang.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
register_card("FLASH_BANG", {
name = l("cards.FLASH_BANG.name", "Flash Bang"),
description = l("cards.FLASH_BANG.description", highlight("One-Time") .. "\n\nInflicts " .. highlight("Blinded") .. " on the target, causing them to deal less damage."),
tags = { "CC" },
tags = { "CC", "_ACT_0" },
max_level = 0,
color = COLOR_PURPLE,
need_target = true,
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/equipment/consumeable/flash_shield.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ register_card("FLASH_SHIELD", {
l("cards.FLASH_SHIELD.description","%s\n\nDeploy a temporary shield. %s the next attack."),
highlight("One-Time"), highlight("Negates")
),
tags = { "DEF" },
tags = { "DEF", "_ACT_0" },
max_level = 0,
color = COLOR_BLUE,
need_target = false,
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/equipment/consumeable/nano_charger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ register_card("NANO_CHARGER", {
l("cards.NANO_CHARGER.description","%s\n\nSupercharge your next attack. Deals %s damage."),
highlight("One-Time"), highlight("Double")
),
tags = { "BUFF" },
tags = { "BUFF", "_ACT_0" },
max_level = 0,
color = COLOR_RED,
need_target = false,
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/equipment/consumeable/stim_pack.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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" },
tags = { "HEAL", "_ACT_0" },
max_level = 0,
color = COLOR_BLUE,
need_target = false,
Expand Down
61 changes: 61 additions & 0 deletions assets/scripts/equipment/consumeable/ultra_flash_shield.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
register_card("ULTRA_FLASH_SHIELD", {
name = l("cards.ULTRA_FLASH_SHIELD.name", "Ultra Flash Shield"),
description = string.format(
l("cards.ULTRA_FLASH_SHIELD.description","%s\n\nDeploy a temporary shield. %s all attack this turn."),
highlight("One-Time"), highlight("Negates")
),
tags = { "DEF", "_ACT_0" },
max_level = 0,
color = COLOR_BLUE,
need_target = false,
does_consume = true,
point_cost = 3,
price = 250,
callbacks = {
on_cast = function(ctx)
give_status_effect("ULTRA_FLASH_SHIELD", ctx.caster, 1 + ctx.level)
return nil
end
}
})

register_status_effect("ULTRA_FLASH_SHIELD", {
name = l("status_effects.ULTRA_FLASH_SHIELD.name", "Ultra Flash Shield"),
description = l("status_effects.ULTRA_FLASH_SHIELD.description", "Negates all attacks."),
look = "UFS",
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
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("ULTRA_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 ~= 0 then
return "Expected 0 damage, got " .. damage
end
end
})
end
})
2 changes: 1 addition & 1 deletion assets/scripts/equipment/permanents/arm_mounted_gun.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ register_card("ARM_MOUNTED_GUN", {
price = -1,
callbacks = {
on_cast = function(ctx)
deal_damage(ctx.caster, ctx.target, 7 + ctx.level * 3)
deal_damage_card(ctx.caster, ctx.guid, ctx.target, 7 + ctx.level * 3)
return nil
end
},
Expand Down
8 changes: 6 additions & 2 deletions assets/scripts/equipment/permanents/basic_hand_weapons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ HAND_WEAPONS = {
base_damage = 2,
base_cards = 3,
tags = { "ATK", "M", "T", "HND" },
event_tags = { "_ACT_0" },
additional_cards = { "KNOCK_OUT" },
price = 80
},
Expand All @@ -19,6 +20,7 @@ HAND_WEAPONS = {
base_damage = 3,
base_cards = 3,
tags = { "ATK", "M", "T", "HND" },
event_tags = { "_ACT_0" },
additional_cards = { "VIBRO_OVERCLOCK" },
price = 180
},
Expand All @@ -29,6 +31,7 @@ HAND_WEAPONS = {
base_damage = 4,
base_cards = 3,
tags = { "ATK", "R", "T", "HND" },
event_tags = { "_ACT_1" },
additional_cards = { "LZR_OVERCHARGE" },
price = 280
},
Expand All @@ -39,6 +42,7 @@ HAND_WEAPONS = {
base_damage = 5,
base_cards = 3,
tags = { "ATK", "R", "T", "HND" },
event_tags = { "_ACT_1" },
additional_cards = { "HAR_BURST", "TARGET_PAINTER" },
price = 380
}
Expand All @@ -61,7 +65,7 @@ for _, weapon in pairs(HAND_WEAPONS) do
price = 0,
callbacks = {
on_cast = function(ctx)
deal_damage(ctx.caster, ctx.target, weapon.base_damage + ctx.level * 3)
deal_damage_card(ctx.caster, ctx.guid, ctx.target, weapon.base_damage + ctx.level * 3)
return nil
end
},
Expand Down Expand Up @@ -117,7 +121,7 @@ for _, weapon in pairs(HAND_WEAPONS) do
}
})

add_found_artifact_event(weapon.id, weapon.image, string.format("%s\n\n%s", weapon.description, hand_warning), registered.card[weapon.id].description)
add_found_artifact_event(weapon.id, weapon.image, string.format("%s\n\n%s", weapon.description, hand_warning), registered.card[weapon.id].description, weapon.event_tags)
end

---hand_weapon_event returns a random hand weapon event weighted by price.
Expand Down
22 changes: 22 additions & 0 deletions assets/scripts/equipment/permanents/combat_glasses.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
register_artifact("COMBAT_GLASSES", {
name = "Combat Glasses",
description = "Whenever you play a " .. highlight("Ranged (R)") .. " card, deal " .. highlight("1 additional damage"),
tags = { "_ACT_0" },
price = 100,
order = 0,
callbacks = {
on_damage_calc = function(ctx)
local card = get_card(ctx.card)
if card ~= nil then
if table.contains(card.tags, "R") and ctx.source == ctx.owner and ctx.target ~= ctx.owner then
return ctx.damage + 1
end
end
return ctx.damage
end
},
test = function()
give_card(HAND_WEAPONS[2].id, PLAYER_ID)
return assert_cast_damage(HAND_WEAPONS[2].id, HAND_WEAPONS[2].base_damage + 1)
end
});
Loading

0 comments on commit d3afc3b

Please sign in to comment.