Skip to content

Commit

Permalink
updated to 1.5.2 to add getallcardsbydeck hook
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemandev-git committed Sep 18, 2020
1 parent dc48d17 commit b3eb613
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion dist/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions dist/scripts/socketListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}));
});
2 changes: 1 addition & 1 deletion src/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions src/scripts/socketListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,25 @@ Hooks.on("ready", () => {
(<Deck>game.decks.get(data.deckID)).addToDeckState(game.decks.get(data.deckID)._discard);
(<Deck>game.decks.get(data.deckID)).removeFromDiscard(game.decks.get(data.deckID)._discard);
(<Deck>game.decks.get(data.deckID)).shuffle();
} else if (data?.type == "GETALLCARDSBYDECK"){
let cards:JournalEntry[] = [];
let deck =(<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,
Expand Down

0 comments on commit b3eb613

Please sign in to comment.