From b3eb613f2fe94fd52bc77993a4c788ad8e57c676 Mon Sep 17 00:00:00 2001 From: spacemandev Date: Fri, 18 Sep 2020 17:45:32 -0500 Subject: [PATCH] updated to 1.5.2 to add getallcardsbydeck hook --- changelog.md | 4 ++++ dist/module.json | 2 +- dist/scripts/socketListener.js | 9 +++++++++ src/module.json | 2 +- src/scripts/socketListener.ts | 15 +++++++++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index b027d5f..399e070 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +1.5.2 +- Added socket "GETCARDSBYDECK" that returns JournalEntries of all cards in a given deck. It does this by calling the hool +`deckID-info` with (deckID, cards) where cards is a list of journal entries in the deck + 1.5.1 - Fixed the deck not coming onto the scene (needed to add legacy support for deck images not being on older decks) diff --git a/dist/module.json b/dist/module.json index 2514dbb..91aa9fd 100644 --- a/dist/module.json +++ b/dist/module.json @@ -3,7 +3,7 @@ "title": "Card Support (Unofficial)", "description": "Unofficial deck support for foundry that allows you to have cards and player hands and the like.", "author": "Spacemandev, Norc", - "version": "1.5.1", + "version": "1.5.2", "minimumCoreVersion": "0.6.0", "compatibleCoreVersion": "0.7.2", "url": "https://github.com/spacemandev-git/fvtt-card-support", diff --git a/dist/scripts/socketListener.js b/dist/scripts/socketListener.js index 59ce007..8c9aabf 100644 --- a/dist/scripts/socketListener.js +++ b/dist/scripts/socketListener.js @@ -145,5 +145,14 @@ Hooks.on("ready", () => { game.decks.get(data.deckID).removeFromDiscard(game.decks.get(data.deckID)._discard); game.decks.get(data.deckID).shuffle(); } + else if ((data === null || data === void 0 ? void 0 : data.type) == "GETALLCARDSBYDECK") { + let cards = []; + let deck = game.decks.get(data.deckID); + let cardIDs = deck._state.slice(deck._state.length - data.viewNum); + cards = cardIDs.map(el => { + return game.journal.get(el); + }).reverse(); + Hooks.call(`${data.deckID}-info`, (data.deckID, cards)); + } })); }); diff --git a/src/module.json b/src/module.json index 2514dbb..91aa9fd 100644 --- a/src/module.json +++ b/src/module.json @@ -3,7 +3,7 @@ "title": "Card Support (Unofficial)", "description": "Unofficial deck support for foundry that allows you to have cards and player hands and the like.", "author": "Spacemandev, Norc", - "version": "1.5.1", + "version": "1.5.2", "minimumCoreVersion": "0.6.0", "compatibleCoreVersion": "0.7.2", "url": "https://github.com/spacemandev-git/fvtt-card-support", diff --git a/src/scripts/socketListener.ts b/src/scripts/socketListener.ts index 58fa261..718bea5 100644 --- a/src/scripts/socketListener.ts +++ b/src/scripts/socketListener.ts @@ -121,10 +121,25 @@ Hooks.on("ready", () => { (game.decks.get(data.deckID)).addToDeckState(game.decks.get(data.deckID)._discard); (game.decks.get(data.deckID)).removeFromDiscard(game.decks.get(data.deckID)._discard); (game.decks.get(data.deckID)).shuffle(); + } else if (data?.type == "GETALLCARDSBYDECK"){ + let cards:JournalEntry[] = []; + let deck =(game.decks.get(data.deckID)) + let cardIDs = deck._state.slice(deck._state.length - data.viewNum) + cards = cardIDs.map(el => { + return game.journal.get(el) + }).reverse() + Hooks.call(`${data.deckID}-info`, (data.deckID, cards)) } }) }) +export interface MSG_GETALLCARDSBYDECK { + type: "GETALLCARDSBYDECK", + playerID: string, + deckID: string + to:string +} + export interface MSG_SHUFFLEBACKDISCARD { type: "SHUFFLEBACKDISCARD", playerID: string,