Manage GM cards

This commit is contained in:
sladecraven 2021-03-08 22:46:33 +01:00
parent 10fbcec5fb
commit c2c837b778
10 changed files with 193 additions and 25 deletions

BIN
img/cards/hearth.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1 @@
<svg style="height: 512px; width: 512px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><defs><radialGradient id="lorc-bleeding-wound-gradient-0"><stop offset="0%" stop-color="#000" stop-opacity="1"></stop><stop offset="100%" stop-color="#9b9b9b" stop-opacity="1"></stop></radialGradient></defs><rect fill="url(#lorc-bleeding-wound-gradient-0)" stroke="#000000" stroke-opacity="1" stroke-width="1" height="510" width="510" rx="32" ry="32"></rect><g class="" style="" transform="translate(-5,-11)"><path d="M26.996 47.947c11.726 44.806 56.176 129.96 67.496 242.934-6.597 76.494-22.66 98.81-22.66 152.74 0 27.602 11.33 38.038 23.254 38.038 11.662 0 23.72-11.823 23.72-40.896 0-56.606-16.937-73.84-23.283-151.65 6.472-83.65 59.715-45.933 59.715 2.765 0-112.652 101.99-85.16 116.024-34.77-5.164 35.11-15.028 45.947-15.028 75.368 0 16.633 8.51 28.86 16.74 28.86 8.416 0 16.41-11.433 16.41-27.226 0-27.953-9.303-41.066-14.515-75.825 15.447-37.68 115.544-34.583 115.845-1.754-3.41 26.414-12.764 32.13-12.764 51.16 0 9.714 6.58 16.855 12.943 16.855 6.506 0 12.685-6.677 12.685-15.9 0-18.435-9.164-25.838-12.596-52.854 14.138-49.16 86.57-19.867 92.008-73.298-51.22 45.91-357.175 26.76-455.994-134.545zm128.85 266.22c-4.676 31.802-17.635 40.28-17.635 61.724 0 10.642 8.592 18.346 17.636 18.346 8.844 0 17.988-8.24 17.988-19.45 0-22.338-13.464-28.757-17.988-60.62z" fill="#fff" fill-opacity="1" transform="translate(25.6, 25.6) scale(0.9, 0.9) rotate(0, 256, 256) skewX(0) skewY(0)"></path></g></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -54,8 +54,12 @@ export class SoSActor extends Actor {
super.prepareData(); super.prepareData();
if ( !this.cardDeck ) { if ( !this.cardDeck ) {
this.cardDeck = new SoSCardDeck(); if ( this.hasPlayerOwner) {
this.cardDeck.initCardDeck( this, this.data.data.internals.deck ); this.cardDeck = new SoSCardDeck();
this.cardDeck.initCardDeck( this, this.data.data.internals.deck );
} else {
this.cardDeck = game.system.sos.gmDeck;
}
} }
this.controlScores(); this.controlScores();
} }
@ -100,10 +104,14 @@ export class SoSActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
saveDeck( ) { saveDeck( ) {
let deck = { deck: duplicate(this.cardDeck.data.deck), let deck = { deck: duplicate(this.cardDeck.data.deck),
discard: duplicate(this.cardDeck.data.discard), discard: duplicate(this.cardDeck.data.discard),
cardEdge: duplicate(this.cardDeck.data.cardEdge) cardEdge: duplicate(this.cardDeck.data.cardEdge)
} }
this.update( { 'data.internals.deck': deck }); if ( this.hasPlayerOwner ) {
this.update( { 'data.internals.deck': deck });
} else {
game.settings.set("foundryvtt-shadows-over-sol", "gmDeck", deck );
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -89,19 +89,19 @@ export class SoSFlipDialog extends Dialog {
this.updateScoreBase(); this.updateScoreBase();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
updateConsequenceBonus(event) { updateConsequenceBonus(event) {
this.flipData.consequencesSelected = $('#consequenceSelectBonus').val(); this.flipData.consequencesSelected = $('#consequenceSelectBonus').val();
let bonusConsequence = 0; let bonusConsequence = 0;
for (let consequenceId of this.flipData.consequencesSelected) { for (let consequenceId of this.flipData.consequencesSelected) {
let consequence = this.flipData.consequencesList.find( item => item._id == consequenceId); let consequence = this.flipData.consequencesList.find( item => item._id == consequenceId);
console.log(consequence, consequenceId); console.log(consequence, consequenceId);
bonusConsequence += SoSUtility.getConsequenceBonus( consequence.data.severity ); bonusConsequence += SoSUtility.getConsequenceBonus( consequence.data.severity );
}
$('#consequence-bonus').text(bonusConsequence);
this.flipData.bonusConsequence = bonusConsequence;
this.updateScoreBase();
} }
$('#consequence-bonus').text(bonusConsequence);
this.flipData.bonusConsequence = bonusConsequence;
this.updateScoreBase();
}
/* -------------------------------------------- */ /* -------------------------------------------- */
activateListeners(html) { activateListeners(html) {

124
module/sos-gm-deck.js Normal file
View File

@ -0,0 +1,124 @@
/* -------------------------------------------- */
import { SoSUtility } from "./sos-utility.js";
import { SoSCardDeck } from "./sos-card-deck.js";
/* -------------------------------------------- */
export class SoSGMDeck extends Dialog {
/* -------------------------------------------- */
constructor(html) {
let conf = {
title: 'GM Deck Dialog',
content: html,
buttons: {
'flip-close': { label: 'Cancel and Close', callback: html => this.onFlipClose() }
},
default: 'flip'
};
super(conf, { classes: ["sosdialog"], width: 640 });
let deckData = game.settings.get("foundryvtt-shadows-over-sol", "gmDeck" );
if ( deckData == undefined || deckData.deck == undefined) {
deckData = {deck:[], discard: [], cardEdge:[] };
}
this.name = "GM Deck";
this.GMdeck = new SoSCardDeck();
this.GMdeck.initCardDeck( this, deckData );
}
/* -------------------------------------------- */
onFlipClose() {
this.close();
}
/* -------------------------------------------- */
saveDeck( ) {
let deck = {
deck: duplicate(this.GMdeck.data.deck),
discard: duplicate(this.GMdeck.data.discard),
cardEdge: duplicate(this.GMdeck.data.cardEdge)
}
game.settings.set("foundryvtt-shadows-over-sol", "gmDeck", deck );
}
/* -------------------------------------------- */
async updateFlip( deckData) {
$('.view-deck').remove();
$("#view-gm-deck").append(await this.GMdeck.getDeckHTML());
$('.view-edge').remove();
$("#view-gm-edge").append(await this.GMdeck.getEdgeHTMLForFlip());
//this.flipData.GMdeck.drawFromDeck();
}
/* -------------------------------------------- */
async drawCard() {
let card = this.GMdeck.drawFromDeck();
let cardPath = `systems/foundryvtt-shadows-over-sol/img/cards/${card.cardName}.webp`;
let cardData = { card: card, cardPath: cardPath };
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-card.html', cardData );
ChatMessage.create( { content: html, whisper: [ ChatMessage.getWhisperRecipients("GM") ] });
//dialog.onFlipClose();
}
/* -------------------------------------------- */
resetDeckFull( ) {
this.GMdeck.shuffleDeck();
this.GMdeck.drawEdge( 3 );
this.saveDeck();
}
/* -------------------------------------------- */
drawNewEdge( ) {
this.GMdeck.drawEdge( 1 );
this.saveDeck();
}
/* -------------------------------------------- */
discardEdge( cardName ) {
this.GMdeck.discardEdge( cardName );
this.saveDeck();
}
/* -------------------------------------------- */
resetDeck( ) {
this.GMdeck.resetDeck();
this.saveDeck();
}
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
this.bringToTop();
var dialog = this;
function onLoad() {
dialog.updateFlip();
}
// Setup everything onload
$(function () { onLoad(); });
html.find('.class-view-deck').click((event) => {
this.drawCard();
});
html.find('.reset-deck-full').click((event) => {
this.resetDeckFull();
this.render(true);
});
html.find('.draw-new-edge').click((event) => {
this.drawNewEdge();
this.render(true);
});
html.find('.reset-deck').click((event) => {
this.resetDeck();
this.render(true);
});
}
}

View File

@ -14,6 +14,7 @@ import { SoSActorSheet } from "./actor-sheet.js";
import { SoSUtility } from "./sos-utility.js"; import { SoSUtility } from "./sos-utility.js";
import { SoSCombat } from "./sos-combat.js"; import { SoSCombat } from "./sos-combat.js";
import { gearConverter } from "./gears_convert.js"; import { gearConverter } from "./gears_convert.js";
import { SoSGMDeck } from "./sos-gm-deck.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Foundry VTT Initialization */ /* Foundry VTT Initialization */
@ -23,10 +24,24 @@ import { gearConverter } from "./gears_convert.js";
Hooks.once("init", async function () { Hooks.once("init", async function () {
console.log(`Initializing Shadows Over Sol System`); console.log(`Initializing Shadows Over Sol System`);
/* -------------------------------------------- */
game.settings.register("foundryvtt-shadows-over-sol", "gmDeck", {
name: "gmDeck",
scope: "world",
config: false,
type: Object
});
/* -------------------------------------------- */
// preload handlebars templates // preload handlebars templates
SoSUtility.preloadHandlebarsTemplates(); SoSUtility.preloadHandlebarsTemplates();
// Create useful storage space // Create useful storage space
game.system.sos = { } let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/gm-deck.html', {} );
let gmDeck = new SoSGMDeck(html);
gmDeck.render(true);
game.system.sos = {
gmDeck: gmDeck,
}
/* -------------------------------------------- */ /* -------------------------------------------- */
// Set an initiative formula for the system // Set an initiative formula for the system

View File

@ -2,11 +2,11 @@
"name": "foundryvtt-shadows-over-sol", "name": "foundryvtt-shadows-over-sol",
"title": "Shadows over Sol", "title": "Shadows over Sol",
"description": "Shadows over Sol for FoundryVTT", "description": "Shadows over Sol for FoundryVTT",
"version": "0.1.2", "version": "0.1.4",
"manifestPlusVersion": "1.0.0", "manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.7.5", "minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.9", "compatibleCoreVersion": "0.7.9",
"templateVersion": 17, "templateVersion": 18,
"author": "LeRatierBretonnien", "author": "LeRatierBretonnien",
"esmodules": [ "module/sos-main.js" ], "esmodules": [ "module/sos-main.js" ],
"styles": ["styles/simple.css"], "styles": ["styles/simple.css"],

View File

@ -1,6 +1,6 @@
{ {
"Actor": { "Actor": {
"types": ["character", "npc"], "types": ["character"],
"templates": { "templates": {
"subactors": { "subactors": {
"subactors": { "subactors": {
@ -133,9 +133,6 @@
}, },
"character": { "character": {
"templates": [ "background", "common", "subactors" ] "templates": [ "background", "common", "subactors" ]
},
"npc": {
"templates": [ "background", "common" ]
} }
}, },
"Item": { "Item": {

2
templates/chat-card.html Normal file
View File

@ -0,0 +1,2 @@
<h4>GM draws a card from its deck ! </h4>
<span><img class="chat-icon card-icon" src="{{cardPath}}" /></span>

21
templates/gm-deck.html Normal file
View File

@ -0,0 +1,21 @@
<form class="flip-dialog">
<section>
<div class="flexcol">
<label class="dialog-label">Click on deck to draw a card!</label>
</div>
<div class="flexrow">
<span class="edge-name"><a class="card-button reset-deck-full">Reset full deck and edges</a></span>
<span class="edge-name"><a class="card-button draw-new-edge">Draw a new Edge card</a></span>
<span class="edge-name"><a class="card-button reset-deck">Reset deck only (ie after a Joker)</a></span>
</div>
<div class="flexrow">
<span class="class-view-deck" id="view-gm-deck"></span>
<span class="class-view-edge" id="view-gm-edge"></span>
</div>
<div class="flexrow">
<label class="dialog-label"></label>
</div>
</section>
</form>