Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 125 additions & 46 deletions compatibility/TheOrder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@
-- Patches card creation to not be ante-based and use a single pool for every type/rarity
local cc = create_card
function create_card(_type, area, legendary, _rarity, skip_materialize, soulable, forced_key, key_append)
if MP.INTEGRATIONS.TheOrder then
local a = G.GAME.round_resets.ante
G.GAME.round_resets.ante = 0
if _type == "Tarot" or _type == "Planet" or _type == "Spectral" then
key_append = _type
end
local c = cc(_type, area, legendary, _rarity, skip_materialize, soulable, forced_key, _rarity) -- _rarity replacing key_append can be entirely removed to normalise skip tags and riff raff with shop rarity queues
G.GAME.round_resets.ante = a
return c
end
return cc(_type, area, legendary, _rarity, skip_materialize, soulable, forced_key, key_append)
if MP.INTEGRATIONS.TheOrder then
local a = G.GAME.round_resets.ante
local src = key_append
G.GAME.round_resets.ante = 0
if _type == "Tarot" or _type == "Planet" or _type == "Spectral" then
key_append = _type
end
local c = cc(_type, area, legendary, _rarity, skip_materialize, soulable, forced_key, _rarity) -- _rarity replacing key_append can be entirely removed to normalise skip tags and riff raff with shop rarity queues

if src and c.ability and c.ability.name then
sendTraceMessage(
string.format("Client sent message: action:createCard,card:%s,key:%s,src:%s", c.ability.name,
MP.UTILS.joker_to_string(c), src),
"MULTIPLAYER"
)
end
G.GAME.round_resets.ante = a
return c
end
return cc(_type, area, legendary, _rarity, skip_materialize, soulable, forced_key, key_append)
end

-- Patches idol RNG when using the order to sort deck based on count of identical cards instead of default deck order
Expand All @@ -35,15 +44,25 @@ function reset_idol_card()
count_map[key].count = count_map[key].count + 1
end
end
--failsafe in case all are stone or no cards in deck. Defaults to Ace of Spades
--failsafe in case all are stone or no cards in deck. Defaults to Ace of Spades
if #valid_idol_cards == 0 then
return
end

local value_order = {
["Ace"] = 1, ["2"] = 2, ["3"] = 3, ["4"] = 4, ["5"] = 5,
["6"] = 6, ["7"] = 7, ["8"] = 8, ["9"] = 9, ["10"] = 10,
["Jack"] = 11, ["Queen"] = 12, ["King"] = 13
["Ace"] = 1,
["2"] = 2,
["3"] = 3,
["4"] = 4,
["5"] = 5,
["6"] = 6,
["7"] = 7,
["8"] = 8,
["9"] = 9,
["10"] = 10,
["Jack"] = 11,
["Queen"] = 12,
["King"] = 13
}

local suit_order = {
Expand Down Expand Up @@ -76,7 +95,7 @@ function reset_idol_card()
total_weight = total_weight + entry.count
end

local raw_random = pseudorandom('idol'..G.GAME.round_resets.ante)
local raw_random = pseudorandom('idol' .. G.GAME.round_resets.ante)
local rand = raw_random * 1000

local threshold = 0
Expand All @@ -96,7 +115,6 @@ function reset_idol_card()
return original_reset_idol_card()
end


local original_reset_mail_rank = reset_mail_rank

function reset_mail_rank()
Expand All @@ -106,9 +124,19 @@ function reset_mail_rank()
local count_map = {}
local total_weight = 0
local value_order = {
["Ace"] = 1, ["2"] = 2, ["3"] = 3, ["4"] = 4, ["5"] = 5,
["6"] = 6, ["7"] = 7, ["8"] = 8, ["9"] = 9, ["10"] = 10,
["Jack"] = 11, ["Queen"] = 12, ["King"] = 13
["Ace"] = 1,
["2"] = 2,
["3"] = 3,
["4"] = 4,
["5"] = 5,
["6"] = 6,
["7"] = 7,
["8"] = 8,
["9"] = 9,
["10"] = 10,
["Jack"] = 11,
["Queen"] = 12,
["King"] = 13
}

local valid_ranks = {}
Expand All @@ -125,8 +153,8 @@ function reset_mail_rank()
end

-- Failsafe: all stone cards
if #valid_ranks == 0 then
return
if #valid_ranks == 0 then
return
end

-- Sort by count desc, then value asc
Expand All @@ -142,7 +170,7 @@ function reset_mail_rank()
total_weight = total_weight + count_map[entry.value].count
end

local raw_random = pseudorandom('mail'..G.GAME.round_resets.ante)
local raw_random = pseudorandom('mail' .. G.GAME.round_resets.ante)
local rand = raw_random * 1000

local threshold = 0
Expand All @@ -156,48 +184,70 @@ function reset_mail_rank()
break
end
end


return
end

return original_reset_mail_rank()
end



-- Take ownership of standard pack card creation
-- This is irritating
SMODS.Booster:take_ownership_by_kind('Standard', {
create_card = function(self, card, i)
local s_append = '' -- MP.get_booster_append(card)
local b_append = MP.ante_based()..s_append

local _edition = poll_edition('standard_edition'..b_append, 2, true)
local _seal = SMODS.poll_seal({mod = 10, key = 'stdseal'..b_append})

return {set = (pseudorandom(pseudoseed('stdset'..b_append)) > 0.6) and "Enhanced" or "Base", edition = _edition, seal = _seal, area = G.pack_cards, skip_materialize = true, soulable = true, key_append = "sta"..s_append}
local s_append = '' -- MP.get_booster_append(card)
local b_append = MP.ante_based() .. s_append

local _edition = poll_edition('standard_edition' .. b_append, 2, true)
local _seal = SMODS.poll_seal({ mod = 10, key = 'stdseal' .. b_append })

return {
set = (pseudorandom(pseudoseed('stdset' .. b_append)) > 0.6) and "Enhanced" or "Base",
edition =
_edition,
seal = _seal,
area = G.pack_cards,
skip_materialize = true,
soulable = true,
key_append = "sta" ..
s_append
}
end,
}, true)

-- Rest of the packs since we're dealing with pack queues now
SMODS.Booster:take_ownership_by_kind('Arcana', {
create_card = function(self, card, i)
local s_append = '' -- MP.get_booster_append(card)
local s_append = '' -- MP.get_booster_append(card)

local _card
if G.GAME.used_vouchers.v_omen_globe and pseudorandom('omen_globe') > 0.8 then
_card = {set = "Spectral", area = G.pack_cards, skip_materialize = true, soulable = true, key_append = "ar2"..s_append}
_card = {
set = "Spectral",
area = G.pack_cards,
skip_materialize = true,
soulable = true,
key_append = "ar2" ..
s_append
}
else
_card = {set = "Tarot", area = G.pack_cards, skip_materialize = true, soulable = true, key_append = "ar1"..s_append}
_card = {
set = "Tarot",
area = G.pack_cards,
skip_materialize = true,
soulable = true,
key_append = "ar1" ..
s_append
}
end
return _card
end,
}, true)
SMODS.Booster:take_ownership_by_kind('Celestial', {
create_card = function(self, card, i)
local s_append = '' -- MP.get_booster_append(card)
local s_append = '' -- MP.get_booster_append(card)

local _card
if G.GAME.used_vouchers.v_telescope and i == 1 then
local _planet, _hand, _tally = nil, nil, 0
Expand All @@ -214,23 +264,52 @@ SMODS.Booster:take_ownership_by_kind('Celestial', {
end
end
end
_card = {set = "Planet", area = G.pack_cards, skip_materialize = true, soulable = true, key = _planet, key_append = "pl1"..s_append}
_card = {
set = "Planet",
area = G.pack_cards,
skip_materialize = true,
soulable = true,
key = _planet,
key_append =
"pl1" .. s_append
}
else
_card = {set = "Planet", area = G.pack_cards, skip_materialize = true, soulable = true, key_append = "pl1"..s_append}
_card = {
set = "Planet",
area = G.pack_cards,
skip_materialize = true,
soulable = true,
key_append = "pl1" ..
s_append
}
end
return _card
end,
}, true)
SMODS.Booster:take_ownership_by_kind('Spectral', {
create_card = function(self, card, i)
local s_append = '' -- MP.get_booster_append(card)
return {set = "Spectral", area = G.pack_cards, skip_materialize = true, soulable = true, key_append = "spe"..s_append}
local s_append = '' -- MP.get_booster_append(card)
return {
set = "Spectral",
area = G.pack_cards,
skip_materialize = true,
soulable = true,
key_append = "spe" ..
s_append
}
end,
}, true)
SMODS.Booster:take_ownership_by_kind('Buffoon', {
create_card = function(self, card, i)
local s_append = MP.get_booster_append(card)
return {set = "Joker", area = G.pack_cards, skip_materialize = true, soulable = true, key_append = "buf"..s_append}
return {
set = "Joker",
area = G.pack_cards,
skip_materialize = true,
soulable = true,
key_append = "buf" ..
s_append
}
end,
}, true)

Expand Down Expand Up @@ -260,9 +339,9 @@ end
-- ^^^ above statement is unnecessary for now since functionality is only active for buffoon packs ^^^
function MP.get_booster_append(booster)
if MP.INTEGRATIONS.TheOrder and false then
if booster.ability.extra > 3.5 then -- midpoint, i don't feel like string matching and this handles vanilla cases
if booster.ability.extra > 3.5 then -- midpoint, i don't feel like string matching and this handles vanilla cases
if (booster.config.center.config.choose or 1) > 1.5 then
return 'mega' -- if we want jumbos to have same queue as megas, change this or 'jumb' to be the same
return 'mega' -- if we want jumbos to have same queue as megas, change this or 'jumb' to be the same
else
return 'jumb'
end
Expand Down
22 changes: 19 additions & 3 deletions misc/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ local sell_card_ref = Card.sell_card
function Card:sell_card()
if self.ability and self.ability.name then
sendTraceMessage(
string.format("Client sent message: action:soldCard,card:%s", self.ability.name),
string.format("Client sent message: action:soldCard,card:%s,key:%s", self.ability.name,
MP.UTILS.joker_to_string(self)),
"MULTIPLAYER"
)
end
Expand All @@ -376,18 +377,33 @@ function G.FUNCS.buy_from_shop(e)
local c1 = e.config.ref_table
if c1 and c1:is(Card) then
sendTraceMessage(
string.format("Client sent message: action:boughtCardFromShop,card:%s,cost:%s", c1.ability.name, c1.cost),
string.format("Client sent message: action:boughtCardFromShop,card:%s,cost:%s,key:%s", c1.ability.name,
c1.cost, MP.UTILS.joker_to_string(c1)),
"MULTIPLAYER"
)
end
return buy_from_shop_ref(e)
end

local copy_card_ref = copy_card
function copy_card(other, new_card, card_scale, playing_card, strip_edition)
local card = copy_card_ref(other, new_card, card_scale, playing_card, strip_edition)
if card and card.ability and card.ability.name then
sendTraceMessage(
string.format("Client sent message: action:copyCard,card:%s,key:%s", card.ability.name,
MP.UTILS.joker_to_string(card)),
"MULTIPLAYER"
)
end
return card
end

local use_card_ref = G.FUNCS.use_card
function G.FUNCS.use_card(e, mute, nosave)
if e.config and e.config.ref_table and e.config.ref_table.ability and e.config.ref_table.ability.name then
sendTraceMessage(
string.format("Client sent message: action:usedCard,card:%s", e.config.ref_table.ability.name),
string.format("Client sent message: action:usedCard,card:%s,key:%s", e.config.ref_table.ability.name,
MP.UTILS.joker_to_string(e.config.ref_table)),
"MULTIPLAYER"
)
end
Expand Down