diff --git a/app/imports/api/creature/CreatureProperties.js b/app/imports/api/creature/CreatureProperties.js index 92d9a167..1011a9bf 100644 --- a/app/imports/api/creature/CreatureProperties.js +++ b/app/imports/api/creature/CreatureProperties.js @@ -264,6 +264,48 @@ const damageProperty = new ValidatedMethod({ }, }); +const adjustQuantity = new ValidatedMethod({ + name: 'CreatureProperties.methods.adjustQuantity', + validate: new SimpleSchema({ + _id: SimpleSchema.RegEx.Id, + operation: { + type: String, + allowedValues: ['set', 'increment'] + }, + value: Number, + }).validator(), + run({_id, operation, value}) { + let currentProperty = CreatureProperties.findOne(_id); + // Check permissions + assertPropertyEditPermission(currentProperty, this.userId); + // Check if property can take damage + let schema = CreatureProperties.simpleSchema(currentProperty); + if (!schema.allowsKey('quantity')){ + throw new Meteor.Error( + 'Adjust quantity failed', + `Property of type "${currentProperty.type}" doesn't have a quantity` + ); + } + if (operation === 'set'){ + CreatureProperties.update(_id, { + $set: {quantity: value} + }, { + selector: currentProperty + }); + } else if (operation === 'increment'){ + // value here is 'damage' + value = -value; + let currentQuantity = currentProperty.quantity; + if (currentQuantity + value < 0) value = -currentQuantity; + CreatureProperties.update(_id, { + $inc: {quantity: value} + }, { + selector: currentProperty + }); + } + }, +}); + const pushToProperty = new ValidatedMethod({ name: 'CreatureProperties.methods.push', validate: null, @@ -317,6 +359,7 @@ export { insertPropertyFromLibraryNode, updateProperty, damageProperty, + adjustQuantity, pushToProperty, pullFromProperty, softRemoveProperty, diff --git a/app/imports/api/creature/computation/recomputeCreature.js b/app/imports/api/creature/computation/recomputeCreature.js index 6990087f..733c4904 100644 --- a/app/imports/api/creature/computation/recomputeCreature.js +++ b/app/imports/api/creature/computation/recomputeCreature.js @@ -72,6 +72,9 @@ const calculationPropertyTypes = [ * - Write the computed results back to the database */ export function recomputeCreatureById(creatureId){ + // Skipping computation on the client can result in the server being made to + // do work that isn't possible, in exchange for dramatic performance gains + if (Meteor.isClient) return; let props = getActiveProperties({ ancestorId: creatureId, filter: {type: {$in: calculationPropertyTypes}}, @@ -81,7 +84,6 @@ export function recomputeCreatureById(creatureId){ computeMemo(computationMemo); writeAlteredProperties(computationMemo); writeCreatureVariables(computationMemo, creatureId); - // if(Meteor.isClient) console.log(computationMemo); recomputeDamageMultipliersById(creatureId); return computationMemo; } diff --git a/app/imports/api/properties/Items.js b/app/imports/api/properties/Items.js index a1443295..e944310e 100644 --- a/app/imports/api/properties/Items.js +++ b/app/imports/api/properties/Items.js @@ -24,13 +24,13 @@ const ItemSchema = new SimpleSchema({ weight: { type: Number, min: 0, - defaultValue: 0, + optional: true, }, // Value per item in the stack, in gold pieces value: { type: Number, min: 0, - defaultValue: 0, + optional: true, }, // If this item is equipped, it requires attunement // Being equipped is `enabled === true` diff --git a/app/imports/constants/SVG_ICONS.js b/app/imports/constants/SVG_ICONS.js new file mode 100644 index 00000000..6dbccbf5 --- /dev/null +++ b/app/imports/constants/SVG_ICONS.js @@ -0,0 +1,24 @@ +const SVG_ICONS = Object.freeze({ + 'abacus': { + name: 'abacus', + shape: 'M37 73v382h18V73zm418.045 0l1.91 382h18l-1.91-382zM105 160c-14.638 0-27.157 9.715-31.43 23-2.405 6.634-1.479 14.38-.574 18 3.61 14.3 16.641 25 32.004 25 14.17 0 26.36-9.102 31-21.736C140.64 216.898 152.83 226 167 226c15.363 0 28.394-10.7 32.004-25h238.682l-.09-18H198.43c-4.273-13.285-16.792-23-31.43-23-14.17 0-26.36 9.102-31 21.736C131.36 169.102 119.17 160 105 160zm0 18c8.39 0 15 6.61 15 15s-6.61 15-15 15-15-6.61-15-15 6.61-15 15-15zm62 0c8.39 0 17 6.61 17 15s-8.61 15-17 15-15-6.61-15-15 6.61-15 15-15zm33 45c-15.002 0-27.775 10.206-31.729 24H73v18h95.271c3.954 13.794 16.727 24 31.729 24 15.002 0 27.775-10.206 31.729-24h206.277l-.092-18H231.73c-3.954-13.794-16.727-24-31.729-24zm0 18c8.39 0 15 6.61 15 15s-6.61 15-15 15-15-6.61-15-15 6.61-15 15-15zm83 47c-14.638 0-27.157 9.715-31.43 23H73v18h177.996c3.61 14.3 16.641 25 32.004 25 14.17 0 26.36-9.102 31-21.736C318.64 344.898 330.83 354 345 354c14.17 0 26.36-9.102 31-21.736C380.64 344.898 392.83 354 407 354c15.363 0 28.394-10.7 32.004-25 1.31-3.077.621-13.458-.77-18C432 294.406 418.467 288.286 407 288c-14.17 0-26.36 9.102-31 21.736C371.36 297.102 359.17 288 345 288c-14.17 0-26.36 9.102-31 21.736C309.36 297.102 297.17 288 283 288zm62 66c-13.892 0-25.874 8.752-30.71 21H73v18h239.564c2.853 15.29 16.366 27 32.436 27s29.583-11.71 32.436-27h61.209l-.09-18H375.71c-4.837-12.248-16.819-21-30.711-21zm-62-48c8.39 0 15 6.61 15 15s-6.61 15-15 15-15-6.61-15-15 6.61-15 15-15zm62 0c8.39 0 15 6.61 15 15s-6.61 15-15 15-15-6.61-15-15 6.61-15 15-15zm62 0c8.39 0 15 6.61 15 15s-6.61 15-15 15-15-6.61-15-15 6.61-15 15-15zm-62 66c8.39 0 15 6.61 15 15s-6.61 15-15 15-15-6.61-15-15 6.61-15 15-15zM25 473v16h462v-16z', + }, + 'two-coins': { + name:'two-coins', + shape:'M264.4 95.01c-35.6-.06-80.2 11.19-124.2 34.09C96.27 152 61.45 182 41.01 211.3c-20.45 29.2-25.98 56.4-15.92 75.8 10.07 19.3 35.53 30.4 71.22 30.4 35.69.1 80.29-11.2 124.19-34 44-22.9 78.8-53 99.2-82.2 20.5-29.2 25.9-56.4 15.9-75.8-10.1-19.3-35.5-30.49-71.2-30.49zm91.9 70.29c-3.5 15.3-11.1 31-21.8 46.3-22.6 32.3-59.5 63.8-105.7 87.8-46.2 24.1-93.1 36.2-132.5 36.2-18.6 0-35.84-2.8-50.37-8.7l10.59 20.4c10.08 19.4 35.47 30.5 71.18 30.5 35.7 0 80.3-11.2 124.2-34.1 44-22.8 78.8-52.9 99.2-82.2 20.4-29.2 26-56.4 15.9-75.7zm28.8 16.8c11.2 26.7 2.2 59.2-19.2 89.7-18.9 27.1-47.8 53.4-83.6 75.4 11.1 1.2 22.7 1.8 34.5 1.8 49.5 0 94.3-10.6 125.9-27.1 31.7-16.5 49.1-38.1 49.1-59.9 0-21.8-17.4-43.4-49.1-59.9-16.1-8.4-35.7-15.3-57.6-20zm106.7 124.8c-10.2 11.9-24.2 22.4-40.7 31-35 18.2-82.2 29.1-134.3 29.1-21.2 0-41.6-1.8-60.7-5.2-23.2 11.7-46.5 20.4-68.9 26.1 1.2.7 2.4 1.3 3.7 2 31.6 16.5 76.4 27.1 125.9 27.1s94.3-10.6 125.9-27.1c31.7-16.5 49.1-38.1 49.1-59.9z', + }, + 'cash': { + name: 'cash', + shape:'M251.813 20.5c-.78-.008-1.558.003-2.344.03-11.005.39-22.285 5.142-32.376 17.814l-5.156 6.468-7.063-4.343c-13.67-8.436-30.948-11.566-45.5-8.75-14.552 2.814-26.03 10.716-31.344 25.374l-3.624 9.968L115 62.22c-16.243-8.34-24.717-8.468-31.75-5.314-5.606 2.515-11.456 8.555-18.094 17.375L147.594 138c12.92 4.168 31.79 4.086 50.75-.813 18.95-4.895 37.863-14.44 51.625-27.406l31.124-76.905c-6.596-6.452-16.42-11.52-26.938-12.28-.778-.058-1.563-.087-2.344-.095zM265 121.28l-.594.595c-16.8 16.497-39.04 27.636-61.375 33.406-6.883 1.78-13.784 3.075-20.56 3.814-3.682 6.112-6.727 12.262-9.19 18.47l.532-.033c1.4 24.178 11.835 42.98 26.75 60.876l-14.343 11.97c-8.29-9.947-15.738-20.762-21.282-32.814-.92 23.227 4.222 47.218 12.78 72.22l-17.687 6.062c-15.615-45.618-20.942-92.383 1-136.375-7.386-.588-14.426-1.96-20.905-4.25l-.344-.126c-4.26 4.08-8.35 8.368-12.25 12.875-31.64 36.583-49.03 85.3-39.936 123.25 4.87 20.324 13.632 39.513 26.156 55.874 3.653-.298 7.256-.49 10.78-.53 11.585-.138 22.4 1.094 32.032 3.623 3.04.798 5.98 1.776 8.813 2.875 7.484-.797 15.245-1.218 23.22-1.218 28.474 0 54.303 5.297 73.843 14.47 7.586 3.56 14.44 7.848 20 12.81-.047-.742-.063-1.493-.063-2.25 0-4.568.85-8.905 2.438-13-8.938-8.382-14.532-18.546-14.532-30.187 0-16.12 10.75-29.346 26.22-39 .012-4.624.893-9.02 2.53-13.156-10.165-8.73-16.655-19.555-16.655-32.092 0-7.917 2.594-15.142 7.063-21.594-4.47-6.452-7.063-13.677-7.063-21.594 0-3.813.598-7.456 1.72-10.938-9.688-8.603-15.814-19.182-15.814-31.375 0-12.108 6.054-22.594 15.626-31.156-5.94-4.6-12.232-8.505-18.906-11.5zm111.438 2.345c-26.022 0-49.507 5.433-65.688 13.563-16.18 8.13-23.78 18.062-23.78 26.75 0 8.687 7.6 18.65 23.78 26.78 16.18 8.13 39.666 13.532 65.688 13.532 11.222 0 21.978-1.018 31.875-2.813v-17.03c13.862-2.068 25.41-5.9 32.812-10.782v17.563c.328-.16.678-.307 1-.47 16.18-8.13 23.813-18.093 23.813-26.78 0-8.687-7.632-18.62-23.813-26.75-16.18-8.13-39.666-13.563-65.688-13.563zm96.5 67.625c-3.334 3.582-7.283 6.86-11.657 9.844l.25 29.03c12.545-7.523 18.5-16.197 18.5-23.874 0-4.788-2.31-9.965-7.092-15zm-171.844 15.47c.265 8.576 7.887 18.325 23.78 26.31 16.182 8.13 39.667 13.532 65.688 13.532 16.316 0 31.636-2.13 44.782-5.718l.625-27.28c-17.166 6.025-37.58 9.374-59.533 9.374-28.558 0-54.474-5.69-74.062-15.532-.435-.218-.852-.464-1.28-.687zm1.97 34.81c-1.345 2.694-2.002 5.352-2.002 7.907 0 8.688 7.632 18.652 23.813 26.782 16.18 8.13 39.666 13.53 65.688 13.53 13.194 0 25.73-1.384 37-3.813v-24.062c-11.556 2.212-24.002 3.375-37 3.375-28.56 0-54.506-5.69-74.094-15.53-4.828-2.426-9.34-5.17-13.408-8.19zm174.967 0c-4.067 3.02-8.58 5.764-13.405 8.19-1.382.693-2.806 1.346-4.25 2V274c13.335-7.677 19.656-16.654 19.656-24.563 0-2.548-.662-5.218-2-7.906zm7.5 36.75c-2.03 2.028-4.236 3.956-6.624 5.783v32.468c10.314-7.004 15.25-14.77 15.25-21.75 0-5.266-2.816-10.994-8.625-16.5zm-170.124 14.064c-.13.817-.22 1.64-.22 2.437.002 8.69 7.633 18.62 23.814 26.75 16.18 8.13 39.666 13.564 65.688 13.564 14.953 0 29.064-1.775 41.437-4.844v-29.875c-16.304 5.196-35.265 8.063-55.563 8.063-28.558 0-54.505-5.69-74.093-15.532-.36-.18-.708-.378-1.064-.562zm-13.594 21.312c-8.665 6.538-12.843 13.626-12.843 20.03 0 8.69 7.63 18.653 23.81 26.783 16.182 8.13 39.667 13.53 65.69 13.53 9.54 0 18.72-.71 27.342-2.03v-18.19c-.377.003-.747 0-1.125 0-28.558 0-54.505-5.688-74.093-15.53-12.46-6.26-22.86-14.558-28.78-24.594zm162.532 30.688c-7.93 2.796-16.566 5.006-25.72 6.594V363c1.92-.813 3.78-1.65 5.532-2.53 9.82-4.935 16.47-10.537 20.188-16.126zM473.5 362.5c-3.77 3.77-8.21 7.184-13.125 10.25v28.688c13.335-7.678 19.656-16.655 19.656-24.563 0-4.59-2.138-9.537-6.53-14.375zm-348.72 2.813c-10.14.115-21.222 1.413-32.624 4.062-22.803 5.3-42.462 15.006-55.25 25.688-12.788 10.68-17.74 21.388-16.28 29.125 1.46 7.736 9.393 14.833 24.78 18.875 15.388 4.04 36.854 4.204 59.657-1.094 9.19-2.136 17.857-4.97 25.78-8.314V413.03c14.53-6.486 25.467-14.375 30.376-21.905V415.5c12.102-10.422 16.83-20.828 15.405-28.375-1.46-7.735-9.425-14.802-24.813-18.844-7.693-2.02-16.89-3.083-27.03-2.967zm64.657 5.218c2.71 3.895 4.61 8.28 5.532 13.158 1.128 5.983.634 11.85-1.126 17.53 9.822 2.56 18.812 6.073 26.656 10.47 4.39 2.46 8.47 5.268 12.125 8.343 9.022-2.163 16.573-5.152 21.938-8.686v20.53c16.183-7.61 23.5-16.89 23.5-24.312 0-7.43-7.334-16.726-23.563-24.343-16.054-7.537-39.295-12.58-65.063-12.69zm111.72 4.94c-.044.467-.094.944-.094 1.405 0 8.688 7.63 18.65 23.812 26.78 16.18 8.13 39.666 13.533 65.688 13.533 13.194 0 25.73-1.384 37-3.813V386.53c-14.77 4-31.43 6.19-49.094 6.19-28.56 0-54.507-5.72-74.095-15.564-1.086-.546-2.165-1.11-3.22-1.687zM304 412.81c-1.958 3.257-2.938 6.484-2.938 9.563 0 8.688 7.632 18.65 23.813 26.78 16.18 8.13 39.666 13.533 65.688 13.533 13.194 0 25.73-1.384 37-3.813V432.5c-11.556 2.212-24.002 3.375-37 3.375-28.56 0-54.506-5.69-74.094-15.53-4.47-2.246-8.643-4.777-12.47-7.533zm173.125 0c-3.832 2.762-8.025 5.283-12.5 7.532-1.382.694-2.806 1.347-4.25 2v24.594c13.335-7.678 19.656-16.655 19.656-24.563 0-3.077-.953-6.308-2.905-9.563zM184.5 418.22c-3.47 4.383-7.572 8.55-12.188 12.405-15.66 13.082-37.66 23.643-63 29.53-9.14 2.125-18.11 3.472-26.75 4.126 3.2 5.317 8.83 10.542 17.063 15.158 13.698 7.677 33.69 12.843 55.875 12.843 10.077 0 19.68-1.084 28.47-2.967v-20.844c13.858-2.068 25.41-5.903 32.81-10.783v18.407c10.023-6.95 14.845-14.89 14.845-22.375 0-8.723-6.552-18.043-20.25-25.72-7.35-4.12-16.532-7.518-26.875-9.78z', + }, + 'injustice': { + name: 'injustice', + shape: 'M403.438 23.08s-70.897 56.757-118.08 70.513c-47.182 13.756-70.642-15.469-70.642-15.469s14.65 34.485-19.828 69.494c-34.482 35.01-118.112 70.531-118.112 70.531l-2.366 13.93 6.452 8.121L29.36 376.606c-.6 1.101-.593 2.104-.593 3.313 0 18.897 8.252 34.243 20.343 44 12.09 9.758 27.564 14.31 42.938 14.312 15.376.003 30.877-4.555 42.969-14.312 12.092-9.756 20.343-25.094 20.343-44 .198-1.352-.192-2.316-.687-3.531L99.735 241.76c.059-1.373.239-2.845 1.551-6.002 20.336-15.642 69.497-51.446 106.305-61.696 18.947-5.273 35.577.53 35.015 6.936L215.87 369.577l21.406 30.31c-17.75 7.75-32.593 24.84-37.562 51.344-56.076 6.195-95.469 20.742-95.469 37.69H416.12c0-16.947-39.392-31.495-95.467-37.69-4.91-26.6-19.57-44.112-37.187-51.906l21-29.75-30.737-194.596c4.17-19.161 18.107-42.676 28.875-57.654 16.23-22.415 108.224-65.652 109.659-64.096l-54.938 134.627c-.495 1.216-.885 2.18-.687 3.532 0 18.906 8.251 34.244 20.343 44 12.092 9.757 27.595 14.315 42.971 14.312 15.374-.003 30.846-4.554 42.936-14.312 12.09-9.757 20.345-25.103 20.345-44 0-1.21.004-2.212-.595-3.313L430.796 50.763c.97-4.868 3.99-8.561 7.094-12.034l-11.833-14.786zm18.264 56.526l40.936 108.375h-85.155zM90.296 268.138l44.22 108.375H49.36z', + }, + 'weight': { + name: 'weight', + shape: 'M256 46c-45.074 0-82 36.926-82 82 0 25.812 12.123 48.936 30.938 64H128L32 480h448l-96-288h-76.938C325.877 176.936 338 153.812 338 128c0-45.074-36.926-82-82-82zm0 36c25.618 0 46 20.382 46 46s-20.382 46-46 46-46-20.382-46-46 20.382-46 46-46z', + }, +}); + +export default SVG_ICONS; diff --git a/app/imports/ui/components/CoinValue.vue b/app/imports/ui/components/CoinValue.vue new file mode 100644 index 00000000..e97a9b99 --- /dev/null +++ b/app/imports/ui/components/CoinValue.vue @@ -0,0 +1,40 @@ + + + + + diff --git a/app/imports/ui/components/IncrementButton.vue b/app/imports/ui/components/IncrementButton.vue new file mode 100644 index 00000000..608ecc08 --- /dev/null +++ b/app/imports/ui/components/IncrementButton.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/app/imports/ui/components/IncrementMenu.vue b/app/imports/ui/components/IncrementMenu.vue new file mode 100644 index 00000000..9d3caeb4 --- /dev/null +++ b/app/imports/ui/components/IncrementMenu.vue @@ -0,0 +1,166 @@ + + + + + diff --git a/app/imports/ui/components/propertyToolbar.vue b/app/imports/ui/components/propertyToolbar.vue index 49ab6876..c46a895a 100644 --- a/app/imports/ui/components/propertyToolbar.vue +++ b/app/imports/ui/components/propertyToolbar.vue @@ -9,7 +9,7 @@ class="mr-2" /> - {{ model.name || getPropertyName(model.type) }} + {{ title }} diff --git a/app/imports/ui/properties/components/attributes/HealthBar.vue b/app/imports/ui/properties/components/attributes/HealthBar.vue index 524f33ef..ae930b21 100644 --- a/app/imports/ui/properties/components/attributes/HealthBar.vue +++ b/app/imports/ui/properties/components/attributes/HealthBar.vue @@ -51,82 +51,31 @@ - + + +
- - - - add - - - remove - - - - - done - - - close - - - + class="page-tint" + @click="cancelEdit" + /> - -
- + +