Skip to content

Commit a737bab

Browse files
authored
Merge pull request #26 from League-of-Fabulous-Developers/dev
feat: setting up clocks for testing
2 parents 3d7e85f + c1b8538 commit a737bab

25 files changed

+454
-108
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Major thanks to the following contributors:
4545
A few assets/code were used from the following projects:
4646

4747
- **game-icons**: [game-icons.net](https://game-icons.net), various icons were used from here, licensed under the [CC-BY-3.0 license](https://creativecommons.org/licenses/by/3.0/)
48-
4948
- **fultimator**: [fultimator](https://github.com/codeclysm/fultimator) by codeclysm, specifically project/ritual/sp counter code, licensed under the [MIT License](https://github.com/codeclysm/fultimator/blob/main/LICENSE.md)
5049
- **animate.css**: [animate.css](https://animate.style/) by Daniel Eden, licensed under the [Hippocratic License](https://github.com/animate-css/animate.css/blob/main/LICENSE-HIPPOCRATIC).
5150
- **RPG-Awesome**: [RPG-Awesome](https://nagoshiashumari.github.io/Rpg-Awesome/) by Daniela Howe and Ivan Montiel, licensed under the [BSD 2-Clause "Simplified" License](https://github.com/NagoshiAshumari/Rpg-Awesome/blob/master/LICENSE).
51+
- [Savantford](https://github.com/Savantford), specifically for providing code for clocks and helping me set it up.

lang/en.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
"Timing": "Timing",
303303
"Action": "Action",
304304
"Actions": "Actions",
305+
"ActionAbbr": "ACT",
305306
"Reaction": "Reaction",
306307
"Free": "Free",
307308
"BeforeConflict": "Before Conflict Scene",
@@ -325,9 +326,9 @@
325326
"MainHand": "Main Hand",
326327
"OffHand": "Off Hand",
327328
"Twin": "Two Hands",
328-
"MainAbbr": "Main",
329-
"OffAbbr": "Off",
330-
"TwinAbbr": "Twin",
329+
"MainAbbr": "MAIN",
330+
"OffAbbr": "OFF",
331+
"TwinAbbr": "TWIN",
331332
"HRZero": "HR0",
332333
"HRZeroStatus": "HR0?",
333334
"hasCollateral": "Has Collateral Damage?",
@@ -450,6 +451,7 @@
450451
"Days": "Days",
451452
"Clock": "Clock",
452453
"Clocks": "Clocks",
454+
"ClockStatus": "Clock?",
453455
"Target": "Target",
454456
"Duration": "Duration",
455457
"Current": "Current",

lang/it.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"Discount": "Sconto",
7575
"Condition": "Condizione",
7676
"Stat": "Statistica",
77-
"Stats": "Statistiche",
77+
"Stats": "Stati",
7878
"Combattimento": "Combat",
7979
"Combattimenti": "Combat",
8080
"Class": "Classe",
@@ -105,7 +105,7 @@
105105
"Attributes": "Attributi",
106106
"AttributesKey": "Attributi Principali",
107107
"Equipped": "Equipaggiato",
108-
"EquipStatus": "Equipaggiato?",
108+
"EquipStatus": "Equip?",
109109
"EquipItem": "Equipaggia Oggetto",
110110
"UnequipItem": "Rimuovi Oggetto",
111111
"Favorite": "Preferito",
@@ -302,6 +302,7 @@
302302
"Timing": "Tempistica",
303303
"Action": "Azione",
304304
"Actions": "Azioni",
305+
"ActionAbbr": "AZI",
305306
"Reaction": "Reazione",
306307
"Free": "Gratuita",
307308
"BeforeConflict": "Prima della Scena di Conflitto",
@@ -325,9 +326,9 @@
325326
"MainHand": "Mano Principale",
326327
"OffHand": "Mano Secondaria",
327328
"Twin": "Mano Doppia",
328-
"MainAbbr": "Principale",
329-
"OffAbbr": "Secondaria",
330-
"TwinAbbr": "Doppia",
329+
"MainAbbr": "MAIN",
330+
"OffAbbr": "OFF",
331+
"TwinAbbr": "TWIN",
331332
"HRZero": "HR0",
332333
"HRZeroStatus": "HR0?",
333334
"HasCollateral": "Ha danni collaterali?",
@@ -450,6 +451,7 @@
450451
"Days": "Giorni",
451452
"Clock": "Orologio",
452453
"Clocks": "Orologi",
454+
"ClockStatus": "Orologio?",
453455
"Target": "Bersaglio",
454456
"Duration": "Durata",
455457
"Current": "Attua",

module/documents/item.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,11 @@ export class FUItem extends Item {
663663
return '';
664664
}
665665

666+
getClockString() {
667+
668+
669+
}
670+
666671
/**
667672
* Handle clickable rolls.
668673
* @param {Event} event The originating click event.

module/helpers/templates.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const preloadHandlebarsTemplates = async function () {
1717

1818
// Actor Component partials.
1919
'systems/fabulaultima/templates/actor/partials/actor-study.hbs',
20-
'systems/fabulaultima/templates/actor/partials/actor-actions.hbs',
2120
'systems/fabulaultima/templates/actor/partials/actor-affinities.hbs',
2221
'systems/fabulaultima/templates/actor/partials/actor-attributes.hbs',
2322
'systems/fabulaultima/templates/actor/partials/actor-defensive.hbs',
@@ -28,6 +27,7 @@ export const preloadHandlebarsTemplates = async function () {
2827

2928
'systems/fabulaultima/templates/actor/partials/actor-item-name.hbs',
3029
'systems/fabulaultima/templates/actor/partials/actor-actions.hbs',
30+
'systems/fabulaultima/templates/actor/partials/actor-clocks.hbs',
3131
'systems/fabulaultima/templates/actor/partials/actor-npc-items.hbs',
3232
'systems/fabulaultima/templates/actor/partials/actor-npc-skills.hbs',
3333
'systems/fabulaultima/templates/actor/partials/actor-favorite.hbs',
@@ -36,7 +36,9 @@ export const preloadHandlebarsTemplates = async function () {
3636
'systems/fabulaultima/templates/actor/partials/actor-divider.hbs',
3737
'systems/fabulaultima/templates/actor/partials/actor-equip.hbs',
3838
'systems/fabulaultima/templates/actor/partials/actor-control.hbs',
39-
39+
'systems/fabulaultima/templates/actor/partials/actor-progress-clock.hbs',
40+
'systems/fabulaultima/templates/actor/partials/actor-progress-clock-xl.hbs',
41+
4042
// Item partials
4143
'systems/fabulaultima/templates/item/partials/item-effects.hbs',
4244
'systems/fabulaultima/templates/item/partials/item-controls.hbs',

module/sheets/actor-standard-sheet.mjs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,28 @@ export class FUStandardActorSheet extends ActorSheet {
178178
i.progressStep = i.system.progress?.step;
179179
i.progressMax = i.system.progress?.max;
180180

181+
for (let i of context.items) {
182+
// Prepare progress clock array
183+
if (i.type === 'zeroPower' || i.type === 'ritual' || i.type === 'miscAbility' || i.type === 'rule') {
184+
const progressArr = [];
185+
186+
const progress = i.system.progress ? i.system.progress : { current: 0, max: 6 };
187+
188+
for (let i = 0; i < progress.max; i++) {
189+
progressArr.push({
190+
id: i + 1,
191+
checked: parseInt(progress.current) === i + 1 ? true : false,
192+
});
193+
}
194+
195+
if (progress.current === progress.max) {
196+
console.log("Clock is completed!")
197+
}
198+
199+
i.progressArr = progressArr.reverse();
200+
}
201+
}
202+
181203
if (['armor', 'shield', 'accessory'].includes(i.type)) {
182204
i.def = i.isMartial && i.type === 'armor' ? i.system.def.value : `+${i.system.def.value}`;
183205
i.mdef = `+${i.system.mdef.value}`;
@@ -352,6 +374,11 @@ export class FUStandardActorSheet extends ActorSheet {
352374
*
353375
*/
354376

377+
// Update Progress
378+
html.find('.progress input').click((ev) => this._onProgressUpdate(ev));
379+
380+
// Update Progress
381+
html.find('.progress input').contextmenu((ev) => this._onProgressReset(ev));
355382

356383
function handleItemClick(ev, isRightClick) {
357384
const li = $(ev.currentTarget).parents('.item');
@@ -956,6 +983,39 @@ export class FUStandardActorSheet extends ActorSheet {
956983
});
957984
}
958985

986+
// Set progress clock value to the segment clicked
987+
_onProgressUpdate(ev) {
988+
const input = ev.currentTarget;
989+
const segment = input.value;
990+
991+
const li = $(input).closest('.item');
992+
993+
if (li.length) {
994+
// If the clock is from an item
995+
const itemId = li.data('itemId');
996+
const item = this.actor.items.get(itemId);
997+
item.update({ 'system.progress.current': segment });
998+
} else {
999+
// If not from an item
1000+
this.actor.update({ 'system.progress.current': segment });
1001+
}
1002+
}
1003+
1004+
// Reset Progress Clock
1005+
_onProgressReset(ev) {
1006+
const input = ev.currentTarget;
1007+
const li = $(input).closest('.item');
1008+
if (li.length) {
1009+
// If the clock is from an item
1010+
const itemId = li.data('itemId');
1011+
const item = this.actor.items.get(itemId);
1012+
item.update({ 'system.progress.current': 0 });
1013+
} else {
1014+
// If not from an item
1015+
this.actor.update({ 'system.progress.current': 0 });
1016+
}
1017+
}
1018+
9591019
/**
9601020
* Handles clickable rolls based on different roll types.
9611021
* @param {Event} event The originating click event

styles/css/fabulaultima.css

Lines changed: 99 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
.progress {
2+
--size: 50px;
3+
--border-width: 2px;
4+
width: var(--size);
5+
height: var(--size);
6+
position: relative;
7+
}
8+
9+
.progress[data-segments="2"] .pie { clip-path: polygon(50% -25%, 50% 125%, 120% 50%); }
10+
.progress[data-segments="3"] .pie { clip-path: polygon(50% -50%, 50% 50%, 140% 100%); }
11+
.progress[data-segments="4"] .pie { clip-path: polygon(50% -25%, 50% 50%, 120% 50%); }
12+
.progress[data-segments="6"] .pie { clip-path: polygon(50% -10%, 50% 50%, 100% 20%); }
13+
.progress[data-segments="8"] .pie { clip-path: polygon(50% 0, 50% 50%, 100% 0); }
14+
.progress[data-segments="10"] .pie { clip-path: polygon(50% 0, 50% 50%, 85% 0); }
15+
.progress[data-segments="12"] .pie { clip-path: polygon(50% 0, 50% 50%, 80% 0); }
16+
17+
.progress .foreground {
18+
pointer-events: none;
19+
position: absolute;
20+
width: var(--size);
21+
height: var(--size);
22+
border-radius: 50%;
23+
border: var(--border-width) solid $color-secondary;
24+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
25+
z-index: 2;
26+
}
27+
28+
.progress .divider {
29+
pointer-events: none;
30+
position: absolute;
31+
width: var(--border-width);
32+
height: calc(50% - .5 * var(--border-width));
33+
top: calc(.5 * var(--border-width));
34+
right: calc(50% - var(--border-width) / 2);
35+
background: $color-ternary;
36+
transform-origin: center bottom;
37+
transform: rotate(calc((var(--index) * 1turn) / var(--segments)));
38+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
39+
z-index: 2;
40+
}
41+
42+
.progress input[type="radio"].pie {
43+
position: absolute;
44+
top: 0;
45+
margin: 0;
46+
appearance: none;
47+
width: var(--size);
48+
height: var(--size);
49+
border-radius: 50%;
50+
transform: rotate(calc(((var(--index) - 1) * 1turn) / var(--segments)));
51+
z-index: 1;
52+
}
53+
54+
.progress .pie:hover {
55+
cursor: pointer;
56+
}
57+
58+
.progress .pie:checked,
59+
.progress .pie:checked ~ .pie {
60+
background-color: $color-secondary;
61+
}
62+
63+
.progress .pie:hover,
64+
.progress .pie:hover ~ .pie {
65+
background-color: $color-secondary-inverted;
66+
}
67+
68+
.progress .pie:checked:hover,
69+
.progress .pie:checked:hover ~ .pie,
70+
.progress .pie:checked ~ .pie:hover,
71+
.progress .pie:checked ~ .pie:hover ~ .pie,
72+
.progress .pie:hover ~ .pie:checked,
73+
.progress .pie:hover ~ .pie:checked ~ .pie {
74+
background-color: $color-secondary;
75+
}
76+

styles/scss/fabulaultima.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
@import "components/affinity";
2323
@import "components/barmeter";
2424
@import "components/buttons";
25+
@import "components/clocks";
2526
@import "components/divider";
2627
@import "components/effects";
2728
@import "components/forms";

template.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@
8989
"mdef": { "value": 0 },
9090
"init": { "value": 0 }
9191
},
92-
"hasProgress": { "progress": { "current": 0, "step": 1, "max": 6 } },
92+
"hasProgress": {
93+
"hasClock": { "value": false },
94+
"progress": { "current": 0, "step": 1, "max": 6 } },
9395
"hasBehavior": { "isBehavior": false, "weight": { "value": 1 } },
9496
"hasLevel": { "level": { "value": 1, "max": 10, "min": 0 } },
9597
"hasClass": { "class": { "value": "" } },
@@ -208,7 +210,7 @@
208210
"templates": ["base", "equippable", "rollInfo", "hasBehavior", "hasProgress"]
209211
},
210212
"rule": {
211-
"templates": ["base", "hasBehavior"]
213+
"templates": ["base", "hasBehavior", "hasProgress"]
212214
},
213215
"behavior": {
214216
"templates": ["base"],

0 commit comments

Comments
 (0)