-
Notifications
You must be signed in to change notification settings - Fork 3
/
BadAppleJoker.lua
231 lines (203 loc) · 8.35 KB
/
BadAppleJoker.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
--- STEAMODDED HEADER
--- MOD_NAME: Bad Apple Joker
--- MOD_ID: BadApple
--- MOD_AUTHOR: [JamestheJellyfish]
--- MOD_DESCRIPTION: Adds the Bad Apple Joker to the game
----------------------------------------------
------------MOD CODE -------------------------
--[[SMODS.Joker:new(
name, slug,
config,
spritePos, loc_txt,
rarity, cost, unlocked, discovered, blueprint_compat, eternal_compat
)
]]
function SMODS.INIT.BadApple()
local localization = {
bad_apple_joker = {
name = "Bad Apple Joker",
text = {
"You aren't quite sure what this",
"does. But it sure is intriguing to look at.",
}
},
}
-- Localization
init_localization()
local jokers = {
bad_apple_joker = SMODS.Joker:new(
"Bad Apple Joker", "",
{},
{}, "",
3, 10, true, true, false, true
),
}
-- Blacklist individual Jokers here
local jokerBlacklists = {
bad_apple_joker = false
}
sendDebugMessage("Loaded BadAppleJoker~")
-- Add Jokers to center
for k, v in pairs(jokers) do
if not jokerBlacklists[k] then
v.slug = "j_" .. k
v.loc_txt = localization[k]
v.spritePos = { x = 0, y = 0 }
v:register()
SMODS.Sprite:new("BadApple", SMODS.findModByID("BadApple").path, v.slug..".png", 71, 95, "animation_atli", 6555):register()
end
end
end
local set_sprites_ref = Card.set_sprites
function Card:set_sprites(_center, _front)
if _center then
if _center.name == 'Bad Apple Joker' then
self.children.center = AnimatedSprite(self.T.x, self.T.y, self.T.w, self.T.h, G.ANIMATION_ATLAS['BadApple'], self.config.center.pos)
self.children.center.states.hover = self.states.hover
self.children.center.states.click = self.states.click
self.children.center.states.drag = self.states.drag
self.children.center.states.collide.can = false
self.children.center.framerate_override = 30
self.children.center:set_role({major = self, role_type = 'Glued', draw_major = self})
if not self.children.back then
self.children.back = Sprite(self.T.x, self.T.y, self.T.w, self.T.h, G.ASSET_ATLAS["centers"], self.params.bypass_back or (self.playing_card and G.GAME[self.back].pos or G.P_CENTERS['b_red'].pos))
self.children.back.states.hover = self.states.hover
self.children.back.states.click = self.states.click
self.children.back.states.drag = self.states.drag
self.children.back.states.collide.can = false
self.children.back:set_role({major = self, role_type = 'Glued', draw_major = self})
end
return
end
end
set_sprites_ref(self, _center, _front)
end
function AnimatedSprite:animate()
local FPS = G.ANIMATION_FPS
if self.framerate_override then FPS = self.framerate_override end
local new_frame = math.floor(FPS*(G.TIMERS.REAL - self.offset_seconds))%self.current_animation.frames
local frame_length = math.floor(self.image_dims[1] / self.animation.w)
if new_frame ~= self.current_animation.current then
self.current_animation.current = new_frame % frame_length
self.frame_offset = math.floor(self.animation.w*(self.current_animation.current))
self.sprite:setViewport(
self.frame_offset,
self.animation.h*(self.animation.y + math.floor(new_frame / frame_length)),
self.animation.w,
self.animation.h)
end
if self.float then
self.T.r = 0.02*math.sin(2*G.TIMERS.REAL+self.T.x)
self.offset.y = -(1+0.3*math.sin(0.666*G.TIMERS.REAL+self.T.y))*self.shadow_parrallax.y
self.offset.x = -(0.7+0.2*math.sin(0.666*G.TIMERS.REAL+self.T.x))*self.shadow_parrallax.x
end
end
-- UIBox garbage / Copied from LushMod. Thanks luscious!
local generate_UIBox_ability_tableref = Card.generate_UIBox_ability_table
function Card.generate_UIBox_ability_table(self)
local card_type, hide_desc = self.ability.set or "None", nil
local loc_vars = nil
local main_start, main_end = nil, nil
local no_badge = nil
if self.config.center.unlocked == false and not self.bypass_lock then -- For everyting that is locked
elseif card_type == 'Undiscovered' and not self.bypass_discovery_ui then -- Any Joker or tarot/planet/voucher that is not yet discovered
elseif self.debuff then
elseif card_type == 'Default' or card_type == 'Enhanced' then
elseif self.ability.set == 'Joker' then
local customJoker = false
if self.ability.name == 'Bad Apple Joker' then
customJoker = true
end
if customJoker then
local badges = {}
if (card_type ~= 'Locked' and card_type ~= 'Undiscovered' and card_type ~= 'Default') or self.debuff then
badges.card_type = card_type
end
if self.ability.set == 'Joker' and self.bypass_discovery_ui and (not no_badge) then
badges.force_rarity = true
end
if self.edition then
if self.edition.type == 'negative' and self.ability.consumeable then
badges[#badges + 1] = 'negative_consumable'
else
badges[#badges + 1] = (self.edition.type == 'holo' and 'holographic' or self.edition.type)
end
end
if self.seal then
badges[#badges + 1] = string.lower(self.seal) .. '_seal'
end
if self.ability.eternal then
badges[#badges + 1] = 'eternal'
end
if self.pinned then
badges[#badges + 1] = 'pinned_left'
end
if self.sticker then
loc_vars = loc_vars or {};
loc_vars.sticker = self.sticker
end
local center = self.config.center
return generate_card_ui(center, nil, loc_vars, card_type, badges, hide_desc, main_start, main_end)
end
end
return generate_UIBox_ability_tableref(self)
end
local draw_from_deck_to_hand_ref = G.FUNCS.draw_from_deck_to_hand
G.FUNCS.draw_from_deck_to_hand = function(e)
if not next(find_joker("Bad Apple Joker")) then
return draw_from_deck_to_hand_ref()
end
if not (G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK) and
G.hand.config.card_limit <= 0 and #G.hand.cards == 0 then
G.STATE = G.STATES.GAME_OVER; G.STATE_COMPLETE = false
return true
end
local hand_space = e or math.min(#G.deck.cards, G.hand.config.card_limit - #G.hand.cards)
if G.GAME.blind.name == 'The Serpent' and
not G.GAME.blind.disabled and
(G.GAME.current_round.hands_played > 0 or
G.GAME.current_round.discards_used > 0) then
hand_space = math.min(#G.deck.cards, 3)
end
delay(0.3)
local override_cards = {}
for i=1, hand_space do --draw cards from deck
local card = nil
if next(find_joker("Bad Apple Joker")) then
if pseudorandom('bad_apple') <= 0.28 * #find_joker("Bad Apple Joker") then
sendDebugMessage("Bad Apple Found!" .. tostring(#G.deck.cards))
for j=1,math.max(1,math.floor(#G.deck.cards/2)) do
local v = pseudorandom_element(G.deck.cards, pseudoseed('bad_apple_draw'))
local already_drawn = false
for k=1,#override_cards do
if v == override_cards[k] then already_drawn = true;sendDebugMessage("Already drew: " .. tostring(v)) end
end
if not card and not already_drawn then card = v end
if card and card:get_chip_bonus() + 1 < v:get_chip_bonus() and not already_drawn then
card = v
end
end
if card then
override_cards[#override_cards + 1] = card
sendDebugMessage("Overriding card drawn to be: " .. tostring(card))
end
else
local already_drawn = true
while already_drawn do
card = pseudorandom_element(G.deck.cards, pseudoseed('normal_draw'))
already_drawn = false
for k=1,#override_cards do
if card == override_cards[k] then already_drawn = true;sendDebugMessage("Already drew: " .. tostring(v)) end
end
end
sendDebugMessage("Drawing Normal Card: " .. tostring(card))
override_cards[#override_cards + 1] = card
end
end
if G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK then
draw_card(G.deck,G.hand, i*100/hand_space,'up', true, card)
else
draw_card(G.deck,G.hand, i*100/hand_space,'up', true, card)
end
end
end