Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some potential V10 fixes #14

Merged
merged 21 commits into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5cdbffc
Merge pull request #1 from orcnog/develop
orcnog Jun 16, 2023
3be226e
Merge pull request #2 from orcnog/develop
orcnog Jul 2, 2023
eabece5
Merge pull request #3 from orcnog/develop
orcnog Jul 3, 2023
9e20f4c
Merge pull request #9 from orcnog/develop
orcnog Jul 5, 2023
3074552
adds demo GIF, under 100mb so git will accept the push
orcnog Jul 6, 2023
56f0211
Merge pull request #11 from orcnog/demo-gif
orcnog Jul 6, 2023
ed91085
Merge pull request #12 from orcnog/develop
orcnog Jul 6, 2023
2957010
Merge pull request #13 from orcnog/develop
orcnog Jul 6, 2023
1e5e849
Sets FVTT minimum compatibility back to 10
kristianserrano Jul 7, 2023
5e8a2bc
Fixes some errors
kristianserrano Jul 7, 2023
d21ba05
Changes Deck of Many Things to source name
kristianserrano Jul 7, 2023
8d03a7f
update the demo GIF to include click-to-view chat image example
orcnog Jul 7, 2023
ee598be
release 0.1.4
orcnog Jul 7, 2023
7742fc0
fixed a typo found by @kristianserrano in PR #14, and version bump. r…
orcnog Jul 7, 2023
1ff9f67
Changes Macros pack to be v10 compatible
kristianserrano Jul 7, 2023
56559af
Adds .DS_Store to .gitignore
kristianserrano Jul 7, 2023
597584d
Restores custom action string
kristianserrano Jul 7, 2023
64f3263
Just some whitespace trimming
kristianserrano Jul 7, 2023
ca14388
Adds two hidden settings for sharing and viewing
kristianserrano Jul 7, 2023
6470c10
Adds use of hidden settings for share and view
kristianserrano Jul 7, 2023
bcbf4ee
Merge branch 'v10-support' into v10-fixes
orcnog Jul 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ foundryconfig.json
/releases
versionbump.js
playtest.py
/archive
/archive
.DS_Store
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,4 @@ Fixed Issue #10, 'Deck of Many Things' hardcoded. Also added a new GIF demo vide
Fixed a bug pointed out by @kristianserrano in this PR: https://github.com/orcnog/orcnog-card-viewer/pull/14/files

## v0.1.6
This release is for testing only! It's a carbon copy of the v0.1.5 release, but the compatibility is lowered to include v10.
This release is for testing only! It's a carbon copy of the v0.1.5 release, but the compatibility is lowered to include v10.
2 changes: 1 addition & 1 deletion dist/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"changelog": "https://github.com/orcnog/orcnog-card-viewer/blob/master/README.md",
"author": "orcnog",
"compatibility": {
"minimum": "9",
"minimum": "10",
"verified": "11"
},
"scripts": [],
Expand Down
6 changes: 4 additions & 2 deletions dist/module/cardDealer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class CardDealer {
}

async draw(share) {
await game.settings.set('orcnog-card-viewer', 'share', share);
try {
await this.initPromise;

Expand All @@ -53,7 +54,7 @@ class CardDealer {
const pile = this.pile;

// Deal 1 random card and grab reference to the dealt card
await deck.deal([pile], 1, { how: CONST.CARD_DRAW_MODES.RANDOM, action: shareToAll ? 'deal orcnog_card_viewer_doshare' : 'deal' });
await deck.deal([pile], 1, { how: CONST.CARD_DRAW_MODES.RANDOM});

const drawnCard = pile.cards.contents[pile.cards.size - 1];

Expand Down Expand Up @@ -83,10 +84,11 @@ class CardDealer {
* @param {boolean} faceDown Optional, tells the viewer whether to render the card face-down or not (default is yes)
* @param {boolean} whisper Optional, tells the viewer whether to whisper the card details to the DM on view (default is yes)
* @param {boolean} share Optional, tells the viewer whether to share to all players or not (default is no)
* @returns
* @returns
*/
async view(card, faceDown, whisper, share) {
try {
await game.settings.set('orcnog-card-viewer', 'share', share);
const deck = this.deck;
const deckName = this.deckName;
const showFaceDown = faceDown;
Expand Down
8 changes: 4 additions & 4 deletions dist/module/hooks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default function registerHooks() {
// Exit early if necessary;
if (!game.settings.get('orcnog-card-viewer', 'enableCardIconClick')) return;
if (app instanceof CardsConfig !== true) return;

// Register card icon click handler
const $card_icon = $html.find('img.card-face');
$card_icon.on('click.orcnog_card_viewer', (event) => {
Expand Down Expand Up @@ -160,7 +160,7 @@ export default function registerHooks() {
// Exit early if necessary;
if (!game.settings.get('orcnog-card-viewer', 'enableDisplayOnDeal')) return;
if (context.toCreate.length === 0) return;

// Show any and all cards that were dealt
// TODO: show multiple cards in one render (instead of multiple renders)
// Temporary TODO^ fix: on click of background, close all popped up cards.
Expand All @@ -169,8 +169,8 @@ export default function registerHooks() {
dest.forEach(card => {
const faceDown = true;
const whisper = game.settings.get('orcnog-card-viewer', 'enableWhisperCardTextToDM');
const shareToAll = context.action.includes('orcnog_card_viewer_doshare');
const doView = !context.action.includes('orcnog_card_viewer_noshow');
const shareToAll = game.settings.get('orcnog-card-viewer', 'share')
const doView = game.settings.get('orcnog-card-viewer', 'view');
if (doView) viewer.view(card._id, faceDown, whisper, shareToAll);
});
});
Expand Down
19 changes: 18 additions & 1 deletion dist/module/settings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,21 @@ export const registerSettings = function() {
default: true,
type: Boolean
});
}
// Enable/disable whispering card details to the DM on view.
game.settings.register('orcnog-card-viewer', 'share', {
name: "Share Card to Chat",
hint: "Determines whether or not to share the card to chat.",
scope: 'world',
config: false,
default: true,
type: Boolean
});
game.settings.register('orcnog-card-viewer', 'view', {
name: "View Card(s)",
hint: "Determines whether or not to view the cards for a given action.",
scope: 'world',
config: false,
default: true,
type: Boolean
});
};
5 changes: 4 additions & 1 deletion dist/packs/macros.db
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{"name":"Example for Adding Effect","type":"script","author":"CcIKAxG2yVRyrflR","img":"icons/svg/dice-target.svg","scope":"global","command":"const uuid = canvas.tokens.controlled[0].actor.uuid;\nconst hasEffectApplied = await game.dfreds.effectInterface.hasEffectApplied('Bane', uuid);\n\nif (!hasEffectApplied) {\n game.dfreds.effectInterface.addEffect({ effectName: 'Bane', uuid });\n}","flags":{"core":{"sourceId":"Macro.dRKN6lkyWvkUtPcQ"}},"ownership":{"default":0,"EtluHVpGWyEPNP7F":3,"CcIKAxG2yVRyrflR":3},"_stats":{"systemId":"dnd5e","systemVersion":"2.1.5","coreVersion":"10.291","createdTime":1662008142237,"modifiedTime":1677222870207,"lastModifiedBy":"CcIKAxG2yVRyrflR"},"folder":null,"sort":0,"_id":"gWo1oA8IvCSR3nH0"}
{"name":"View a Card","type":"script","author":"92aKSz8wx6tVXpQm","img":"modules/orcnog-card-viewer/assets/card-view-fancy.svg","scope":"global","command":"// Requires Orcnog's Card Viewer\n// Peeks at a card, but does not draw and discard it.\n\nlet deckName = 'Deck of Many Things';\nlet card = 'Gem'; // card name or ID\nlet faceDown = true;\nlet whisper = false;\nlet share = false;\n\nOrcnogFancyCardDealer({\n deckName: deckName,\n}).view(card, faceDown, whisper, share);","flags":{"core":{"sourceId":"Macro.dq0cclm7r5tOc4pL"},"exportSource":{"world":"v11-test","system":"worldbuilding","coreVersion":"11.305","systemVersion":"0.8.1"}},"_stats":{"systemId":"swade","systemVersion":"2.4.2","coreVersion":"10.303","createdTime":1686860654456,"modifiedTime":1688760983048,"lastModifiedBy":"92aKSz8wx6tVXpQm"},"folder":null,"sort":0,"ownership":{"default":0,"92aKSz8wx6tVXpQm":3},"_id":"PSnKE22o6C86rSvS"}
{"name":"Draw and show a card in a regular popout","type":"script","author":"92aKSz8wx6tVXpQm","img":"modules/orcnog-card-viewer/assets/card-draw.svg","scope":"global","command":"// Does not require Orcnog's Card Viewer!\n// A helper macro to automate drawing a random card and viewing it in a native Image Popout.\n\nlet deckName = \"Deck of Many Things\";\nlet discardPileName = \"My Discard Pile\";\nlet drawMethod = \"RANDOM\"; // should be \"RANDOM\" or \"TOP\"\n\n\n// Smart detect a discard pile existence.\nif (!discardPileName ) discardPileName = SmartMatchDiscardName(deckName);\n\n// get reference to src/dst cards objects\nconst src_cards = game.cards.filter(cards => cards.data.name===deckName)[0];\nconst dst_cards = game.cards.filter(cards => cards.data.name===discardPileName)[0]\n || await Cards.create({name: deckName + \" - Discard Pile\", type:\"pile\"});\n\n// deal 1 card and grab reference to the dealt card\ntry {\n await games.settings.set('orcnog-card-viewer', 'view', false)\n await src_cards.deal([dst_cards], 1, {\n how: CONST.CARD_DRAW_MODES[drawMethod]\n });\n} catch {}\nlet most_recent_drawn = dst_cards.cards.contents[dst_cards.cards.size - 1];\nconsole.log(most_recent_drawn);\nconst cardId = most_recent_drawn._id;\nconst name = most_recent_drawn.faces[0].name;\nconst front = most_recent_drawn.faces[0].img;\nconst back = most_recent_drawn.back.img;\nconst desc = most_recent_drawn.faces[0].text;\n\n// Show it as an Image Popout...\nconst ip = new ImagePopout(front, {});\nif (ip.render(true)) {\n // Share the image with other connected players\n ip.shareImage();\n}\n\n// Whisper the card instructions to the DM\nconst dm = game.users.find(u => u.isGM && u.active);\nif (dm) {\n const messageContent = `<div class=\"card-draw orcnog-card-viewer-msg flexrow\" data-deck=\"${deckName}\" data-card=\"${cardId}\" data-back=\"${back}\">\n <img class=\"card-face\" src=\"${front}\" alt=\"${name}\"/>\n <h4 class=\"card-name\">${name}</h4>\n </div>\n <p>${desc}</p>`\n ChatMessage.create({ content: messageContent, whisper: [dm._id] });\n} else {\n ui.notifications.warn(\"DM user not found.\");\n}\n\n/**\n * SmartMatchDiscardName - Find the Discard Pile for a specified deck name\n * @param {String} name - The name of the deck you want to find the Discard Pile for\n * @returns {Cards|null} - The Cards object representing the Discard Pile or null if not found\n */\nfunction SmartMatchDiscardName(name) {\n const stopwords = [\"deck\", \"cards\", \"card\", \"of\", \"in\", \"on\", \"the\", \"a\", \"an\"];\n const matchwordsOr = [\"discard\", \"drawn\", \"played\", \"used\"];\n\n const namePattern = new RegExp(\n name.replace(new RegExp(`\\\\b(?:${stopwords.join(\"|\")})\\\\b\\\\s*`, \"gi\"), \"\"),\n \"i\"\n );\n const discardPattern = new RegExp(`(?:${matchwordsOr.join(\"|\")})`, \"i\");\n const fallbackPattern = /Discard(?:\\s+Pile)?/i;\n\n for (const [deckId, deck] of game.cards.entries()) {\n if ((namePattern.test(deck.name) && discardPattern.test(deck.name)) || fallbackPattern.test(deck.name)) {\n console.log(`Discard Pile found for deck \"${name}\":`, deck.name);\n return deck.name;\n }\n }\n\n return null;\n}","flags":{"advanced-macros":{"runAsGM":false,"runForSpecificUser":""},"core":{"sourceId":"Macro.D8iIDVZZi08bN4wG"},"exportSource":{"world":"v11-test","system":"worldbuilding","coreVersion":"11.305","systemVersion":"0.8.1"}},"_stats":{"systemId":"swade","systemVersion":"2.4.2","coreVersion":"10.303","createdTime":1685747438944,"modifiedTime":1688766657549,"lastModifiedBy":"92aKSz8wx6tVXpQm"},"folder":null,"sort":0,"ownership":{"default":0,"92aKSz8wx6tVXpQm":3},"_id":"TOWwsX1u4d43kZYb"}
{"name":"Draw a Card","type":"script","author":"92aKSz8wx6tVXpQm","img":"modules/orcnog-card-viewer/assets/card-draw-fancy.svg","scope":"global","command":"// Requires Orcnog's Card Viewer\n// Draws, views, and discards a card from a given deck name. Leave discardPile null to smart-match an existing discard pile name or auto-create a new one named \"[your deck name] - Discard Pile\".\n\nlet deckName = 'Deck of Many Things';\nlet discardPile = 'My Discard Pile';\nlet share = true;\n\nOrcnogFancyCardDealer({\n deckName: deckName ,\n discardPileName: discardPile\n}).draw(share);","flags":{"core":{"sourceId":"Macro.UsTgJD5uFf9tOGYO"},"exportSource":{"world":"v11-test","system":"worldbuilding","coreVersion":"11.305","systemVersion":"0.8.1"}},"_stats":{"systemId":"swade","systemVersion":"2.4.2","coreVersion":"10.303","createdTime":1686860654456,"modifiedTime":1688760985877,"lastModifiedBy":"92aKSz8wx6tVXpQm"},"folder":null,"sort":0,"ownership":{"default":0,"92aKSz8wx6tVXpQm":3},"_id":"XCvcqGgOsDhwXDR9"}
{"name":"View Any Image as a Card","type":"script","author":"92aKSz8wx6tVXpQm","img":"modules/orcnog-card-viewer/assets/image-view-fancy.svg","scope":"global","command":"// Requires Orcnog's Card Viewer\n// This macro demonstrates the easiest way to view any image (URL or local path) as a flippable card. The card back image is automatically provided.\n\nlet img = 'modules/orcnog-card-viewer/assets/beefy-abraham-lincoln.webp';\nlet backImg = 'modules/orcnog-card-viewer/assets/orcnogback.webp'; // optional\nlet cardBorder = '#da6';\nlet shareToAll = true;\n\nOrcnogFancyDisplay({\n front: img,\n back: backImg,\n border: cardBorder\n}).render(shareToAll)","flags":{"core":{"sourceId":"Macro.W2KFsMfjHy8uC9AY"},"exportSource":{"world":"v11-test","system":"worldbuilding","coreVersion":"11.305","systemVersion":"0.8.1"}},"_stats":{"systemId":"swade","systemVersion":"2.4.2","coreVersion":"10.303","createdTime":1686762627106,"modifiedTime":1688760981671,"lastModifiedBy":"92aKSz8wx6tVXpQm"},"folder":null,"sort":0,"ownership":{"default":0,"92aKSz8wx6tVXpQm":3},"_id":"uRc3ORD74VGZBLcS"}
Empty file removed dist/packs/macros/000008.log
Empty file.
Binary file removed dist/packs/macros/000010.ldb
Binary file not shown.
1 change: 0 additions & 1 deletion dist/packs/macros/CURRENT

This file was deleted.

Empty file removed dist/packs/macros/LOCK
Empty file.
15 changes: 0 additions & 15 deletions dist/packs/macros/LOG

This file was deleted.

5 changes: 0 additions & 5 deletions dist/packs/macros/LOG.old

This file was deleted.

Binary file removed dist/packs/macros/MANIFEST-000006
Binary file not shown.