diff --git a/app/imports/api/engine/action/applyProperties/applySavingThrowProperty.ts b/app/imports/api/engine/action/applyProperties/applySavingThrowProperty.ts index e8c53c96..8f76dddc 100644 --- a/app/imports/api/engine/action/applyProperties/applySavingThrowProperty.ts +++ b/app/imports/api/engine/action/applyProperties/applySavingThrowProperty.ts @@ -4,7 +4,6 @@ import InputProvider from '/imports/api/engine/action/functions/userInput/InputP import { applyDefaultAfterPropTasks } from '/imports/api/engine/action/functions/applyTaskGroups'; import { getEffectiveActionScope } from '/imports/api/engine/action/functions/getEffectiveActionScope'; import recalculateCalculation from '/imports/api/engine/action/functions/recalculateCalculation'; -import { applyUnresolvedEffects } from '/imports/api/engine/action/methods/doCheck'; import { PropTask } from '/imports/api/engine/action/tasks/Task'; import TaskResult from '/imports/api/engine/action/tasks/TaskResult'; import { getVariables } from '/imports/api/engine/loadCreatures'; @@ -64,11 +63,8 @@ export default async function applySavingThrowProperty( applyDefaultAfterPropTasks(action, prop, [targetId], inputProvider); } - let rollModifierText = numberToSignedString(save.value, true); - let rollModifier = save.value - const { effectBonus, effectString } = applyUnresolvedEffects(save, scope) - rollModifierText += effectString; - rollModifier += effectBonus; + const rollModifierText = numberToSignedString(save.value, true); + const rollModifier = save.value; let value, resultPrefix; if (save.advantage === 1) { diff --git a/app/imports/api/engine/action/functions/userInput/InputProvider.ts b/app/imports/api/engine/action/functions/userInput/InputProvider.ts index 51244a25..87235fdf 100644 --- a/app/imports/api/engine/action/functions/userInput/InputProvider.ts +++ b/app/imports/api/engine/action/functions/userInput/InputProvider.ts @@ -37,8 +37,8 @@ export type Advantage = 0 | 1 | -1; export type CheckParams = { advantage: Advantage; - skillVariableName: string; - abilityVariableName: string; + skillVariableName?: string; + abilityVariableName?: string; dc: number | null; contest?: true; targetSkillVariableName?: string; diff --git a/app/imports/api/engine/action/methods/doCheck.js b/app/imports/api/engine/action/methods/doCheck.js deleted file mode 100644 index efdb352d..00000000 --- a/app/imports/api/engine/action/methods/doCheck.js +++ /dev/null @@ -1,139 +0,0 @@ -import SimpleSchema from 'simpl-schema'; -import { ValidatedMethod } from 'meteor/mdg:validated-method'; -import { RateLimiterMixin } from 'ddp-rate-limiter-mixin'; -import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties'; -import { assertEditPermission } from '/imports/api/creature/creatures/creaturePermissions'; -import rollDice from '/imports/parser/rollDice'; -import numberToSignedString from '/imports/api/utility/numberToSignedString'; -import { getSingleProperty } from '/imports/api/engine/loadCreatures'; - -// TODO Migrate this to the new action engine - -const doCheck = new ValidatedMethod({ - name: 'creatureProperties.doCheck', - validate: new SimpleSchema({ - propId: SimpleSchema.RegEx.Id, - scope: { - type: Object, - blackbox: true, - }, - }).validator(), - mixins: [RateLimiterMixin], - rateLimit: { - numRequests: 10, - timeInterval: 5000, - }, - run({ propId, scope }) { - console.warn('do check not implemented'); - return; - const prop = CreatureProperties.findOne(propId); - if (!prop) throw new Meteor.Error('not-found', 'The property was not found'); - const creatureId = prop.root.id; - const actionContext = new ActionContext(creatureId, [creatureId], this); - Object.assign(actionContext.scope, scope); - actionContext.scope[`#${prop.type}`] = prop; - - // Check permissions - assertEditPermission(actionContext.creature, this.userId); - - // Do the check - doCheckWork({ prop, actionContext }); - }, -}); - -export default doCheck; - -export function doCheckWork({ prop, actionContext }) { - - applyTriggers(actionContext.triggers.check?.before, prop, actionContext); - rollCheck(prop, actionContext); - applyTriggers(actionContext.triggers.check?.after, prop, actionContext); - - // Insert the log - actionContext.writeLog(); -} - -function rollCheck(prop, actionContext) { - const scope = actionContext.scope; - // get the modifier for the roll - let rollModifier; - let logName = `${prop.name} check`; - if (prop.type === 'skill') { - rollModifier = prop.value; - if (prop.skillType === 'save') { - if (prop.name.match(/save/i)) { - logName = prop.name; - } else { - logName = prop.name ? `${prop.name} save` : 'Saving Throw'; - } - } - } else if (prop.type === 'attribute') { - if (prop.attributeType === 'ability') { - rollModifier = prop.modifier; - } else { - rollModifier = prop.value; - } - } else { - throw (`${prop.type} not supported for checks`); - } - - let rollModifierText = numberToSignedString(rollModifier, true); - - const { effectBonus, effectString } = applyUnresolvedEffects(prop, actionContext) - rollModifierText += effectString; - rollModifier += effectBonus; - - let value, values, resultPrefix; - if (scope['~checkAdvantage']?.value === 1) { - logName += ' (Advantage)'; - const [a, b] = rollDice(2, 20); - if (a >= b) { - value = a; - resultPrefix = `1d20 [ ${a}, ~~${b}~~ ] ${rollModifierText} = `; - } else { - value = b; - resultPrefix = `1d20 [ ~~${a}~~, ${b} ] ${rollModifierText} = `; - } - } else if (scope['~checkAdvantage']?.value === -1) { - logName += ' (Disadvantage)'; - const [a, b] = rollDice(2, 20); - if (a <= b) { - value = a; - resultPrefix = `1d20 [ ${a}, ~~${b}~~ ] ${rollModifierText} = `; - } else { - value = b; - resultPrefix = `1d20 [ ~~${a}~~, ${b} ] ${rollModifierText} = `; - } - } else { - values = rollDice(1, 20); - value = values[0]; - resultPrefix = `1d20 [ ${value} ] ${rollModifierText} = ` - } - const result = (value + rollModifier) || 0; - scope['~checkDiceRoll'] = { value }; - scope['~checkRoll'] = { value: result }; - scope['~checkModifier'] = { value: rollModifier }; - actionContext.addLog({ - name: logName, - value: `${resultPrefix} **${result}**`, - }); -} - -// TODO replace this with recalculating and then rolling/reducing the value node -export function applyUnresolvedEffects(prop, actionContext) { - let effectBonus = 0; - let effectString = ''; - if (!prop.effectIds) { - return { effectBonus, effectString }; - } - prop.effectIds.forEach(id => { - const effect = getSingleProperty(actionContext.creature._id, id); - if (!effect.amount?.parseNode) return; - if (effect.operation !== 'add') return; - recalculateCalculation(effect.amount, actionContext, undefined, 'reduce'); - if (typeof effect.amount?.value !== 'number') return; - effectBonus += effect.amount.value; - effectString += ` ${effect.amount.value < 0 ? '-' : '+'} [${effect.amount.calculation}] ${Math.abs(effect.amount.value)}` - }); - return { effectBonus, effectString }; -} diff --git a/app/imports/client/ui/components/RollPopup.vue b/app/imports/client/ui/components/RollPopup.vue deleted file mode 100644 index 0aaca754..00000000 --- a/app/imports/client/ui/components/RollPopup.vue +++ /dev/null @@ -1,122 +0,0 @@ - - - - - diff --git a/app/imports/client/ui/components/rolls/Check.vue b/app/imports/client/ui/components/rolls/Check.vue deleted file mode 100644 index 78500a7b..00000000 --- a/app/imports/client/ui/components/rolls/Check.vue +++ /dev/null @@ -1,99 +0,0 @@ - - - - - diff --git a/app/imports/client/ui/properties/components/attributes/AbilityListTile.vue b/app/imports/client/ui/properties/components/attributes/AbilityListTile.vue index ffb0df15..5732e261 100644 --- a/app/imports/client/ui/properties/components/attributes/AbilityListTile.vue +++ b/app/imports/client/ui/properties/components/attributes/AbilityListTile.vue @@ -7,16 +7,14 @@ class="ma-0" style="min-width: 40px;" > -
@@ -40,7 +38,7 @@
-
+ @@ -64,15 +62,11 @@