diff --git a/mossed.lua b/mossed.lua index 57e6099..8d5dffc 100644 --- a/mossed.lua +++ b/mossed.lua @@ -202,16 +202,20 @@ function SMODS.current_mod.reset_game_globals(run_start) local kitchen_card = pseudorandom_element({"Spades","Hearts","Diamonds","Clubs"}, pseudoseed("kitchen" .. G.GAME.round_resets.ante)) G.GAME.current_round.kitchen_card.suit = kitchen_card end +local kitchen_joker_active = false local issuitref = Card.is_suit function Card.is_suit(self, suit, bypass_debuff, flush_calc) + if not kitchen_joker_active then + return issuitref(self, suit, bypass_debuff, flush_calc) + end if flush_calc then - if next(SMODS.find_card('j_moss_kitchen')) and SMODS.has_no_suit(self) and ( G.GAME.current_round.kitchen_card.suit == G.GAME.current_round.kitchen_card.suit ) == ( suit == G.GAME.current_round.kitchen_card.suit ) and not ( G.GAME.current_round.kitchen_card.suit == G.GAME.current_round.kitchen_card.suit ) == ( suit ~= G.GAME.current_round.kitchen_card.suit ) then + if SMODS.has_no_suit(self) and ( G.GAME.current_round.kitchen_card.suit == G.GAME.current_round.kitchen_card.suit ) == ( suit == G.GAME.current_round.kitchen_card.suit ) and not ( G.GAME.current_round.kitchen_card.suit == G.GAME.current_round.kitchen_card.suit ) == ( suit ~= G.GAME.current_round.kitchen_card.suit ) then return true end return issuitref(self, suit, bypass_debuff, flush_calc) else - if self.debuff and not bypass_debuff then return end - if next(SMODS.find_card('j_moss_kitchen')) and SMODS.has_no_suit(self) and ( G.GAME.current_round.kitchen_card.suit == G.GAME.current_round.kitchen_card.suit ) == ( suit == G.GAME.current_round.kitchen_card.suit ) and not ( G.GAME.current_round.kitchen_card.suit == G.GAME.current_round.kitchen_card.suit ) == ( suit ~= G.GAME.current_round.kitchen_card.suit ) then + if self.debuff and not bypass_debuff then return end + if SMODS.has_no_suit(self) and ( G.GAME.current_round.kitchen_card.suit == G.GAME.current_round.kitchen_card.suit ) == ( suit == G.GAME.current_round.kitchen_card.suit ) and not ( G.GAME.current_round.kitchen_card.suit == G.GAME.current_round.kitchen_card.suit ) == ( suit ~= G.GAME.current_round.kitchen_card.suit ) then return true end return issuitref(self, suit, bypass_debuff, flush_calc) @@ -230,6 +234,12 @@ SMODS.Joker{ cost = 8, config = { extra = { } }, enhancement_gate = "m_stone", + add_to_deck = function(self, card, from_debuff) + kitchen_joker_active = true + end, + remove_from_deck = function(self, card, from_debuff) + kitchen_joker_active = false + end, loc_vars = function(self, info_queue, card) info_queue[#info_queue+1] = G.P_CENTERS.m_stone return { @@ -1124,4 +1134,8 @@ SMODS.Tag { end end end, -} \ No newline at end of file +} + +if Balatest then + assert(SMODS.load_file('tests/jokers.lua'))() +end \ No newline at end of file diff --git a/tests/jokers.lua b/tests/jokers.lua new file mode 100644 index 0000000..42bd3cf --- /dev/null +++ b/tests/jokers.lua @@ -0,0 +1,156 @@ +Balatest.TestPlay({ + name = "kitchen_inactive_normal_flush", + category = {"jokers"}, + execute = function() + Balatest.play_hand({"2S", "3S", "4S", "5S", "7S"}); + end, + assert = function() + Balatest.assert_chips((35 + 2 + 3 + 4 + 5 + 7) * 4); + end +}); + +Balatest.TestPlay({ + name = "kitchen_inactive_stone_no_flush", + category = {"jokers"}, + deck = { + cards = { + {r = "2", s = "S", e = "m_stone"}, + {r = "3", s = "S"}, + {r = "4", s = "S"}, + {r = "5", s = "S"}, + {r = "7", s = "S"}, + {r = "A", s = "S"}, + {r = "A", s = "H"}, + {r = "A", s = "D"} + } + }, + execute = function() + Balatest.play_hand({"2S", "3S", "4S", "5S", "7S"}); + end, + assert = function() + Balatest.assert_chips((5 + 7 + 50) * 1); + end +}); + +Balatest.TestPlay({ + name = "kitchen_active_stone_flush_spades", + category = {"jokers"}, + jokers = {"j_moss_kitchen"}, + deck = { + cards = { + {r = "2", s = "S", e = "m_stone"}, + {r = "3", s = "S"}, + {r = "4", s = "S"}, + {r = "5", s = "S"}, + {r = "7", s = "S"}, + {r = "A", s = "S"}, + {r = "A", s = "H"}, + {r = "A", s = "D"} + } + }, + no_auto_start = true, + execute = function() + Balatest.q(function() + G.GAME.current_round.kitchen_card = {suit = "Spades"}; + end); + + Balatest.start_round(); + + Balatest.play_hand({"2S", "3S", "4S", "5S", "7S"}); + end, + assert = function() + Balatest.assert_chips((35 + 50 + 3 + 4 + 5 + 7) * 4); + end +}); + +Balatest.TestPlay({ + name = "kitchen_active_stone_wrong_suit", + category = {"jokers"}, + jokers = {"j_moss_kitchen"}, + deck = { + cards = { + {r = "2", s = "S", e = "m_stone"}, + {r = "3", s = "S"}, + {r = "4", s = "S"}, + {r = "5", s = "S"}, + {r = "7", s = "S"}, + {r = "A", s = "S"}, + {r = "A", s = "H"}, + {r = "A", s = "D"} + } + }, + no_auto_start = true, + execute = function() + Balatest.q(function() + G.GAME.current_round.kitchen_card = {suit = "Hearts"}; + end); + + Balatest.start_round(); + + Balatest.play_hand({"2S", "3S", "4S", "5S", "7S"}); + end, + assert = function() + Balatest.assert_chips(5 + 7 + 50); + end +}); + +Balatest.TestPlay({ + name = "kitchen_active_stone_flush_hearts", + category = {"jokers"}, + jokers = {"j_moss_kitchen"}, + deck = { + cards = { + {r = "2", s = "H", e = "m_stone"}, + {r = "3", s = "H"}, + {r = "4", s = "H"}, + {r = "5", s = "H"}, + {r = "7", s = "H"}, + {r = "A", s = "S"}, + {r = "A", s = "D"}, + {r = "A", s = "C"} + } + }, + no_auto_start = true, + execute = function() + Balatest.q(function() + G.GAME.current_round.kitchen_card = {suit = "Hearts"}; + end); + + Balatest.start_round(); + + Balatest.play_hand({"2H", "3H", "4H", "5H", "7H"}); + end, + assert = function() + Balatest.assert_chips((35 + 50 + 3 + 4 + 5 + 7) * 4); + end +}); + +Balatest.TestPlay({ + name = "kitchen_active_normal_flush", + category = {"jokers"}, + jokers = {"j_moss_kitchen"}, + execute = function() + Balatest.play_hand({"2S", "3S", "4S", "5S", "7S"}); + end, + assert = function() + Balatest.assert_chips((35 + 2 + 3 + 4 + 5 + 7) * 4); + end +}); + +Balatest.TestPlay({ + name = "kitchen_suit_changes_each_round", + category = {"jokers"}, + jokers = {"j_moss_kitchen"}, + execute = function() + Balatest.next_round(); + end, + assert = function() + local suit = G.GAME.current_round.kitchen_card.suit; + + Balatest.assert( + suit == "Spades" or suit == "Hearts" or suit == "Diamonds" or + suit == "Clubs", + "kitchen suit should be a valid suit after round change" + ); + end +});