Skip to content

Commit

Permalink
Merge pull request #107 from fvtt-fria-ligan/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
aMediocreDad authored Apr 25, 2021
2 parents 9203cdf + 9466ab7 commit 3222927
Show file tree
Hide file tree
Showing 43 changed files with 1,228 additions and 178 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ npm install

```bash
# Build the dist folder where the system package lives.
npm run build
npm run dev
```

### 3. Link dist folder in systems.
Expand Down Expand Up @@ -101,7 +101,7 @@ If you do, congratulations:tada:! To begin editing the code:

```bash
# Run the command that builds the dist folder then watches it for changes.
npm run build:watch
npm run dev:watch
```

You can cancel watching the files for changes by using the command `ctrl + c` in the terminal window.
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const stylesDirectory = `${sourceDirectory}/styles`;
const stylesExtension = "scss";
const sourceFileExtension = "js";
const srcFiles = ["lang", "templates"];
const staticFiles = ["assets", "fonts", "scripts", "system.json", "template.json"];
const staticFiles = ["assets", "fonts", "scripts", "system.json", "template.json", "LICENSE"];
const getDownloadURL = (version) =>
`https://github.com/fvtt-fria-ligan/forbidden-lands-foundry-vtt/releases/download/v${version}/v${version}.zip`;
const repoPathing = (relativeSourcePath = ".", sourcemapPath = ".") => {
Expand Down
58 changes: 57 additions & 1 deletion package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
}
],
"scripts": {
"build": "cross-env NODE_ENV=development gulp build",
"build:watch": "cross-env NODE_ENV=development gulp watch",
"dev": "cross-env NODE_ENV=development gulp build",
"dev:watch": "cross-env NODE_ENV=development gulp watch",
"build": "cross-env NODE_ENV=production gulp build",
"link-project": "gulp link",
"clean": "gulp clean",
"clean:link": "gulp link --clean",
Expand All @@ -34,6 +35,7 @@
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^11.2.1",
"@rollup/plugin-strip": "^2.0.0",
"@types/foundry-vtt-types": "npm:@league-of-foundry-developers/foundry-vtt-types@^0.7.9-5",
"@types/jquery": "^3.5.5",
"@typhonjs-fvtt/eslint-config-foundry.js": "^0.7.9",
Expand Down
19 changes: 17 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const { nodeResolve } = require("@rollup/plugin-node-resolve");
const { nodeResolve } = require("@rollup/plugin-node-resolve"); // Node resolve is used to bundle node-modules at build if needed.
const { terser } = require("rollup-plugin-terser"); // We are using terser to shave off 42% of our codebase at production
const strip = require("@rollup/plugin-strip"); // Strip is used to remove console.logs and the hooks debug setting.
const dotenv = require("dotenv");
const result = dotenv.config();
const env = process.env.NODE_ENV || "development";
Expand All @@ -13,5 +15,18 @@ module.exports = {
format: "es",
sourcemap: env === "development" ? true : false,
},
plugins: [nodeResolve()],
plugins: [
env === "production"
? strip({
labels: ["hookDebug"],
})
: null,
nodeResolve(),
env === "production"
? terser({
mangle: false,
module: true,
})
: null,
],
};
5 changes: 3 additions & 2 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"ARTIFACT.APPEARANCE": "Appearance",
"ARTIFACT.ARTIFACT_BONUS": "Artifact Bonus",
"ARTIFACT.DESCRIPTION": "Description",
"ARTIFACT.DICELESS": "Special",
"ARTIFACT.DRAWBACK": "Drawback",
"ARTIFACT.EPIC": "Epic",
"ARTIFACT.LEGENDARY": "Legendary",
Expand Down Expand Up @@ -350,9 +351,9 @@
"FLCG.TALENT": "Talent",

"FLCG.SETTINGS.DATASET_DIR": "Dataset Directory",
"FLCG.SETTINGS.DATASET_DIR_HINT": "Path to a directory with dataset.json file. You can make your own dataset to customize generator's output.",
"FLCG.SETTINGS.DATASET_DIR_HINT": "Path to a directory with dataset.json file. You can make your own dataset to customize the generator's output.",
"FLCG.WARNING": "WARNING!",
"FLCG.WARNING_DESTRUCTIVE_EDIT": "You are about to destructively edit your character.",
"FLCG.WARNING_HINT": "Clicking the \"Apply!\"-button in the character generator will change your character with no way to reset the changes.",
"FLCG.WARNING_HINT": "Clicking the \"Apply!\"-button in the character generator will permanently change your character with no way to revert these changes.",
"FLCG.WARNING_ARE_YOU_SURE": "Are you sure you want to do this?"
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class CharacterConverter {
return new ItemClass({
name: name,
type: type || "gear",
data: type === "talent" ? {} : { weight: "tiny" },
data: type === "talent" ? {} : { weight: "none" },
});
}

Expand Down
26 changes: 18 additions & 8 deletions src/module/components/character-generator/character-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class ForbiddenLandsCharacterGenerator extends Application {
await this.existActor.update({ ["data"]: updateData.data });
await this.existActor.createEmbeddedEntity("OwnedItem", updateData.items);

return false;
return this.close();
}

handleInputKin(event) {
Expand Down Expand Up @@ -237,13 +237,22 @@ export class ForbiddenLandsCharacterGenerator extends Application {
let kin = kinKey ? this.dataset.kin[kinKey] : this.rollOn(this.dataset.kin);

character.kin = kin.key;
if (character.age === undefined) {
character.age = this.rollAge(kin.age);
if (character.kin === "elf") {
character.age = {
ageNumber: NaN,
ageKey: 1,
ageString: "Adult",
};
character = this.rollFormativeEvents(character);
} else {
character.age.ageNumber = this.rollNumber(
kin.age[character.age.ageKey][0],
kin.age[character.age.ageKey][1],
);
if (character.age === undefined) {
character.age = this.rollAge(kin.age);
} else {
character.age.ageNumber = this.rollNumber(
kin.age[character.age.ageKey][0],
kin.age[character.age.ageKey][1],
);
}
}
character.childhood = this.rollOn(kin.childhood);

Expand All @@ -258,6 +267,7 @@ export class ForbiddenLandsCharacterGenerator extends Application {

rollFormativeEvents(character) {
let profession = this.dataset.profession[character.profession];
if (!profession) return character;
let formativeEvents = [];
let rolled = [];
let event = {};
Expand Down Expand Up @@ -304,8 +314,8 @@ export class ForbiddenLandsCharacterGenerator extends Application {
const mapping = ["Young", "Adult", "Old"];
let age = {};
age.ageKey = this.rollNumber(0, 2);
age.ageString = mapping[age.ageKey];
age.ageNumber = this.rollNumber(ageRanges[age.ageKey][0], ageRanges[age.ageKey][1]);
age.ageString = mapping[age.ageKey];

return age;
}
Expand Down
9 changes: 7 additions & 2 deletions src/module/forbidden-lands.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import FBL from "./system/config.js";
import registerSettings from "./system/settings.js";
import { BaseDie, GearDie } from "./components/dice.js";

//CONFIG.debug.hooks = true;
/**
* We use this label to remove the debug option in production builds. @See rollup.config.js
*/
// eslint-disable-next-line no-unused-labels
hookDebug: CONFIG.debug.hooks = true;
console.warn("HOOKS DEBUG ENABLED: ", CONFIG.debug.hooks);

Hooks.once("init", () => {
game.fbl = {
Expand All @@ -31,8 +36,8 @@ Hooks.once("init", () => {
});

Hooks.once("ready", () => {
migrateWorld();
initializeCalendar();
migrateWorld();
});

Hooks.once("diceSoNiceReady", (dice3d) => {
Expand Down
7 changes: 4 additions & 3 deletions src/module/hooks/calendar-weather.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export function initializeCalendar() {
// Init support for the Calendar/Weather module
if (!game.modules.get("calendar-weather")?.active) {
console.warn(
"Install the Calendar/Weather module for calendar support: https://foundryvtt.com/packages/calendar-weather/",
);
if (game.settings.get("forbidden-lands", "worldSchemaVersion") === 0)
ui.notifications.notify(
"Install the Calendar/Weather module for calendar support: https://foundryvtt.com/packages/calendar-weather/",
);
return;
}

Expand Down
8 changes: 4 additions & 4 deletions src/module/hooks/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const migrateWorld = async () => {
await actor.update(update, { enforceTypes: false });
}
} catch (e) {
console.error(e);
ui.notifications.error("Migration of actors failed.");
}
}
for (let item of game.items.entities) {
Expand All @@ -24,7 +24,7 @@ export const migrateWorld = async () => {
await item.update(update, { enforceTypes: false });
}
} catch (e) {
console.error(e);
ui.notifications.error("Migration of items failed.");
}
}
for (let scene of game.scenes.entities) {
Expand All @@ -33,8 +33,8 @@ export const migrateWorld = async () => {
if (!isObjectEmpty(update)) {
await scene.update(update, { enforceTypes: false });
}
} catch (err) {
console.error(err);
} catch (e) {
ui.notifications.error("Migration of scenes failed.");
}
}
for (let pack of game.packs.filter(
Expand Down
1 change: 1 addition & 0 deletions src/module/sheets/actor/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class ForbiddenLandsActorSheet extends ActorSheet {

activateListeners(html) {
super.activateListeners(html);
if (!game.user.isGM && this.actor.limited) return;
// Attribute markers
html.find(".change-attribute").on("click contextmenu", (ev) => {
const attributeName = $(ev.currentTarget).data("attribute");
Expand Down
9 changes: 7 additions & 2 deletions src/module/sheets/actor/character.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ export class ForbiddenLandsCharacterSheet extends ForbiddenLandsActorSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["forbidden-lands", "sheet", "actor"],
template: "systems/forbidden-lands/templates/character.hbs",
width: 700,
height: 770,
height: 780,
resizable: false,
scrollY: [
".armors .item-list .items",
Expand All @@ -27,6 +26,11 @@ export class ForbiddenLandsCharacterSheet extends ForbiddenLandsActorSheet {
});
}

get template() {
if (!game.user.isGM && this.actor.limited) return "systems/forbidden-lands/templates/limited-character.hbs";
return "systems/forbidden-lands/templates/character.hbs";
}

getData() {
const data = super.getData();
this.computeSkills(data);
Expand Down Expand Up @@ -221,6 +225,7 @@ export class ForbiddenLandsCharacterSheet extends ForbiddenLandsActorSheet {
<br/>`,
yes: async () => await this._charGen(),
no: () => {},
defaultYes: false,
});
} else {
await this._charGen();
Expand Down
2 changes: 1 addition & 1 deletion src/module/sheets/item/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export class ForbiddenLandsItemSheet extends ItemSheet {
return mergeObject(super.defaultOptions, {
...super.defaultOptions,
classes: ["forbidden-lands", "sheet", "item"],
width: window.innerWidth * 0.18 + 150,
width: window.innerWidth * 0.12 + 250,
resizable: false,
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/module/system/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function registerSettings() {
game.settings.register("forbidden-lands", "allowUnlimitedPush", {
name: game.i18n.localize("FLPS.SETTINGS.ALLOW_PUSH"),
hint: game.i18n.localize("FLPS.SETTINGS.ALLOW_PUSH_HINT"),
scope: "world",
scope: "client",
config: true,
default: false,
type: Boolean,
Expand Down
Loading

0 comments on commit 3222927

Please sign in to comment.