content: [manifest]
  version = "0.1.0"
  dump_lua = true
  priority = 0
  
  ## Extra Deck
  
  # Prevent add_to_deck when buying an Extra Deck Joker
  [[patches]]
  [patches.pattern]
  target = "functions/button_callbacks.lua"
  pattern = "c1:add_to_deck()"
  position = 'at'
  match_indent = true
  payload = '''
  if JoyousSpring and not (JoyousSpring.is_extra_deck_monster(c1) or JoyousSpring.is_field_spell(c1)) then
      c1:add_to_deck()
  end
  if c1.children.joy_side_button then c1.children.joy_side_button:remove() end
  c1.children.joy_side_button = nil
  '''
  
  # Add joker to Extra Deck when buying from the shop
  [[patches]]
  [patches.pattern]
  target = "functions/button_callbacks.lua"
  pattern = "G.jokers:emplace(c1)"
  position = 'at'
  match_indent = true
  payload = '''
  if JoyousSpring and (JoyousSpring.is_extra_deck_monster(c1) or JoyousSpring.is_field_spell(c1)) then
      JoyousSpring.add_to_extra_deck(c1)
      JoyousSpring.open_extra_deck(false, false, 1.85)
  else
      G.jokers:emplace(c1)
  end
  '''
  
  # Add joker to Extra Deck when selecting from a pack
  [[patches]]
  [patches.pattern]
  target = "functions/button_callbacks.lua"
  pattern = "elseif card.ability.set == 'Joker' then"
  position = 'before'
  match_indent = true
  payload = '''
  elseif card.ability.set == 'Joker' and JoyousSpring and (JoyousSpring.is_extra_deck_monster(card) or JoyousSpring.is_field_spell(card)) then
      JoyousSpring.add_to_extra_deck(card)
      JoyousSpring.open_extra_deck(false, false, 1.85)
      play_sound('card1', 0.8, 0.6)
      play_sound('generic1')
      dont_dissolve = true
      delay_fac = 0.2
  '''
  
  # Change background color
  [[patches]]
  [patches.pattern]
  target = "cardarea.lua"
  pattern = "{n=G.UIT.R, config={minw = self.T.w,minh = self.T.h,align = \"cm\", padding = 0.1, mid = true, r = 0.1, colour = self ~= G.shop_vouchers and {0,0,0,0.1} or nil, ref_table = self}, nodes={"
  position = 'at'
  match_indent = true
  payload = '''
  {n=G.UIT.R, config={minw = self.T.w,minh = self.T.h,align = "cm", padding = 0.1, mid = true, r = 0.1, colour = (self == JoyousSpring.field_spell_area or self == JoyousSpring.extra_deck_area) and {G.C.JOY.SPELL[1],G.C.JOY.SPELL[2],G.C.JOY.SPELL[3],0.5} or self ~= G.shop_vouchers and {0,0,0,0.1} or nil, ref_table = self}, nodes={
  '''
  
  ## Summon Materials
  
  # Remove card count when selecting summoning materials
  [[patches]]
  [patches.pattern]
  target = "cardarea.lua"
  pattern = "self.children.area_uibox = UIBox{"
  position = 'before'
  match_indent = true
  payload = '''
  if self.config.type == 'summon_materials' then
      card_count = nil
  end
  '''
  
  # Field Spells
  
  # Change other_joker key
  [[patches]]
  [patches.pattern]
  target = "functions/state_events.lua"
  pattern = "-- TARGET: add context.other_something identifier to your cards"
  position = 'before'
  match_indent = true
  payload = '''
  if JoyousSpring and JoyousSpring.is_field_spell(_card) then other_key = 'other_field_spell' end
  '''
  
  # Add field spell area to joker evaluation
  [[patches]]
  [patches.pattern]
  target = '=[SMODS _ "src/utils.lua"]'
  pattern = "-- TARGET: add your own CardAreas for joker evaluation"
  position = 'before'
  match_indent = true
  payload = '''
  if JoyousSpring and JoyousSpring.field_spell_area then table.insert(t, JoyousSpring.field_spell_area) end
  '''
  