Skip to content

Commit

Permalink
0.11: Weapon Properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Savantford committed Aug 23, 2023
1 parent 7204409 commit daa57df
Show file tree
Hide file tree
Showing 21 changed files with 91 additions and 46 deletions.
18 changes: 16 additions & 2 deletions module/documents/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ export class WeirdWizardActor extends Actor {
this.system.stats.speed.raw = this.system.stats.speed.value;

// Reset Natural Defense and Defense before Active Effects
this.system.stats.defense.natural = 10;
this.system.stats.defense.total = 0;

if (this.type == 'Character') {
this.system.stats.defense.natural = 10;
this.system.stats.defense.total = 0;
}

}

async _preCreate(data, options, user) {
Expand Down Expand Up @@ -112,6 +116,16 @@ export class WeirdWizardActor extends Actor {
for (let [key, attribute] of Object.entries(system.attributes)) {
if (key != 'luck') attribute.mod = attribute.value - 10;
}

// Create .statuses manually for v10
if (this.statuses == undefined) {
this.statuses = this.effects.reduce((acc, eff) => {
if(!eff.modifiesActor) return acc;
const status = eff.flags.core?.statusId;
if(status) acc.add(status);
return acc;
}, new Set());
}

// Make separate methods for each Actor type (character, npc, etc.) to keep
// things organized.
Expand Down
28 changes: 28 additions & 0 deletions module/documents/item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* @extends {Item}
*/

import { capitalize, i18n } from '../helpers/utils.mjs';

export class WeirdWizardItem extends Item {
/**
* Augment the basic Item data model with additional dynamic data.
Expand All @@ -14,6 +16,32 @@ export class WeirdWizardItem extends Item {
// Get the Item's data
const system = this.system;
const actorData = this.actor ? this.actor.system : {};

// Prepare properties list for weapons
if (system.subtype == 'weapon') {
let properties = system.properties;

// Compatibility: Convert old string data to object
if (typeof properties == 'string') properties = {};

let list = '';

//console.log(Object.entries(properties))
Object.entries(properties).map((x) => {

if (x[1]) list = list.concat(
list ?
', ' + i18n('WW.Properties.' + capitalize(x[0]) + '.Label') :
i18n('WW.Properties.' + capitalize(x[0]) + '.Label')

)

})

this.system.propertiesList = list;

console.log(this.system)
}

}

Expand Down
6 changes: 2 additions & 4 deletions module/helpers/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ export function getEffectBoons (attribute) {
}

// Formatting

//export const i18n = (s,d) => d ? game.i18n.format(s,d) : game.i18n.format(s)
export const i18n = (s,d={}) => game.i18n.format(s,d);

/*export function capitalize(string) {
export function capitalize(string) {
return string?.charAt(0).toUpperCase() + string?.toLowerCase().slice(1)
}*/
}

export function plusify(x) {
return x >= 0 ? '+' + x : x
Expand Down
2 changes: 2 additions & 0 deletions module/sheets/actor-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export class WeirdWizardActorSheet extends ActorSheet {
CONFIG.statusEffects.forEach(function (e) {
context.hasEffect[e.id] = actorData.statuses.has(e.id);
})
console.log(actorData.statuses)
console.log(actorData.effects)

// Prepare character data and items.
if (actorData.type == 'Character') {
Expand Down
19 changes: 1 addition & 18 deletions module/sheets/item-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,9 @@ export class WeirdWizardItemSheet extends ItemSheet {
//context.frequenciesObj = CONFIG.WW.dropdownFrequencies;
context.armorObj = CONFIG.WW.armorTypes;

// Prepare properties list for weapons
if (context.system.subtype == 'weapon') {
context.gripObj = CONFIG.WW.weaponGrip;
context.properties = CONFIG.WW.weaponProperties;

let itemData = this.object.system;
let properties = itemData.properties;
if (typeof properties == 'string') properties = {};

if (properties) {
console.log(properties)
/*properties.map(function (e) {
//context.hasEffect[e.id] = actorData.statuses.has(e.id);
})*/
}
/*forEach(x => {
//if (x) system.propertiesList.push(key)
})*/

//console.log(system.propertiesList)
}

break;
Expand Down Expand Up @@ -104,7 +87,7 @@ export class WeirdWizardItemSheet extends ItemSheet {

// Prepare effect change key-labels
context.effectChangeKeys = CONFIG.WW.effectChangeKeys;

return context;
}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packs/armor/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000043
MANIFEST-000045
6 changes: 3 additions & 3 deletions packs/armor/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2023/08/23-00:26:57.604 4e98 Recovering log #42
2023/08/23-00:26:57.610 4e98 Delete type=0 #42
2023/08/23-00:26:57.610 4e98 Delete type=3 #41
2023/08/23-13:45:03.178 2914 Recovering log #44
2023/08/23-13:45:03.186 2914 Delete type=0 #44
2023/08/23-13:45:03.186 2914 Delete type=3 #43
6 changes: 3 additions & 3 deletions packs/armor/LOG.old
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2023/08/23-00:01:58.822 1b5c Recovering log #40
2023/08/23-00:01:58.828 1b5c Delete type=0 #40
2023/08/23-00:01:58.828 1b5c Delete type=3 #39
2023/08/23-00:26:57.604 4e98 Recovering log #42
2023/08/23-00:26:57.610 4e98 Delete type=0 #42
2023/08/23-00:26:57.610 4e98 Delete type=3 #41
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion packs/weapons/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000043
MANIFEST-000045
6 changes: 3 additions & 3 deletions packs/weapons/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2023/08/23-00:26:57.604 c9c Recovering log #42
2023/08/23-00:26:57.610 c9c Delete type=0 #42
2023/08/23-00:26:57.610 c9c Delete type=3 #41
2023/08/23-13:45:03.180 b28 Recovering log #44
2023/08/23-13:45:03.186 b28 Delete type=0 #44
2023/08/23-13:45:03.186 b28 Delete type=3 #43
6 changes: 3 additions & 3 deletions packs/weapons/LOG.old
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2023/08/23-00:01:58.822 21ec Recovering log #40
2023/08/23-00:01:58.828 21ec Delete type=0 #40
2023/08/23-00:01:58.828 21ec Delete type=3 #39
2023/08/23-00:26:57.604 c9c Recovering log #42
2023/08/23-00:26:57.610 c9c Delete type=0 #42
2023/08/23-00:26:57.610 c9c Delete type=3 #41
Binary file not shown.
15 changes: 15 additions & 0 deletions styles/weirdwizard.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion templates/actors/parts/Character-equipment.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</label>
<div class="item-fixed damage-roll"><a>{{item.system.damage}}</a></div>
<div class="item-fixed">{{item.system.grip}}</div>
<div class="item-properties">{{item.system.properties}}</div>
<div class="item-properties">{{item.system.propertiesList}}</div>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
Expand Down
4 changes: 2 additions & 2 deletions templates/actors/parts/Character-summary.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@
{{#if item.system.description.value}}<a class="item-scroll" data-tooltip="{{item.system.description.value}}"><i class="far fa-scroll"></i></a>{{/if}}
<a class="damage-roll" title="Roll Damage Dice"><i class="fas fa-burst"></i></a>
{{#if item.system.reload}}<input class="checkbox-reloaded" type="checkbox" name="item.system.reloaded" title="Weapon realoded?" {{checked item.system.reloaded}}/>{{/if}}
({{item.system.grip}}{{#if item.system.properties}};
{{item.system.properties}}{{/if}})
({{item.system.grip}}{{#if item.system.propertiesList}};
{{item.system.propertiesList}}{{/if}})

{{item.system.attributeLabel}}
{{#if item.system.boons}} {{localize "WW.Boons.With"}} {{item.system.boons}}
Expand Down
4 changes: 2 additions & 2 deletions templates/actors/parts/NPC-stats.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

<div class="mb-2">
<div class="mt-2 flex-row stat-inline flex-group-left">{{!-- Defense --}}
<label>{{localize "WW.Defense"}}</label>
<label>{{localize "WW.Defense.Title"}}</label>
<input class="mr-1" type="number" name="system.stats.defense.total"
value="{{system.stats.defense.total}}" min="0" data-dtype="Number" />
<input type="text" name="system.stats.defense.details" value="{{system.stats.defense.details}}"
data-dtype="String" placeholder="{{localize "WW.DefenseDetails"}}" />
data-dtype="String" placeholder="{{localize "WW.Defense.Details"}}" />
</div>
<div class="flex-row stat-inline flex-group-left">{{!-- Damage / Health --}}
<label>{{localize "WW.Health.Title"}}</label>
Expand Down
2 changes: 1 addition & 1 deletion templates/actors/parts/NPC-summary.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<a class="damage-roll" title="Roll Damage Dice"><i class="fas fa-burst"></i></a>
{{#if item.system.reload}}<input class="checkbox-reloaded" type="checkbox" name="item.system.reloaded" title="Weapon realoded?" {{checked item.system.reloaded}}/>{{/if}}

{{#if item.system.properties}}({{item.system.properties}}) {{/if}}
{{#if item.system.propertiesList}}({{item.system.propertiesList}}) {{/if}}

{{item.system.attributeLabel}}
{{#if item.system.boons}} {{localize "WW.Boons.With"}} {{item.system.boons}}
Expand Down
9 changes: 7 additions & 2 deletions templates/items/item-Equipment-sheet.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,14 @@
</div>

{{!-- Weapon Properties --}}
<div class="flexrow flex-wrap justify-between mt-2" style="gap: 5px">
<div class="mt-2">
<label>{{localize "WW.Properties.Title"}}</label>
{{system.propertiesList}}
</div>

<div class="flexrow properties-list">
{{#each properties as |property id|}}
<div class="nowrap flex-row align-center stat selectable {{#if (lookup @root.system.properties id)}}selected{{/if}}" style="width: 100%" title="{{localize property.tip}}">
<div class="nowrap flex-row align-center stat smaller selectable {{#if (lookup @root.system.properties id)}}selected{{/if}}" style="width: 100%" title="{{localize property.tip}}">

<input type="checkbox" name="system.properties.{{id}}" {{checked (lookup @root.system.properties id)}}/>

Expand Down

0 comments on commit daa57df

Please sign in to comment.