WIP: Generators
parent
e23adf87f9
commit
0ea0e25fba
|
@ -15,6 +15,7 @@
|
|||
"OSE.dialog.partysheet": "Party Overview",
|
||||
"OSE.dialog.selectActors": "Select PCs",
|
||||
"OSE.dialog.dealXP": "Deal XP",
|
||||
"OSE.dialog.generateSaves": "Generate Saves",
|
||||
|
||||
"OSE.Formula": "Formula",
|
||||
"OSE.SitMod": "Situational Modifier",
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
"OSE.dialog.partysheet": "Fiche de Groupe",
|
||||
"OSE.dialog.selectActors": "Choisir PJs",
|
||||
"OSE.dialog.dealXP": "Donner XP",
|
||||
"OSE.dialog.generateSaves": "Générer les Sauvegardes",
|
||||
|
||||
"OSE.Formula": "Formule",
|
||||
"OSE.SitMod": "Mod. de situation",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { OseActor } from "./entity.js";
|
||||
import { OseActorSheet } from "./actor-sheet.js";
|
||||
import { OseCharacterModifiers } from "../dialog/character-modifiers.js";
|
||||
import { OseCharacterCreator } from "../dialog/character-creation.js";
|
||||
|
||||
/**
|
||||
* Extend the basic ActorSheet with some very simple modifications
|
||||
|
@ -33,6 +34,22 @@ export class OseActorSheetCharacter extends OseActorSheet {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Character creation helpers
|
||||
* @param {...any} args
|
||||
*/
|
||||
async _render(...args) {
|
||||
super._render(...args).then(() => {
|
||||
if (this.actor.isNew()) {
|
||||
event.preventDefault();
|
||||
new OseCharacterCreator(this.actor, {
|
||||
top: this.position.top + 40,
|
||||
left: this.position.left + (this.position.width - 400) / 2,
|
||||
}).render(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare data for rendering the Actor sheet
|
||||
* The prepared data object contains both the actor data as well as additional sheet options
|
||||
|
|
|
@ -51,6 +51,56 @@ export class OseActor extends Actor {
|
|||
});
|
||||
}
|
||||
|
||||
isNew() {
|
||||
const data = this.data.data;
|
||||
if (this.data.type == 'character') {
|
||||
let ct = 0;
|
||||
Object.values(data.scores).forEach((el) => {
|
||||
ct += el.value;
|
||||
})
|
||||
return ct == 0 ? true : false;
|
||||
} else if (this.data.type == 'monster') {
|
||||
let ct = 0;
|
||||
Object.values(data.saves).forEach(el => {
|
||||
ct += el.value;
|
||||
});
|
||||
return ct == 0 ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
generator() {
|
||||
|
||||
}
|
||||
|
||||
generateSave(hd) {
|
||||
let saves = {};
|
||||
for (let i = 0; i <= hd; i++) {
|
||||
let tmp = CONFIG.OSE.monster_saves[i];
|
||||
if (tmp) {
|
||||
saves = tmp;
|
||||
}
|
||||
}
|
||||
this.update({
|
||||
"data.saves": {
|
||||
death: {
|
||||
value: saves.d
|
||||
},
|
||||
wand: {
|
||||
value: saves.w
|
||||
},
|
||||
paralysis: {
|
||||
value: saves.p
|
||||
},
|
||||
breath: {
|
||||
value: saves.b
|
||||
},
|
||||
spell: {
|
||||
value: saves.s
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Rolls */
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
@ -32,6 +32,38 @@ export class OseActorSheetMonster extends OseActorSheet {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Monster creation helpers
|
||||
* @param {...any} args
|
||||
*/
|
||||
async _render(...args) {
|
||||
super._render(...args).then(() => {
|
||||
if (this.actor.isNew()) {
|
||||
const template = `
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label>Hit dice count</label>
|
||||
<input name="total" placeholder="Hit Dice" type="text"/>
|
||||
</div>
|
||||
</form>`;
|
||||
new Dialog({
|
||||
title: game.i18n.localize("OSE.dialog.generateSaves"),
|
||||
content: template,
|
||||
buttons: {
|
||||
set: {
|
||||
icon: '<i class="fas fa-dice"></i>',
|
||||
label: game.i18n.localize("OSE.dialog.generateSaves"),
|
||||
callback: (html) => {
|
||||
let hd = html.find('input[name="total"]').val();
|
||||
this.actor.generateSave(hd);
|
||||
},
|
||||
},
|
||||
},
|
||||
}).render(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare data for rendering the Actor sheet
|
||||
* The prepared data object contains both the actor data as well as additional sheet options
|
||||
|
|
|
@ -87,5 +87,70 @@ export const OSE = {
|
|||
splash: "/systems/ose/assets/splash.png",
|
||||
reload: "/systems/ose/assets/reload.png",
|
||||
charge: "/systems/ose/assets/charge.png",
|
||||
},
|
||||
monster_saves: {
|
||||
0: {
|
||||
d: 14,
|
||||
w: 15,
|
||||
p: 16,
|
||||
b: 17,
|
||||
s: 18
|
||||
},
|
||||
1: {
|
||||
d: 12,
|
||||
w: 13,
|
||||
p: 14,
|
||||
b: 15,
|
||||
s: 16
|
||||
},
|
||||
4: {
|
||||
d: 10,
|
||||
w: 11,
|
||||
p: 12,
|
||||
b: 13,
|
||||
s: 14
|
||||
},
|
||||
7: {
|
||||
d: 8,
|
||||
w: 9,
|
||||
p: 10,
|
||||
b: 10,
|
||||
s: 12
|
||||
},
|
||||
10: {
|
||||
d: 6,
|
||||
w: 7,
|
||||
p: 8,
|
||||
b: 8,
|
||||
s: 10
|
||||
},
|
||||
13: {
|
||||
d: 4,
|
||||
w: 5,
|
||||
p: 6,
|
||||
b: 5,
|
||||
s: 8
|
||||
},
|
||||
16: {
|
||||
d: 2,
|
||||
w: 3,
|
||||
p: 4,
|
||||
b: 3,
|
||||
s: 6
|
||||
},
|
||||
19: {
|
||||
d: 2,
|
||||
w: 2,
|
||||
p: 2,
|
||||
b: 2,
|
||||
s: 4
|
||||
},
|
||||
22: {
|
||||
d: 2,
|
||||
w: 2,
|
||||
p: 2,
|
||||
b: 2,
|
||||
s: 2
|
||||
},
|
||||
}
|
||||
};
|
|
@ -0,0 +1,57 @@
|
|||
// eslint-disable-next-line no-unused-vars
|
||||
import { OseActor } from '../actor/entity.js';
|
||||
|
||||
export class OseCharacterCreator extends FormApplication {
|
||||
static get defaultOptions() {
|
||||
const options = super.defaultOptions;
|
||||
options.id = 'character-creator';
|
||||
options.template =
|
||||
'systems/ose/templates/actors/dialogs/character-creation.html';
|
||||
options.width = 380;
|
||||
return options;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Add the Entity name into the window title
|
||||
* @type {String}
|
||||
*/
|
||||
get title() {
|
||||
return `${this.object.name}: ${game.i18n.localize('OSE.dialog.tweaks')}`;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Construct and return the data object used to render the HTML template for this form application.
|
||||
* @return {Object}
|
||||
*/
|
||||
getData() {
|
||||
let data = this.object.data;
|
||||
data.user = game.user;
|
||||
data.config = CONFIG.OSE;
|
||||
return data;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called upon form submission after form data is validated
|
||||
* @param event {Event} The initial triggering submission event
|
||||
* @param formData {Object} The object of validated form data with which to update the object
|
||||
* @private
|
||||
*/
|
||||
async _updateObject(event, formData) {
|
||||
event.preventDefault();
|
||||
// Update the actor
|
||||
this.object.update(formData);
|
||||
// Re-draw the updated sheet
|
||||
this.object.sheet.render(true);
|
||||
}
|
||||
}
|
|
@ -31,19 +31,19 @@
|
|||
},
|
||||
"saves": {
|
||||
"death": {
|
||||
"value": 10
|
||||
"value": 0
|
||||
},
|
||||
"wand": {
|
||||
"value": 10
|
||||
"value": 0
|
||||
},
|
||||
"paralysis": {
|
||||
"value": 10
|
||||
"value": 0
|
||||
},
|
||||
"breath": {
|
||||
"value": 10
|
||||
"value": 0
|
||||
},
|
||||
"spell": {
|
||||
"value": 10
|
||||
"value": 0
|
||||
}
|
||||
},
|
||||
"movement": {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<form autocomplete="off" onsubmit="event.preventDefault();">
|
||||
<ol class="attribute-list">
|
||||
{{#each config.scores as |score id| }}
|
||||
<li data-score="{{id}}">{{score}}</li>
|
||||
{{/each}}
|
||||
</ol>
|
||||
</form>
|
Loading…
Reference in New Issue