Added discard shuffle button

This commit is contained in:
Chr1Z93 2024-09-18 20:52:24 +02:00
parent c20d747921
commit 6f9d7eeefc
7 changed files with 31 additions and 96 deletions

View File

@ -34,6 +34,11 @@
"Type": 0, "Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/" "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/"
}, },
{
"Name": "shuffle",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2450610458447905243/AFDBF9BA4702899973FD5A5E7544C6E3F81E1366/"
},
{ {
"Name": "option_on", "Name": "option_on",
"Type": 0, "Type": 0,

View File

@ -342,28 +342,6 @@
"ImageURL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/", "ImageURL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/",
"WidthScale": 0 "WidthScale": 0
}, },
"CustomUIAsset": [
{
"Name": "option_on",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/"
},
{
"Name": "option_off",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
},
{
"Name": "option_button",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/"
},
{
"Name": "option_gear_white",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/"
}
],
"Description": "", "Description": "",
"DragSelectable": true, "DragSelectable": true,
"GMNotes": "", "GMNotes": "",

View File

@ -342,28 +342,6 @@
"ImageURL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/", "ImageURL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/",
"WidthScale": 0 "WidthScale": 0
}, },
"CustomUIAsset": [
{
"Name": "option_on",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/"
},
{
"Name": "option_off",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
},
{
"Name": "option_button",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/"
},
{
"Name": "option_gear_white",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/"
}
],
"Description": "", "Description": "",
"DragSelectable": true, "DragSelectable": true,
"GMNotes": "", "GMNotes": "",

View File

@ -342,28 +342,6 @@
"ImageURL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/", "ImageURL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/",
"WidthScale": 0 "WidthScale": 0
}, },
"CustomUIAsset": [
{
"Name": "option_on",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/"
},
{
"Name": "option_off",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
},
{
"Name": "option_button",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/"
},
{
"Name": "option_gear_white",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/"
}
],
"Description": "", "Description": "",
"DragSelectable": true, "DragSelectable": true,
"GMNotes": "", "GMNotes": "",

View File

@ -342,28 +342,6 @@
"ImageURL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/", "ImageURL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/",
"WidthScale": 0 "WidthScale": 0
}, },
"CustomUIAsset": [
{
"Name": "option_on",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/"
},
{
"Name": "option_off",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/"
},
{
"Name": "option_button",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/"
},
{
"Name": "option_gear_white",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/"
}
],
"Description": "", "Description": "",
"DragSelectable": true, "DragSelectable": true,
"GMNotes": "", "GMNotes": "",

View File

@ -551,11 +551,9 @@ end
function shuffleDiscardIntoDeck() function shuffleDiscardIntoDeck()
local deckAreaObjects = getDeckAreaObjects() local deckAreaObjects = getDeckAreaObjects()
if not deckAreaObjects.discard.is_face_down then if not deckAreaObjects.discard then return end
deckAreaObjects.discard.flip()
end deckLib.placeOrMergeIntoDeck({ deckAreaObjects.topCard, deckAreaObjects.discard }, self.positionToWorld(DRAW_DECK_POSITION), _, _, true)
deckAreaObjects.discard.shuffle()
deckAreaObjects.discard.setPositionSmooth(self.positionToWorld(DRAW_DECK_POSITION), false, false)
end end
-- utility function for Norman Withers to flip the top card to the revealed side -- utility function for Norman Withers to flip the top card to the revealed side
@ -699,6 +697,20 @@ function createXML()
end end
end end
-- create a button for shuffling the discard pile back
local shuffleDiscardXML = {
tag = "Button",
attributes = {
onClick = "shuffleDiscardIntoDeck",
width = "7",
height = "7",
position = "-182 30.5 -11",
rotation = "0 0 180",
image = "shuffle"
}
}
table.insert(xml, shuffleDiscardXML)
-- create the personal option panel -- create the personal option panel
local defaultsXML = { local defaultsXML = {
tag = "Defaults", tag = "Defaults",

View File

@ -2,12 +2,13 @@ do
local DeckLib = {} local DeckLib = {}
local searchLib = require("util/SearchLib") local searchLib = require("util/SearchLib")
-- places a card/deck at a position or merges into an existing deck below -- places a card/deck at a position or merges into an existing deck
---@param objOrTable tts__Object|table Object or table of objects to move ---@param objOrTable tts__Object|table Object or table of objects to move
---@param pos table New position for the object ---@param pos table New position for the object
---@param rot? table New rotation for the object ---@param rot? table New rotation for the object
---@param below? boolean Should the object be placed below an existing deck? ---@param below? boolean Should the object be placed below an existing deck?
DeckLib.placeOrMergeIntoDeck = function(objOrTable, pos, rot, below) ---@param shuffle? boolean Should the resulting deck be shuffled?
DeckLib.placeOrMergeIntoDeck = function(objOrTable, pos, rot, below, shuffle)
if objOrTable == nil or pos == nil then return end if objOrTable == nil or pos == nil then return end
-- handle 'objOrTable' parameter -- handle 'objOrTable' parameter
@ -63,11 +64,16 @@ do
else else
targetObj = obj targetObj = obj
end end
-- this is the final object, maybe shuffle
if i == 1 and targetObj.type == "Deck" and shuffle then
targetObj.shuffle()
end
end, end,
-- check state of the object (make sure it's not moving) -- check state of the object (make sure it's not moving)
function() return obj.isDestroyed() or not obj.isSmoothMoving() end, function() return obj.isDestroyed() or not obj.isSmoothMoving() end,
2) 2)
end, (#objects- i) * 0.1) end, (#objects - i) * 0.1)
end end
end end