Skip to content

Commit

Permalink
Merge pull request #34 from ortegamarcel/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ortegamarcel authored May 18, 2023
2 parents 30a7886 + 0cf123a commit 0d8a591
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 20 deletions.
26 changes: 22 additions & 4 deletions languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
"noDetailsAvailable": "Zu diesem Gegenstand sind keine detaillierten Information vorhanden.",
"zoomableItems": "Interessante Gegenstände",
"Settings": {
"rollSkillsNatively": "Native Fertigkeiten-Proben",
"rollSkillsNativelyHint": "Wenn aktiviert, wird die vom System bereitgestellte Methode zum Würfeln von Fertigkeiten verwendet. Dies funktioniert nur mit der Version 'v0.97-alpha.4' und höher. Es wird automatisch eine alternative Methode verwendet, wenn du eine inkompatible Version verwendest.",
"sortSkillsAlphabetically": "Fertigkeiten sortieren",
"sortSkillsAlphabeticallyHint": "Wenn angekreuzt, werden alle Fertigkeiten innerhalb ihrer Kategorie von A nach Z sortiert.",
"sortSkillsAlphabeticallyHint": "Wenn aktiviert, werden alle Fertigkeiten innerhalb ihrer Kategorie von A nach Z sortiert.",
"showSkillCategories": "Fertigkeiten Kategorisieren",
"showSkillCategoriesHint": "Wenn angekreuz, werden alle Fertigkeiten in ihrer entsprechenden Grundattribut-Kategorie angezeigt. Ansonstent werden sie alle nebeneinander angezeigt.",
"showSkillSuffix": "Fertigkeiten Suffix anzeigen",
Expand All @@ -33,7 +35,7 @@
"skillSuffixSkillpoints": "Skillpunkte",
"skillSuffixBasevalue": "Basiswert",
"showMagicStaCost": "Zeige AUS-Kosten an",
"showMagicStaCostHint": "Wenn angekreuzt, werden hinter allen Zaubersprüchen die Ausdauer Kosten angezeigt.",
"showMagicStaCostHint": "Wenn aktiviert, werden hinter allen Zaubersprüchen die Ausdauer Kosten angezeigt.",
"magicVarStaCostLabel": "Zeichen für variable AUS-Kosten",
"magicVarStaCostLabelHint": "Wenn AUS-Kosten angezeigt werden, ist das die Zeichenkette die hinter Zaubern mit variablen Kosten angezeigt wird. Lasse es leer, damit nichts angezeigt wird.",
"skillSettings": "Fertigkeiten Anzeige",
Expand All @@ -43,15 +45,31 @@
"save": "Speichern",
"deselectAll": "Alle Abwählen",
"selectAll": "Alle Auswählen",
"showToAll": "Zeige Verbrauchsgegenstände allen an",
"showToAllHint": "Wenn angekreuzt, wird allen eine Chat Nachricht angezeigt, wenn jemand einen Verbrauchsgegenstand konsumiert. Ansonsten, kann es nur der Verbraucher und der Spielleiter sehen."
"showToAll": "Öffentliche Verbrauchsnachrichten",
"showToAllHint": "Wenn aktiviert, wird allen eine Chat Nachricht angezeigt, wenn jemand einen Verbrauchsgegenstand konsumiert. Ansonsten, kann es nur der Verbraucher und der Spielleiter sehen.",
"showQuestItems": "Questgegenstände anzeigen",
"showQuestItemsHint": "Wenn aktiviert, werden Quest-Gegenstände unter \"Interessante Gegenstände\" angezeigt. Quest-Gegenstände existieren nur in The Witcher TRPG v0.97-alpha.4 oder höher.",
"showUnsupportedSystemMessage": "Zeige Hinweis beim Start",
"showUnsupportedSystemMessageHint": "Wenn aktiviert, wird dem SL beim Start eine Benachrichtigung angezeigt, falls die installierte System Version nicht vollständig mit diesem Modul kompatibel ist."
},
"Chat": {
"actorConsumedOil": "Ich habe ein Klingenöl auf meine Waffe aufgetragen!",
"actorConsumedAlchemicalItem": "Ich habe einen alchemistischen Gegenstand verwendet!",
"actorConsumedPotion": "Ich habe einen Hexer-Trank getrunken!",
"actorConsumedDecoction": "Ich habe eine Hexer-Mixtur getrunken!",
"actorConsumedFoodOrDrink": "Ich habe etwas verzehrt!"
},
"UnsupportedVersion": {
"dontShowAgain": "Nicht wieder anzeigen",
"ignore": "Ignorieren",
"title": "System Version nicht vollständig kompatibel",
"content": "<p>Einige Funktionen von <strong>Token Action HUD The Witcher TRPG</strong> funktionieren möglicherweise nicht ordnungsgemäß mit deiner aktuellen System Version '%version'. Daher empfehle ich, die Version <a href=\"https://github.com/ortegamarcel/TheWitcherTRPG/wiki\" target=\"_blank\"><strong>v0.97-alpha.4</strong></a> oder höher zu installieren. Den Installationsleitfaden findest du <a href=\"https://github.com/ortegamarcel/TheWitcherTRPG/wiki/Installation-Guide\" target=\"_blank\">hier</a>.</p><p>Zu den Funktionen, die nicht richtig oder gar nicht funktionieren, gehören:</p><ul><li>Es gibt keine Quest-Gegenstände</li><li>Bilder von Gegenständen im Inventar können nicht vergrößert angezeigt werden</li><li>Fertigkeiten werden nicht nativ gewürfelt</li></ul>"
},
"Gwent": {
"decks": "Decks",
"gameBoards": "Spielbretter",
"open": "Öffne",
"playWith": "Spiele mit"
}
}
}
22 changes: 20 additions & 2 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"noDetailsAvailable": "There are no detailed information available for this item.",
"zoomableItems": "Interesting Items",
"Settings": {
"rollSkillsNatively": "Roll Skills Natively",
"rollSkillsNativelyHint": "If checked, it will use the Systems exposed method for rolling skills. This only works with version 'v0.97-alpha.4' and higher. It will use a fallback method if you are using an incompable version.",
"sortSkillsAlphabetically": "Sort Skills",
"sortSkillsAlphabeticallyHint": "If checked, all skills are sorted from A to Z within their category.",
"showSkillCategories": "Categorize Skills",
Expand All @@ -43,15 +45,31 @@
"save": "Save",
"deselectAll": "Deselect All",
"selectAll": "Select All",
"showToAll": "Show Consumables to everyone",
"showToAllHint": "If checked, everyone will be shown a chat message when someone consumes a item. Otherwise, only the consumer and the gamemaster can see it."
"showToAll": "Public Consume-Messages",
"showToAllHint": "If checked, everyone will be shown a chat message when someone consumes a item. Otherwise, only the consumer and the gamemaster can see it.",
"showQuestItems": "Show Quest Items",
"showQuestItemsHint": "If checked, quest items will appear under \"Interesting Items\". Quest Items do only exist in The Witcher TRPG v0.97-alpha.4 or higher.",
"showUnsupportedSystemMessage": "Show Notification at the Start",
"showUnsupportedSystemMessageHint": "If checked, the GM will be notified upon startup if the installed system version is not fully compatible with this module."
},
"Chat": {
"actorConsumedOil": "I have applied a blade coating to my weapon!",
"actorConsumedAlchemicalItem": "I have used an alchemical item!",
"actorConsumedPotion": "I have consumed a Witcher potion!",
"actorConsumedDecoction": "I have consumed a Witcher decoction!",
"actorConsumedFoodOrDrink": "I have consumed something!"
},
"UnsupportedVersion": {
"dontShowAgain": "Don't Show Again",
"ignore": "Ignore",
"title": "System version not fully compatible",
"content": "<p>Some features of <strong>Token Action HUD The Witcher TRPG</strong> may not work properly with your current system version '%version'. Therefore, I recommend installing version <a href=\"https://github.com/ortegamarcel/TheWitcherTRPG/wiki\" target=\"_blank\"><strong>v0.97-alpha.4</strong></a> or higher. You can find the installation guide <a href=\"https://github.com/ortegamarcel/TheWitcherTRPG/wiki/Installation-Guide\" target=\"_blank\">here</a>.</p><p>The features that do not work correctly or at all include:</p><ul><li>There are no quest items</li><li>Images of items in the inventory cannot be displayed enlarged</li><li>Skills are not rolled natively</li></ul>"
},
"Gwent": {
"decks": "Decks",
"gameBoards": "Game Boards",
"open": "Open",
"playWith": "Play with"
}
}
}
29 changes: 28 additions & 1 deletion scripts/action-handler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ACTION_TYPE, GROUP, ICON } from "./constants.js";
import { ACTION_TYPE, GROUP, GWENT_MODULE, ICON } from "./constants.js";
import { FilterFn, ItemFilterOptions } from "./types.js";
import { Utils } from "./utils.js";

Expand Down Expand Up @@ -75,6 +75,10 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
consumableOptions.filterFn = FilterFn.byTypeAndSubtype('alchemical', 'decoction');
this._getItems(actor, token.id, { id: GROUP.decoctions.id, type: 'system' }, consumableOptions);

if (game.modules.get(GWENT_MODULE.ID)?.active) {
this._getGwentDecks(actor, token.id, { id: GROUP.gwentDecks.id, type: 'system' });
this._getGwentBoards(actor, token.id, { id: GROUP.gwentBoards.id, type: 'system' });
}

//if (settings.get("showHudTitle")) result.hudTitle = token.name;
}
Expand Down Expand Up @@ -256,5 +260,28 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
}));
this.addActions(actions, parent);
}

async _getGwentDecks(actor, tokenId, parent) {
const actions = actor.items
.filter(item => item.flags[GWENT_MODULE.ID]?.initialized && item.flags[GWENT_MODULE.ID]?.data?.isComplete)
.map(item => ({
id: item.id,
name: `${Utils.i18n('TAH_WITCHER.Gwent.playWith')} ${item.name}`,
img: Utils.getImage(item),
encodedValue: [ACTION_TYPE.playGwent, actor.id, tokenId, item.id].join(this.delimiter)
}));
this.addActions(actions, parent);
}

async _getGwentBoards(actor, tokenId, parent) {
const boardId = game.settings.get(GWENT_MODULE.ID, GWENT_MODULE.SETTINGS.BOARD_ID);
const board = game.actors.get(boardId);
this.addActions([{
id: boardId,
name: `${Utils.i18n('TAH_WITCHER.Gwent.open')} ${board.name}`,
img: board.img,
encodedValue: [ACTION_TYPE.showGwentBoard, actor.id, tokenId, boardId].join(this.delimiter)
}], parent);
}
}
});
24 changes: 24 additions & 0 deletions scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,31 @@ export const MODULE = {
ID: 'fvtt-token-action-hud-thewitchertrpg'
};

/**
* Gwen't - The Dice Game Module
*/
export const GWENT_MODULE = {
ID: 'fvtt-gwent',
SETTINGS: {
GAME_NAME: 'gameName',
BOARD_ID: 'boardId'
}
};

/**
* Core module
*/
export const CORE_MODULE = {
ID: 'token-action-hud-core'
};

/**
* Dice so Nice Module
*/
export const DSN_MODULE = {
ID: 'dice-so-nice'
};

/**
* Core module version required by the system module
*/
Expand Down Expand Up @@ -40,6 +58,8 @@ export const ACTION_TYPE = {
consume: 'consume',
zoom: 'zoom',
show: 'show',
playGwent: 'play_gwent',
showGwentBoard: 'show_gwent_board',
};

export const GROUP = {
Expand Down Expand Up @@ -75,6 +95,10 @@ export const GROUP = {
potions: { id: 'potions', name: 'TAH_WITCHER.potions', type: 'system' },
decoctions: { id: 'decoctions', name: 'TAH_WITCHER.decoctions', type: 'system' },
oils: { id: 'oils', name: 'WITCHER.Inventory.Oils', type: 'system' },

// Gwen't - The Dice Game
gwentDecks: { id: 'gwent-decks', name: 'TAH_WITCHER.Gwent.decks', type: 'system' },
gwentBoards: { id: 'gwent-boards', name: 'TAH_WITCHER.Gwent.gameBoards', type: 'system' },
};

export const SKILL = {
Expand Down
16 changes: 15 additions & 1 deletion scripts/defaults.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GROUP } from './constants.js'
import { GROUP, GWENT_MODULE, MODULE } from './constants.js'

/**
* Default categories and groups
Expand Down Expand Up @@ -76,4 +76,18 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
],
groups: groupsArray
}

if (game.modules.get(GWENT_MODULE.ID)?.active) {
console.log(`${MODULE.ID} | Gwen't - The Dice Game Module installed`);
console.log(`${MODULE.ID} | Initialize Gwen't Actions`);
DEFAULTS.layout.push({
nestId: 'gwent',
id: 'gwent',
name: game.settings.get(GWENT_MODULE.ID, GWENT_MODULE.SETTINGS.GAME_NAME),
groups: [
{ ...groups.gwentDecks, nestId: 'gwent_decks' },
{ ...groups.gwentBoards, nestId: 'gwent_boards' },
]
});
}
});
25 changes: 23 additions & 2 deletions scripts/init.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SystemManager } from './system-manager.js'
import { MODULE, REQUIRED_CORE_MODULE_VERSION } from './constants.js'
import { registerSettings } from './settings.js';
import { Utils } from './utils.js';

async function preloadHandlebarsTemplates() {
const templatePath = [
Expand All @@ -15,8 +16,28 @@ Hooks.on('tokenActionHudCoreApiReady', async () => {
requiredCoreModuleVersion: REQUIRED_CORE_MODULE_VERSION,
SystemManager
}
const version = game.system.version;
const alphaVersion = Number('v0.96-alpha.1'.split('-alpha.')?.[1] ?? -1);

preloadHandlebarsTemplates();
registerSettings();
Hooks.call('tokenActionHudSystemReady', module)
registerSettings(alphaVersion >= 4);
Hooks.call('tokenActionHudSystemReady', module);

const showUnsupportedSystemMessage = Utils.getSetting('showUnsupportedSystemMessage');
if (game.user.isGM && alphaVersion < 4 && showUnsupportedSystemMessage) {
new Dialog({
title: Utils.i18n('TAH_WITCHER.UnsupportedVersion.title'),
content: Utils.i18n('TAH_WITCHER.UnsupportedVersion.content').replace('%version', version),
buttons: [
{
label: Utils.i18n('TAH_WITCHER.UnsupportedVersion.dontShowAgain'),
callback: () => { Utils.setSetting('showUnsupportedSystemMessage', false) }
},
{
label: Utils.i18n('TAH_WITCHER.UnsupportedVersion.ignore'),
callback: () => {}
}
]
}).render(true);
}
});
Loading

0 comments on commit 0d8a591

Please sign in to comment.