|
17 | 17 | function Utils.getHandData() |
18 | 18 | local _hand = { } |
19 | 19 |
|
20 | | - for i = 1, #G.hand.cards do |
21 | | - local _card = Utils.getCardData(G.hand.cards[i]) |
22 | | - _hand[i] = _card |
| 20 | + if G and G.hand and G.hand.cards then |
| 21 | + for i = 1, #G.hand.cards do |
| 22 | + local _card = Utils.getCardData(G.hand.cards[i]) |
| 23 | + _hand[i] = _card |
| 24 | + end |
23 | 25 | end |
24 | 26 |
|
25 | 27 | return _hand |
|
28 | 30 | function Utils.getJokersData() |
29 | 31 | local _jokers = { } |
30 | 32 |
|
31 | | - for i = 1, #G.jokers.cards do |
32 | | - local _card = Utils.getCardData(G.jokers.cards[i]) |
33 | | - _jokers[i] = _card |
| 33 | + if G and G.jokers and G.jokers.cards then |
| 34 | + for i = 1, #G.jokers.cards do |
| 35 | + local _card = Utils.getCardData(G.jokers.cards[i]) |
| 36 | + _jokers[i] = _card |
| 37 | + end |
34 | 38 | end |
35 | 39 |
|
36 | 40 | return _jokers |
|
39 | 43 | function Utils.getConsumablesData() |
40 | 44 | local _consumables = { } |
41 | 45 |
|
42 | | - for i = 1, #G.consumeables.cards do |
43 | | - local _card = Utils.getCardData(G.consumeables.cards[i]) |
44 | | - _consumables[i] = _card |
| 46 | + if G and G.consumables and G.consumables.cards then |
| 47 | + for i = 1, #G.consumeables.cards do |
| 48 | + local _card = Utils.getCardData(G.consumeables.cards[i]) |
| 49 | + _consumables[i] = _card |
| 50 | + end |
45 | 51 | end |
46 | 52 |
|
47 | 53 | return _consumables |
|
68 | 74 |
|
69 | 75 | function Utils.getShopData() |
70 | 76 | local _shop = { } |
71 | | - if not G.shop then return _shop end |
| 77 | + if not G or not G.shop then return _shop end |
72 | 78 |
|
73 | 79 | _shop.reroll_cost = G.GAME.current_round.reroll_cost |
74 | 80 | _shop.cards = { } |
|
0 commit comments