Skip to content

Commit 61abf29

Browse files
authored
Merge pull request #102 from Cussa/master
Roll d66, small fix and automatically reports to Foundry when new version is released
2 parents 3be41e8 + 27f4c1a commit 61abf29

File tree

7 files changed

+102
-4
lines changed

7 files changed

+102
-4
lines changed

Diff for: .github/workflows/main.yml

+36
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,39 @@ jobs:
4040
artifacts: './system.json, ./system.zip'
4141
tag: ${{ github.event.release.tag_name }}
4242
body: ${{ github.event.release.body }}
43+
44+
- name: Get Compatibility
45+
run: |
46+
echo 'COMPATIBILITY<<EOF' >> $GITHUB_ENV
47+
cat system.json | jq .compatibility >> $GITHUB_ENV
48+
echo 'EOF' >> $GITHUB_ENV
49+
50+
- name: Send package to foundry
51+
run: |
52+
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST 'https://api.foundryvtt.com/_api/packages/release_version/' \
53+
--header 'Authorization: ${{ secrets.PACKAGE_TOKEN }}' \
54+
--header 'Content-Type: application/json' \
55+
--data '{
56+
"id": "vaesen",
57+
"release": {
58+
"version": "${{ github.event.release.tag_name }}",
59+
"manifest": "https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/system.json",
60+
"notes": "https://github.com/${{github.repository}}/releases/tag/${{github.event.release.tag_name}}",
61+
"compatibility": ${{ env.COMPATIBILITY }}
62+
}
63+
}')
64+
65+
# extract the body
66+
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
67+
68+
# extract the status
69+
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
70+
71+
# print the body
72+
echo "$HTTP_BODY"
73+
74+
# example using the status
75+
if [ ! $HTTP_STATUS -eq 200 ]; then
76+
echo "Error [HTTP status: $HTTP_STATUS]"
77+
exit 1
78+
fi

Diff for: README.md

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

34+
v4.3.0
35+
- Improvement: any roll using the `/r` chat command now shows the result of the roll directly
36+
![D66 Roll](asset/d66roll.png?raw=true)
37+
- Deployment Feature: automatically reports to Foundry when a new release is created
38+
3439
v4.2.1
3540
- Fixed: css heights on inputs sometimes cut off tails of letters
3641

37-
3842
v4.2.0
3943
- Feature: Added random Character Generator!
4044
![Character Generation](https://github.com/fvtt-fria-ligan/vaesen-foundry-vtt/blob/master/asset/chargen.png?raw=true)

Diff for: asset/d66roll.png

65.6 KB
Loading

Diff for: model/templates/dice/roll.hbs

+5
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@
1919
<div class="dice-formula">{{formula}}</div>
2020
{{{tooltip}}}
2121

22+
{{#if (eq options.type "total")}}
23+
<h4 class="dice-total">{{total}}</h4>
24+
{{/if}}
25+
{{#unless (eq options.type "total")}}
2226
{{#if (gt success 0)}}
2327
<h4 class="dice-total success">{{localize "CHAT.SUCCESS"}} : {{success}}</h4>
2428
{{/if}}
2529
{{#if (eq success 0)}}
2630
<h4 class="dice-total failure"> {{localize "CHAT.SUCCESS"}} : {{success}}</h4>
2731
{{/if}}
32+
{{/unless}}
2833
</div>
2934
</div>
3035
{{!-- Extra info added for Year Zero rolls --}}

Diff for: script/hooks.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { PlayerCharacterSheet } from "./sheet/player.js";
33
import { NpcCharacterSheet } from "./sheet/npc.js";
44
import { VaesenCharacterSheet } from "./sheet/vaesen.js";
55
import { HeadquarterCharacterSheet } from "./sheet/headquarter.js";
6-
import { prepareRollNewDialog, push } from "./util/roll.js";
6+
import { prepareRollNewDialog, push, totalRoll as totalRoll } from "./util/roll.js";
77
import { registerSystemSettings } from "./util/settings.js";
88
import { vaesen } from "./config.js";
99
import { conditions } from "./util/conditions.js";
@@ -83,7 +83,7 @@ Hooks.once("init", () => {
8383
});
8484

8585
Handlebars.registerHelper('ifIn', function(elem, list, options) {
86-
if(list.indexOf(elem) > -1) {
86+
if(list && list.indexOf(elem) > -1) {
8787
return options.fn(this);
8888
}
8989
return options.inverse(this);
@@ -104,6 +104,7 @@ Hooks.once("ready", async function () {
104104
setupCards();
105105
conditions.onReady();
106106
Hooks.on("hotbarDrop", (bar, data, slot) => createRollMacro(data, slot));
107+
Hooks.on("chatMessage", (_, messageText, chatData) => totalRoll(messageText, chatData));
107108
migrate();
108109

109110
});

Diff for: script/util/roll.js

+51
Original file line numberDiff line numberDiff line change
@@ -399,3 +399,54 @@ export function adjustBonusText(bonus) {
399399
bonus = parseInt(bonus, 10);
400400
return bonus > 0 ? "+" + bonus : bonus;
401401
}
402+
403+
export function totalRoll(messageText, chatData) {
404+
const pattern = /^\/r ((\d*)d(\d+).*$)/g;
405+
const matches = [...messageText.toLowerCase().matchAll(pattern)];
406+
const customRolls = {
407+
"66" : "1d6*10+1d6",
408+
"666": "1d6*100+1d6*10+1d6",
409+
"6666": "1d6*1000+1d6*100+1d6*10+1d6"
410+
};
411+
if (matches.length == 0)
412+
return true;
413+
414+
let actor = undefined;
415+
if (chatData.speaker.actor)
416+
actor = game.actors.get(chatData.speaker.actor);
417+
418+
const diceSide = matches[0][3];
419+
const formula = matches[0][1];
420+
const numberDice = parseInt(matches[0][2] ? matches[0][2] : "1");
421+
422+
if (Object.keys(customRolls).indexOf(diceSide) == -1)
423+
{
424+
createCustomRoll(actor, formula, formula);
425+
return false;
426+
}
427+
428+
for (let index = 0; index < numberDice; index++) {
429+
createCustomRoll(actor, customRolls[diceSide], `D${diceSide}`);
430+
}
431+
return false;
432+
}
433+
434+
async function createCustomRoll(actor, formula, name) {
435+
let options = {
436+
token: actor?.img
437+
};
438+
439+
let templateData = {
440+
flavor: `${name} ${game.i18n.localize("ROLL.ROLL")}`,
441+
type: "total"
442+
};
443+
444+
const roll = Roll.create(formula, options);
445+
446+
let messageData = {
447+
content: await roll.render(templateData),
448+
};
449+
let rollMode = game.settings.get("core", "rollMode");
450+
451+
await roll.toMessage(messageData, { rollMode });
452+
}

Diff for: system.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"title": "Vaesen",
33
"description": "Nordic horror role-playing",
4-
"version": "4.2.1",
4+
"version": "4.3.0",
55
"esmodules": [
66
"script/hooks.js"
77
],
@@ -101,6 +101,7 @@
101101
{
102102
"name": "Cussa Mitre",
103103
"url": "https://github.com/Cussa",
104+
"discord": "CussaMitre",
104105
"flags": {}
105106
},
106107
{

0 commit comments

Comments
 (0)