Review combat mode
This commit is contained in:
parent
1008c8afb1
commit
4e7b8b9a78
@ -267,6 +267,10 @@ a:hover {
|
||||
.bol button {
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.chat-button {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.bol select {
|
||||
box-shadow: none;
|
||||
font-size: 14px;
|
||||
|
@ -162,6 +162,7 @@ export class BoLRoll {
|
||||
const modifiers = parseInt(attrValue) + parseInt(aptValue) + parseInt(rollData.mod) + parseInt(rollData.career) - rollData.defence - shieldMalus;
|
||||
const formula = (isMalus) ? dicePool + "d6kl2 + " + modifiers : dicePool + "d6kh2 + " + modifiers;
|
||||
rollData.formula = formula;
|
||||
rollData.modifiers = modifiers
|
||||
|
||||
let r = new BoLDefaultRoll(rollData);
|
||||
r.roll();
|
||||
@ -177,85 +178,116 @@ export class BoLRoll {
|
||||
|
||||
export class BoLDefaultRoll {
|
||||
constructor(rollData) {
|
||||
BoLUtility.storeRoll(rollData);
|
||||
BoLUtility.storeRoll(rollData)
|
||||
this.rollData = rollData
|
||||
if ( this.rollData.isSuccess == undefined ) { // First init
|
||||
this.rollData.isSuccess = false;
|
||||
this.rollData.isCritical = false;
|
||||
this.rollData.isFumble = false;
|
||||
}
|
||||
if ( this.rollData.optionsId) {
|
||||
$(`#${this.rollData.optionsId}`).hide() // Hide the options roll buttons
|
||||
}
|
||||
if ( this.rollData.applyId) {
|
||||
$(`#${this.rollData.applyId}`).hide() // Hide the options roll buttons
|
||||
}
|
||||
this.rollData.optionsId = randomID(16)
|
||||
this.rollData.applyId = randomID(16)
|
||||
}
|
||||
|
||||
async roll() {
|
||||
console.log("ROLL", this.rollData)
|
||||
|
||||
const r = new Roll(this.rollData.formula);
|
||||
await r.roll({ "async": false });
|
||||
//await BoLUtility.showDiceSoNice(r);
|
||||
const activeDice = r.terms[0].results.filter(r => r.active);
|
||||
const diceTotal = activeDice.map(r => r.result).reduce((a, b) => a + b);
|
||||
this.rollData.roll = r
|
||||
this.rollData.isSuccess = (r.total >= 9);
|
||||
this.rollData.isCritical = (diceTotal === 12);
|
||||
this.rollData.isCritical = (diceTotal === 12)
|
||||
this.rollData.isRealCritical = (diceTotal === 12)
|
||||
this.rollData.isFumble = (diceTotal === 2);
|
||||
this.rollData.isFailure = !this.rollData.isSuccess
|
||||
if (this.rollData.reroll == undefined) {
|
||||
this.rollData.reroll = this.rollData.actor.heroReroll()
|
||||
}
|
||||
|
||||
if (this.rollData.registerInit) {
|
||||
this.rollData.actor.registerInit(r.total, this.rollData.isCritical);
|
||||
}
|
||||
|
||||
console.log("ROLL", this.rollData)
|
||||
await this.sendChatMessage()
|
||||
|
||||
}
|
||||
|
||||
async sendChatMessage() {
|
||||
this._buildChatMessage(this.rollData).then(msgFlavor => {
|
||||
r.toMessage({
|
||||
this.rollData.roll.toMessage({
|
||||
user: game.user.id,
|
||||
flavor: msgFlavor,
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.rollData.actor }),
|
||||
flags: { msgType: "default" }
|
||||
}).then(this.processResult());
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
async processDefense() {
|
||||
if (this.rollData.isCritical) {
|
||||
ChatMessage.create({
|
||||
alias: this.rollData.actor.name,
|
||||
whisper: BoLUtility.getWhisperRecipientsAndGMs(this.rollData.actor.name),
|
||||
content: await renderTemplate('systems/bol/templates/chat/rolls/attack-heroic-card.hbs', this.rollData )
|
||||
})
|
||||
} else {
|
||||
BoLUtility.sendAttackSuccess(this.rollData);
|
||||
}
|
||||
upgradeToCritical() {
|
||||
// Force to Critical roll
|
||||
this.rollData.isCritical = true
|
||||
this.rollData.isRealCritical = false
|
||||
this.rollData.isSuccess = true
|
||||
this.rollData.isFailure = false
|
||||
this.rollData.reroll = false
|
||||
this.rollData.roll = new Roll("12+" + this.rollData.modifiers)
|
||||
this.rollData.reroll = false
|
||||
this.sendChatMessage()
|
||||
}
|
||||
|
||||
setSuccess(flag) {
|
||||
this.rollData.isSuccess = flag
|
||||
}
|
||||
|
||||
async processResult() {
|
||||
if ( this.rollData.mode != "weapon") { // Only specific process in Weapon mode
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.rollData.isSuccess) {
|
||||
let attrDamage = this.rollData.weapon.data.data.properties.damageAttribute;
|
||||
let weaponFormula = BoLUtility.getDamageFormula(this.rollData.weapon.data.data.properties.damage,
|
||||
this.rollData.weapon.data.data.properties.damageModifiers,
|
||||
this.rollData.weapon.data.data.properties.damageMultiplier)
|
||||
let damageFormula = weaponFormula + ((attrDamage) ? "+" + this.rollData.actor.data.data.attributes[attrDamage].value : "+0");
|
||||
|
||||
//console.log("Formula", weaponFormula, damageFormula, this.rollData.weapon.data.data.properties.damage)
|
||||
this.rollData.damageRoll = new Roll(damageFormula);
|
||||
await this.rollData.damageRoll.roll({ "async": false });
|
||||
await BoLUtility.showDiceSoNice(this.rollData.damageRoll);
|
||||
// Update rollData object
|
||||
this.rollData.damageFormula = damageFormula;
|
||||
|
||||
async sendDamageMessage() {
|
||||
this._buildDamageChatMessage(this.rollData).then(msgFlavor => {
|
||||
this.rollData.damageRoll.toMessage({
|
||||
user: game.user.id,
|
||||
flavor: msgFlavor,
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.rollData.actor }),
|
||||
flags: { msgType: "default" }
|
||||
}).then(this.processDefense());
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
async rollDamage() {
|
||||
if (this.rollData.mode != "weapon") { // Only specific process in Weapon mode
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.rollData.isSuccess) {
|
||||
if ( !this.rollData.damageRoll) {
|
||||
let bonusDmg = 0
|
||||
if ( this.rollData.damageMode == 'damage-plus-6') {
|
||||
bonusDmg = 6
|
||||
}
|
||||
if ( this.rollData.damageMode == 'damage-plus-12') {
|
||||
bonusDmg = 12
|
||||
}
|
||||
console.log("DAMAGE !!!")
|
||||
let attrDamage = this.rollData.weapon.data.data.properties.damageAttribute;
|
||||
let weaponFormula = BoLUtility.getDamageFormula(this.rollData.weapon.data.data.properties.damage,
|
||||
this.rollData.weapon.data.data.properties.damageModifiers,
|
||||
this.rollData.weapon.data.data.properties.damageMultiplier)
|
||||
let damageFormula = weaponFormula + "+" + bonusDmg + ((attrDamage) ? "+" + this.rollData.actor.data.data.attributes[attrDamage].value : "+0");
|
||||
|
||||
//console.log("Formula", weaponFormula, damageFormula, this.rollData.weapon.data.data.properties.damage)
|
||||
this.rollData.damageFormula = damageFormula
|
||||
this.rollData.damageRoll = new Roll(damageFormula)
|
||||
this.rollData.damageTotal = this.rollData.damageRoll.total
|
||||
await this.rollData.damageRoll.roll({ "async": false })
|
||||
}
|
||||
$(`#${this.rollData.optionsId}`).hide() // Hide the options roll buttons
|
||||
this.sendDamageMessage()
|
||||
}
|
||||
}
|
||||
|
||||
_buildDamageChatMessage(rollData) {
|
||||
|
@ -119,23 +119,35 @@ export class BoLUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async chatListeners(html) {
|
||||
|
||||
// Damage handling
|
||||
html.on("click", '.damage-increase', event => {
|
||||
html.on("click", '.chat-damage-apply', event => {
|
||||
let rollData = BoLUtility.getLastRoll()
|
||||
$(`#${rollData.applyId}`).hide()
|
||||
BoLUtility.sendAttackSuccess(rollData)
|
||||
});
|
||||
|
||||
html.on("click", '.chat-damage-roll', event => {
|
||||
event.preventDefault();
|
||||
let attackId = event.currentTarget.attributes['data-attack-id'].value;
|
||||
let damageMode = event.currentTarget.attributes['data-damage-mode'].value;
|
||||
if ( game.user.isGM) {
|
||||
BoLUtility.processDamageIncrease(event, attackId, damageMode)
|
||||
} else {
|
||||
game.socket.emit("system.bol", { msg: "msg_damage_increase", data: {event: event, attackId: attackId, damageMode: damageMode} });
|
||||
}
|
||||
let rollData = BoLUtility.getLastRoll()
|
||||
rollData.damageMode = event.currentTarget.attributes['data-damage-mode'].value;
|
||||
let bolRoll = new BoLDefaultRoll(rollData)
|
||||
bolRoll.rollDamage()
|
||||
});
|
||||
|
||||
html.on("click", '.transform-heroic-roll', event => {
|
||||
event.preventDefault();
|
||||
let rollData = BoLUtility.getLastRoll()
|
||||
rollData.actor.subHeroPoints(1)
|
||||
let r = new BoLDefaultRoll( rollData )
|
||||
r.upgradeToCritical();
|
||||
} );
|
||||
|
||||
html.on("click", '.hero-reroll', event => {
|
||||
event.preventDefault();
|
||||
|
||||
let rollData = BoLUtility.getLastRoll()
|
||||
rollData.actor.subHeroPoints(1)
|
||||
rollData.reroll = false // Disable reroll option for second roll
|
||||
let r = new BoLDefaultRoll( rollData )
|
||||
r.roll();
|
||||
} );
|
||||
@ -145,7 +157,6 @@ export class BoLUtility {
|
||||
let attackId = event.currentTarget.attributes['data-attack-id'].value;
|
||||
let defenseMode = event.currentTarget.attributes['data-defense-mode'].value;
|
||||
let weaponId = (event.currentTarget.attributes['data-weapon-id']) ? event.currentTarget.attributes['data-weapon-id'].value : -1
|
||||
console.log("DEFENSE1", event.currentTarget, attackId, defenseMode, weaponId);
|
||||
if ( game.user.isGM) {
|
||||
BoLUtility.processDamageHandling(event, attackId, defenseMode, weaponId)
|
||||
} else {
|
||||
@ -154,31 +165,6 @@ export class BoLUtility {
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async processDamageIncrease(event, attackId, damageMode ) {
|
||||
if ( !game.user.isGM) {
|
||||
return;
|
||||
}
|
||||
BoLUtility.removeChatMessageId(BoLUtility.findChatMessageId(event.currentTarget));
|
||||
|
||||
// Only GM process this
|
||||
let attackDef = this.attackStore[attackId];
|
||||
if (attackDef) {
|
||||
attackDef.damageMode = damageMode;
|
||||
if (defenseMode == 'damage-plus-6') {
|
||||
attackDef.damageRoll.total += 6;
|
||||
}
|
||||
if (defenseMode == 'damage-plus-12') {
|
||||
attackDef.damageRoll.total += 12;
|
||||
attackDef.defender.subHeroPoints(1);
|
||||
}
|
||||
if (defenseMode == 'damage-normal') {
|
||||
// Do nothing !
|
||||
}
|
||||
BoLUtility.sendAttackSuccess( this.attackDef);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async processDamageHandling(event, attackId, defenseMode, weaponId=-1) {
|
||||
if ( !game.user.isGM) {
|
||||
@ -188,7 +174,7 @@ export class BoLUtility {
|
||||
|
||||
//console.log("Damage Handling", event, attackId, defenseMode, weaponId)
|
||||
// Only GM process this
|
||||
let attackDef = this.attackStore[attackId];
|
||||
let attackDef = this.attackStore[attackId]
|
||||
if (attackDef) {
|
||||
if (attackDef.defenseDone) return; // ?? Why ???
|
||||
attackDef.defenseDone = true
|
||||
@ -389,9 +375,6 @@ export class BoLUtility {
|
||||
if (sockmsg.name == "msg_damage_handling") {
|
||||
BoLUtility.processDamageHandling(sockmsg.data.event, sockmsg.data.attackId, sockmsg.data.defenseMode)
|
||||
}
|
||||
if (sockmsg.name == "msg_damage_increase") {
|
||||
BoLUtility.processDamageIncrease(sockmsg.data.event, sockmsg.data.attackId, sockmsg.data.damageMode)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -32,6 +32,7 @@ export const preloadHandlebarsTemplates = async function () {
|
||||
"systems/bol/templates/item/parts/properties/feature/race-properties.hbs",
|
||||
|
||||
// DIALOGS
|
||||
"systems/bol/templates/chat/rolls/attack-damage-card.hbs",
|
||||
"systems/bol/templates/roll/parts/roll-dialog-modifiers.hbs",
|
||||
"systems/bol/templates/roll/parts/roll-dialog-attribute.hbs",
|
||||
"systems/bol/templates/dialogs/aptitude-roll-part.hbs",
|
||||
|
@ -7,7 +7,7 @@
|
||||
"url": "https://github.com/ZigmundKreud/bol",
|
||||
"license": "LICENSE.txt",
|
||||
"flags": {},
|
||||
"version": "0.8.9.9",
|
||||
"version": "0.9.0.0",
|
||||
"templateVersion": 16,
|
||||
"minimumCoreVersion": "0.8.6",
|
||||
"compatibleCoreVersion": "9",
|
||||
|
7
templates/chat/rolls/attack-damage-card.hbs
Normal file
7
templates/chat/rolls/attack-damage-card.hbs
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
<button class="chat-damage-roll" data-damage-mode="normal-damage" data-attack-id="{{id}}">Lancer les dommages</button>
|
||||
|
||||
{{#if isCritical}}
|
||||
<button class="chat-damage-roll" data-damage-mode="damage-plus-6" data-attack-id="{{id}}">Lancer les dommages +6</button>
|
||||
<button class="chat-damage-roll" data-damage-mode="damage-plus-12" data-attack-id="{{id}}">Dommages +12 (1 Pt. d'Heroisme)</button>
|
||||
{{/if}}
|
@ -1,6 +0,0 @@
|
||||
<img class="chat-icon" src="{{actor.img}}" alt="{{actor.name}}"/>
|
||||
Jet Héroïque !
|
||||
<button class="damage-increase" data-damage-mode="damage-plus-6" data-attack-id="{{id}}">Augmenter les dommages de 6</button>
|
||||
<button class="damage-increase" data-damage-mode="damage-plus-12" data-attack-id="{{id}}">Augmenter les dommages de 12 (1 point d'Heroisme)</button>
|
||||
<button class="damage-increase" data-damage-mode="damage-normal" data-attack-id="{{id}}">Laisser les dommages inchangés</button>
|
||||
|
@ -1,7 +1,8 @@
|
||||
<img class="chat-icon" src="{{weapon.img}}" alt="{{weapon.name}}"/>
|
||||
<h3><strong>Dommages de l'arme : {{damage}}</strong>
|
||||
{{!#if hasDescription}}
|
||||
<!--<h4>-->
|
||||
<!-- <pre class="rollDescr-line">{{!description}}</pre>-->
|
||||
<!--</h4>-->
|
||||
{{!/if}}
|
||||
<h3><strong>Dommages de {{weapon.name}} : {{damageRoll.total}}</strong>
|
||||
|
||||
{{#if target}}
|
||||
<div id="{{applyId}}">
|
||||
<button class="chat-damage-apply" data-attack-id="{{id}}">Appliquer les dommages à la cible</button>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
@ -16,11 +16,15 @@
|
||||
|
||||
<h3><strong>{{description}}</strong></h3>
|
||||
|
||||
{{#if reroll}}
|
||||
<a class="button hero-reroll" data-roll-id=="{{rollId}}"" data-actor-id="{{actor.id}}">Relancer!</a>
|
||||
<div id="{{optionsId}}">
|
||||
{{#if (and isSuccess weapon)}}
|
||||
{{> "systems/bol/templates/chat/rolls/attack-damage-card.hbs"}}
|
||||
{{/if}}
|
||||
{{!#if hasDescription}}
|
||||
<!--<h4>-->
|
||||
<!-- <pre class="rollDescr-line">{{!description}}</pre>-->
|
||||
<!--</h4>-->
|
||||
{{!/if}}
|
||||
|
||||
{{#if reroll}}
|
||||
<button class="chat-button button hero-reroll" data-roll-id=="{{rollId}}" data-actor-id="{{actor.id}}">Relancer (1 P. Heroisme)</button>
|
||||
{{/if}}
|
||||
{{#if isRealCritical}}
|
||||
<button class="chat-button button transform-heroic-roll" data-roll-id=="{{rollId}}" data-actor-id="{{actor.id}}">Transformer en succes héroique (1 P. Heroisme)</button>
|
||||
{{/if}}
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user