Skip to content

Commit d714c83

Browse files
committed
fix(utils): check if GAME is nil in get_game_state
1 parent 732039c commit d714c83

File tree

1 file changed

+32
-33
lines changed

1 file changed

+32
-33
lines changed

src/lua/utils.lua

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,41 @@ local json = require("json")
1717
---Extracts the current game state including game info, hand, and jokers
1818
---@return G game_state The complete game state
1919
function utils.get_game_state()
20-
local tags = {}
21-
if G.GAME.tags then
22-
for i, tag in pairs(G.GAME.tags) do
23-
tags[i] = {
24-
-- There are a couples of fieds regarding UI. we are not intersted in that.
25-
-- HUD_tag = table/list, -- ??
26-
-- ID = int -- id used in the UI or tag id?
27-
-- ability = table/list, -- ??
28-
-- config = table/list, -- ??
29-
key = tag.key, -- id string of the tag (e.g. "tag_foil")
30-
name = tag.name, -- text string of the tag (e.g. "Foil Tag")
31-
-- pos = table/list, coords of the tags in the UI
32-
-- tag_sprite = table/list, sprite of the tag for the UI
33-
-- tally = int (default 0), -- ??
34-
-- triggered = bool (default false), -- false when the tag will be trigger in later stages.
35-
-- For exaple double money trigger instantly and it's not even add to the tags talbe,
36-
-- while other tags trigger in the next shop phase.
37-
}
20+
local game = nil
21+
if G.GAME then
22+
local tags = {}
23+
if G.GAME.tags then
24+
for i, tag in pairs(G.GAME.tags) do
25+
tags[i] = {
26+
-- There are a couples of fieds regarding UI. we are not intersted in that.
27+
-- HUD_tag = table/list, -- ??
28+
-- ID = int -- id used in the UI or tag id?
29+
-- ability = table/list, -- ??
30+
-- config = table/list, -- ??
31+
key = tag.key, -- id string of the tag (e.g. "tag_foil")
32+
name = tag.name, -- text string of the tag (e.g. "Foil Tag")
33+
-- pos = table/list, coords of the tags in the UI
34+
-- tag_sprite = table/list, sprite of the tag for the UI
35+
-- tally = int (default 0), -- ??
36+
-- triggered = bool (default false), -- false when the tag will be trigger in later stages.
37+
-- For exaple double money trigger instantly and it's not even add to the tags talbe,
38+
-- while other tags trigger in the next shop phase.
39+
}
40+
end
3841
end
39-
end
4042

41-
local last_blind = {
42-
boss = false,
43-
name = "",
44-
}
45-
if G.GAME.last_blind then
46-
last_blind = {
47-
boss = G.GAME.last_blind.boss, -- bool. True if the last blind was a boss
48-
name = G.GAME.last_blind.name, -- str (default "" before entering round 1)
49-
-- When entering round 1, the last blind is set to "Small Blind".
50-
-- So I think that the last blind refers to the blind selected in the most recent BLIND_SELECT state.
43+
local last_blind = {
44+
boss = false,
45+
name = "",
5146
}
52-
end
53-
54-
local game = nil
55-
if G.GAME then
47+
if G.GAME.last_blind then
48+
last_blind = {
49+
boss = G.GAME.last_blind.boss, -- bool. True if the last blind was a boss
50+
name = G.GAME.last_blind.name, -- str (default "" before entering round 1)
51+
-- When entering round 1, the last blind is set to "Small Blind".
52+
-- So I think that the last blind refers to the blind selected in the most recent BLIND_SELECT state.
53+
}
54+
end
5655
game = {
5756
-- STOP_USE = int (default 0), -- ??
5857
bankrupt_at = G.GAME.bankrupt_at,

0 commit comments

Comments
 (0)