forked from public/fvtt-cthulhu-eternal
Initial release
This commit is contained in:
parent
15f512ea3a
commit
b44ac05b1e
@ -98,7 +98,6 @@ Hooks.once("init", function () {
|
||||
const type = anchor.dataset.rollType
|
||||
const target = anchor.dataset.rollTarget
|
||||
const title = anchor.dataset.rollTitle
|
||||
const avantage = anchor.dataset.rollAvantage
|
||||
})
|
||||
|
||||
console.info("CTHULHU ETERNAL | System Initialized")
|
||||
|
@ -92,6 +92,9 @@
|
||||
"RangedWeapons": "Ranged Weapons",
|
||||
"FirearmsBeams": "Firearms / Beam Weapons",
|
||||
"FIELDS": {
|
||||
"isAdversary": {
|
||||
"label": "Adversary"
|
||||
},
|
||||
"settings": {
|
||||
"label": "Settings era"
|
||||
},
|
||||
@ -253,6 +256,8 @@
|
||||
"veryHarsh": "Very Harsh"
|
||||
},
|
||||
"Label": {
|
||||
"titleSkill": "Skill",
|
||||
"titleWeapon": "Weapon",
|
||||
"biodata": "Biodata",
|
||||
"skill": "Skill",
|
||||
"modifier": "Modifier",
|
||||
|
@ -185,9 +185,10 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
|
||||
async _onRoll(event, target) {
|
||||
const rollType = $(event.currentTarget).data("roll-type")
|
||||
let item
|
||||
let li
|
||||
// Debug : console.log(">>>>", event, target, rollType)
|
||||
// Deprecated : if (this.isEditMode) return
|
||||
switch(rollType) {
|
||||
switch (rollType) {
|
||||
case "char":
|
||||
let charId = $(event.currentTarget).data("char-id")
|
||||
item = foundry.utils.duplicate(this.actor.system.characteristics[charId])
|
||||
@ -195,7 +196,12 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
|
||||
item.targetScore = item.value * 5
|
||||
break
|
||||
case "skill":
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
li = $(event.currentTarget).parents(".item");
|
||||
item = this.actor.items.get(li.data("item-id"));
|
||||
break
|
||||
case "weapon":
|
||||
case "damage":
|
||||
li = $(event.currentTarget).parents(".item");
|
||||
item = this.actor.items.get(li.data("item-id"));
|
||||
break
|
||||
default:
|
||||
|
@ -1,4 +1,5 @@
|
||||
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
export default class CthulhuEternalRoll extends Roll {
|
||||
/**
|
||||
* The HTML template path used to render dice checks of this type
|
||||
@ -74,6 +75,10 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
return this.options.realDamage
|
||||
}
|
||||
|
||||
get weapon() {
|
||||
return this.options.weapon
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt the user with a dialog to configure and execute a roll.
|
||||
*
|
||||
@ -98,6 +103,32 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
case "char":
|
||||
options.initialScore = options.rollItem.targetScore
|
||||
break
|
||||
case "damage":
|
||||
let formula = options.rollItem.system.damage
|
||||
let damageRoll = new Roll(formula)
|
||||
await damageRoll.evaluate()
|
||||
await damageRoll.toMessage({
|
||||
flavor: `${options.rollItem.name} - Damage Roll`
|
||||
});
|
||||
let isLethal = false
|
||||
if (options.rollItem.system.lethality > 0 ) {
|
||||
let lethalityRoll = new Roll("1d100")
|
||||
await lethalityRoll.evaluate()
|
||||
isLethal = (lethalityRoll.total <= options.rollItem.system.lethality)
|
||||
await lethalityRoll.toMessage({
|
||||
flavor: `${options.rollItem.name} - Lethality Roll : ${lethalityRoll.total} <= ${options.rollItem.system.lethality} => ${isLethal}`
|
||||
});
|
||||
}
|
||||
return
|
||||
case "weapon":
|
||||
let era = game.settings.get("fvtt-cthulhu-eternal", "settings-era")
|
||||
let skillName = game.i18n.localize(SYSTEM.WEAPON_SKILL_MAPPING[era][options.rollItem.system.weaponType])
|
||||
let actor = game.actors.get(options.actorId)
|
||||
options.weapon = options.rollItem
|
||||
options.rollItem = actor.items.find(i => i.type === "skill" && i.name.toLowerCase() === skillName.toLowerCase())
|
||||
options.initialScore = options.rollItem.system.computeScore()
|
||||
console.log("WEAPON", skillName, era, options.rollItem)
|
||||
break
|
||||
default:
|
||||
options.initialScore = 50
|
||||
break
|
||||
@ -114,7 +145,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
"-10": "-10",
|
||||
"-20": "-20",
|
||||
"-40": "-40",
|
||||
0: "0",
|
||||
"0": "0",
|
||||
"+10": "+10",
|
||||
"+20": "+20",
|
||||
"+40": "+40",
|
||||
@ -128,6 +159,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
let dialogContext = {
|
||||
rollType: options.rollType,
|
||||
rollItem: foundry.utils.duplicate(options.rollItem), // Object only, no class
|
||||
weapon: options?.weapon,
|
||||
initialScore: options.initialScore,
|
||||
targetScore: options.initialScore,
|
||||
isLowWP: options.isLowWP,
|
||||
@ -201,12 +233,12 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
if (roll.total <= rollData.targetScore) {
|
||||
resultType = "success"
|
||||
// Detect if decimal == unit in the dire total result
|
||||
if (dec === unit || roll.total == 1) {
|
||||
if (dec === unit || roll.total === 1) {
|
||||
resultType = "successCritical"
|
||||
}
|
||||
} else {
|
||||
// Detect if decimal == unit in the dire total result
|
||||
if (dec === unit || roll.total == 100) {
|
||||
if (dec === unit || roll.total === 100) {
|
||||
resultType = "failureCritical"
|
||||
}
|
||||
}
|
||||
@ -234,9 +266,11 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
static createTitle(type, target) {
|
||||
switch (type) {
|
||||
case "skill":
|
||||
return `${game.i18n.localize("CTHULHUETERNAL.Dialog.titleSkill")}`
|
||||
return `${game.i18n.localize("CTHULHUETERNAL.Label.titleSkill")}`
|
||||
case "weapon":
|
||||
return `${game.i18n.localize("CTHULHUETERNAL.Label.titleWeapon")}`
|
||||
default:
|
||||
return game.i18n.localize("CTHULHUETERNAL.Dialog.titleStandard")
|
||||
return game.i18n.localize("CTHULHUETERNAL.Label.titleStandard")
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,6 +321,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
cardData.targetArmor = this.targetArmor
|
||||
cardData.realDamage = this.realDamage
|
||||
cardData.isPrivate = isPrivate
|
||||
cardData.weapon = this.weapon
|
||||
|
||||
console.log(cardData)
|
||||
|
||||
|
@ -155,25 +155,13 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
/**
|
||||
* Rolls a dice for a character.
|
||||
* @param {("save"|"resource|damage")} rollType The type of the roll.
|
||||
* @param {number} rollTarget The target value for the roll. Which caracteristic or resource. If the roll is a damage roll, this is the id of the item.
|
||||
* @param {"="|"+"|"++"|"-"|"--"} rollAdvantage If there is an avantage (+), a disadvantage (-), a double advantage (++), a double disadvantage (--) or a normal roll (=).
|
||||
* @param {number} rollItem The target value for the roll. Which caracteristic or resource. If the roll is a damage roll, this is the id of the item.
|
||||
* @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled.
|
||||
*/
|
||||
async roll(rollType, rollTarget, rollAdvantage = "=") {
|
||||
let rollValue
|
||||
async roll(rollType, rollItem) {
|
||||
let opponentTarget
|
||||
switch (rollType) {
|
||||
default:
|
||||
// Handle other cases or do nothing
|
||||
break
|
||||
}
|
||||
await this._roll(rollType, rollTarget, rollValue, opponentTarget, rollAdvantage)
|
||||
}
|
||||
|
||||
/** Main roll function
|
||||
*/
|
||||
async _roll(rollType, rollItem, opponentTarget = undefined) {
|
||||
const hasTarget = opponentTarget !== undefined
|
||||
|
||||
let roll = await CthulhuEternalRoll.prompt({
|
||||
rollType,
|
||||
rollItem,
|
||||
|
@ -12,6 +12,7 @@ export default class CthulhuEternalSkill extends foundry.abstract.TypeDataModel
|
||||
schema.bonus = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
|
||||
schema.diceEvolved = new fields.BooleanField({ required: true, initial: true })
|
||||
schema.rollFailed = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.isAdversary = new fields.BooleanField({ required: true, initial: false })
|
||||
|
||||
return schema
|
||||
}
|
||||
|
@ -9,9 +9,15 @@
|
||||
{{#if (eq rollType "char")}}
|
||||
<li><strong>{{localize "CTHULHUETERNAL.Label.charRoll"}}</strong></li>
|
||||
{{/if}}
|
||||
|
||||
{{#if (eq rollType "skill")}}
|
||||
<li><strong>{{localize "CTHULHUETERNAL.Label.skillRoll"}}</strong></li>
|
||||
{{/if}}
|
||||
|
||||
{{#if weapon}}
|
||||
<li><strong>Weapon : {{weapon.name}}</strong></li>
|
||||
{{/if}}
|
||||
|
||||
<li><strong>{{rollItem.name}} : {{initialScore}}%</strong></li>
|
||||
<li>{{localize "CTHULHUETERNAL.Label.modifier"}} : {{modifier}}%</li>
|
||||
<li>{{localize "CTHULHUETERNAL.Label.targetScore"}} : {{targetScore}}%</li>
|
||||
|
@ -6,9 +6,9 @@
|
||||
<div class="weapons">
|
||||
{{#each weapons as |item|}}
|
||||
{{!log 'weapon' this}}
|
||||
<div class="weapon" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}" data-drag="true" data-drag-type="damage">
|
||||
<div class="weapon item" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}" data-drag="true" >
|
||||
<img class="item-img" src="{{item.img}}" data-tooltip="{{item.name}}" />
|
||||
<div class="name rollable" data-tooltip="{{{item.system.description}}}">
|
||||
<div class="name rollable" data-roll-type="weapon" data-tooltip="{{{item.system.description}}}">
|
||||
{{item.name}}
|
||||
</div>
|
||||
<a class="damage rollable" data-item-id="{{item.id}}" data-action="roll" data-roll-type="damage" data-roll-value="{{item.system.damage}}">{{localize "CTHULHUETERNAL.Label.damageShort"}} : {{item.system.damage}}</a>
|
||||
|
@ -7,7 +7,13 @@
|
||||
{{#if (eq rollType "char")}}
|
||||
<legend>{{localize "CTHULHUETERNAL.Label.characteristic"}}</legend>
|
||||
{{/if}}
|
||||
|
||||
<div class="dialog-skill">{{rollItem.name}} : {{initialScore}}%</div>
|
||||
|
||||
{{#if weapon}}
|
||||
<div class="dialog-skill">Weapon : {{weapon.name}}</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if isZeroWP}}
|
||||
<div class="dialog-skill">Zero WP : Automatic failure (ie 0%)</div>
|
||||
{{else}}
|
||||
|
@ -13,6 +13,7 @@
|
||||
<legend>{{localize "CTHULHUETERNAL.Label.totalScore"}}</legend>
|
||||
{{system.skillTotal}}
|
||||
</div>
|
||||
{{formField systemFields.isAdversary value=system.isAdversary}}
|
||||
{{formField systemFields.diceEvolved value=system.diceEvolved}}
|
||||
{{#if system.diceEvolved}}
|
||||
{{formField systemFields.rollFailed value=system.rollFailed}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user