Skip to content

Commit

Permalink
Added dice so nice integration
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickBauer committed Mar 17, 2023
1 parent c7c64fe commit dee5a9f
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 19 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Changelog

### 1.2.2
* Added option to change the color for magic dice

### 1.2.1
* Fixed some wording and added a reload button after changing specific system settings

### 1.2.0
* Added support for the Guild Codex magic system (disabled by default)
* Added support for the GuildCodex magic system (disabled by default)

### 1.1.1
* Automatically updates the prototype token name when an actors name is changed (if both were identical). Can be disabled in the system settings.
Expand Down
5 changes: 0 additions & 5 deletions src/fatex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ Hooks.once("init", async () => {
// Register HandlebarsHelpers
HandlebarsHelpers.registerHelpers();

// Register Fate die modifier
FateDie.MODIFIERS["m"] = function magicModifier(_modifier) {
this.results = this.results.map((result) => ({ ...result, count: result.result === 1 ? 2 : result.result }));
};

// Unregister Core sheets
Actors.unregisterSheet("core", ActorSheet);
Items.unregisterSheet("core", ItemSheet);
Expand Down
1 change: 0 additions & 1 deletion src/module/chat/FateChatCard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-nocheck

import { FateActor } from "../actor/FateActor";
import { FateRoll } from "./FateRoll";
import { FateChatCardDataModel } from "../data/FateChatCardDataModel";
Expand Down
7 changes: 2 additions & 5 deletions src/module/chat/FateRoll.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-nocheck

import { FateRollDataModel } from "../data/FateRollDataModel";
import { SkillItemData } from "../item/ItemTypes";
import { ItemDataProperties } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/itemData";
Expand Down Expand Up @@ -43,10 +42,8 @@ export class FateRoll extends FateRollDataModel {
}

async rollMagic(userId = "", magicCount: number) {
const normalCount = 4 - magicCount;

const magicRoll = new Roll(`${this.options.magicCount}dFm`).roll({ async: false });
const normalRoll = new Roll(`${normalCount}dF`).roll({ async: false });
const magicRoll = new Roll(`${magicCount}dMe`).roll({ async: false });
const normalRoll = new Roll(`${4 - magicCount}dF`).roll({ async: false });

this.updateSource({
faces: [...magicRoll.terms[0].results, ...normalRoll.terms[0].results].map((r) => r.count ?? r.result),
Expand Down
1 change: 0 additions & 1 deletion src/module/data/FateChatCardDataModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-nocheck

import { FateRollsArrayField } from "./fields/FateRollsArrayField";
import { FateRoll } from "../chat/FateRoll";

Expand Down
1 change: 0 additions & 1 deletion src/module/data/FateRollDataModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-nocheck

import { FateRollHistoryDataModel } from "./FateRollHistoryDataModel";

export class FateRollDataModel extends foundry.abstract.DataModel {
Expand Down
1 change: 0 additions & 1 deletion src/module/data/fields/FateRollsArrayField.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-nocheck

export class FateRollsArrayField extends foundry.data.fields.ArrayField {
_validateSpecial(value) {
super._validateSpecial(value);
Expand Down
1 change: 0 additions & 1 deletion src/module/features/ChatActionsFeature.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-nocheck

import { FateChatCard } from "../chat/FateChatCard";

export class ChatActionsFeature {
Expand Down
27 changes: 27 additions & 0 deletions src/module/features/MagicSystem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// @ts-nocheck
export class MagicDie extends FateDie {
static DENOMINATION = "m";
}

export class MagicSystem {
static hooks() {
Expand All @@ -12,6 +15,30 @@ export class MagicSystem {
requiresReload: true,
type: Boolean,
});

CONFIG.Dice.terms["m"] = MagicDie;

FateDie.MODIFIERS["e"] = function magicModifier(_modifier) {
this.results = this.results.map((result) => ({
...result,
count: result.result === 1 ? 2 : result.result,
}));
};
});

Hooks.once("diceSoNiceReady", (dice3d) => {
if (!game.settings.get("fatex", "guildCodexMagicSystemEnabled")) return;

dice3d.addDicePreset(
{
type: "dm",
labels: ["−", " ", "+"],
values: { min: -1, max: 1 },
fontScale: 2,
system: "standard",
},
"d6"
);
});
}
}
1 change: 0 additions & 1 deletion src/module/features/PrototypeTokenNameSyncFeature.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-nocheck

export class PrototypeTokenNameSyncFeature {
static hooks() {
Hooks.once("init", () => {
Expand Down
2 changes: 1 addition & 1 deletion system/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
"Hint": "Automatically updates the prototype token name when an actors name is changed (if both were identical)."
},
"magicSystemEnabled": {
"Name": "Enable the magic system from Guild Codex",
"Name": "Enable the magic system from GuildCodex",
"Hint": "This will add a magic skill to the character sheet and allow you to use magic dice."
}
},
Expand Down
2 changes: 1 addition & 1 deletion system/system.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "fatex",
"title": "FateX - Fate Extended",
"description": "An extended implementation of Fate and its derivative systems",
"version": "1.2.1",
"version": "1.2.2",
"authors": [
{
"name": "Patrick Bauer",
Expand Down

0 comments on commit dee5a9f

Please sign in to comment.