Merge pull request #323 from argonui/upkeep-rotation
Upkeep: rotate cards to the next multiple of 90° towards 0°
This commit is contained in:
commit
d7e33a6e3b
@ -280,9 +280,23 @@ function doUpkeep(_, clickedByColor, isRightClick)
|
||||
elseif obj.tag == "Card" and not inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then
|
||||
local cardMetadata = JSON.decode(obj.getGMNotes()) or {}
|
||||
if not doNotReady(obj) then
|
||||
local cardRotation = round(obj.getRotation().y, 0) - rot.y
|
||||
local yRotDiff = 0
|
||||
|
||||
if cardRotation < 0 then
|
||||
cardRotation = cardRotation + 360
|
||||
end
|
||||
|
||||
-- rotate cards to the next multiple of 90° towards 0°
|
||||
if cardRotation > 90 and cardRotation <= 180 then
|
||||
yRotDiff = 90
|
||||
elseif cardRotation < 270 and cardRotation > 180 then
|
||||
yRotDiff = 270
|
||||
end
|
||||
|
||||
-- set correct rotation for face-down cards
|
||||
rot.z = obj.is_face_down and 180 or 0
|
||||
obj.setRotation(rot)
|
||||
obj.setRotation({rot.x, rot.y + yRotDiff, rot.z})
|
||||
end
|
||||
if cardMetadata.id == "08031" then
|
||||
forcedLearning = true
|
||||
@ -916,3 +930,11 @@ function updatePlayerCards(args)
|
||||
local playerCardData = customDataHelper.getTable("PLAYER_CARD_DATA")
|
||||
tokenManager.addPlayerCardData(playerCardData)
|
||||
end
|
||||
|
||||
-- utility function for rounding
|
||||
---@param num Number Initial value
|
||||
---@param numDecimalPlaces Number Amount of decimal places
|
||||
function round(num, numDecimalPlaces)
|
||||
local mult = 10^(numDecimalPlaces or 0)
|
||||
return math.floor(num * mult + 0.5) / mult
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user