|
33 | 33 | -- card is the card instance you are dealing with. 99% of the time it will be just card (the one provided you by the function) |
34 | 34 | -- table is the reference table to look up and compare. |
35 | 35 | function FG.alternate_card(key,card,table) |
36 | | - local convert_to = FG.get_equivalent(key,table,FG.is_alternate(key,table)) |
| 36 | + local _table = table or FG.joker_equivalents |
| 37 | + local convert_to = FG.get_equivalent(key,_table,FG.is_alternate(key,_table)) |
37 | 38 | local new_card = SMODS.add_card({ |
38 | 39 | set = 'Joker', |
39 | 40 | skip_materialize = true, |
40 | 41 | key = tostring(convert_to), |
41 | 42 | }) |
42 | 43 | if card.edition then |
43 | | - new_card:set_edition(tostring(card.edition.key),true,true) |
44 | | - else |
45 | | - new_card:set_edition(nil,true,true) |
| 44 | + FG.update_edition(new_card) |
46 | 45 | end |
47 | 46 | card:start_dissolve(nil,false,0,true) |
48 | 47 | end |
49 | 48 |
|
50 | | -function FG.flip_editions(card) |
| 49 | +-- Allows to integrate original<>alternate entries to the mod's tables. |
| 50 | +-- Target table: The table you are adding entries to. |
| 51 | +-- Source table: The table you are taking entries from. |
| 52 | +function FG.register_alternate(target_table, source_table) |
| 53 | + if not target_table or not source_table then |
| 54 | + sendWarnMessage("Missing or incorrect arguments: target_table [table], source_table [table]","Fool's Gambit/register_cards") |
| 55 | + return |
| 56 | + end |
| 57 | + for k,v in pairs(source_table) do |
| 58 | + target_table[k] = v |
| 59 | + end |
| 60 | +end |
| 61 | + |
| 62 | +-- card is the old card, that is being deleted |
| 63 | +-- new_card is the new card created for alternating. |
| 64 | +function FG.update_alternate_values(old_card,new_card) |
| 65 | + for k,v in ipairs(old_card.config.extra.alternating_values) do |
| 66 | + new_card.config.extra.alternating_values.k = v |
| 67 | + end |
| 68 | +end |
| 69 | + |
| 70 | +-- Transfers the edition from the old card to the new card. |
| 71 | +-- card is the card object of which the edition has to be updated. |
| 72 | +function FG.update_edition(card) |
51 | 73 | if card.edition then |
52 | | - if card.edition.negative then |
53 | | - card:set_edition(nil, true) |
54 | | - elseif card.edition.polychrome then |
55 | | - card:set_edition("e_fg_polished", true) |
56 | | - elseif card.edition.fg_polished then |
57 | | - card:set_edition("e_polychrome", true) |
58 | | - elseif card.edition.holo then |
59 | | - card:set_edition("e_foil", true) |
60 | | - elseif card.edition.foil then |
61 | | - card:set_edition("e_holo", true) |
62 | | - end |
| 74 | + card:set_edition(tostring(card.edition.key),true,true) |
63 | 75 | else |
64 | | - card:set_edition("e_negative", true) |
| 76 | + card:set_edition(nil,true,true) |
65 | 77 | end |
66 | 78 | end |
67 | 79 |
|
68 | 80 | -- UNFINISHED !!! |
69 | 81 | function FG.change_pace() |
70 | 82 | if common_alt.default_weight > 0 then |
71 | 83 | sendInfoMessage("Regular", "MyInfoLogger") |
72 | | - common_alt.default_weight = 0 |
73 | | - uncommon_alt.default_weight = 0 |
74 | | - rare_alt.default_weight= 0 |
| 84 | + common_alt.default_weight = 0 |
| 85 | + uncommon_alt.default_weight = 0 |
| 86 | + rare_alt.default_weight= 0 |
75 | 87 | else |
76 | 88 | sendInfoMessage("Alternate", "MyInfoLogger") |
77 | 89 | common_alt.default_weight = .70 |
|
0 commit comments