Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

[*]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
end_of_line = lf

[*.md]
indent_size = 4

[Makefile]
indent_style = tab

[*.lua]
indent_size = 4

15 changes: 15 additions & 0 deletions .github/workflows/pr_check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lua Linting
uses: lunarmodules/luacheck@v1
with:
args: ./src

67 changes: 67 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
std = {
globals = {
"love",
"G",
"localize",
"generate_card_ui",
"UIBox_button",
"Moveable",
"Event",
"card_generate_uibox_ability_table",
"Card",
"ease_discard",
"ease_hands_played",
"ease_dollars",
"Back",
"Game",
"mods",
"LOGGERS",
"START_TIME",
"inject",
"injectHead",
"injectTail",
"os",
"UIBox",
"is_loaded",
"buildPaths",
"current_game_code",
"escaped_function_body",
"escaped_modified_function_code",
"original_testFunction",
"testFunction",
"error",
"select",
"rawget",
"loc_parse_string",
"create_playing_card",
"playing_card_joker_effects"
},
read_globals = {
"string",
"math",
"pairs",
"ipairs",
"table",
"tonumber",
"tostring",
"setmetatable",
"getmetatable",
"next",
"type",
"assert",
"pcall",
"require",
"pseudorandom",
"pseudorandom_element",
"pseudoseed",
"create_option_cycle",
"create_badge",
"create_UIBox_generic_options",
"create_tabs",
"setfenv",
"load",
"getfenv"
}
}

unused_args = false
2 changes: 1 addition & 1 deletion src/assets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ local function getAtli(modId, textureScaling)
local atliPath = "mods/" .. modId .. "/assets/textures/"..textureScaling.."x"
local dir = love.filesystem.getDirectoryItems(atliPath)
for i, path in ipairs(dir) do
local filename, extension = string.match(path, "([^/]+)%.(.+)$")
local filename, _ = string.match(path, "([^/]+)%.(.+)$")
local name = modId .. "_" .. filename
local image = love.graphics.newImage(atliPath.."/"..path, {mipmaps = true, dpiscale = textureScaling})
local assetType = assetTypes[string.match(filename, "(.+)_")]
Expand Down
9 changes: 4 additions & 5 deletions src/balamod.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local utils = require('utils')
local tar = require('tar')
local https = require('https')

logger = logging.getLogger('balamod')
local logger = logging.getLogger('balamod')
mods = {}
local apis = {
logging = logging,
Expand Down Expand Up @@ -68,8 +68,7 @@ end

local function request(url)
logger:debug('Request made with url: ', url)
local code
local response
local code, response, headers
code, response, headers = https.request(url, {headers = {['User-Agent'] = 'Balamod-Client'}})
if (code == 301 or code == 302) and headers.location then
-- follow redirects if necessary
Expand Down Expand Up @@ -764,7 +763,7 @@ mods["dev_console"] = {
else
G.consumeables:emplace(c1)
end

G.CONTROLLER:save_cardarea_focus('jokers')
G.CONTROLLER:recall_cardarea_focus('jokers')
return true
Expand Down Expand Up @@ -1235,4 +1234,4 @@ return {
toggleMod = toggleMod,
sortMods = sortMods,
callModCallbacksIfExists = callModCallbacksIfExists,
}
}
6 changes: 3 additions & 3 deletions src/balamod_back.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local back_apply_to_run = back_apply_to_run or Back.apply_to_run
local back_apply_to_run = back_apply_to_run or Back.apply_to_run -- luacheck: ignore

function Back:apply_to_run()
if self.effect.config.cards then
G.GAME.starting_params.cards = self.effect.config.cards
end
back_apply_to_run(self)
end
back_apply_to_run(self) -- luacheck: ignore
end
27 changes: 13 additions & 14 deletions src/balamod_card.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
local joker = require('joker')
local seal = require('seal')
local assets = require('assets')
local logging = require('logging')
local logger = logging.getLogger('card')
local logger = logging.getLogger('card') -- luacheck: ignore
local consumable = require("consumable")

-- references to original patched functions
local card_calculate_joker = card_calculate_joker or Card.calculate_joker
local card_generate_uibox_ability_table = card_generate_uibox_ability_table or Card.generate_UIBox_ability_table
local card_set_sprites = card_set_sprites or Card.set_sprites
local card_calculate_seal = card_calculate_seal or Card.calculate_seal
local card_get_end_of_round_effect = card_get_end_of_round_effect or Card.get_end_of_round_effect
local card_eval_card = eval_card
local card_open = card_open or Card.open
local card_calculate_dollar_bonus = Card.calculate_dollar_bonus
local card_add_to_deck = Card.add_to_deck
local card_remove_from_deck = Card.remove_from_deck
local card_use_consumeable = Card.use_consumeable
local card_can_use_consumeable = Card.can_use_consumeable
local card_calculate_joker = card_calculate_joker or Card.calculate_joker -- luacheck: ignore
local card_generate_uibox_ability_table = card_generate_uibox_ability_table or Card.generate_UIBox_ability_table -- luacheck: ignore
local card_set_sprites = card_set_sprites or Card.set_sprites -- luacheck: ignore
local card_calculate_seal = card_calculate_seal or Card.calculate_seal -- luacheck: ignore
local card_get_end_of_round_effect = card_get_end_of_round_effect or Card.get_end_of_round_effect -- luacheck: ignore
local card_eval_card = eval_card -- luacheck: ignore
local card_open = card_open or Card.open -- luacheck: ignore
local card_calculate_dollar_bonus = Card.calculate_dollar_bonus -- luacheck: ignore
local card_add_to_deck = Card.add_to_deck -- luacheck: ignore
local card_remove_from_deck = Card.remove_from_deck -- luacheck: ignore
local card_use_consumeable = Card.use_consumeable -- luacheck: ignore
local card_can_use_consumeable = Card.can_use_consumeable -- luacheck: ignore


function Card:calculate_joker(context)
Expand Down
4 changes: 2 additions & 2 deletions src/balamod_game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ local logging = require('logging')
local logger = logging.getLogger('game')
local balamod = require('balamod')

local game_set_render_settings = game_set_render_settings or Game.set_render_settings
local game_start_run = game_start_run or Game.start_run
local game_set_render_settings = game_set_render_settings or Game.set_render_settings -- luacheck: ignore
local game_start_run = game_start_run or Game.start_run -- luacheck: ignore

function Game:set_render_settings()
game_set_render_settings(self)
Expand Down
17 changes: 13 additions & 4 deletions src/balamod_love.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ local game_love_mousepressed = love.mousepressed
local game_love_mousereleased = love.mousereleased
local game_love_mousemoved = love.mousemoved
local game_love_wheelmoved = love.wheelmoved
local game_love_textinput = love.textinput
local game_love_resize = love.resize
local game_love_textinput = love.textinput -- luacheck: ignore
local game_love_resize = love.resize -- luacheck: ignore
local game_love_quit = love.quit
local game_love_load = love.load
local game_love_gamepad_pressed = love.gamepadpressed
Expand All @@ -21,6 +21,8 @@ local utils = require('utils')
local logger = logging.getLogger('love')
local localization = require('localization')

local status, message

function love.load(args)
local status, message = pcall(balamod.callModCallbacksIfExists, balamod.mods, "on_game_load", true, args)
if not status then
Expand Down Expand Up @@ -69,7 +71,7 @@ function love.update(dt)
end
end

local status, result = pcall(balamod.callModCallbacksIfExists, balamod.mods, "on_post_update", false, dt)
status, result = pcall(balamod.callModCallbacksIfExists, balamod.mods, "on_post_update", false, dt)
if not status then
logger:warn("Failed on_post_update for mods: ", result)
end
Expand Down Expand Up @@ -227,7 +229,14 @@ end

function love.joystickaxis(joystick, axis, value)
local cancel_event = false
local status, result = pcall(balamod.callModCallbacksIfExists, balamod.mods, "on_joystick_axis", false, joystick, axis, value)
local status, result = pcall(
balamod.callModCallbacksIfExists,
balamod.mods, "on_joystick_axis",
false,
joystick,
axis,
value
)
if not status then
logger:warn("Failed on_joystick_axis for mods: ", result)
else
Expand Down
5 changes: 2 additions & 3 deletions src/balamod_misc_functions.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
local localization = require('localization')
local consumable = require("consumable")
local utils = require("utils")

local misc_functions_init_localization = misc_functions_init_localization or init_localization
local misc_generate_card_ui = generate_card_ui
local misc_functions_init_localization = misc_functions_init_localization or init_localization -- luacheck: ignore
local misc_generate_card_ui = generate_card_ui -- luacheck: ignore

function init_localization()
localization.inject()
Expand Down
35 changes: 17 additions & 18 deletions src/challenge.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
local _MODULE = {}
_MODULE._VERSION = "1.0.0"

local balamod = require("balamod")
local logging = require("logging")
local logger = logging.getLogger("challenge")
local utils = require("utils")
-- local utils = require("utils")
_MODULE.logger = logger
local challenges = {}

Expand Down Expand Up @@ -39,23 +38,23 @@ local allModifiers = {
"hand_size",
}

local function isIdInTable(id, theTable)
for _, value in ipairs(theTable) do
if value.id == id then
return true
end
end
return false
end
-- local function isIdInTable(id, theTable)
-- for _, value in ipairs(theTable) do
-- if value.id == id then
-- return true
-- end
-- end
-- return false
-- end

local function isValueForIdInTable(id, value, theTable)
for _, v in ipairs(theTable) do
if v.id == id and v.value == value then
return true
end
end
return false
end
-- local function isValueForIdInTable(id, value, theTable)
-- for _, v in ipairs(theTable) do
-- if v.id == id and v.value == value then
-- return true
-- end
-- end
-- return false
-- end

local function validateChallengeId(challengeId)
if challengeId == nil then
Expand Down
13 changes: 9 additions & 4 deletions src/deck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

local utils = require("utils")
local logging = require("logging")
local logger = logging.getLogger("deck")
local logger = logging.getLogger("deck") -- luacheck: ignore
local math = require("math")


Expand All @@ -11,7 +11,7 @@ _MODULE._VERSION = "1.0.0"
local decks = {}
local GAME_BACKS = utils.copyTable(G.P_CENTER_POOLS.Back, true) -- copy the original table

local function getNextOrder()
local function getNextOrder() -- luacheck: ignore
local latestOrder = utils.reduce(
G.P_CENTER_POOLS.Back,
function(acc, deck)
Expand All @@ -24,7 +24,7 @@ end

local function computeDeckOrders()
local latestOrder = utils.reduce(
GAME_BACKS
GAME_BACKS,
function(acc, deck)
return math.max(acc, deck.order or 1)
end,
Expand All @@ -41,7 +41,12 @@ local function add(deck_id, deck)
computeDeckOrders()
G.P_CENTERS[deck_id] = decks[deck_id]
table.insert(G.P_CENTER_POOLS.Back, deck)
table.sort(self.P_CENTER_POOLS["Back"], function (a, b) return (a.order - (a.unlocked and 100 or 0)) < (b.order - (b.unlocked and 100 or 0)) end)
table.sort(
self.P_CENTER_POOLS["Back"],
function (a, b)
return (a.order - (a.unlocked and 100 or 0)) < (b.order - (b.unlocked and 100 or 0))
end
)
end

local function remove(deck_id)
Expand Down
Loading