Add hindrance dice
This commit is contained in:
parent
c1eb33bc21
commit
ba98d9c264
BIN
images/dice/hindrance-dice-empty.png
Normal file
BIN
images/dice/hindrance-dice-empty.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.0 KiB |
25
modules/pegasus-hindrance-die.js
Normal file
25
modules/pegasus-hindrance-die.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
export class PegasusHindranceDie extends Die {
|
||||||
|
constructor(termData ) {
|
||||||
|
termData.faces=6;
|
||||||
|
super(termData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
static DENOMINATION = "h";
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
getResultLabel(result) {
|
||||||
|
return {
|
||||||
|
"1": '<img src="systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png" />',
|
||||||
|
"2": '<img src="systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png" />',
|
||||||
|
"3": '<img src="systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png" />',
|
||||||
|
"4": '<img src="systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png" />',
|
||||||
|
"5": '<img src="systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png" />',
|
||||||
|
"6": '<img src="systems/fvtt-pegasus-rpg/images/dice/hindrance-dice.png" />'
|
||||||
|
}[result.result];
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ import { PegasusVehicleSheet } from "./pegasus-vehicle-sheet.js";
|
|||||||
import { PegasusUtility } from "./pegasus-utility.js";
|
import { PegasusUtility } from "./pegasus-utility.js";
|
||||||
import { PegasusCombatTracker,PegasusCombat } from "./pegasus-combat.js";
|
import { PegasusCombatTracker,PegasusCombat } from "./pegasus-combat.js";
|
||||||
import { PegasusItem } from "./pegasus-item.js";
|
import { PegasusItem } from "./pegasus-item.js";
|
||||||
|
import { PegasusHindranceDie } from "./pegasus-hindrance-die.js";
|
||||||
import { PEGASUS_CONFIG } from "./pegasus-config.js"
|
import { PEGASUS_CONFIG } from "./pegasus-config.js"
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -57,6 +58,7 @@ Hooks.once("init", async function () {
|
|||||||
CONFIG.Actor.documentClass = PegasusActor
|
CONFIG.Actor.documentClass = PegasusActor
|
||||||
CONFIG.Item.documentClass = PegasusItem
|
CONFIG.Item.documentClass = PegasusItem
|
||||||
CONFIG.ui.combat = PegasusCombatTracker
|
CONFIG.ui.combat = PegasusCombatTracker
|
||||||
|
CONFIG.Dice.terms["h"] = PegasusHindranceDie
|
||||||
game.system.pegasus = {
|
game.system.pegasus = {
|
||||||
utility: PegasusUtility,
|
utility: PegasusUtility,
|
||||||
config: PEGASUS_CONFIG
|
config: PEGASUS_CONFIG
|
||||||
@ -74,7 +76,6 @@ Hooks.once("init", async function () {
|
|||||||
|
|
||||||
PegasusUtility.init()
|
PegasusUtility.init()
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -26,6 +26,29 @@ export class PegasusUtility {
|
|||||||
/* Deprecated, no more used in rules Hooks.on("getCombatTrackerEntryContext", (html, options) => {
|
/* Deprecated, no more used in rules Hooks.on("getCombatTrackerEntryContext", (html, options) => {
|
||||||
PegasusUtility.pushInitiativeOptions(html, options);
|
PegasusUtility.pushInitiativeOptions(html, options);
|
||||||
});*/
|
});*/
|
||||||
|
Hooks.once('diceSoNiceReady', (dice3d) => {
|
||||||
|
dice3d.addSystem({ id: "pegasus-hindrance", name: "Hindrance Die" }, "preferred");
|
||||||
|
dice3d.addDicePreset({
|
||||||
|
type: "dh",
|
||||||
|
labels: [
|
||||||
|
'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png',
|
||||||
|
'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png',
|
||||||
|
'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png',
|
||||||
|
'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png',
|
||||||
|
'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png',
|
||||||
|
'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice.png'
|
||||||
|
],
|
||||||
|
bumpMaps: [
|
||||||
|
'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png',
|
||||||
|
'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png',
|
||||||
|
'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png',
|
||||||
|
'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png',
|
||||||
|
'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png',
|
||||||
|
'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice.png'
|
||||||
|
],
|
||||||
|
system: "pegasus-hindrance"
|
||||||
|
}, "d6")
|
||||||
|
})
|
||||||
Hooks.on("dropCanvasData", (canvas, data) => {
|
Hooks.on("dropCanvasData", (canvas, data) => {
|
||||||
PegasusUtility.dropItemOnToken(canvas, data)
|
PegasusUtility.dropItemOnToken(canvas, data)
|
||||||
});
|
});
|
||||||
@ -224,9 +247,9 @@ export class PegasusUtility {
|
|||||||
for (let weapon of rollData.vehicleWeapons) {
|
for (let weapon of rollData.vehicleWeapons) {
|
||||||
if (weapon.applied) {
|
if (weapon.applied) {
|
||||||
newDicePool = newDicePool.concat(this.buildDicePool("damage", weapon.value, 0))
|
newDicePool = newDicePool.concat(this.buildDicePool("damage", weapon.value, 0))
|
||||||
if( weapon.weapon.system.extradamage) {
|
if (weapon.weapon.system.extradamage) {
|
||||||
for(let i=0; i < weapon.weapon.system.extradamagevalue; i++) {
|
for (let i = 0; i < weapon.weapon.system.extradamagevalue; i++) {
|
||||||
newDicePool = newDicePool.concat(this.buildDicePool("damage", 5, 0) )
|
newDicePool = newDicePool.concat(this.buildDicePool("damage", 5, 0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -567,7 +590,7 @@ export class PegasusUtility {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static getDiceFromLevel(level = 0) {
|
static getDiceFromLevel(level = 0) {
|
||||||
level = Math.max( Number(level), 0)
|
level = Math.max(Number(level), 0)
|
||||||
return this.diceList[level];
|
return this.diceList[level];
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -846,7 +869,7 @@ export class PegasusUtility {
|
|||||||
myRoll = new Roll(diceFormula).roll({ async: false })
|
myRoll = new Roll(diceFormula).roll({ async: false })
|
||||||
rollData.roll = myRoll
|
rollData.roll = myRoll
|
||||||
}
|
}
|
||||||
if ( rollData.hindranceDices > 0) {
|
if (rollData.hindranceDices > 0) {
|
||||||
rollData.hindranceRoll = new Roll(rollData.hindranceDices + "d6").roll({ async: false })
|
rollData.hindranceRoll = new Roll(rollData.hindranceDices + "d6").roll({ async: false })
|
||||||
this.showDiceSoNice(rollData.hindranceRoll, game.settings.get("core", "rollMode"))
|
this.showDiceSoNice(rollData.hindranceRoll, game.settings.get("core", "rollMode"))
|
||||||
for (let res of rollData.hindranceRoll.terms[0].results) {
|
for (let res of rollData.hindranceRoll.terms[0].results) {
|
||||||
@ -855,7 +878,7 @@ export class PegasusUtility {
|
|||||||
rollData.img = `systems/fvtt-pegasus-rpg/images/dice/hindrance-dice.png`
|
rollData.img = `systems/fvtt-pegasus-rpg/images/dice/hindrance-dice.png`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||||
|
|
||||||
// Final score and keep data
|
// Final score and keep data
|
||||||
@ -876,7 +899,7 @@ export class PegasusUtility {
|
|||||||
if (rollData.isInit) {
|
if (rollData.isInit) {
|
||||||
let combat = game.combats.get(rollData.combatId)
|
let combat = game.combats.get(rollData.combatId)
|
||||||
await combat.setTic(rollData.combatantId, rollData)
|
await combat.setTic(rollData.combatantId, rollData)
|
||||||
combat.updateEmbeddedDocuments("Combatant", [{ _id: rollData.combatantId, initiative: rollData.finalScore }])
|
combat.updateEmbeddedDocuments("Combatant", [{ _id: rollData.combatantId, initiative: rollData.finalScore }])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stun specific -> Suffer a stun level when dmg-res for character
|
// Stun specific -> Suffer a stun level when dmg-res for character
|
||||||
@ -1071,9 +1094,9 @@ export class PegasusUtility {
|
|||||||
let defenderActor = target.actor
|
let defenderActor = target.actor
|
||||||
rollData.defenderTokenId = target.id
|
rollData.defenderTokenId = target.id
|
||||||
rollData.defenderSize = 0
|
rollData.defenderSize = 0
|
||||||
if ( defenderActor.type == "character") {
|
if (defenderActor.type == "character") {
|
||||||
rollData.defenderSize = Number(defenderActor.system.biodata.sizenum) + Number(defenderActor.system.biodata.sizebonus)
|
rollData.defenderSize = Number(defenderActor.system.biodata.sizenum) + Number(defenderActor.system.biodata.sizebonus)
|
||||||
} else if ( defenderActor.type == "vehicle" ){
|
} else if (defenderActor.type == "vehicle") {
|
||||||
rollData.defenderSize = Number(defenderActor.system.statistics.hr.size)
|
rollData.defenderSize = Number(defenderActor.system.statistics.hr.size)
|
||||||
}
|
}
|
||||||
//rollData.attackerId = this.id
|
//rollData.attackerId = this.id
|
||||||
@ -1117,10 +1140,10 @@ export class PegasusUtility {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static checkIsVehicleCrew(actorId) {
|
static checkIsVehicleCrew(actorId) {
|
||||||
let vehicles = game.actors.filter( actor=> actor.type == "vehicle") || []
|
let vehicles = game.actors.filter(actor => actor.type == "vehicle") || []
|
||||||
for(let vehicle of vehicles) {
|
for (let vehicle of vehicles) {
|
||||||
console.log("Checking", vehicle.name)
|
console.log("Checking", vehicle.name)
|
||||||
if ( vehicle.inCrew(actorId) ) {
|
if (vehicle.inCrew(actorId)) {
|
||||||
return vehicle
|
return vehicle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1153,7 +1176,7 @@ export class PegasusUtility {
|
|||||||
let tacticianTokens = canvas.tokens.placeables.filter(token => token.actor.isTactician() && !token.document.hidden)
|
let tacticianTokens = canvas.tokens.placeables.filter(token => token.actor.isTactician() && !token.document.hidden)
|
||||||
for (let token of tacticianTokens) {
|
for (let token of tacticianTokens) {
|
||||||
token.refresh()
|
token.refresh()
|
||||||
let friends = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == token.document.disposition)
|
let friends = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == token.document.disposition)
|
||||||
for (let friend of friends) {
|
for (let friend of friends) {
|
||||||
if (friend.actor.id != token.actor.id) {
|
if (friend.actor.id != token.actor.id) {
|
||||||
let existing = toApply[friend.id] || { token: friend, add: false, level: 0, names: [] }
|
let existing = toApply[friend.id] || { token: friend, add: false, level: 0, names: [] }
|
||||||
@ -1201,7 +1224,7 @@ export class PegasusUtility {
|
|||||||
let enhancerTokens = canvas.tokens.placeables.filter(token => token.actor.isEnhancer() && !token.document.hidden)
|
let enhancerTokens = canvas.tokens.placeables.filter(token => token.actor.isEnhancer() && !token.document.hidden)
|
||||||
for (let token of enhancerTokens) {
|
for (let token of enhancerTokens) {
|
||||||
token.refresh()
|
token.refresh()
|
||||||
let friends = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == token.document.disposition)
|
let friends = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == token.document.disposition)
|
||||||
for (let friend of friends) {
|
for (let friend of friends) {
|
||||||
if (friend.actor.id != token.actor.id) {
|
if (friend.actor.id != token.actor.id) {
|
||||||
let existing = toApply[friend.id] || { token: friend, add: false, level: 0, names: [] }
|
let existing = toApply[friend.id] || { token: friend, add: false, level: 0, names: [] }
|
||||||
@ -1253,13 +1276,13 @@ export class PegasusUtility {
|
|||||||
token.refresh()
|
token.refresh()
|
||||||
let ennemies = []
|
let ennemies = []
|
||||||
if (token.document.disposition == -1) {
|
if (token.document.disposition == -1) {
|
||||||
ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && (newToken.document.disposition == 1 || newToken.document.disposition == 0 ))
|
ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && (newToken.document.disposition == 1 || newToken.document.disposition == 0))
|
||||||
}
|
}
|
||||||
if (token.document.disposition == 1) {
|
if (token.document.disposition == 1) {
|
||||||
ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && (newToken.document.disposition == -1 || newToken.document.disposition == 0 ))
|
ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && (newToken.document.disposition == -1 || newToken.document.disposition == 0))
|
||||||
}
|
}
|
||||||
if (token.document.disposition == 0) {
|
if (token.document.disposition == 0) {
|
||||||
ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && (newToken.document.disposition == -1 || newToken.document.disposition == 1 ))
|
ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && (newToken.document.disposition == -1 || newToken.document.disposition == 1))
|
||||||
}
|
}
|
||||||
console.log("Ennemies for token", token.actor.name, ennemies)
|
console.log("Ennemies for token", token.actor.name, ennemies)
|
||||||
for (let ennemy of ennemies) {
|
for (let ennemy of ennemies) {
|
||||||
|
@ -252,7 +252,7 @@
|
|||||||
],
|
],
|
||||||
"title": "Pegasus RPG",
|
"title": "Pegasus RPG",
|
||||||
"url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg",
|
"url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg",
|
||||||
"version": "11.0.5",
|
"version": "11.0.6",
|
||||||
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v11.0.5.zip",
|
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v11.0.6.zip",
|
||||||
"background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp"
|
"background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp"
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user