Initial system development
This commit is contained in:
76
module/actor-sheet.js
Normal file
76
module/actor-sheet.js
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
* Extend the basic ActorSheet with some very simple modifications
|
||||
* @extends {ActorSheet}
|
||||
*/
|
||||
|
||||
import { SoSUtility } from "./sos-utility.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class SoSActorSheet extends ActorSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["sos", "sheet", "actor"],
|
||||
template: "systems/foundryvtt-shadows-over-sol/templates/actor-sheet.html",
|
||||
width: 640,
|
||||
//height: 720,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }],
|
||||
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }]
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getData() {
|
||||
let data = super.getData();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onDrop(event) {
|
||||
super._onDrop(event);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM);
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
|
||||
// Update Inventory Item
|
||||
html.find('.item-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const item = this.actor.getOwnedItem(li.data("item-id"));
|
||||
item.sheet.render(true);
|
||||
});
|
||||
|
||||
// Delete Inventory Item
|
||||
html.find('.item-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
RdDUtility.confirmerSuppression(this, li);
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
setPosition(options = {}) {
|
||||
const position = super.setPosition(options);
|
||||
const sheetBody = this.element.find(".sheet-body");
|
||||
const bodyHeight = position.height - 192;
|
||||
sheetBody.css("height", bodyHeight);
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
_updateObject(event, formData) {
|
||||
// Update the Actor
|
||||
return this.object.update(formData);
|
||||
}
|
||||
}
|
75
module/item-sheet.js
Normal file
75
module/item-sheet.js
Normal file
@ -0,0 +1,75 @@
|
||||
import { SoSUtility } from "./sos-utility.js";
|
||||
|
||||
/**
|
||||
* Extend the basic ItemSheet with some very simple modifications
|
||||
* @extends {ItemSheet}
|
||||
*/
|
||||
export class SoSItemSheet extends ItemSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["foundryvtt-shadows-over-sol", "sheet", "item"],
|
||||
template: "systems/foundryvtt-shadows-over-sol/templates/item-sheet.html",
|
||||
width: 550,
|
||||
height: 550
|
||||
//tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}]
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_getHeaderButtons() {
|
||||
let buttons = super._getHeaderButtons();
|
||||
// Add "Post to chat" button
|
||||
// We previously restricted this to GM and editable items only. If you ever find this comment because it broke something: eh, sorry!
|
||||
buttons.unshift(
|
||||
{
|
||||
class: "post",
|
||||
icon: "fas fa-comment",
|
||||
onclick: ev => {} //new RdDItem(this.item.data).postItem()
|
||||
})
|
||||
return buttons
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
setPosition(options={}) {
|
||||
const position = super.setPosition(options);
|
||||
const sheetBody = this.element.find(".sheet-body");
|
||||
const bodyHeight = position.height - 192;
|
||||
sheetBody.css("height", bodyHeight);
|
||||
return position;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
let data = super.getData();
|
||||
data.isGM = game.user.isGM;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
get template()
|
||||
{
|
||||
let type = this.item.type;
|
||||
return `systems/foundryvtt-shadows-over-sol/templates/item-${type}-sheet.html`;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
_updateObject(event, formData) {
|
||||
return this.object.update(formData);
|
||||
}
|
||||
}
|
48
module/sos-card-deck.js
Normal file
48
module/sos-card-deck.js
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const NB_POKER_CARD = 54;
|
||||
const IDX2CARDFAMILY = ['c', 'd', 'h', 's'];
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class SoSCardDeck extends Application {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async create(data, options) {
|
||||
data.deck = [];
|
||||
data.discard = [];
|
||||
data.cardState = [];
|
||||
|
||||
return super.create(data, options);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
shuffleDeck() {
|
||||
this.cleanCardList();
|
||||
// Randomize deck
|
||||
while (data.deck.length != NB_POKER_CARD) {
|
||||
let idx = new Roll("1d54").roll().total;
|
||||
if (!this.data.cardState[idx - 1]) {
|
||||
if (idx == 53) { // Red Joker
|
||||
data.deck.push = { cardName: 'jr' }
|
||||
} else if (idx == 54) { // Black Joker
|
||||
data.deck.push = { cardName: 'jb' }
|
||||
} else {
|
||||
let familyIdx = idx % 4;
|
||||
let cardName = IDX2CARDFAMILY[familyIdx] + String((idx % 13) + 1);
|
||||
data.deck.push = { cardName: cardName }
|
||||
}
|
||||
this.data.cardState[idx - 1] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
cleanCardList() {
|
||||
data.discard = []; // Reinit discard pile
|
||||
data.deck = [];
|
||||
for (let i = 0; i < NB_POKER_CARD; i++) {
|
||||
data.cardState[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -12,8 +12,8 @@ import { SoSActor } from "./actor.js";
|
||||
import { SoSItemSheet } from "./item-sheet.js";
|
||||
import { SoSActorSheet } from "./actor-sheet.js";
|
||||
import { SoSUtility } from "./rdd-utility.js";
|
||||
import { SoSTokenHud } from "./rdd-token-hud.js";
|
||||
import { SoSCommands } from "./rdd-commands.js";
|
||||
//import { SoSTokenHud } from "./rdd-token-hud.js";
|
||||
//import { SoSCommands } from "./rdd-commands.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Foundry VTT Initialization */
|
||||
|
@ -1,8 +1,12 @@
|
||||
|
||||
export class SoSUtility {
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async preloadHandlebarsTemplates() {
|
||||
const templatePaths = [
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/editor-notes-gm.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/item-shet.html'
|
||||
]
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user