Skip to content

Commit

Permalink
Merge pull request #138 from juanferrer/master
Browse files Browse the repository at this point in the history
The big unification
  • Loading branch information
ClipplerBlood committed Oct 15, 2023
2 parents a177147 + a335451 commit d454ab6
Show file tree
Hide file tree
Showing 47 changed files with 1,216 additions and 1,329 deletions.
6 changes: 3 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async function buildCompendium(compendium) {
compendium = parts.at(-1);
}

const command = `fvtt package pack --type ${packageType} --id ${packageId} -n "${compendium}" --in "${compendiaDirectory}/${compendium}" --out "${distDirectory}/packs"`
const command = `fvtt package pack --type ${packageType} --id ${packageId} -n "${compendium}" --in "${compendiaDirectory}/${compendium}" --out "${distDirectory}/packs/${compendium}"`
console.log(cp.execSync(command).toString());
}

Expand Down Expand Up @@ -272,9 +272,9 @@ function getPackageId() {
/* EXPORTS */
/********************/

const execBuild = gulp.parallel(buildCode, buildStyles, copyFiles, buildCompendia);
const execBuild = gulp.parallel(buildCode, buildStyles, buildCompendia);

exports.build = gulp.series(clean, execBuild);
exports.build = gulp.series(clean, execBuild, copyFiles);
exports.watch = buildWatch;
exports.clean = clean;
exports.link = linkUserData;
Expand Down
12 changes: 6 additions & 6 deletions src/module/active-effects/item-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,12 @@ export class DLActiveEffects {
// --- Attack
const action = talentData.action
const attackChanges = [
addEffect('system.bonuses.attack.boons.strength', action.boonsbanes * action.strengthboonsbanesselect, priority),
addEffect('system.bonuses.attack.boons.agility', action.boonsbanes * action.agilityboonsbanesselect, priority),
addEffect('system.bonuses.attack.boons.intellect', action.boonsbanes * action.intellectboonsbanesselect, priority),
addEffect('system.bonuses.attack.boons.will', action.boonsbanes * action.willboonsbanesselect, priority),
concatDiceEffect('system.bonuses.attack.damage', action.damage),
concatDiceEffect('system.bonuses.attack.plus20Damage', action.plus20damage),
addEffect('system.bonuses.attack.boons.strength', action.extraboonsbanes * action.strengthboonsbanesselect, priority),
addEffect('system.bonuses.attack.boons.agility', action.extraboonsbanes * action.agilityboonsbanesselect, priority),
addEffect('system.bonuses.attack.boons.intellect', action.extraboonsbanes * action.intellectboonsbanesselect, priority),
addEffect('system.bonuses.attack.boons.will', action.extraboonsbanes * action.willboonsbanesselect, priority),
concatDiceEffect('system.bonuses.attack.damage', action.extradamage),
concatDiceEffect('system.bonuses.attack.plus20Damage', action.extraplus20damage),
concatString('system.bonuses.attack.extraEffect', action.extraeffect, '\n'),
].filter(falsyChangeFilter)

Expand Down
104 changes: 64 additions & 40 deletions src/module/actor/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,13 @@ export class DemonlordActor extends Actor {
return
}

if (item.system?.vs?.attribute)
if (item.system?.action?.attack) {
launchRollDialog(game.i18n.localize('DL.TalentVSRoll') + game.i18n.localize(item.name), async html =>
await this.useTalent(item, html.find('[id="boonsbanes"]').val(), html.find('[id="modifier"]').val()),
)
else await this.useTalent(item, 0, 0)
} else {
await this.useTalent(item, 0, 0)
}
}

async useTalent(talent, inputBoons, inputModifier) {
Expand All @@ -455,20 +457,20 @@ export class DemonlordActor extends Actor {
const target = targets[0]
let attackRoll = null

if (!talentData?.vs?.attribute) {
if (!talentData?.action?.attack) {
await this.activateTalent(talent, true)
} else {
await this.activateTalent(talent, Boolean(talentData.vs?.damageActive))
await this.activateTalent(talent, Boolean(talentData.action?.damageActive))

const attackAttribute = talentData.vs.attribute.toLowerCase()
const defenseAttribute = talentData.vs?.against?.toLowerCase()
const attackAttribute = talentData.action.attack.toLowerCase()
const defenseAttribute = talentData.action?.attack?.toLowerCase()

let modifier = parseInt(inputModifier) + (this.getAttribute(attackAttribute)?.modifier || 0)

let boons =
parseInt(inputBoons) +
(this.system.bonuses.attack[attackAttribute] || 0) + // FIXME: is it a challenge or an attack?
parseInt(talentData.vs?.boonsbanes || 0)
parseInt(talentData.action?.boonsbanes || 0)
if (targets.length > 0) boons -= target?.actor?.system.bonuses.defense[defenseAttribute] || 0
const boonsReroll = parseInt(this.system.bonuses.rerollBoon1Dice)

Expand Down Expand Up @@ -507,11 +509,13 @@ export class DemonlordActor extends Actor {
return
} else await item.update({'system.castings.value': uses + 1}, {parent: this})

if (isAttack && attackAttribute)
if (isAttack && attackAttribute) {
launchRollDialog(game.i18n.localize('DL.DialogSpellRoll') + game.i18n.localize(item.name), async html =>
await this.useSpell(item, html.find('[id="boonsbanes"]').val(), html.find('[id="modifier"]').val()),
)
else await this.useSpell(item, 0, 0)
} else {
await this.useSpell(item, 0, 0)
}
}

async useSpell(spell, inputBoons, inputModifier) {
Expand Down Expand Up @@ -553,16 +557,55 @@ export class DemonlordActor extends Actor {

/* -------------------------------------------- */

async useItem(itemID) {
const item = duplicate(this.items.get(itemID))
if (item.type !== 'item') return postItemToChat(this, item)
if (item.system.quantity < 1) {
ui.notifications.warn(game.i18n.localize('DL.ItemMaxUsesReached'))
async rollItem(itemID, _options = {event: null}) {
const item = this.items.get(itemID)

if (item.system.quantity != null) {
if (item.system.quantity < 1) {
ui.notifications.warn(game.i18n.localize('DL.ItemMaxUsesReached'))
return
}

item.system.quantity--
await Item.updateDocuments([item], {parent: this})
}

if (item.system?.action?.attack) {
launchRollDialog(game.i18n.localize('DL.ItemVSRoll') + game.i18n.localize(item.name), async html =>
await this.useItem(item, html.find('[id="boonsbanes"]').val(), html.find('[id="modifier"]').val()),
)
} else {
await this.useItem(item, 0, 0)
}
}

async useItem(item, inputBoons, inputModifier) {
const itemData = item.system
const targets = tokenManager.targets
const target = targets[0]
let attackRoll = null

if (!itemData?.action?.attack) {
postItemToChat(this, item, null, null)
return
} else {
const attackAttribute = itemData.action.attack.toLowerCase()
const defenseAttribute = itemData.action?.attack?.toLowerCase()

let modifier = parseInt(inputModifier) + (this.getAttribute(attackAttribute)?.modifier || 0)

let boons =
parseInt(inputBoons) +
(this.system.bonuses.attack[attackAttribute] || 0) + // FIXME: is it a challenge or an attack?
parseInt(itemData.action?.boonsbanes || 0)
if (targets.length > 0) boons -= target?.actor?.system.bonuses.defense[defenseAttribute] || 0
const boonsReroll = parseInt(this.system.bonuses.rerollBoon1Dice)

attackRoll = new Roll(this.rollFormula(modifier, boons, boonsReroll), {})
attackRoll.evaluate({async: false})
}
item.system.quantity--
await Item.updateDocuments([item], {parent: this})
postItemToChat(this, item)

postItemToChat(this, item, attackRoll, target?.actor)
}

/* -------------------------------------------- */
Expand Down Expand Up @@ -641,7 +684,7 @@ export class DemonlordActor extends Actor {
}

getTargetNumber(item) {
let tagetNumber
let targetNumber
game.user.targets.forEach(async target => {
const targetActor = target.actor
if (targetActor) {
Expand All @@ -652,33 +695,14 @@ export class DemonlordActor extends Actor {
}

if (againstSelectedAttribute == 'defense') {
tagetNumber = targetActor.system?.characteristics?.defense
} else {
tagetNumber = targetActor.system?.attributes[againstSelectedAttribute]?.value
}
}
})

return tagetNumber
}

getVSTargetNumber(talent) {
let tagetNumber

game.user.targets.forEach(async target => {
const targetActor = target.actor
if (targetActor) {
const againstSelectedAttribute = talent.system.vs.against.toLowerCase()

if (againstSelectedAttribute == 'defense') {
tagetNumber = targetActor.system.characteristics.defense
targetNumber = targetActor.system?.characteristics?.defense
} else {
tagetNumber = targetActor.getAttribute(againstSelectedAttribute).value
targetNumber = targetActor.system?.attributes[againstSelectedAttribute]?.value
}
}
})

return tagetNumber
return targetNumber
}

/* -------------------------------------------- */
Expand Down
2 changes: 1 addition & 1 deletion src/module/actor/sheets/base-actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export default class DLBaseActorSheet extends ActorSheet {
})
} else {
const id = event.currentTarget.closest("[data-item-id]").dataset.itemId
await this.actor.useItem(id)
await this.actor.rollItem(id, {event: event})
}
})

Expand Down
4 changes: 2 additions & 2 deletions src/module/chat/chat-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ async function _onChatRollDamage(event) {
const token = li.closest('.demonlord')
const actor = _getChatCardActor(token)
const item = li.children[0]
const damageformular = item.dataset.damage
const damageformula = item.dataset.damage
const damagetype = item.dataset.damagetype
const selected = tokenManager.targets
const itemId = item.dataset.itemId || li.closest('.demonlord').dataset.itemId

const damageRoll = new Roll(damageformular, {})
const damageRoll = new Roll(damageformula, {})
damageRoll.evaluate({async: false})

let totalDamage = ''
Expand Down
2 changes: 1 addition & 1 deletion src/module/chat/effect-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function buildAttackEffectsMessage(attacker, defender, item, attackAttrib
break
case 'talent':
if (!attackAttribute) return
itemBoons = item.system.vs.boonsbanes
itemBoons = item.system.action.boonsbanes
break
default:
return
Expand Down
Loading

0 comments on commit d454ab6

Please sign in to comment.