orcnog / orcnog-card-viewer

MIT License
4 stars 0 forks source link

Card Viewer

A Module for Foundry VTT

Purpose

After setting up a deck of many things in one of my games, I found there wasn't great out-of-the-box way to simply view and share a card. Taking visual inspiration from a popular 5e toolset, I ported their card viewer UX over to the Foundry system. Now, I can view cards beautifully in a 3d-feel viewer, flip the cards over to view the card art or read the card stats, and even share this beautiful view with my players on the fly.

Dependencies

socketlib

Compatibility

This was built on Foundry v11 and, based on initial user feedback, appears to be currently mostly compatible with v10 but may have some bugs. As for compatibility with other modules, none have been tested, but the functionality of this mod doesn't mess with the core card system and only serves to enhance the UI in exactly one way, so I doubt there will be many conflicts. If you come across any issues in v10 or with mother modules, please feel free to log in the github issues section.

Demo

A demo showing how to view a card from a deck, flip it, share it, dismiss it, and what output to expect in the DM chat:

Demo of orcnog-card-viewer module


A quick demo showcasing 2 macros that will draw a random card from a given deck and discard it, or peek at a card without drawing it:

Demo of orcnog-card-viewer module

Settings

Macros

You'll need to import all the macros from the compendium in this module and customize them.

Draw a Card

  1. Replace 'Deck of Many Things' with name of a deck in your world.
  2. Replace 'My Discard Pile' with the name of a pile in your world.
  3. If you set share to true, everyone logged in FVTT will see the card immediately when drawn.
  4. face determines how the card is initially displayed. This var can be ommitted, or set to "UP", "DOWN", or "REVEAL" to flip the card face-up with animation.
// 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".

let deckName = 'Deck of Many Things';
let discardPile = 'My Discard Pile';
let share = true;
let face = "REVEAL"; //either "UP", "DOWN", or "REVEAL" to flip up

OrcnogFancyCardDealer({
   deckName: deckName ,
   discardPileName: discardPile
}).draw(share, face);

View a Card

  1. Replace 'Deck of Many Things' with name of a deck in your world.
  2. Replace 'Gem' with the name of a card in the deck or the UID.
  3. set faceDown to true and the card will shown flipped.
  4. If you set share to true, everyone logged in FVTT will see the card.
// Peeks at a card, but does not draw and discard it.

let deckName = 'Deck of Many Things';
let card = 'Gem'; // card name or ID
let faceDown = true;
let whisper = false;
let share = false;

OrcnogFancyCardDealer({
   deckName: deckName,
}).view(card, faceDown, whisper, share);

View Any Image as a Card

  1. Replace 'modules/orcnog-card-viewer/assets/beefy-abraham-lincoln.webp' with a path or URL to any image you want.
  2. You can replace 'modules/orcnog-card-viewer/assets/orcnogback.webp' with a path or URL to any card back image.
  3. borderColor can change the border color.
  4. borderWidth can change the colored border thickness.
  5. shareToAll will show to everyone.
// Requires Orcnog's Card Viewer
// 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.

let img = 'modules/orcnog-card-viewer/assets/beefy-abraham-lincoln.webp';
let backImg = 'https://i.imgur.com/mStOCso.png'; // optional
let borderColor = '#543'; // optional
let borderWidth = '5px'; // optional
let shareToAll = true; // optional

OrcnogFancyDisplay({
   front: img,
   back: backImg,
   border: borderColor,
   borderWidth: borderWidth
}).render(shareToAll)

API Methods

This module ships with several API methods that can be leveraged in code, and a couple of added global convenience functions.

Global functions

These functions shuold be accessible at the global level. Use them in macros or in other module code as needed. With the API methods exposed, I probably should just get rid of these... but they do clean up the macros' code.

Changelog

v0.0.0

testing this github release functionality.

v0.1.0

Orcnog Card Viewer's world debut! (or so i thought!)

v0.1.1

Release 0.1.1 - ready for package submission! (or so i thought!)

v0.1.2

Release 0.1.2 - some quick changes for package approval. removed possibly-copyrighted sabaac image. ACTUAL WORLD DEBUT HERE. Hello world!

v0.1.3

First round of bugfixes and me-aculpas. Added decent README (including this changelog section), and a demo video. Nerfed the compatibility to just v11, as user feedback indicates it's not compatible with v10 =/

v0.1.4

Fixed Issue #10, 'Deck of Many Things' hardcoded. Also added a new GIF demo video.

v0.1.5

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.

v0.1.7

Added game settings for default border color & width and cardback image. Made borderWidth configurable in macros and api calls. Fixed Issue #18.

v0.1.8

Completes localization or all client-facing or language-functional strings. Attempts to fix .deal() erroring out.

v0.2.0

Handle for Pass and Draw (to a hand) actions, with new settings to handle whether those trigger card views. Module now depends on socketlib. Moevs several values to a new CONSTS file. Fixed an annoyance where it searched for a discard pile every time, even if just viewing a card.

v0.3.0

Multiple cards are now grouped into a single display. "Dramatic reveal" (I know, corny name), is now implemented to show cards face-down at first, but then auto-flip them over after a small (dramatic?) delay. Several new settings added to add fine control over display behaviors based on specific card actions, e.g. on the Deal action, always show cards face-up, but on Draw action, show them face-down, while on Pass actions, show them with a dramatic reveal (flip from face-down to -up automagically). Settings menu has also been enhanced with collapsible groups of settings. The grouping of multiple cards into a single viewer was enough to merit a new minor version on its own, but with all the enhancements to settings, dramatic reveal, and a few other things crossed off the TODO list, I'm happy with calling this a new minor version. After a few weeks/months of beta testing, I may as well call this version 1.0, but cart/horse.

v0.3.1

Quick bug fix: .viewImage and .viewImageAsCard api methods and global OrcnogFancyDisplay() and OrcnogFancyImage() functions broke in v0.3.0 after the image input for the fancyDisplay class was converted from singular fonr/back img params to an Array (to support multiple cards in one view). This fix ought to solve that before ppl start logging bugs.

v0.3.2

Updated to Foundry v12 (verified in module.json). Also updated the TODOs a bit.