Initial import
This commit is contained in:
parent
522cad2ff8
commit
b3f0af8c12
Binary file not shown.
Before Width: | Height: | Size: 105 KiB |
@ -41,6 +41,8 @@ export class PegasusActorSheet extends ActorSheet {
|
|||||||
effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)),
|
effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)),
|
||||||
limited: this.object.limited,
|
limited: this.object.limited,
|
||||||
specs: this.actor.getSpecs( ),
|
specs: this.actor.getSpecs( ),
|
||||||
|
optionsDiceList: PegasusUtility.getOptionsDiceList(),
|
||||||
|
optionsLevel: PegasusUtility.getOptionsLevel(),
|
||||||
weapons: this.actor.checkAndPrepareWeapons( duplicate(this.actor.getWeapons()) ),
|
weapons: this.actor.checkAndPrepareWeapons( duplicate(this.actor.getWeapons()) ),
|
||||||
armors: duplicate(this.actor.getArmors()),
|
armors: duplicate(this.actor.getArmors()),
|
||||||
shields: duplicate(this.actor.getShields()),
|
shields: duplicate(this.actor.getShields()),
|
||||||
@ -102,10 +104,14 @@ export class PegasusActorSheet extends ActorSheet {
|
|||||||
this.actor.incrementeQuantite( li.data("item-id") );
|
this.actor.incrementeQuantite( li.data("item-id") );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
html.find('.skill-roll').click((event) => {
|
html.find('.roll-stat').click((event) => {
|
||||||
|
const statId = $(event.currentTarget).data("stat-key");
|
||||||
|
this.actor.rollStat(statId);
|
||||||
|
});
|
||||||
|
html.find('.roll-spec').click((event) => {
|
||||||
const li = $(event.currentTarget).parents(".item");
|
const li = $(event.currentTarget).parents(".item");
|
||||||
const skillId = li.data("item-id");
|
const specId = li.data("item-id");
|
||||||
this.actor.rollSkill(skillId);
|
this.actor.rollSpec(specId);
|
||||||
});
|
});
|
||||||
html.find('.technique-roll').click((event) => {
|
html.find('.technique-roll').click((event) => {
|
||||||
const li = $(event.currentTarget).parents(".item");
|
const li = $(event.currentTarget).parents(".item");
|
||||||
|
@ -126,13 +126,16 @@ export class PegasusActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getWeapons() {
|
getWeapons() {
|
||||||
let comp = this.data.items.filter( item => item.type == 'weapon' );
|
let comp = duplicate(this.data.items.filter( item => item.type == 'weapon' ) || []);
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getSpecs() {
|
getSpecs() {
|
||||||
let comp = this.data.items.filter( item => item.type == 'specialisation');
|
let comp = duplicate(this.data.items.filter( item => item.type == 'specialisation') || []);
|
||||||
|
for (let c of comp) {
|
||||||
|
c.data.dice = PegasusUtility.getDiceFromLevel(c.data.level);
|
||||||
|
}
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,44 +353,89 @@ export class PegasusActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
syncRoll( rollData ) {
|
syncRoll( rollData ) {
|
||||||
let linkedRollId = WotGUtility.getDefenseState(this.id);
|
let linkedRollId = PegasusUtility.getDefenseState(this.id);
|
||||||
if ( linkedRollId) {
|
if ( linkedRollId) {
|
||||||
rollData.linkedRollId = linkedRollId;
|
rollData.linkedRollId = linkedRollId;
|
||||||
}
|
}
|
||||||
rollData.rollId = randomID(16);
|
|
||||||
this.lastRollId = rollData.rollId;
|
this.lastRollId = rollData.rollId;
|
||||||
WotGUtility.saveRollData( rollData );
|
PegasusUtility.saveRollData( rollData );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollSkill( skillId ) {
|
getStat( statKey) {
|
||||||
let skill = this.data.items.find( item => item.type == 'skill' && item.id == skillId);
|
let stat = duplicate(this.data.data.statistics[statKey]);
|
||||||
if (skill) {
|
stat.dice = PegasusUtility.getDiceFromLevel(stat.value);
|
||||||
|
return stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
getOneSpec( specId) {
|
||||||
|
let spec = this.data.items.find( item => item.type == 'specialisation' && item.id == specId);
|
||||||
|
if (spec) {
|
||||||
|
spec = duplicate(spec);
|
||||||
|
spec.data.dice = PegasusUtility.getDiceFromLevel(spec.data.level);
|
||||||
|
}
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async rollStat(statKey) {
|
||||||
|
let stat = this.getStat(statKey) ;
|
||||||
|
if (stat) {
|
||||||
let rollData = {
|
let rollData = {
|
||||||
mode: "skill",
|
rollId:randomID(16),
|
||||||
|
mode: "stat",
|
||||||
alias: this.name,
|
alias: this.name,
|
||||||
actorImg: this.img,
|
actorImg: this.img,
|
||||||
actorId: this.id,
|
actorId: this.id,
|
||||||
img: skill.img,
|
img: this.img,
|
||||||
rollMode: game.settings.get("core", "rollMode"),
|
rollMode: game.settings.get("core", "rollMode"),
|
||||||
armorModifier: this.getArmorModifier(),
|
title: `Stat ${stat.label} `,
|
||||||
title: `Skill ${skill.name} `,
|
stat: stat,
|
||||||
skill: duplicate(skill),
|
optionsDiceList: PegasusUtility.getOptionsDiceList(),
|
||||||
skillAttr: this.getAttribute( skill.data.data.attribute ),
|
bonusDicesLevel: 0,
|
||||||
optionsNegative: WotGUtility.getNegativeModifiers(),
|
hindranceDicesLevel: 0,
|
||||||
optionsPositive: WotGUtility.getPositiveModifiers(),
|
otherDicesLevel: 0,
|
||||||
negativeModifier: 0,
|
|
||||||
positiveModifier: 0,
|
|
||||||
specialtiesBonus: 0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.syncRoll( rollData);
|
this.syncRoll( rollData);
|
||||||
|
|
||||||
let rollDialog = await WotGRollDialog.create( this, rollData);
|
let rollDialog = await PegasusRollDialog.create( this, rollData);
|
||||||
console.log(rollDialog);
|
console.log(rollDialog);
|
||||||
rollDialog.render( true );
|
rollDialog.render( true );
|
||||||
} else {
|
} else {
|
||||||
ui.notifications.warn("Skill not found !");
|
ui.notifications.warn("Statistic not found !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async rollSpec( specId ) {
|
||||||
|
let spec = this.getOneSpec( specId)
|
||||||
|
if (spec) {
|
||||||
|
let rollData = {
|
||||||
|
mode: "spec",
|
||||||
|
alias: this.name,
|
||||||
|
actorImg: this.img,
|
||||||
|
actorId: this.id,
|
||||||
|
img: spec.img,
|
||||||
|
rollMode: game.settings.get("core", "rollMode"),
|
||||||
|
title: `Specialisation Roll : ${spec.name} `,
|
||||||
|
spec : spec ,
|
||||||
|
optionsDiceList: PegasusUtility.getOptionsDiceList(),
|
||||||
|
stat: this.getStat( spec.data.statistic ),
|
||||||
|
bonusDicesLevel: 0,
|
||||||
|
hindranceDicesLevel: 0,
|
||||||
|
otherDicesLevel: 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
this.syncRoll( rollData);
|
||||||
|
|
||||||
|
let rollDialog = await PegasusRollDialog.create( this, rollData);
|
||||||
|
console.log(rollDialog);
|
||||||
|
rollDialog.render( true );
|
||||||
|
} else {
|
||||||
|
ui.notifications.warn("Specialisation not found !");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ export class PegasusItemSheet extends ItemSheet {
|
|||||||
name: objectData.name,
|
name: objectData.name,
|
||||||
editable: this.isEditable,
|
editable: this.isEditable,
|
||||||
cssClass: this.isEditable ? "editable" : "locked",
|
cssClass: this.isEditable ? "editable" : "locked",
|
||||||
|
optionsDiceList: PegasusUtility.getOptionsDiceList(),
|
||||||
data: itemData,
|
data: itemData,
|
||||||
limited: this.object.limited,
|
limited: this.object.limited,
|
||||||
options: this.options,
|
options: this.options,
|
||||||
|
@ -28,6 +28,16 @@ Hooks.once("init", async function () {
|
|||||||
// preload handlebars templates
|
// preload handlebars templates
|
||||||
PegasusUtility.preloadHandlebarsTemplates();
|
PegasusUtility.preloadHandlebarsTemplates();
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
game.settings.register("fvtt-pegasus-rpg", "dice-max-level", {
|
||||||
|
name: "Maximum level value for dices lists",
|
||||||
|
hint: "Se the maximum level value for dices lists",
|
||||||
|
scope: "world",
|
||||||
|
config: true,
|
||||||
|
default: 20,
|
||||||
|
type: Number
|
||||||
|
});
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
// Set an initiative formula for the system
|
// Set an initiative formula for the system
|
||||||
CONFIG.Combat.initiative = {
|
CONFIG.Combat.initiative = {
|
||||||
|
@ -7,12 +7,12 @@ export class PegasusRollDialog extends Dialog {
|
|||||||
|
|
||||||
let html
|
let html
|
||||||
let options = { classes: ["WotGdialog"], width: 420, height: 320, 'z-index': 99999 };
|
let options = { classes: ["WotGdialog"], width: 420, height: 320, 'z-index': 99999 };
|
||||||
if ( rollData.mode == "skill") {
|
if ( rollData.mode == "stat") {
|
||||||
html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-skill.html', rollData);
|
html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-stat.html', rollData);
|
||||||
|
options.height = 320;
|
||||||
|
} else if (rollData.mode == "spec") {
|
||||||
|
html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-spec.html', rollData);
|
||||||
options.height = 360;
|
options.height = 360;
|
||||||
} else if (rollData.mode == "chidamage") {
|
|
||||||
html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-damage-chi.html', rollData);
|
|
||||||
options.height = 380;
|
|
||||||
} else if (rollData.mode == "technique") {
|
} else if (rollData.mode == "technique") {
|
||||||
html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-technique.html', rollData);
|
html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-technique.html', rollData);
|
||||||
options.height = 380;
|
options.height = 380;
|
||||||
@ -53,7 +53,7 @@ export class PegasusRollDialog extends Dialog {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
roll () {
|
roll () {
|
||||||
PegasusUtility.rollWotG( this.rollData )
|
PegasusUtility.rollPegasus( this.rollData )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -65,20 +65,14 @@ export class PegasusRollDialog extends Dialog {
|
|||||||
}
|
}
|
||||||
$(function () { onLoad(); });
|
$(function () { onLoad(); });
|
||||||
|
|
||||||
html.find('#negativeModifier').change((event) => {
|
html.find('#bonusDicesLevel').change((event) => {
|
||||||
this.rollData.negativeModifier = Number(event.currentTarget.value);
|
this.rollData.bonusDicesLevel = Number(event.currentTarget.value);
|
||||||
});
|
});
|
||||||
html.find('#positiveModifier').change((event) => {
|
html.find('#hindranceDicesLevel').change((event) => {
|
||||||
this.rollData.positiveModifier = Number(event.currentTarget.value);
|
this.rollData.hindranceDicesLevel = Number(event.currentTarget.value);
|
||||||
});
|
});
|
||||||
html.find('#specialtiesBonus').change((event) => {
|
html.find('#otherDicesLevel').change((event) => {
|
||||||
this.rollData.specialtiesBonus = Number(event.currentTarget.value);
|
this.rollData.otherDicesLevel = Number(event.currentTarget.value);
|
||||||
});
|
|
||||||
html.find('#selectedChi').change((event) => {
|
|
||||||
this.rollData.selectedChi = Number(event.currentTarget.value);
|
|
||||||
});
|
|
||||||
html.find('#bonusMalus').change((event) => {
|
|
||||||
this.rollData.bonusMalus = Number(event.currentTarget.value);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
const __level2Dice = [ "d0", "d4", "d6", "d8", "d10", "d12" ];
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
export class PegasusUtility {
|
export class PegasusUtility {
|
||||||
@ -9,6 +10,10 @@ export class PegasusUtility {
|
|||||||
Hooks.on('renderChatLog', (log, html, data) => PegasusUtility.chatListeners(html));
|
Hooks.on('renderChatLog', (log, html, data) => PegasusUtility.chatListeners(html));
|
||||||
this.rollDataStore = {}
|
this.rollDataStore = {}
|
||||||
this.defenderStore = {}
|
this.defenderStore = {}
|
||||||
|
this.diceList = [];
|
||||||
|
this.diceFoundryList = [];
|
||||||
|
this.optionsDiceList = "";
|
||||||
|
this.buildDiceLists();
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static getSpecs( ) {
|
static getSpecs( ) {
|
||||||
@ -21,6 +26,47 @@ export class PegasusUtility {
|
|||||||
this.specs = specs.map(i => i.toObject());
|
this.specs = specs.map(i => i.toObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static buildDiceLists() {
|
||||||
|
let maxLevel = game.settings.get("fvtt-pegasus-rpg", "dice-max-level");
|
||||||
|
let diceList = [ "0" ];
|
||||||
|
let diceFoundryList = [ "d0" ];
|
||||||
|
let diceLevel = 1;
|
||||||
|
let concat = "";
|
||||||
|
let concatFoundry = "";
|
||||||
|
let optionsDiceList = '<option value="0">0</option>';
|
||||||
|
let optionsLevel = '<option value="0">0</option>';
|
||||||
|
for(let i=1; i<=maxLevel;i++) {
|
||||||
|
let currentDices = concat + __level2Dice[diceLevel];
|
||||||
|
diceList.push( currentDices );
|
||||||
|
diceFoundryList.push( concatFoundry + __level2Dice[diceLevel] + "x" );
|
||||||
|
if ( __level2Dice[diceLevel] == "d12") {
|
||||||
|
concat = concat + "d12 ";
|
||||||
|
concatFoundry = concatFoundry + "d12x, ";
|
||||||
|
diceLevel = 1;
|
||||||
|
} else {
|
||||||
|
diceLevel++;
|
||||||
|
}
|
||||||
|
optionsDiceList += `<option value="${i}">${currentDices}</option>`;
|
||||||
|
optionsLevel += `<option value="${i}">${i}</option>`;
|
||||||
|
}
|
||||||
|
this.diceList = diceList;
|
||||||
|
this.diceFoundryList = diceFoundryList;
|
||||||
|
this.optionsDiceList = optionsDiceList;
|
||||||
|
this.optionsLevel = optionsLevel;
|
||||||
|
|
||||||
|
console.log("Defautl dice List", diceList, diceFoundryList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static getOptionsDiceList() {
|
||||||
|
return this.optionsDiceList;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static getOptionsLevel() {
|
||||||
|
return this.optionsLevel;
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static computeAttackDefense(defenseRollId) {
|
static computeAttackDefense(defenseRollId) {
|
||||||
let defenseRollData = this.getRollData(defenseRollId );
|
let defenseRollData = this.getRollData(defenseRollId );
|
||||||
@ -43,14 +89,6 @@ export class PegasusUtility {
|
|||||||
defender.processNoDefense( attackRollData ) ;
|
defender.processNoDefense( attackRollData ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static reduceDamageWithChi( defenseRollId) {
|
|
||||||
let defenseRollData = this.getRollData(defenseRollId );
|
|
||||||
let attackRollData = this.getRollData(defenseRollData.linkedRollId);
|
|
||||||
let defender = game.actors.get( defenseRollData.actorId);
|
|
||||||
defender.reduceDamageWithChi(defenseRollData, attackRollData);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async chatListeners(html) {
|
static async chatListeners(html) {
|
||||||
|
|
||||||
@ -103,28 +141,19 @@ export class PegasusUtility {
|
|||||||
}
|
}
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static getChiList() {
|
static getDiceFromLevel(level = 0) {
|
||||||
let chi = [];
|
level = Number(level)
|
||||||
chi.push( { name: "Jade" });
|
return this.diceList[level];
|
||||||
chi.push( { name: "Crimson" });
|
|
||||||
chi.push( { name: "Gold" });
|
|
||||||
chi.push( { name: "White" });
|
|
||||||
chi.push( { name: "Silver" });
|
|
||||||
return chi;
|
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static getskillChiList( ) {
|
static getFoundryDiceFromLevel(level = 0) {
|
||||||
let skillsName = [];
|
level = Number(level)
|
||||||
let skills = this.getSkills();
|
console.log(this.diceFoundryList);
|
||||||
console.log("SKILLS", skills);
|
return this.diceFoundryList[level];
|
||||||
for (let skill of skills) {
|
|
||||||
skillsName.push( { name: skill.name });
|
|
||||||
}
|
|
||||||
skillsName = skillsName.concat( this.getChiList() );
|
|
||||||
return skillsName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static createDirectOptionList( min, max) {
|
static createDirectOptionList( min, max) {
|
||||||
let options = {};
|
let options = {};
|
||||||
@ -142,29 +171,6 @@ export class PegasusUtility {
|
|||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
|
||||||
static getNegativeModifiers(min, max) {
|
|
||||||
let options = ""
|
|
||||||
options += `<option value="0">0</option>`
|
|
||||||
options += `<option value="-5">-5</option>`
|
|
||||||
options += `<option value="-10">-10</option>`
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static getPositiveModifiers(min, max) {
|
|
||||||
let options = ""
|
|
||||||
options += `<option value="0">0</option>`
|
|
||||||
options += `<option value="5">+5</option>`
|
|
||||||
options += `<option value="10">+10</option>`
|
|
||||||
options += `<option value="15">+15</option>`
|
|
||||||
options += `<option value="20">+20</option>`
|
|
||||||
options += `<option value="30">+30</option>`
|
|
||||||
options += `<option value="40">+40</option>`
|
|
||||||
options += `<option value="50">+60</option>`
|
|
||||||
options += `<option value="60">+50</option>`
|
|
||||||
options += `<option value="70">+70</option>`
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static getTarget() {
|
static getTarget() {
|
||||||
@ -300,93 +306,50 @@ export class PegasusUtility {
|
|||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async rollWotG( rollData ) {
|
static async rollPegasus( rollData ) {
|
||||||
|
|
||||||
if (rollData.mode == "chidamage" ) {
|
let dicePool = [ {name:"stat", level: 0, statmod: 0}, {name: "spec", level: 0}, {name:"bonus", level: 0}, {name:"hindrance", level: 0}, {name:"other", level:0} ];
|
||||||
let defender = game.actors.get( rollData.actorId);
|
if (rollData.stat) {
|
||||||
defender.rollChiDamage(rollData);
|
dicePool[0].level += Number(rollData.stat.value);
|
||||||
return;
|
dicePool[0].statmod = Number(rollData.stat.mod);
|
||||||
|
}
|
||||||
|
if (rollData.spec) {
|
||||||
|
dicePool[1].level += Number(rollData.spec.data.level);
|
||||||
|
}
|
||||||
|
if (rollData.bonusDicesLevel) {
|
||||||
|
dicePool[2].level += Number(rollData.bonusDicesLevel);
|
||||||
|
}
|
||||||
|
if (rollData.hindranceDicesLevel) {
|
||||||
|
dicePool[3].level += Number(rollData.hindranceDicesLevel);
|
||||||
|
}
|
||||||
|
if (rollData.otherDicesLevel) {
|
||||||
|
dicePool[4].level += Number(rollData.otherDicesLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
let nbDice = 0;
|
let diceFormulaTab = [];
|
||||||
if ( rollData.mode == 'skill' || rollData.mode == 'technique') {
|
for (let diceGroup of dicePool) {
|
||||||
nbDice = rollData.skill?.data.level || 0;
|
diceFormulaTab.push( this.getFoundryDiceFromLevel( diceGroup.level) )
|
||||||
}
|
}
|
||||||
if ( rollData.mode == 'weapon' ) {
|
let diceFormula = '{' + diceFormulaTab.join(', ') + '}kh';
|
||||||
rollData.skill = rollData.weapon.data.skills[rollData.skillKey];
|
console.log(diceFormula);
|
||||||
rollData.skillAttr = rollData.weapon.data.skills[rollData.skillKey].data.attr;
|
|
||||||
nbDice = rollData.skill?.data.level || 0;
|
|
||||||
}
|
|
||||||
if ( rollData.mode == 'technique') {
|
|
||||||
// Compute number of dice
|
|
||||||
if (rollData.attr ) {
|
|
||||||
rollData.skillAttr = rollData.attr;
|
|
||||||
}
|
|
||||||
if (rollData.chi ) {
|
|
||||||
rollData.skillAttr = rollData.chi;
|
|
||||||
nbDice = rollData.skillAttr.value || 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( rollData.skill && rollData.skillAttr.value >= rollData.skill.data.level) {
|
|
||||||
nbDice++;
|
|
||||||
}
|
|
||||||
if ( nbDice == 0) nbDice = 1;
|
|
||||||
nbDice += rollData.specialtiesBonus;
|
|
||||||
|
|
||||||
// Build dice formula
|
|
||||||
let diceTab = [];
|
|
||||||
for(let i=0; i<nbDice; i++) {
|
|
||||||
diceTab[i] = "1d10";
|
|
||||||
}
|
|
||||||
let formula = "{"+ diceTab.join(',') + '}';
|
|
||||||
|
|
||||||
// Performs roll
|
// Performs roll
|
||||||
let myRoll = rollData.roll;
|
let myRoll = rollData.roll;
|
||||||
if ( !myRoll ) { // New rolls only of no rerolls
|
if ( !myRoll ) { // New rolls only of no rerolls
|
||||||
myRoll = new Roll(formula).roll( { async: false} );
|
myRoll = new Roll(diceFormula).roll( { async: false} );
|
||||||
console.log("ROLL : ", formula);
|
console.log("ROLL : ", diceFormula);
|
||||||
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode") );
|
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode") );
|
||||||
rollData.roll = myRoll
|
rollData.roll = myRoll
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the list of dices per number of occurence
|
|
||||||
let sortedRoll = [];
|
|
||||||
let bestScore = 0;
|
|
||||||
let diceResults = [];
|
|
||||||
for (let i=0; i<10; i++) {
|
|
||||||
sortedRoll[i] = 0;
|
|
||||||
}
|
|
||||||
for (let i=0; i<nbDice; i++) {
|
|
||||||
let dice1 = duplicate(myRoll.dice[i]);
|
|
||||||
if (dice1.results[0].result == 10) dice1.results[0].result = 0;
|
|
||||||
dice1.results[0].diceIndex = i;
|
|
||||||
diceResults.push( dice1.results[0] );
|
|
||||||
let nbFound = 1;
|
|
||||||
for (let j=0; j<nbDice; j++) {
|
|
||||||
if (j!=i) {
|
|
||||||
let dice2 = myRoll.dice[j];
|
|
||||||
if (dice2.results[0].result == 10) dice2.results[0].result = 0;
|
|
||||||
if (dice1.results[0].result == dice2.results[0].result) {
|
|
||||||
nbFound++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let score = (nbFound * 10) + dice1.results[0].result;
|
|
||||||
if (score > bestScore) bestScore = score;
|
|
||||||
sortedRoll[dice1.results[0].result] = nbFound;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Final score and keep data
|
// Final score and keep data
|
||||||
rollData.nbDice = nbDice;
|
rollData.finalScore = myRoll.total + dicePool[0].statmod;
|
||||||
rollData.bestScore = bestScore;
|
|
||||||
rollData.diceResults = diceResults;
|
|
||||||
rollData.finalScore = bestScore + rollData.negativeModifier + rollData.positiveModifier;
|
|
||||||
console.log("ROLLLL!!!!", rollData);
|
console.log("ROLLLL!!!!", rollData);
|
||||||
|
|
||||||
let actor = game.actors.get(rollData.actorId);
|
let actor = game.actors.get(rollData.actorId);
|
||||||
|
|
||||||
this.createChatWithRollMode( rollData.alias, {
|
this.createChatWithRollMode( rollData.alias, {
|
||||||
content: await renderTemplate(`systems/fvtt-weapons-of-the-gods/templates/chat-generic-result.html`, rollData)
|
content: await renderTemplate(`systems/fvtt-pegasus-rpg/templates/chat-generic-result.html`, rollData)
|
||||||
});
|
});
|
||||||
|
|
||||||
if ( rollData.defender ) {
|
if ( rollData.defender ) {
|
||||||
@ -401,34 +364,6 @@ export class PegasusUtility {
|
|||||||
return Math.floor(result/5) + 1;
|
return Math.floor(result/5) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static removeDice( rollData, diceIndex) {
|
|
||||||
|
|
||||||
let diceResults = rollData.diceResults;
|
|
||||||
diceResults.splice( diceIndex, 1);
|
|
||||||
rollData.diceResults = diceResults;
|
|
||||||
|
|
||||||
rollData.nbDice = diceResults.length;
|
|
||||||
|
|
||||||
this.updateRoll(rollData);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static addDice(rollId, diceValue) {
|
|
||||||
|
|
||||||
let rollData = this.getRollData( rollId );
|
|
||||||
|
|
||||||
let diceResults = rollData.diceResults;
|
|
||||||
let newResult = duplicate(diceResults[0]);
|
|
||||||
newResult.result = diceValue;
|
|
||||||
diceResults.push( newResult);
|
|
||||||
rollData.diceResults = diceResults;
|
|
||||||
|
|
||||||
rollData.nbDice = diceResults.length;
|
|
||||||
|
|
||||||
this.updateRoll(rollData);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------- ------------------- */
|
/* ------------------------- ------------------- */
|
||||||
static async updateRoll( rollData) {
|
static async updateRoll( rollData) {
|
||||||
|
|
||||||
@ -550,18 +485,6 @@ export class PegasusUtility {
|
|||||||
this.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions);
|
this.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static buildDifficultyOptions( ) {
|
|
||||||
let options = ""
|
|
||||||
options += `<option value="0">None</option>`
|
|
||||||
options += `<option value="8">Easy</option>`
|
|
||||||
options += `<option value="12">Moderate</option>`
|
|
||||||
options += `<option value="16">Difficult</option>`
|
|
||||||
options += `<option value="18">Very Difficult</option>`
|
|
||||||
return options;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async confirmDelete(actorSheet, li) {
|
static async confirmDelete(actorSheet, li) {
|
||||||
let itemId = li.data("item-id");
|
let itemId = li.data("item-id");
|
||||||
|
@ -1153,7 +1153,7 @@ ul, li {
|
|||||||
color: #CCC
|
color: #CCC
|
||||||
}
|
}
|
||||||
#pause > img {
|
#pause > img {
|
||||||
content: url(../images/ui/wotg_logo_01.webp);
|
content: url(../images/ui/pegasus_logo_v1.webp);
|
||||||
height: 160px;
|
height: 160px;
|
||||||
width: 256px;
|
width: 256px;
|
||||||
top: -80px;
|
top: -80px;
|
||||||
@ -1161,7 +1161,7 @@ ul, li {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#logo {
|
#logo {
|
||||||
content : url(../images/ui/wotg_logo_01.webp);
|
content : url(../images/ui/pegasus_logo_v1.webp);
|
||||||
width: 110px;
|
width: 110px;
|
||||||
height: 70px;
|
height: 70px;
|
||||||
}
|
}
|
||||||
|
@ -142,10 +142,13 @@
|
|||||||
},
|
},
|
||||||
"specialisation": {
|
"specialisation": {
|
||||||
"statistic": "",
|
"statistic": "",
|
||||||
"level": 0,
|
"level": 1,
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"perk": {
|
"perk": {
|
||||||
|
"level": 1,
|
||||||
|
"active": false,
|
||||||
|
"roundcount": 0,
|
||||||
"description": "",
|
"description": "",
|
||||||
"upgrades": "",
|
"upgrades": "",
|
||||||
"rules": ""
|
"rules": ""
|
||||||
|
@ -36,10 +36,10 @@
|
|||||||
<ul>
|
<ul>
|
||||||
{{#each data.statistics as |stat key|}}
|
{{#each data.statistics as |stat key|}}
|
||||||
<li class="item flexrow list-item" data-attr-key="{{key}}">
|
<li class="item flexrow list-item" data-attr-key="{{key}}">
|
||||||
<span class="stat-label flexrow" name="{{key}}"><h4><a class="roll-stat" data-stat-id="{{key}}"">{{stat.label}}</a></h4></span>
|
<span class="stat-label flexrow" name="{{key}}"><h4><a class="roll-stat" data-stat-key="{{key}}"">{{stat.label}}</a></h4></span>
|
||||||
<select class="carac-base flexrow" type="text" name="data.statistics.{{key}}.value" value="{{stat.value}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
|
<select class="carac-base flexrow" type="text" name="data.statistics.{{key}}.value" value="{{stat.value}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
|
||||||
{{#select stat.value}}
|
{{#select stat.value}}
|
||||||
{{> systems/fvtt-pegasus-rpg/templates/partial-options-level.html}}
|
{{{@root.optionsDiceList}}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
</select>
|
</select>
|
||||||
<input type="text" class="input-numeric-short padd-right" name="stat.mod" value="{{stat.mod}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}/>
|
<input type="text" class="input-numeric-short padd-right" name="stat.mod" value="{{stat.mod}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}/>
|
||||||
@ -55,7 +55,7 @@
|
|||||||
<span class="stat-label flexrow" name="{{key}}"><h4>{{stat2.label}}</h4></span>
|
<span class="stat-label flexrow" name="{{key}}"><h4>{{stat2.label}}</h4></span>
|
||||||
<select class="carac-base flexrow" type="text" name="data.secondary.{{key}}.value" value="{{stat2.value}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
|
<select class="carac-base flexrow" type="text" name="data.secondary.{{key}}.value" value="{{stat2.value}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
|
||||||
{{#select stat2.value}}
|
{{#select stat2.value}}
|
||||||
{{> systems/fvtt-pegasus-rpg/templates/partial-options-level.html}}
|
{{{@root.optionsLevel}}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
</select>
|
</select>
|
||||||
</li>
|
</li>
|
||||||
@ -77,7 +77,9 @@
|
|||||||
{{#each specs as |spec key|}}
|
{{#each specs as |spec key|}}
|
||||||
<li class="item stat flexrow list-item" data-item-id="{{spec._id}}">
|
<li class="item stat flexrow list-item" data-item-id="{{spec._id}}">
|
||||||
<img class="sheet-competence-img" src="{{spec.img}}"/>
|
<img class="sheet-competence-img" src="{{spec.img}}"/>
|
||||||
<span class="stat-label">{{spec.name}}</span>
|
<span class="stat-label"><a class="roll-spec">{{spec.name}}</a></span>
|
||||||
|
<span class="stat-label">{{spec.data.statistic}}</span>
|
||||||
|
<span class="stat-label">{{spec.data.dice}}</span>
|
||||||
<div class="item-controls">
|
<div class="item-controls">
|
||||||
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
||||||
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||||
@ -93,14 +95,6 @@
|
|||||||
<div class="tab fight" data-group="primary" data-tab="fight">
|
<div class="tab fight" data-group="primary" data-tab="fight">
|
||||||
<div class="flexcol">
|
<div class="flexcol">
|
||||||
|
|
||||||
<ul class="stat-list alternate-list">
|
|
||||||
<li class="item stat flexrow list-item">
|
|
||||||
<span class="generic-label"><h3>Health</h3></span>
|
|
||||||
<input type="text" class="" name="data.secondary.health.value" value="{{data.secondary.health.value}}" data-dtype="Number"/>
|
|
||||||
/ {{data.secondary.health.max}}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<span class="generic-label"><h3>Weapons</h3></span>
|
<span class="generic-label"><h3>Weapons</h3></span>
|
||||||
<ul class="stat-list alternate-list">
|
<ul class="stat-list alternate-list">
|
||||||
{{#each weapons as |weapon key|}}
|
{{#each weapons as |weapon key|}}
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
<div >
|
<div >
|
||||||
<img class="chat-icon" src="{{img}}" alt="{{name}}" />
|
<img class="chat-icon" src="{{img}}" alt="{{name}}" />
|
||||||
<h4>
|
<h4>
|
||||||
{{#if (eq mode "skill")}}
|
{{#if (eq mode "stat")}}
|
||||||
Skill : {{skill.name}}
|
Statistic : {{stat.label}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if (eq mode "technique")}}
|
{{#if (eq mode "spec")}}
|
||||||
Technique : {{technique.name}}
|
Technique : {{spec.name}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if (eq mode "weapon")}}
|
{{#if (eq mode "weapon")}}
|
||||||
Weapon attack : {{weapon.name}}
|
Weapon attack : {{weapon.name}}
|
||||||
@ -23,33 +23,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flexcol">
|
<div class="flexcol">
|
||||||
<div class="dice-total">
|
|
||||||
{{#each diceResults as |diceResult key|}}
|
|
||||||
<div class="dice">
|
|
||||||
{{#if (gt @root.nbDice 2)}}
|
|
||||||
<a class="dice-to-river" data-actor-id="{{@root.actorId}}" data-roll-id="{{@root.rollId}}" data-dice-index="{{key}}" data-dice-value="{{diceResult.result}}">
|
|
||||||
{{/if}}
|
|
||||||
<label>{{diceResult.result}}</label>
|
|
||||||
<img src="systems/fvtt-weapons-of-the-gods/images/dice/d10black.svg" />
|
|
||||||
{{#if (gt @root.nbDice 2)}}
|
|
||||||
</a>
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<ul>
|
<ul>
|
||||||
{{#if (eq mode "technique")}}
|
|
||||||
<li>{{technique.data.chicolor}} Chi cost : {{technique.data.chicost}} </li>
|
|
||||||
<li><button class="chat-card-button apply-technique-cost" data-actor-id="{{actorId}}" data-roll-id="{{@root.rollId}}" data-technique-id="{{technique._id}}">Apply Chi cost</button></li>
|
|
||||||
<li>Effect description : {{technique.data.effectdescription}}</li>
|
|
||||||
{{/if}}
|
|
||||||
{{#if (eq mode "weapon")}}
|
{{#if (eq mode "weapon")}}
|
||||||
<li>Effect description : {{weapon.data.effectdescription}}</li>
|
<li>Effect description : {{weapon.data.effectdescription}}</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<li>Modifiers : {{negativeModifier}} / {{positiveModifier}} </li>
|
<li><strong>Final Result : {{finalScore}}</strong>
|
||||||
<li><strong>Total Roll : {{finalScore}}</strong>
|
|
||||||
|
|
||||||
{{#if linkedRollId}}
|
{{#if linkedRollId}}
|
||||||
<li><button class="chat-card-button apply-defense-roll" data-roll-score="{{finalScore}}" data-roll-id="{{@root.rollId}}" data-actor-id="{{actorId}}" data-defender-id="{{defenseAttackerId}}">Use this Roll as defense</button></li>
|
<li><button class="chat-card-button apply-defense-roll" data-roll-score="{{finalScore}}" data-roll-id="{{@root.rollId}}" data-actor-id="{{actorId}}" data-defender-id="{{defenseAttackerId}}">Use this Roll as defense</button></li>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<li class="flexrow"><label class="generic-label">Level</label>
|
<li class="flexrow"><label class="generic-label">Level</label>
|
||||||
<select class="competence-base flexrow" type="text" name="data.level" value="{{data.level}}" data-dtype="Number">
|
<select class="competence-base flexrow" type="text" name="data.level" value="{{data.level}}" data-dtype="Number">
|
||||||
{{#select data.level}}
|
{{#select data.level}}
|
||||||
{{> systems/fvtt-pegasus-rpg/templates/partial-options-level.html}}
|
{{{optionsDiceList}}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
</select>
|
</select>
|
||||||
</li>
|
</li>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<option value="0">0</option>
|
||||||
<option value="1">d4</option>
|
<option value="1">d4</option>
|
||||||
<option value="2">d6</option>
|
<option value="2">d6</option>
|
||||||
<option value="3">d8</option>
|
<option value="3">d8</option>
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
<form class="skill-roll-dialog">
|
|
||||||
<header class="roll-dialog-header">
|
|
||||||
<img class="actor-icon" src="{{img}}" data-edit="img" title="{{name}}" />
|
|
||||||
<h1 class="dialog-roll-title roll-dialog-header">{{title}}</h1>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="floxrow">
|
|
||||||
<div class="flexrow">
|
|
||||||
<span class="roll-dialog-label" >{{skillAttr.label}} : {{skillAttr.value}}</span>
|
|
||||||
<span class="roll-dialog-label" >Skill Level : {{skill.data.level}}</span>
|
|
||||||
</div>
|
|
||||||
<div class="flexrow">
|
|
||||||
<span class="roll-dialog-label" >Specialties reminder : </span>
|
|
||||||
<span class="roll-dialog-label" >{{skill.data.specialties}}</span>
|
|
||||||
</div>
|
|
||||||
<div class="flexrow">
|
|
||||||
<span class="roll-dialog-label" >Specialties Dices Bonus : </span>
|
|
||||||
<select class="competence-base" id="specialtiesBonus" type="text" name="specialtiesBonus" value="{{specialtiesBonus}}" data-dtype="Number">
|
|
||||||
{{#select specialtiesBonus}}
|
|
||||||
<option value="0">0</option>
|
|
||||||
<option value="1">1</option>
|
|
||||||
<option value="2">2</option>
|
|
||||||
{{/select}}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="flexrow">
|
|
||||||
<span class="roll-dialog-label" >Negative Modifier :</span>
|
|
||||||
<select class="roll-dialog-label" id="negativeModifier" type="text" name="negativeModifier" value="{{negativeModifier}}" data-dtype="Number">
|
|
||||||
{{#select negativeModifier}}
|
|
||||||
{{{optionsNegative}}}
|
|
||||||
{{/select}}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="flexrow">
|
|
||||||
<span class="roll-dialog-label" >Positive Modifier :</span>
|
|
||||||
<select class="roll-dialog-label" id="positiveModifier" type="text" name="positiveModifier" value="{{positiveModifier}}" data-dtype="Number">
|
|
||||||
{{#select positiveModifier}}
|
|
||||||
{{{optionsPositive}}}
|
|
||||||
{{/select}}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</form>
|
|
Loading…
Reference in New Issue
Block a user