Skip to content

Commit

Permalink
fix: Added support for Cepheus Light.
Browse files Browse the repository at this point in the history
Fixes #133
Added setting for choosing between CE and CEL difficulties lists.
Added support for choosing to handle difficulties by changing the target number rather than adding/subtracting modifiers, mainly to support CEL.
Adds in CEL packs and icons from Marvin9257 (the icons are CC BY 3.0 license, sourced from https://game-icons.net)
Updated Spanish translation from ForjaSalvaje
Various minor fixes.

fix: Added support for skills that don't get characteristic modifiers.
Fixes #128

fix: Added support for choosing which characteristic is used for *this* skill roll on shift-click.
Fixes #141

fix: Added icons for Cepheus Engine skills and weapons.
Fixes #144

fix: It is now possible to create macros from skills (drag the skill to the macro bar) and items with skills (drag the item name to the macro bar). They will roll a simple skill roll when clicked.
Fixes #61

Adds these localizations:
```
{
    "TWODSIX": {
        "Items": {
            "Skills": {
                "NONE": "---"
            }
        },
        "Rolls": {
            "using": "using {characteristic}"
        },
        "Settings": {
            "difficultyListUsed": {
                "hint": "Select which variant's difficulty list should be used.",
                "name": "Select which variant's difficulty list should be used."
            },
            "difficultiesAsTargetNumber": {
                "hint": "true=Use target number rather than modifier for difficulties, false=Use modifiers",
                "name": "Use target numbers rather than modifiers for difficulties."
            }
        }
    }
}```
  • Loading branch information
xdy committed Oct 11, 2020
1 parent beb73d8 commit 77522db
Show file tree
Hide file tree
Showing 235 changed files with 881 additions and 319 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Preamble:
This license does not apply to the compendium content listed in this software's "packs" directory. See README.md for licensing information for the compendium packs (and license details in general).
This license does not apply to the content listed in this software's "packs" or "assets" directory. See README.md for licensing information for those (and license details in general).

License:
Apache License
Expand Down
2 changes: 1 addition & 1 deletion OpenGameLicense.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ and Richard Hazlewood.
Cepheus Light © 2018, Stellagama Publishing; Authors Omer Golan-Joel and Josh Peters.
Cepheus: Faster Than Light © 2019, Stellagama Publishing; Author Omer Golan-Joel.
The 2d6 Science Fiction System Reference Document (‘2d6 SF SRD’, '1e 2d6 SF SRD', '2e SF SRD'), is © 2014-2017, Universal Machine Publications.
</pre>
</pre>
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Note:
* Cepheus Engine and Samardan Press™ are the trademarks of Jason "Flynn" Kemp; I am not affiliated with Jason "Flynn" Kemp or Samardan Press™.

This system may eventually claim compatibility with other specific rules sets once it:
a) actually has said compatibility
b) actually has the license to do so
* actually has said compatibility
* actually has the license to do so


### Patch Notes:
Expand All @@ -41,6 +41,9 @@ Virtual Table Top Platform Licenses:
Font licenses:
* [Omnibus-Type/Asap](https://github.com/Omnibus-Type/Asap) Copyright (c) 2019, Omnibus-Type (www.omnibus-type.com | [email protected]): [This Font Software is licensed under the SIL Open Font License, Version 1.1.](http://scripts.sil.org/OFL)

Asset licenses:
* The icons in the assets/twodsix_icons/General folder as well as the original icons from [https://game-icons.net/](https://game-icons.net/) as well as are provided under the [Creative Commons Attribution 3.0 Unported (CC BY 3.0) license](https://creativecommons.org/licenses/by/3.0/)

## Some more stats
* [![GitHub license](https://img.shields.io/github/license/xdy/twodsix-foundryvtt)](https://github.com/xdy/twodsix-foundryvtt/blob/master/LICENSE)
* [![Total alerts](https://img.shields.io/lgtm/alerts/g/xdy/twodsix-foundryvtt.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/xdy/twodsix-foundryvtt/alerts/)
Expand Down
82 changes: 18 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
"file-loader": "^6.0.0",
"foundry-pc-types": "gitlab:foundry-projects/foundry-pc/foundry-pc-types",
"fs-extra": "^9.0.1",
"mini-css-extract-plugin": "^0.12.0",
"mini-css-extract-plugin": "^1.0.0",
"prettier": "^2.1.2",
"sass": "^1.27.0",
"sass-loader": "^10.0.1",
"semantic-release": "^17.1.2",
"source-map-loader": "^1.1.0",
"style-loader": "^1.3.0",
"style-loader": "^2.0.0",
"ts-loader": "^8.0.4",
"ts-node": "^9.0.0",
"typescript": "^4.0.3",
Expand Down
30 changes: 19 additions & 11 deletions src/module/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ TWODSIX.CHARACTERISTICS = {
* @type {Object}
*/
TWODSIX.VARIANTS = {
"ce": "Cepheus Engine",
"CE": "CE",
"CEL": "CEL",
};

TWODSIX.ROLLTYPES = {
Expand All @@ -27,15 +28,22 @@ TWODSIX.ROLLTYPES = {
Disadvantage: "3d6kl2"
};

//This is defined the CE way, but it's mathematically equivalent to other variants.
TWODSIX.DIFFICULTIES = {
Simple: 6,
Easy: 4,
Routine: 2,
Average: 0,
Difficult: -2,
VeryDifficult: -4,
Formidable: -6,
Impossible: -8
"CE": {
Simple: {mod: 6, target: 2},
Easy: {mod: 4, target: 4},
Routine: {mod: 2, target: 6},
Average: {mod: 0, target: 8},
Difficult: {mod: -2, target: 10},
VeryDifficult: {mod: -4, target: 12},
Formidable: {mod: -6, target: 14},
Impossible: {mod: -8, target: 16},
},
"CEL": {
Routine: {mod: 2, target: 4},
Average: {mod: 0, target: 6},
Difficult: {mod: -2, target: 8},
VeryDifficult: {mod: -4, target: 10},
Formidable: {mod: -6, target: 12},
}
};

8 changes: 5 additions & 3 deletions src/module/handlebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ export default function registerHandlebarsHelpers():void {
const actorData = actor.data;
const characteristicElement = actorData.characteristics[getKeyByValue(TWODSIX.CHARACTERISTICS, characteristic)];
if (characteristicElement) {
const mod = calcModFor(characteristicElement.current);
return game.i18n.localize("TWODSIX.Items.Skills." + characteristicElement.shortLabel) + "(" + (mod < 0 ? "" : "+") + mod + ")";
const mod:number = calcModFor(characteristicElement.current);
return game.i18n.localize("TWODSIX.Items.Skills." + characteristic) + "(" + (mod < 0 ? "" : "+") + mod + ")";
} else if ('NONE' === characteristic) {
return game.i18n.localize("TWODSIX.Items.Skills.NONE");
} else {
if (!showedError) {
ui.notifications.error("TWODSIX.Handlebars.CantShowCharacteristic");
ui.notifications.error(game.i18n.localize("TWODSIX.Handlebars.CantShowCharacteristic"));
showedError = true;
}
return "XXX";
Expand Down
64 changes: 30 additions & 34 deletions src/module/hooks/ready.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import {Migration} from "../migration";
import compareVersions from "compare-versions";
import {simpleUpdateInit} from "../settings";
import {TwodsixRolls} from "../utils/TwodsixRolls";


export function before(worldVersion:string, MIGRATIONS_IMPLEMENTED:string):boolean {
return compareVersions(worldVersion, MIGRATIONS_IMPLEMENTED) === -1;
}

Hooks.once("ready", async function () {

//Things that need to be done once settings have been set (and should probably be moved elsewhere...)
simpleUpdateInit(game.settings.get("twodsix", "initiativeFormula"));

// Determine whether a system migration is required and feasible

const MIGRATIONS_IMPLEMENTED = "0.6.1";
Expand All @@ -30,54 +36,43 @@ Hooks.once("ready", async function () {
}

// Wait to register hotbar drop hook on ready so that modules could register earlier if they want to
Hooks.on("hotbarDrop", (bar, data, slot) => createTwodsixMacro(data, slot));
Hooks.on("hotbarDrop", (bar, data, slot) => createItemMacro(data, slot));

});

//TODO Move these to a better place
/**
* Create a Macro from an Item drop.
* Get an existing item macro if one exists, otherwise create a new one.
* @param {Object} data The dropped data
* @param {Object} item The item data
* @param {number} slot The hotbar slot to use
* @returns {Promise}
*/
async function createTwodsixMacro(data, slot) {
if (data.type !== "Item") {
return;
}
if (!("data" in data)) {
return ui.notifications.warn("You can only create macro buttons for owned Items");
}
const item = data.data;

// Create the macro command
const command = `game.twodsix.rollItemMacro("${item.name}");`;

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
let macro:Macro = game.macros.entities.find((m:Macro) => (m.name === item.name) && (m.data.command === command));
async function createItemMacro(item, slot):Promise<void> {
const command = `game.twodsix.rollItemMacro("${item._id ? item._id : item.data._id}");`;
let macro = game.macros.entities.find((m) => (m.name === item.name) /*&& (m.data.command === command)*/);
if (!macro) {
macro = <Macro>await Macro.create({
name: item.name,
type: "script",
img: item.img,
const name = item.name ? item.name : item.data.name;
const img = item.img ? item.img : item.data.img;
macro = await Macro.create({
command: command,
flags: {"twodsix.itemMacro": true}
});
name: name,
type: 'script',
img: img,
flags: {'twodsix.itemMacro': true},
}, {displaySheet: false}) as Macro;

await game.user.assignHotbarMacro(macro, slot);
}
await game.user.assignHotbarMacro(macro, slot);
return false;
}

/**
* Create a Macro from an Item drop.
* Get an existing item macro if one exists, otherwise create a new one.
* @param {string} itemName
* @param {string} itemId
* @return {Promise}
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function rollItemMacro(itemName) { // lgtm [js/unused-local-variable]
export async function rollItemMacro(itemId):Promise<void> {
const speaker = ChatMessage.getSpeaker();
let actor;
if (speaker.token) {
Expand All @@ -86,12 +81,13 @@ function rollItemMacro(itemName) { // lgtm [js/unused-local-variable]
if (!actor) {
actor = game.actors.get(speaker.actor);
}
const item = actor ? actor.items.find(i => i.name === itemName) : null;
const item = actor ? actor.items.find((i) => i._id === itemId) : null;
if (!item) {
return ui.notifications.warn(`Your controlled Actor does not have an item named ${itemName}`);
ui.notifications.warn(`Your controlled Actor does not have an item with ID ${itemId}`);
} else {
// Trigger the item roll
const domStringMap = DOMStringMap.prototype;
await TwodsixRolls.performRoll(actor, itemId, domStringMap, false);
}


// Trigger the item roll
return item.roll();
}

2 changes: 0 additions & 2 deletions src/module/migration.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {TwodsixItemData} from "./entities/TwodsixItem";
import {before} from "./hooks/ready";
import {TWODSIX} from "./config";
import {getKeyByValue} from "./utils/sheetUtils";

//TODO Move all types to a better place
export type UpdateData = {
Expand Down
Loading

0 comments on commit 77522db

Please sign in to comment.