Skip to content

Commit

Permalink
Merge branch '4.0.x' into publish-wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
arbron committed Sep 3, 2024
2 parents 36a217c + 09b577f commit d7509cf
Show file tree
Hide file tree
Showing 2,592 changed files with 415,733 additions and 233,434 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.hbs]
indent_size = 4
78 changes: 38 additions & 40 deletions dnd5e.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import * as documents from "./module/documents/_module.mjs";
import * as enrichers from "./module/enrichers.mjs";
import * as Filter from "./module/filter.mjs";
import * as migrations from "./module/migration.mjs";
import {default as registry} from "./module/registry.mjs";
import * as utils from "./module/utils.mjs";
import {ModuleArt} from "./module/module-art.mjs";
import registerModuleData from "./module/module-registration.mjs";
import Tooltips5e from "./module/tooltips.mjs";

/* -------------------------------------------- */
Expand All @@ -39,6 +41,7 @@ globalThis.dnd5e = {
enrichers,
Filter,
migrations,
registry,
utils
};

Expand All @@ -51,13 +54,7 @@ Hooks.once("init", function() {
console.log(`D&D 5e | Initializing the D&D Fifth Game System - Version ${dnd5e.version}\n${DND5E.ASCII}`);

// TODO: Remove when v11 support is dropped.
CONFIG.compatibility.excludePatterns.push(/filePicker|select/);
CONFIG.compatibility.excludePatterns.push(/foundry\.dice\.terms/);
CONFIG.compatibility.excludePatterns.push(
/aggregateDamageRoll|configureDamage|preprocessFormula|simplifyRollFormula/
);
CONFIG.compatibility.excludePatterns.push(/core\.sourceId/);
if ( game.release.generation < 12 ) Math.clamp = Math.clamped;
CONFIG.compatibility.excludePatterns.push(/select/);

// Record Configuration Values
CONFIG.DND5E = DND5E;
Expand All @@ -72,10 +69,10 @@ Hooks.once("init", function() {
CONFIG.Item.documentClass = documents.Item5e;
CONFIG.Token.documentClass = documents.TokenDocument5e;
CONFIG.Token.objectClass = canvas.Token5e;
CONFIG.Token.ringClass = canvas.TokenRing;
CONFIG.User.documentClass = documents.User5e;
CONFIG.time.roundTime = 6;
Roll.TOOLTIP_TEMPLATE = "systems/dnd5e/templates/chat/roll-breakdown.hbs";
CONFIG.Dice.BasicRoll = dice.BasicRoll;
CONFIG.Dice.DamageRoll = dice.DamageRoll;
CONFIG.Dice.D20Roll = dice.D20Roll;
CONFIG.MeasuredTemplate.defaults.angle = 53.13; // 5e cone RAW should be 53.13 degrees
Expand All @@ -86,8 +83,9 @@ Hooks.once("init", function() {
// Register System Settings
registerSystemSettings();

// Configure module art
// Configure module art & register module data
game.dnd5e.moduleArt = new ModuleArt();
registerModuleData();

// Configure tooltips
game.dnd5e.tooltips = new Tooltips5e();
Expand All @@ -99,11 +97,25 @@ Hooks.once("init", function() {
if ( !game.settings.get("dnd5e", "honorScore") ) delete DND5E.abilities.hon;
if ( !game.settings.get("dnd5e", "sanityScore") ) delete DND5E.abilities.san;

// Legacy rules.
if ( game.settings.get("dnd5e", "rulesVersion") === "legacy" ) {

// Set half-casters to round down.
delete DND5E.spellcastingTypes.leveled.progression.half.roundUp;

// Adjust Wild Shape and Polymorph presets.
delete DND5E.transformationPresets.wildshape.options.keepHP;
delete DND5E.transformationPresets.wildshape.options.keepType;
delete DND5E.transformationPresets.polymorph.options.addTemp;
delete DND5E.transformationPresets.polymorph.options.keepHP;
delete DND5E.transformationPresets.polymorph.options.keepType;
}

// Register Roll Extensions
CONFIG.Dice.rolls.push(dice.D20Roll);
CONFIG.Dice.rolls.push(dice.DamageRoll);
CONFIG.Dice.rolls = [dice.BasicRoll, dice.D20Roll, dice.DamageRoll];

// Hook up system data types
CONFIG.ActiveEffect.dataModels = dataModels.activeEffect.config;
CONFIG.Actor.dataModels = dataModels.actor.config;
CONFIG.Item.dataModels = dataModels.item.config;
CONFIG.JournalEntryPage.dataModels = dataModels.journal.config;
Expand All @@ -124,7 +136,6 @@ Hooks.once("init", function() {
});
Actors.registerSheet("dnd5e", applications.actor.ActorSheet5eNPC, {
types: ["npc"],
makeDefault: true,
label: "DND5E.SheetClassNPCLegacy"
});
DocumentSheetConfig.registerSheet(Actor, "dnd5e", applications.actor.ActorSheet5eNPC2, {
Expand All @@ -144,12 +155,13 @@ Hooks.once("init", function() {
});

DocumentSheetConfig.unregisterSheet(Item, "core", ItemSheet);
DocumentSheetConfig.registerSheet(Item, "dnd5e", applications.item.ItemSheet5e, {
DocumentSheetConfig.registerSheet(Item, "dnd5e", applications.item.ItemSheet5e2, {
makeDefault: true,
label: "DND5E.SheetClassItem"
});
DocumentSheetConfig.unregisterSheet(Item, "dnd5e", applications.item.ItemSheet5e, { types: ["container"] });
DocumentSheetConfig.registerSheet(Item, "dnd5e", applications.item.ContainerSheet, {
DocumentSheetConfig.unregisterSheet(Item, "dnd5e", applications.item.ItemSheet5e2, { types: ["container"] });
DocumentSheetConfig.registerSheet(Item, "dnd5e", applications.item.ContainerSheet2, {
makeDefault: true,
types: ["container"],
label: "DND5E.SheetClassContainer"
Expand Down Expand Up @@ -265,6 +277,7 @@ function _configureConsumableAttributes() {
...Object.keys(DND5E.abilities).map(ability => `abilities.${ability}.value`),
"attributes.ac.flat",
"attributes.hp.value",
"attributes.exhaustion",
...Object.keys(DND5E.senses).map(sense => `attributes.senses.${sense}`),
...Object.keys(DND5E.movementTypes).map(type => `attributes.movement.${type}`),
...Object.keys(DND5E.currencies).map(denom => `currency.${denom}`),
Expand Down Expand Up @@ -371,10 +384,6 @@ Hooks.once("setup", function() {
// Apply custom item compendium
game.packs.filter(p => p.metadata.type === "Item")
.forEach(p => p.applicationClass = applications.item.ItemCompendium5e);

// Configure token rings
CONFIG.DND5E.tokenRings.shaderClass ??= canvas.TokenRingSamplerShaderV11;
CONFIG.Token.ringClass.initialize();
});

/* --------------------------------------------- */
Expand All @@ -396,7 +405,10 @@ function expandAttributeList(attributes) {
/**
* Perform one-time pre-localization and sorting of some configuration objects
*/
Hooks.once("i18nInit", () => utils.performPreLocalization(CONFIG.DND5E));
Hooks.once("i18nInit", () => {
utils.performPreLocalization(CONFIG.DND5E);
Object.values(CONFIG.DND5E.activityTypes).forEach(c => c.documentClass.localize());
});

/* -------------------------------------------- */
/* Foundry VTT Ready */
Expand All @@ -414,6 +426,12 @@ Hooks.once("ready", function() {
}
});

// Register items by type
dnd5e.registry.classes.initialize();

// Chat message listeners
documents.ChatMessage5e.activateListeners();

// Determine whether a system migration is required and feasible
if ( !game.user.isGM ) return;
const cv = game.settings.get("dnd5e", "systemMigrationVersion") || game.world.flags.dnd5e?.version;
Expand All @@ -433,27 +451,6 @@ Hooks.once("ready", function() {
migrations.migrateWorld();
});

/* -------------------------------------------- */
/* Canvas Initialization */
/* -------------------------------------------- */

Hooks.on("canvasInit", gameCanvas => {
if ( game.release.generation < 12 ) {
gameCanvas.grid.diagonalRule = game.settings.get("dnd5e", "diagonalMovement");
SquareGrid.prototype.measureDistances = canvas.measureDistances;
}
CONFIG.Token.ringClass.pushToLoad(gameCanvas.loadTexturesOptions.additionalSources);
});

/* -------------------------------------------- */
/* Canvas Draw */
/* -------------------------------------------- */

Hooks.on("canvasDraw", gameCanvas => {
// The sprite sheet has been loaded now, we can create the uvs for each texture
CONFIG.Token.ringClass.createAssetsUVs();
});

/* -------------------------------------------- */
/* System Styling */
/* -------------------------------------------- */
Expand Down Expand Up @@ -544,6 +541,7 @@ export {
enrichers,
Filter,
migrations,
registry,
utils,
DND5E
};
11 changes: 11 additions & 0 deletions icons/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ The dnd5e system for Foundry Virtual Tabletop includes icon artwork licensed fro
/svg/item-choice.svg - "Choice" by Delapouite under CC BY 3.0
/svg/item-grant.svg - "White book" by Willdabeast under CC BY 3.0
/svg/monster.svg - "Spiked dragon head" by Delapouite under CC BY 3.0
/svg/original-class.svg - "Barbute" by Lorc under CC BY 3.0
/svg/scale-value.svg - "Dice target" by Delapouite under CC BY 3.0
/svg/size.svg - "Body height" by Delapouite under CC BY 3.0
/svg/subclass.svg - "Elf helmet" by Kier Heyl under CC BY 3.0
/svg/trait.svg - "Scroll unfurled" by Lorc under CC BY 3.0
/svg/trait-armor-proficiencies.svg - "Leather armor" by Delapouite under CC BY 3.0
/svg/trait-damage-immunities.svg - "Aura" by Lorc under CC BY 3.0
Expand All @@ -27,6 +29,14 @@ The dnd5e system for Foundry Virtual Tabletop includes icon artwork licensed fro
/svg/trait-weapon-proficiencies.svg - "Crossed swords" by Lorc under CC BY 3.0
/svg/vehicle.svg - "Ship's wheel" by Delapouite under CC BY 3.0
/svg/versatile.svg - "Swiss army knife" by Delapouite under CC BY 3.0
/svg/activity/attack.svg - "Sword clash" by Lorc under CC BY 3.0
/svg/activity/check.svg - "Juggler" by Lorc under CC BY 3.0
/svg/activity/damage.svg - "Earth spit" by Lorc under CC BY 3.0
/svg/activity/enchant.svg - "Rune sword" by Lorc under CC BY 3.0 & "Magic axe" by Delapouite under CC BY 3.0
/svg/activity/heal.svg - "Health increase" by sbed under CC BY 3.0
/svg/activity/save.svg - "Shield reflect" by Lorc under CC BY 3.0
/svg/activity/summon.svg - "Pentagram rose" by Lorc under CC BY 3.0
/svg/activity/utility.svg - "Spanner" by Lorc under CC BY 3.0
/svg/damage/acid.svg - "Fizzling flask" by Lorc under CC BY 3.0
/svg/damage/bludgeoning.svg - "Claw hammer" by Lorc under CC BY 3.0
/svg/damage/cold.svg - "Frozen orb" by Lorc under CC BY 3.0
Expand Down Expand Up @@ -54,6 +64,7 @@ The dnd5e system for Foundry Virtual Tabletop includes icon artwork licensed fro
/svg/items/tool.svg - "Stone crafting" by Lorc under CC BY 3.0
/svg/items/weapon.svg - "Crossed sabers" by Lorc under CC BY 3.0
/svg/properties/magical.svg - "Sparkling sabre icon" by Lorc under CC BY 3.0
/svg/statuses/bloodied.svg - "Blood icon" by Skoll under CC BY 3.0
/svg/statuses/burrowing.svg - "Spade icon" by Lorc under CC BY 3.0
/svg/statuses/cursed.svg - "Ubisoft sun icon" by Lorc under CC BY 3.0
/svg/statuses/diseased.svg - "Biohazard icon" by Lorc under CC BY 3.0
Expand Down
6 changes: 6 additions & 0 deletions icons/svg/activity/attack.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions icons/svg/activity/check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions icons/svg/activity/damage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions icons/svg/activity/enchant.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions icons/svg/activity/heal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions icons/svg/activity/save.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d7509cf

Please sign in to comment.