Added "extra" damage type
Takes on the same damage type as the last damage applied during the same action, otherwise deals "extra" damage
This commit is contained in:
@@ -68,6 +68,15 @@ export default function applyDamage(node, {
|
||||
// Round the damage to a whole number
|
||||
damage = Math.floor(damage);
|
||||
|
||||
// Convert extra damage into the stored type
|
||||
if (prop.damageType === 'extra' && scope['$lastDamageType']) {
|
||||
prop.damageType = scope['$lastDamageType'];
|
||||
}
|
||||
// Store current damage type
|
||||
if (prop.damageType !== 'healing') {
|
||||
scope['$lastDamageType'] = prop.damageType;
|
||||
}
|
||||
|
||||
// Memoise the damage suffix for the log
|
||||
let suffix = (criticalHit ? ' critical ' : ' ') +
|
||||
prop.damageType +
|
||||
|
||||
@@ -4,6 +4,7 @@ import { getPropertyDecendants } from '/imports/api/engine/loadCreatures.js';
|
||||
import { nodeArrayToTree } from '/imports/api/parenting/nodesToTree.js';
|
||||
import applyProperty from '/imports/api/engine/actions/applyProperty.js';
|
||||
import { difference, intersection } from 'lodash';
|
||||
import getEffectivePropTags from '/imports/api/engine/computation/utility/getEffectivePropTags.js';
|
||||
|
||||
export default function applyTriggers(node, { creature, targets, scope, log }, timing) {
|
||||
const prop = node.node;
|
||||
@@ -25,10 +26,11 @@ export default function applyTriggers(node, { creature, targets, scope, log }, t
|
||||
|
||||
function triggerMatchTags(trigger, prop) {
|
||||
let matched = false;
|
||||
const propTags = getEffectivePropTags(prop);
|
||||
// Check the target tags
|
||||
if (
|
||||
!trigger.targetTags?.length ||
|
||||
difference(trigger.targetTags, prop.tags).length === 0
|
||||
difference(trigger.targetTags, propTags).length === 0
|
||||
) {
|
||||
matched = true;
|
||||
}
|
||||
@@ -38,14 +40,14 @@ function triggerMatchTags(trigger, prop) {
|
||||
if (matched) return;
|
||||
if (
|
||||
!extra.tags.length ||
|
||||
difference(extra.tags, prop.tags).length === 0
|
||||
difference(extra.tags, propTags).length === 0
|
||||
) {
|
||||
matched = true;
|
||||
}
|
||||
} else if (extra.operation === 'NOT') {
|
||||
if (
|
||||
extra.tags.length &&
|
||||
intersection(extra.tags, prop.tags)
|
||||
intersection(extra.tags, propTags)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { EJSON } from 'meteor/ejson';
|
||||
import createGraph from 'ngraph.graph';
|
||||
import getEffectivePropTags from '/imports/api/engine/computation/utility/getEffectivePropTags.js';
|
||||
|
||||
export default class CreatureComputation {
|
||||
constructor(properties, creature, variables){
|
||||
@@ -22,28 +23,15 @@ export default class CreatureComputation {
|
||||
// Store by id
|
||||
this.propsById[prop._id] = prop;
|
||||
|
||||
// Store tags
|
||||
const storePropOnTag = (prop, tag) => {
|
||||
// Store sets of ids in each tag
|
||||
getEffectivePropTags(prop).forEach(tag => {
|
||||
if (!tag) return;
|
||||
if (this.propsWithTag[tag]){
|
||||
if (this.propsWithTag[tag]) {
|
||||
this.propsWithTag[tag].push(prop._id);
|
||||
} else {
|
||||
this.propsWithTag[tag] = [prop._id];
|
||||
}
|
||||
}
|
||||
// Store sets of ids in each tag
|
||||
if (prop.tags){
|
||||
prop.tags.forEach(tag => {
|
||||
storePropOnTag(prop, tag);
|
||||
});
|
||||
}
|
||||
// Store tags for the property type
|
||||
storePropOnTag(prop, `#${prop.type}`);
|
||||
// Store tags for some string properties
|
||||
storePropOnTag(prop, prop.damageType);
|
||||
storePropOnTag(prop, prop.skillType);
|
||||
storePropOnTag(prop, prop.attributeType);
|
||||
storePropOnTag(prop, prop.reset);
|
||||
});
|
||||
|
||||
// Store the prop in the dependency graph
|
||||
this.dependencyGraph.addNode(prop._id, prop);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
export default function getEffectivePropTags(prop) {
|
||||
if (!prop.tags) return [];
|
||||
const tags = [...prop.tags];
|
||||
// Tags for the property type, separate #damage from #healing
|
||||
if (prop.type === 'damage' && prop.damageType === 'healing') {
|
||||
tags.push('#healing');
|
||||
} else {
|
||||
tags.push(`#${prop.type}`);
|
||||
}
|
||||
|
||||
// Tags for some string properties
|
||||
if (prop.damageType) tags.push(prop.damageType);
|
||||
if (prop.skillType) tags.push(prop.skillType);
|
||||
if (prop.attributeType) tags.push(prop.attributeType);
|
||||
if (prop.reset) tags.push(prop.reset);
|
||||
return tags;
|
||||
}
|
||||
@@ -13,6 +13,7 @@ const DAMAGE_TYPES = Object.freeze([
|
||||
'psychic',
|
||||
'radiant',
|
||||
'thunder',
|
||||
'extra',
|
||||
]);
|
||||
|
||||
export default DAMAGE_TYPES;
|
||||
|
||||
Reference in New Issue
Block a user