Skip to content

Commit

Permalink
got changes to ADD working for single damage roll
Browse files Browse the repository at this point in the history
  • Loading branch information
mjeffw committed Feb 11, 2021
1 parent f880bbd commit 8e8e95f
Show file tree
Hide file tree
Showing 9 changed files with 736 additions and 483 deletions.
Binary file removed icons/all-the-things.png
Binary file not shown.
4 changes: 4 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"GURPS.addHitLocationWoundModifiers" : "Hit Location Wound Modifiers",
"GURPS.addSpecialCombatSituations" : "Special Situations",
"GURPS.addRangedHalfDamage" : "Ranged, Half Damage (1/2D)",
"GURPS.addRangedHalfDamageShort": "Ranged (1/2D)",
"GURPS.addVulnerability" : "Vulnerability",
"GURPS.addHardenedDRLevel" : "Hardened DR Level",
"GURPS.addInjuryTolerance" : "Injury Tolerance",
Expand All @@ -137,6 +138,9 @@
"GURPS.addApplyInjury" : "Apply Injury",
"GURPS.addApplyInjuryQuietly" : "Apply Injury (Quietly)",

"GURPS.addSingleRollSelected": "Single damage roll selected",
"GURPS.addApplyOptionsToAll": "These options apply to all damage",

"GURPS.crippling" : "Crippling Injury, ",
"GURPS.damageAbove" : "Damage above ",
"GURPS.hpIgnored" : " HP ignored.",
Expand Down
4 changes: 4 additions & 0 deletions lang/pt_br.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"GURPS.addHitLocationWoundModifiers" : "Modificadores de Lesão devido ao Local de Acerto",
"GURPS.addSpecialCombatSituations" : "Situações Especiais de Combate",
"GURPS.addRangedHalfDamage" : "Distância, Meio Dano (1/2D)",
"GURPS.addRangedHalfDamageShort": "TODO::Ranged (1/2D)",
"GURPS.addVulnerability" : "Vulnerabilidade",
"GURPS.addHardenedDRLevel" : "RD Ampliada Nível",
"GURPS.addInjuryTolerance" : "Tolerância a Danos",
Expand All @@ -137,6 +138,9 @@
"GURPS.addApplyInjury" : "Aplicar Dano",
"GURPS.addApplyInjuryQuietly" : "Aplicar Dano (Sileciosamente)",

"GURPS.addSingleRollSelected": "TODO::Single damage roll selected",
"GURPS.addApplyOptionsToAll": "TODO::These options apply to all damage",

"GURPS.crippling" : "Lesão paralisante, ",
"GURPS.damageAbove" : "Dano acima de ",
"GURPS.hpIgnored" : " PV são ignorados.",
Expand Down
29 changes: 13 additions & 16 deletions lib/moustachewax.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,15 @@ export default function () {
Handlebars.registerHelper('isWoundModAdjForLocation', function (calc) {
if (calc.isWoundModifierAdjustedForLocation) {
let location = calc.effectiveWoundModifiers[calc.damageType]
return location.changed === 'hitlocation'
return !!location && location.changed === 'hitlocation'
}
return false
})

Handlebars.registerHelper('isWoundModAdjForInjuryTol', function (calc) {
if (calc.isWoundModifierAdjustedForInjuryTolerance) {
let location = calc.effectiveWoundModifiers[calc.damageType]
return location.changed === 'injury-tolerance'
return !!location && location.changed === 'injury-tolerance'
}
return false
})
Expand Down Expand Up @@ -248,30 +248,27 @@ export default function () {
if (Array.isArray(link)) txt = link.join(',')
return !!txt
? txt
.split(',')
.map((l) => game.GURPS.gurpslink(`[PDF:${l}]`))
.join(', ')
.split(',')
.map(l => game.GURPS.gurpslink(`[PDF:${l}]`))
.join(', ')
: ''
})
// Allows handling of multiple page refs, e.g."B101,MA150" and external links

// Allows handling of multiple page refs, e.g."B101,MA150" and external links
Handlebars.registerHelper('pdflinkext', function (link, externalLink) {
let txt = link
if (Array.isArray(link)) txt = link.join(',')
return !!txt
? txt
.split(',')
.map((l) => {
if (!!externalLink)
return `<a href="${externalLink}">*Link</a>`
else
return game.GURPS.gurpslink(`[PDF:${l}]`)
})
.join(', ')
.split(',')
.map(l => {
if (!!externalLink) return `<a href="${externalLink}">*Link</a>`
else return game.GURPS.gurpslink(`[PDF:${l}]`)
})
.join(', ')
: ''
})


Handlebars.registerHelper('round', function (num) {
return +(Math.round(num + 'e+2') + 'e-2')
})
Expand Down
48 changes: 24 additions & 24 deletions module/damage/applydamage.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ export default class ApplyDamageDialog extends Application {
constructor(actor, damageData, options = {}) {
super(options)

if (!Array.isArray(damageData)) damageData = [damageData]

this._calculator = new CompositeDamageCalculator(actor, damageData)
this.actor = actor
this.isSimpleDialog = game.settings.get(settings.SYSTEM_NAME, settings.SETTING_SIMPLE_DAMAGE)
this.index = 0
}

static get defaultOptions() {
Expand All @@ -52,18 +53,14 @@ export default class ApplyDamageDialog extends Application {
height: game.settings.get(settings.SYSTEM_NAME, settings.SETTING_SIMPLE_DAMAGE)
? simpleDialogHeight
: standardDialogHeight,
title: 'Apply Damage Calculator'
title: 'Apply Damage Calculator',
})
}

get calculator() {
return this._calculator.get(index)
}

getData() {
let data = super.getData()
data.actor = this.actor
data.CALC = this.calculator
data.CALC = this._calculator
data.isSimpleDialog = this.isSimpleDialog
return data
}
Expand All @@ -79,6 +76,9 @@ export default class ApplyDamageDialog extends Application {
html.find('.digits-only').inputFilter(value => digitsOnly.test(value))
html.find('.decimal-digits-only').inputFilter(value => digitsAndDecimalOnly.test(value))

// ==== Multiple Dice ====
html.find('.pagination > div')

// ==== Simple Damage ====
html
.find('#basicDamage')
Expand All @@ -90,7 +90,7 @@ export default class ApplyDamageDialog extends Application {
// Set Apply To dropdown value.
// When dropdown changes, update the calculator and refresh GUI.
html.find('#apply-to').on('change', ev => {
this.calculator.applyTo = $(ev.currentTarget).find('option:selected').val()
this._calculator.applyTo = $(ev.currentTarget).find('option:selected').val()
this.updateUI()
})

Expand All @@ -101,7 +101,7 @@ export default class ApplyDamageDialog extends Application {
.on('change', ev => this._updateModelFromInputText($(ev.currentTarget), 'userEnteredDR', parseIntFrom))

// If the current hit location is Random, resolve the die roll and update the hit location.
if (this.calculator.hitLocation === 'Random') this._randomizeHitLocation()
if (this._calculator.hitLocation === 'Random') this._randomizeHitLocation()

// When the 'random' button is clicked, update the hit location.
html.find('#random-location').on('click', async () => this._randomizeHitLocation())
Expand Down Expand Up @@ -236,21 +236,21 @@ export default class ApplyDamageDialog extends Application {
}
) {
if (element.is(':checked')) {
this.calculator[property] = converter(element.val())
this._calculator[property] = converter(element.val())
this.updateUI()
}
}

_updateModelFromBooleanElement(element, property) {
this.calculator[property] = element.is(':checked')
this._calculator[property] = element.is(':checked')
this.updateUI()
}

/**
* Ask the calculator to randomly select a hit location, and return the roll used.
*/
async _randomizeHitLocation() {
let roll3d = this.calculator.randomizeHitLocation()
let roll3d = this._calculator.randomizeHitLocation()

if (isNiceDiceEnabled()) {
game.dice3d.showForRoll(roll3d).then(display => this.updateUI())
Expand Down Expand Up @@ -292,22 +292,22 @@ export default class ApplyDamageDialog extends Application {
message = await this._renderTemplate('chat-shock.html', {
name: this.actor.data.name,
modifier: object.amount,
doubled: object.amount * 2
doubled: object.amount * 2,
})
}

if (object.type === 'majorwound') {
message = await this._renderTemplate('chat-majorwound.html', {
name: this.actor.data.name,
htCheck: object.modifier === 0 ? 'HT' : `HT-${object.modifier}`
htCheck: object.modifier === 0 ? 'HT' : `HT-${object.modifier}`,
})
}

if (object.type === 'headvitalshit') {
message = await this._renderTemplate('chat-headvitalshit.html', {
name: this.actor.data.name,
location: object.detail,
htCheck: object.modifier === 0 ? 'HT' : `HT-${object.modifier}`
htCheck: object.modifier === 0 ? 'HT' : `HT-${object.modifier}`,
})
}

Expand All @@ -318,7 +318,7 @@ export default class ApplyDamageDialog extends Application {
message = await this._renderTemplate('chat-knockback.html', {
name: this.actor.data.name,
yards: object.amount,
combinedCheck: `${dxCheck}|${acroCheck}|${judoCheck}`
combinedCheck: `${dxCheck}|${acroCheck}|${judoCheck}`,
})
}

Expand All @@ -327,14 +327,14 @@ export default class ApplyDamageDialog extends Application {
name: this.actor.data.name,
location: object.detail,
groundModifier: 'DX-1',
swimFlyModifer: 'DX-2'
swimFlyModifer: 'DX-2',
})
}

let msgData = {
content: message,
user: game.user._id,
type: CONST.CHAT_MESSAGE_TYPES.OOC
type: CONST.CHAT_MESSAGE_TYPES.OOC,
}
if (game.settings.get(settings.SYSTEM_NAME, settings.SETTING_WHISPER_STATUS_EFFECTS)) {
let users = this.actor.getUsers(CONST.ENTITY_PERMISSIONS.OWNER, true)
Expand All @@ -351,8 +351,8 @@ export default class ApplyDamageDialog extends Application {
* @param {boolean} publicly - if true, display to everyone; else display to GM and owner.
*/
submitDirectApply(ev, publicly) {
let injury = this.calculator.basicDamage
let type = this.calculator.applyTo
let injury = this._calculator.basicDamage
let type = this._calculator.applyTo
this.resolveInjury(ev, injury, type, publicly)
}

Expand Down Expand Up @@ -388,7 +388,7 @@ export default class ApplyDamageDialog extends Application {
current: current,
location: this._calculator.hitLocation,
type: type,
resultsTable: results
resultsTable: results,
}

if (type === 'FP') {
Expand All @@ -400,19 +400,19 @@ export default class ApplyDamageDialog extends Application {
this._renderTemplate('chat-damage-results.html', data).then(html => {
let speaker = {
alias: game.user.data.name,
_id: game.user._id
_id: game.user._id,
}
if (!!attackingActor)
speaker = {
alias: attackingActor.data.name,
_id: attackingActor._id,
actor: attackingActor
actor: attackingActor,
}
let messageData = {
user: game.user._id,
speaker: speaker,
content: html,
type: CONST.CHAT_MESSAGE_TYPES.OTHER
type: CONST.CHAT_MESSAGE_TYPES.OTHER,
}

if (!publicly) {
Expand Down
Loading

0 comments on commit 8e8e95f

Please sign in to comment.