Skip to content

Commit 85b3e4d

Browse files
authored
Merge pull request #114 from Cussa/master
✨ Player and Headquarter changelog + Starting Equipment configuration
2 parents 930255a + 2c8e85b commit 85b3e4d

16 files changed

+286
-20
lines changed

Diff for: README.md

+10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ This system provides character sheets and items for your play, if you would lik
3131
## Release Notes
3232
=======
3333

34+
v4.5.0
35+
- ✨ Add changelog for Players and Headerquater by @Cussa in https://github.com/fvtt-fria-ligan/vaesen-foundry-vtt/pull/114
36+
- ✨ Separate Starting Equipment from the normal ones by @Cussa in https://github.com/fvtt-fria-ligan/vaesen-foundry-vtt/pull/114
37+
38+
v4.4.1
39+
- Update german localization by @Tarubain in https://github.com/fvtt-fria-ligan/vaesen-foundry-vtt/pull/107
40+
- Update README.md by @sanderdatema in https://github.com/fvtt-fria-ligan/vaesen-foundry-vtt/pull/108
41+
- Update README.md by @Cussa in https://github.com/fvtt-fria-ligan/vaesen-foundry-vtt/pull/109
42+
- 🐛 Allow NPCs to have some statuses by @Cussa in https://github.com/fvtt-fria-ligan/vaesen-foundry-vtt/pull/111
43+
3444
v4.4.0
3545
- ✨ link archetypes, talents and items in Chargen to their journal pages and items
3646
![Chargen improvements](asset/chargen_links.png?raw=true)

Diff for: lang/en.json

+18-2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"HEADER.CRITICAL_INJURIES": "CRITICAL INJURIES",
124124
"HEADER.WEAPONS": "WEAPONS",
125125
"HEADER.TALENTS": "TALENTS",
126+
"HEADER.STARTING_GEAR": "STARTING GEAR",
126127
"HEADER.GEAR": "GEAR",
127128
"HEADER.INFORMATION": "INFORMATION",
128129
"HEADER.MAGIC": "MAGIC",
@@ -164,6 +165,7 @@
164165
"TAB.GEAR": "GEAR",
165166
"TAB.NOTE": "NOTE",
166167
"TAB.NOTES": "NOTES",
168+
"TAB.LOG" : "LOG",
167169
"TAB.HISTORY": "HISTORY",
168170
"TAB.FACILITY": "FACILITY",
169171
"TAB.CONTACT": "CONTACT",
@@ -197,6 +199,8 @@
197199
"WEAPON.BONUS": "Bonus",
198200
"WEAPON.AVAILABILITY": "Availability",
199201
"WEAPON.SKILL": "Skill",
202+
"WEAPON.STARTING": "SE",
203+
"WEAPON.STARTING_TOOLTIP": "Starting Equipment",
200204

201205
"UI.FAVORITE" : "Toggle Favorite",
202206
"UI.EDIT" : "Edit",
@@ -267,8 +271,20 @@
267271
"GENERATOR.APPLIED": "APPLIED",
268272
"GENERATOR.DISCARDED": "DISCARDED",
269273
"GENERATOR.REROLL": "Reroll",
270-
"GENERATOR.LIFE": "LIfe Path",
274+
"GENERATOR.LIFE": "Life Path",
271275

272276
"HEADQUARTER.MEMBER_RANKING": "MEMBER RANKINGS",
273-
"HEADQUARTER.MEMBER_RANKING_EXPLANATION": "When determining who is best suited for a particular attribute or skill roll, this allows you to take a non-meta-gaming approach. Rather than relying on specific numbers, you consider who is the most skilled in that area. For skills, this is determined by the combined value of the relevant attribute and the skill itself. If multiple characters are listed, it means they roll the same number of dice for that task."
277+
"HEADQUARTER.MEMBER_RANKING_EXPLANATION": "When determining who is best suited for a particular attribute or skill roll, this allows you to take a non-meta-gaming approach. Rather than relying on specific numbers, you consider who is the most skilled in that area. For skills, this is determined by the combined value of the relevant attribute and the skill itself. If multiple characters are listed, it means they roll the same number of dice for that task.",
278+
279+
"CHANGELOG.HEADER": "CHANGELOG",
280+
"CHANGELOG.WHAT": "What",
281+
"CHANGELOG.TYPE": "Type",
282+
"CHANGELOG.CHANGE": "Change",
283+
"CHANGELOG.BY": "By",
284+
"CHANGELOG.WHEN": "When",
285+
"CHANGELOG.ADDED": "added",
286+
"CHANGELOG.REMOVED": "removed",
287+
288+
"STARTING_EQUIP.TITLE": "Delete Starting Equipment?",
289+
"STARTING_EQUIP.CONTENT": "This is a equipment that is marked as part of the Starting Equipment for this actor. Are you sure you want to delete it?"
274290
}

Diff for: model/headquarter.hbs

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<b class="item" data-tab="upgrades">{{localize "TAB.UPGRADES"}}</b>
4141
<b class="item" data-tab="history">{{localize "TAB.NOTES"}}</b>
4242
<b class="item" data-tab="members">{{localize "TAB.MEMBERS"}}</b>
43+
<b class="item" data-tab="changelog">{{localize "TAB.LOG"}}</b>
4344
</div>
4445

4546
<div class="sheet-body flex row">
@@ -52,6 +53,9 @@
5253
<div class="tab members" data-group="primary" data-tab="members">
5354
{{> systems/vaesen/model/tab/headquarter-members.hbs}}
5455
</div>
56+
<div class="tab changelog" data-group="primary" data-tab="changelog">
57+
{{> systems/vaesen/model/tab/changelog.hbs}}
58+
</div>
5559
</div>
5660
</div>
5761
</div>

Diff for: model/player.hbs

+4
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
<b class="item" data-tab="talent">{{localize "TAB.TALENT"}}</b>
107107
<b class="item" data-tab="gear">{{localize "TAB.GEAR"}}</b>
108108
<b class="item" data-tab="note">{{localize "TAB.NOTE"}}</b>
109+
<b class="item" data-tab="changelog">{{localize "TAB.LOG"}}</b>
109110
</div>
110111
111112
<div class="sheet-body flex row">
@@ -123,6 +124,9 @@
123124
</div>
124125
<div class="tab note" data-group="primary" data-tab="note">
125126
{{> systems/vaesen/model/tab/player-note.hbs}}
127+
</div>
128+
<div class="tab changelog" data-group="primary" data-tab="changelog">
129+
{{> systems/vaesen/model/tab/changelog.hbs}}
126130
</div>
127131
</div>
128132
</div>

Diff for: model/tab/changelog.hbs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div class="flex column full">
2+
<div class="flex column heavy-border wrapper" style="width: 99%;">
3+
<b class="title" style="width: 85%; margin: auto;">{{localize "CHANGELOG.HEADER"}}</b>
4+
<div class="changelog flex column margin grow">
5+
<div class="changelogTable grid grid-4col-fr center light-border w-100">
6+
<b class="column">{{localize "CHANGELOG.WHAT"}}</b>
7+
<b class="column">{{localize "CHANGELOG.CHANGE"}}</b>
8+
<b class="column">{{localize "CHANGELOG.BY"}}</b>
9+
<b class="column">{{localize "CHANGELOG.WHEN"}}</b>
10+
</div>
11+
<div class="scrollable">
12+
{{#each system.changelog as |item|}}
13+
<div class="changelogTable item grid grid-4col-fr center align-center w-100" data-item-id="{{item._id}}">
14+
<div class="column">{{item.name}}</div>
15+
<div class="column">{{{item.change}}}</div>
16+
<div class="column">{{{item.by}}}</div>
17+
<div class="column">{{{item.at}}}</div>
18+
</div>
19+
{{/each}}
20+
</div>
21+
</div>
22+
</div>
23+
</div>

Diff for: model/tab/player-combat.hbs

+4-2
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,27 @@
3737
<div class="flex column heavy-border wrapper" style="width: 99%;">
3838
<b class="title" style="width: 85%; margin: auto;">{{localize "HEADER.WEAPONS"}}</b>
3939
<div class="weapons flex column margin grow">
40-
<div class="weapon grid grid-6col-fr gap center light-border w-100">
40+
<div class="weapon flex grid-7col-fr gap center light-border w-100">
4141
<b class="icon">{{localize "WEAPON.ICON"}}</b>
4242
<b class="name">{{localize "WEAPON.NAME"}}</b>
4343
<b class="damage">{{localize "WEAPON.DAMAGE"}}</b>
4444
<b class="range">{{localize "WEAPON.RANGE"}}</b>
4545
<b class="bonus">{{localize "WEAPON.BONUS"}}</b>
46+
<b class="starting" title="{{localize "WEAPON.STARTING_TOOLTIP"}}">{{localize "WEAPON.STARTING"}}</b>
4647
<a class="button item-create" title='{{localize "UI.ADD"}}' data-type="weapon"><i class="fas fa-plus"></i></a>
4748
</div>
4849
<div class="scrollable">
4950
{{#each items as |item|}}
5051
{{#if item.isWeapon}}
5152
<div class="weapon item flex row center align-center" data-item-id="{{item._id}}">
5253

53-
<div class="icon-box"><img class="icon" src="{{item.img}}" title="{{item.name}}" width="25px" height="auto"/></div>
54+
<div class="icon"><img class="icon" src="{{item.img}}" title="{{item.name}}" width="25px" height="auto"/></div>
5455

5556
<div class="name">{{item.name}}</div>
5657
<div class="damage">{{item.system.damage}}</div>
5758
<div class="range">{{item.system.range}}</div>
5859
<div class="bonus">{{item.system.bonus}}</div>
60+
<div class="starting"><i class="fa {{item.cssClass}}"></i></div>
5961
<div class="button">
6062
{{#unless item.system.isFav}}
6163
<a class="item-control fav-togle" title='{{localize "UI.FAVORITE"}}'><i class="far fa-star" data-field="isFav" data-isFav="true"></i></a>

Diff for: model/tab/player-gear.hbs

+34-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
11
<div class="flex column full">
2+
<div class="flex column heavy-border wrapper" style="width: 99%;">
3+
<b class="title" style="width: 85%; margin: auto;">{{localize "HEADER.STARTING_GEAR"}} <i class="fa {{system.startingEquipClass}} starting-equip-toggle"></i></b>
4+
<div class="gears flex column margin grow">
5+
<div class="gear grid grid-5col-fr center light-border w-100">
6+
<b class="icon">{{localize "GEAR.ICON"}}</b>
7+
<b class="name">{{localize "GEAR.NAME"}}</b>
8+
<b class="bonus">{{localize "GEAR.BONUS"}}</b>
9+
<b class="effect">{{localize "GEAR.EFFECT"}}</b>
10+
<a class="button item-create" title='{{localize "UI.ADD"}}' data-type="gear" data-starting="true"><i class="fas fa-plus"></i></a>
11+
</div>
12+
<div class="scrollable">
13+
{{#each items as |item|}}
14+
{{#if item.isGear}}
15+
{{#if item.system.starting}}
16+
<div class="gear item grid grid-5col-fr center align-center w-100" data-item-id="{{item._id}}">
17+
<div class="icon"><img class="icon" src="{{item.img}}" title="{{item.name}}" height="50" width="50"/></div>
18+
<div class="name">{{item.name}}</div>
19+
<div class="bonus">{{item.system.bonus}}</div>
20+
<div class="effect">{{{item.system.effect}}}</div>
21+
<div class="button">
22+
<a class="item-control to-chat" title='{{localize UI.CHAT}}'><i class="fas fa-comment"></i></a>
23+
<a class="item-control item-edit" title='{{localize "UI.EDIT"}}'><i class="fas fa-edit"></i></a>
24+
<a class="item-control item-delete" title='{{localize "UI.DELETE"}}'><i class="fas fa-trash"></i></a>
25+
</div>
26+
</div>
27+
{{/if}}
28+
{{/if}}
29+
{{/each}}
30+
</div>
31+
</div>
32+
</div>
233
<div class="flex column heavy-border wrapper" style="width: 99%;">
334
<b class="title" style="width: 85%; margin: auto;">{{localize "HEADER.GEAR"}}</b>
435
<div class="gears flex column margin grow">
@@ -7,11 +38,12 @@
738
<b class="name">{{localize "GEAR.NAME"}}</b>
839
<b class="bonus">{{localize "GEAR.BONUS"}}</b>
940
<b class="effect">{{localize "GEAR.EFFECT"}}</b>
10-
<a class="button item-create" title='{{localize "UI.ADD"}}' data-type="gear"><i class="fas fa-plus"></i></a>
41+
<a class="button item-create" title='{{localize "UI.ADD"}}' data-type="gear" data-starting=""><i class="fas fa-plus"></i></a>
1142
</div>
1243
<div class="scrollable">
1344
{{#each items as |item|}}
1445
{{#if item.isGear}}
46+
{{#unless item.system.starting}}
1547
<div class="gear item grid grid-5col-fr center align-center w-100" data-item-id="{{item._id}}">
1648
<div class="icon"><img class="icon" src="{{item.img}}" title="{{item.name}}" height="50" width="50"/></div>
1749
<div class="name">{{item.name}}</div>
@@ -23,6 +55,7 @@
2355
<a class="item-control item-delete" title='{{localize "UI.DELETE"}}'><i class="fas fa-trash"></i></a>
2456
</div>
2557
</div>
58+
{{/unless}}
2659
{{/if}}
2760
{{/each}}
2861
</div>

Diff for: script/actor/vaesen-actor-sheet.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,23 @@ export class VaesenActorSheet extends ActorSheet {
271271

272272
onItemDelete(event) {
273273
const div = $(event.currentTarget).parents(".item");
274-
this.actor.deleteEmbeddedDocuments("Item", [div.data("itemId")]);
274+
let item = this.actor.items.get(div.data("itemId"));
275+
276+
if (!item.system.starting) {
277+
this.onItemDeleteAction(div, item.id);
278+
return;
279+
}
280+
281+
Dialog.confirm({
282+
title: game.i18n.localize("STARTING_EQUIP.TITLE"),
283+
content: game.i18n.localize("STARTING_EQUIP.CONTENT"),
284+
yes: () => this.onItemDeleteAction(div, item.id),
285+
defaultYes: false
286+
});
287+
}
288+
289+
onItemDeleteAction(div, item){
290+
this.actor.deleteEmbeddedDocuments("Item", [item]);
275291
div.slideUp(200, () => this.render(false));
276292
}
277293

Diff for: script/actor/vaesen.js

+85
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,95 @@ export class VaesenActor extends Actor {
102102
"prototypeToken.sight.range": "30",
103103
"prototypeToken.bar1.attribute": bar1,
104104
"prototypeToken.bar2.attribute": bar2,
105+
"system.starting": true
105106
};
106107
var headquarters = game.actors.contents.filter(x => x.type === "headquarter");
107108
if (headquarters.length === 1)
108109
actorDefaults["system.headquarter"] = headquarters[0].id;
109110
this.updateSource(actorDefaults);
110111
}
112+
113+
async _preUpdate(changed, options, user) {
114+
const actor = this;
115+
if (actor.type != "player" && actor.type != "headquarter")
116+
return true;
117+
118+
const flattenChanges = flattenObject(changed);
119+
const changedText = game.i18n.localize("CHANGELOG.CHANGED");
120+
const toText = game.i18n.localize("CHANGELOG.TO");
121+
const byText = game.i18n.localize("CHANGELOG.BY");
122+
const atText = game.i18n.localize("CHANGELOG.AT");
123+
const dateChanged = new Date().toLocaleString();
124+
125+
let changelogArray = actor.system.changelog ?? [];
126+
127+
Object.keys(flattenChanges).forEach(current => {
128+
if (current == "_id" || current.startsWith("flags"))
129+
return;
130+
131+
if (current == "system.changelog")
132+
{
133+
changelogArray = current.split('.').reduce((p, c) => p && p[c] || null, changed);
134+
return;
135+
}
136+
137+
const originalValue = current.split('.').reduce((p, c) => p && p[c] || null, actor) ?? 0;
138+
const newValue = current.split('.').reduce((p, c) => p && p[c] || null, changed) ?? 0;
139+
const itemChanged = game.i18n.localize(current
140+
.replace("system.", "").replace(".value", "").toUpperCase()
141+
.replace("COMBAT", "_COMBAT")
142+
.replace("POINT", "POINTS")
143+
.replace("DARKSECRET", "DARK_SECRET"));
144+
145+
if (originalValue == newValue)
146+
return;
147+
148+
const log = {
149+
name: itemChanged,
150+
change: `${originalValue} => ${newValue}`,
151+
by: user.name,
152+
at: dateChanged
153+
};
154+
changelogArray.push(log);
155+
});
156+
157+
foundry.utils.setProperty(changed, "system.changelog", changelogArray);
158+
159+
super._preUpdate(changed,options,user);
160+
}
161+
162+
async _handleItem(document, userId, textType){
163+
const byText = game.i18n.localize("CHANGELOG.BY");
164+
const atText = game.i18n.localize("CHANGELOG.AT");
165+
const dateChanged = new Date().toLocaleString();
166+
const userName = game.users.get(userId)?.name;
167+
let changelogArray = this.system.changelog;
168+
169+
const log = {
170+
name: document.name,
171+
change: `${document.type} ${textType}`,
172+
by: userName,
173+
at: dateChanged
174+
};
175+
176+
changelogArray.push(log);
177+
178+
await this.update({"system.changelog": changelogArray});
179+
}
180+
181+
async _onCreateDescendantDocuments(parent, collection, documents, data, options, userId) {
182+
183+
const addedText = game.i18n.localize("CHANGELOG.ADDED");
184+
await this._handleItem(documents[0], userId, addedText);
185+
186+
super._onCreateDescendantDocuments(parent, collection, documents, data, options, userId);
187+
}
188+
189+
async _onDeleteDescendantDocuments(parent, collection, documents, data, options, userId) {
190+
191+
const removedText = game.i18n.localize("CHANGELOG.REMOVED");
192+
await this._handleItem(documents[0], userId, removedText);
193+
194+
super._onCreateDescendantDocuments(parent, collection, documents, data, options, userId);
195+
}
111196
}

Diff for: script/hooks.js

+1
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ function preloadHandlebarsTemplates() {
282282
"systems/vaesen/model/items/condition.hbs",
283283
"systems/vaesen/model/items/attack.hbs",
284284
"systems/vaesen/model/items/relationship.hbs",
285+
"systems/vaesen/model/tab/changelog.hbs",
285286
];
286287
return loadTemplates(templatePaths);
287288
}

0 commit comments

Comments
 (0)