Various changes + updates
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
import { PegasusCombat } from "./pegasus-combat.js";
|
||||
import { PegasusCommands } from "./pegasus-commands.js";
|
||||
import { PegasusActorCreate } from "./pegasus-create-char.js";
|
||||
import { PegasusRollDialog } from "./pegasus-roll-dialog.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const __level2Dice = ["d0", "d4", "d6", "d8", "d10", "d12"]
|
||||
@ -14,7 +15,10 @@ export class PegasusUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async init() {
|
||||
Hooks.on('renderChatLog', (log, html, data) => PegasusUtility.chatListeners(html));
|
||||
Hooks.on('renderChatLog', (log, html, data) => PegasusUtility.chatListeners(html))
|
||||
Hooks.on('targetToken', (user, token, flag) => PegasusUtility.targetToken(user, token, flag))
|
||||
Hooks.on('renderSidebarTab', (app, html, data) => PegasusUtility.addDiceRollButton(app, html, data))
|
||||
|
||||
Hooks.on("getCombatTrackerEntryContext", (html, options) => {
|
||||
PegasusUtility.pushInitiativeOptions(html, options);
|
||||
});
|
||||
@ -54,6 +58,41 @@ export class PegasusUtility {
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static initGenericRoll() {
|
||||
let rollData = PegasusUtility.getBasicRollData()
|
||||
rollData.alias = "Dice Pool Roll",
|
||||
rollData.mode = "generic"
|
||||
rollData.title = `Dice Pool Roll`
|
||||
rollData.img = "icons/dice/d12black.svg"
|
||||
rollData.isGeneric = true
|
||||
rollData.diceList = PegasusUtility.getDiceList()
|
||||
rollData.dicePool = []
|
||||
rollData.traumaState = "none"
|
||||
return rollData
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async addDiceRollButton(app, html, data) {
|
||||
if (app.tabName !== 'chat') return
|
||||
let $chat_form = html.find('#chat-form')
|
||||
const template = 'systems/fvtt-pegasus-rpg/templates/chat-roll-button.html'
|
||||
renderTemplate(template, {}).then(c => {
|
||||
if (c.length > 0) {
|
||||
let $content = $(c)
|
||||
$chat_form.before($content)
|
||||
$content.find('#pegasus-chat-roll-button').on('click', async event => {
|
||||
event.preventDefault()
|
||||
let rollData = PegasusUtility.initGenericRoll()
|
||||
rollData.isChatRoll = true
|
||||
let rollDialog = await PegasusRollDialog.create( undefined, rollData)
|
||||
rollDialog.render( true )
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static pushInitiativeOptions(html, options) {
|
||||
options.push({ name: "Apply -10", condition: true, icon: '<i class="fas fa-plus"></i>', callback: target => { PegasusCombat.decInitBy10(target.data('combatant-id'), -10); } })
|
||||
@ -345,6 +384,7 @@ export class PegasusUtility {
|
||||
ui.notifications.warn(`No character linked to the player : reroll not allowed.`)
|
||||
return
|
||||
}
|
||||
console.log("Going to reroll", character, rollId)
|
||||
let rollData = this.getRollData(rollId)
|
||||
if (character.getLevelRemaining() > 0) {
|
||||
rollData.rerollHero = true
|
||||
@ -361,6 +401,13 @@ export class PegasusUtility {
|
||||
game.socket.emit("system.fvtt-pegasus-rpg", { name: "msg_reroll_hero", data: { userId: userId, rollId: rollId } })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static targetToken( user, token, flag) {
|
||||
if (flag) {
|
||||
token.actor.checkIfPossible()
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async chatListeners(html) {
|
||||
|
||||
@ -509,7 +556,7 @@ export class PegasusUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getTarget() {
|
||||
if (game.user.targets && game.user.targets.size == 1) {
|
||||
if (game.user.targets) {
|
||||
for (let target of game.user.targets) {
|
||||
return target
|
||||
}
|
||||
@ -546,11 +593,12 @@ export class PegasusUtility {
|
||||
let id = rollData.rollId
|
||||
let oldRollData = this.rollDataStore[id] || {}
|
||||
let newRollData = mergeObject(oldRollData, rollData)
|
||||
console.log("Rolldata saved", id)
|
||||
this.rollDataStore[id] = newRollData
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static saveRollData(rollData) {
|
||||
game.socket.emit("system.pegasus-rpg", {
|
||||
game.socket.emit("system.fvtt-pegasus-rpg", {
|
||||
name: "msg_update_roll", data: rollData
|
||||
}); // Notify all other clients of the roll
|
||||
this.updateRollData(rollData)
|
||||
@ -581,6 +629,7 @@ export class PegasusUtility {
|
||||
this.addItemDropToActor(actor, item)
|
||||
}
|
||||
if (msg.name == "msg_reroll_hero") {
|
||||
console.log("Reroll requested")
|
||||
this.rerollHeroRemaining(msg.data.userId, msg.data.rollId)
|
||||
}
|
||||
if (msg.name == "msg_gm_remove_effect") {
|
||||
@ -681,7 +730,7 @@ export class PegasusUtility {
|
||||
if (game.user.isGM) {
|
||||
this.removeForeignEffect(effect)
|
||||
} else {
|
||||
game.socket.emit("system.fvtt-pegasus-rgp", { msg: "msg_gm_remove_effect", data: effect })
|
||||
game.socket.emit("system.fvtt-pegasus-rpg", { msg: "msg_gm_remove_effect", data: effect })
|
||||
}
|
||||
} else {
|
||||
toRem.push(effect.effect._id)
|
||||
@ -863,7 +912,7 @@ export class PegasusUtility {
|
||||
chatGM.whisper = this.getUsers(user => user.isGM);
|
||||
chatGM.content = "Blinde message of " + game.user.name + "<br>" + chatOptions.content;
|
||||
console.log("blindMessageToGM", chatGM);
|
||||
game.socket.emit("system.fvtt-pegasus-rgp", { msg: "msg_gm_chat_message", data: chatGM });
|
||||
game.socket.emit("system.fvtt-pegasus-rpg", { msg: "msg_gm_chat_message", data: chatGM });
|
||||
}
|
||||
|
||||
|
||||
@ -950,7 +999,7 @@ export class PegasusUtility {
|
||||
console.log("TARGET ", target)
|
||||
let defenderActor = target.actor
|
||||
rollData.defenderTokenId = target.id
|
||||
rollData.attackerId = this.id
|
||||
//rollData.attackerId = this.id
|
||||
console.log("DEFENDER", defenderActor)
|
||||
defenderActor.addHindrancesList(rollData.effectsList)
|
||||
}
|
||||
|
Reference in New Issue
Block a user