271 lines
9.9 KiB
JavaScript
271 lines
9.9 KiB
JavaScript
import {PlayerCharacterDataModel} from "./module/data/character.mjs";
|
|
import {SkillSheet} from "./module/sheets/skillSheet.mjs";
|
|
import {SpellSheet} from "./module/sheets/spellSheet.mjs";
|
|
import {SkillDataModel} from "./module/data/skill.mjs";
|
|
import {SpellDataModel} from "./module/data/spell.mjs";
|
|
import {VornachteileDataModel} from "./module/data/vornachteile.mjs";
|
|
import {Character} from "./module/documents/character.mjs";
|
|
import CharacterSheet from "./module/sheets/characterSheet.mjs";
|
|
import {AdvantageSheet} from "./module/sheets/advantageSheet.mjs";
|
|
import {GroupDataModel} from "./module/data/group.mjs";
|
|
import {GroupSheet} from "./module/sheets/groupSheet.mjs";
|
|
import {EquipmentDataModel} from "./module/data/equipment.mjs";
|
|
import {EquipmentSheet} from "./module/sheets/equipmentSheet.mjs";
|
|
import {CreatureDataModel} from "./module/data/creature.mjs";
|
|
import {CreatureSheet} from "./module/sheets/creatureSheet.mjs";
|
|
import {LiturgySheet} from "./module/sheets/liturgySheet.mjs";
|
|
import {LiturgyDataModel} from "./module/data/liturgy.mjs";
|
|
import {BlessingDataModel} from "./module/data/blessing.mjs";
|
|
import {SpecialAbilityDataModel} from "./module/data/specialAbility.mjs";
|
|
import {SpecialAbilitySheet} from "./module/sheets/specialAbilitySheet.mjs";
|
|
import {ActiveEffectSheet} from "./module/sheets/ActiveEffectSheet.mjs";
|
|
import {ActiveEffectDataModel} from "./module/data/activeeffect.mjs";
|
|
import {Trefferzone, Wunde, Zonenruestung, Zonenwunde} from "./module/data/Trefferzone.js";
|
|
import {ProfessionDataModel} from "./module/data/profession.mjs";
|
|
import {SpeciesDataModel} from "./module/data/species.mjs";
|
|
import {CultureDataModel} from "./module/data/culture.mjs";
|
|
import {CultureSheet} from "./module/sheets/CultureSheet.mjs";
|
|
import {SpeciesSheet} from "./module/sheets/SpeciesSheet.mjs";
|
|
import {ProfessionSheet} from "./module/sheets/ProfessionSheet.mjs";
|
|
import {XmlImportDialog} from "./module/dialog/xmlImportDialog.mjs";
|
|
async function preloadHandlebarsTemplates() {
|
|
return foundry.applications.handlebars.loadTemplates([
|
|
// ui partials.
|
|
'systems/DSA_4-1/templates/ui/partial-rollable-button.hbs',
|
|
'systems/DSA_4-1/templates/ui/partial-rollable-weaponskill-button.hbs',
|
|
'systems/DSA_4-1/templates/ui/partial-rollable-language-button.hbs',
|
|
'systems/DSA_4-1/templates/ui/partial-attribute-button.hbs',
|
|
'systems/DSA_4-1/templates/ui/partial-talent-editable.hbs',
|
|
'systems/DSA_4-1/templates/ui/partial-die.hbs',
|
|
'systems/DSA_4-1/templates/ui/partial-advantage-button.hbs',
|
|
'systems/DSA_4-1/templates/ui/partial-sf-button.hbs',
|
|
'systems/DSA_4-1/templates/ui/partial-action-button.hbs',
|
|
'systems/DSA_4-1/templates/ui/partial-equipment-button.hbs',
|
|
'systems/DSA_4-1/templates/ui/partial-array-editor.hbs',
|
|
'systems/DSA_4-1/templates/dialog/modify-liturgy.hbs'
|
|
]);
|
|
}
|
|
|
|
Hooks.once("init", () => {
|
|
|
|
game.DSA41 = {
|
|
rollItemMacro,
|
|
Zonenruestung,
|
|
Zonenwunde,
|
|
Trefferzone,
|
|
Wunde
|
|
}
|
|
|
|
// Configure custom Document implementations.
|
|
CONFIG.Actor.documentClass = Character;
|
|
|
|
// Configure System Data Models.
|
|
CONFIG.Actor.dataModels = {
|
|
character: PlayerCharacterDataModel,
|
|
group: GroupDataModel,
|
|
creature: CreatureDataModel,
|
|
};
|
|
|
|
CONFIG.Item.dataModels = {
|
|
Skill: SkillDataModel,
|
|
Spell: SpellDataModel,
|
|
Advantage: VornachteileDataModel,
|
|
Equipment: EquipmentDataModel,
|
|
Liturgy: LiturgyDataModel,
|
|
Blessing: BlessingDataModel,
|
|
SpecialAbility: SpecialAbilityDataModel,
|
|
ActiveEffect: ActiveEffectDataModel,
|
|
Profession: ProfessionDataModel,
|
|
Spezies: SpeciesDataModel,
|
|
Kultur: CultureDataModel,
|
|
}
|
|
|
|
CONFIG.Combat.initiative = {
|
|
formula: `(@ini.wuerfel)d6 + @ini.aktuell`,
|
|
decimals: 0
|
|
}
|
|
|
|
console.log("DSA 4.1 is ready for development!")
|
|
|
|
foundry.documents.collections.Actors.registerSheet('dsa41.character', CharacterSheet, {
|
|
types: ["character"],
|
|
makeDefault: true,
|
|
label: 'DSA41.CharacterLabels.Item'
|
|
})
|
|
foundry.documents.collections.Actors.registerSheet('dsa41.creature', CreatureSheet, {
|
|
types: ["creature"],
|
|
makeDefault: true,
|
|
label: 'DSA41.CreatureLabel.Item'
|
|
})
|
|
foundry.documents.collections.Actors.registerSheet('dsa41.group', GroupSheet, {
|
|
types: ["group"],
|
|
makeDefault: true,
|
|
label: 'DSA41.GroupLabel.Item'
|
|
})
|
|
foundry.documents.collections.Items.registerSheet('dsa41.skill', SkillSheet, {
|
|
types: ["Skill"],
|
|
makeDefault: true,
|
|
label: 'DSA41.SkillLabels.Item',
|
|
});
|
|
foundry.documents.collections.Items.registerSheet('dsa41.spell', SpellSheet, {
|
|
types: ["Spell"],
|
|
makeDefault: true,
|
|
label: 'DSA41.SpellLabels.Item',
|
|
});
|
|
foundry.documents.collections.Items.registerSheet('dsa41.advantage', AdvantageSheet, {
|
|
types: ["Advantage"],
|
|
makeDefault: true,
|
|
label: 'DSA41.VornachteilLabels.Item'
|
|
})
|
|
foundry.documents.collections.Items.registerSheet('dsa41.equipment', EquipmentSheet, {
|
|
types: ["Equipment"],
|
|
makeDefault: false,
|
|
label: 'DSA41.AusruestungLabels.Item'
|
|
})
|
|
foundry.documents.collections.Items.registerSheet('dsa41.liturgy', LiturgySheet, {
|
|
types: ["Liturgy"],
|
|
makeDefault: true,
|
|
label: 'DSA41.LiturgyLabels.Item'
|
|
})
|
|
foundry.documents.collections.Items.registerSheet('dsa41.specialAbility', SpecialAbilitySheet, {
|
|
types: ["SpecialAbility"],
|
|
makeDefault: true,
|
|
label: 'DSA41.SpecialAbilityLabels.Item'
|
|
})
|
|
foundry.documents.collections.Items.registerSheet('dsa41.activeEffect', ActiveEffectSheet, {
|
|
types: ['ActiveEffect'],
|
|
makeDefault: true,
|
|
label: 'DSA41.ActiveEffectLabels.ActiveEffect'
|
|
})
|
|
foundry.documents.collections.Items.registerSheet('dsa41.culture', CultureSheet, {
|
|
types: ['Culture'],
|
|
makeDefault: true,
|
|
label: 'DSA41.CultureLabels.Culture'
|
|
})
|
|
foundry.documents.collections.Items.registerSheet('dsa41.spezien', SpeciesSheet, {
|
|
types: ['Species'],
|
|
makeDefault: true,
|
|
label: 'DSA41.SpeciesLabels.Species'
|
|
})
|
|
foundry.documents.collections.Items.registerSheet('dsa41.profession', ProfessionSheet, {
|
|
types: ['Profession'],
|
|
makeDefault: true,
|
|
label: 'DSA41.ProfessionLabels.Profession'
|
|
})
|
|
|
|
game.settings.register('DSA_4-1', 'optional_colorfuldice', {
|
|
name: "Optional: Farbige Würfel nach Paramanthus",
|
|
hint: "Färbt die Würfel je nach Attribut ein",
|
|
scope: "client",
|
|
config: true,
|
|
type: Boolean,
|
|
default: false,
|
|
onChange: value => {
|
|
},
|
|
requiresReload: false
|
|
})
|
|
game.settings.register('DSA_4-1', 'optional_trefferzonen', {
|
|
name: "Optional: Trefferzonen",
|
|
hint: "Ersetzt das Wundensystem aus dem BRW durch das Trefferzonensystem aus WdH",
|
|
scope: "world",
|
|
config: true,
|
|
type: Boolean,
|
|
default: false,
|
|
onChange: value => {
|
|
},
|
|
requiresReload: true
|
|
})
|
|
game.settings.register('DSA_4-1', 'optional_ruestungzonen', {
|
|
name: "Optional: Zonenrüstung",
|
|
hint: "Ersetzt das Rüstungssystem aus dem BRW durch das Zonenrüstungssystem aus WdH",
|
|
scope: "world",
|
|
config: true,
|
|
type: Boolean,
|
|
default: false,
|
|
onChange: value => {
|
|
},
|
|
requiresReload: true
|
|
})
|
|
game.settings.register('DSA_4-1', 'optional_ausdauer', {
|
|
name: "Optional: Ausdauerregeln",
|
|
hint: "Aktiviert Regeln für das Spiel mit Ausdauer",
|
|
scope: "world",
|
|
config: true,
|
|
type: Boolean,
|
|
default: false,
|
|
onChange: value => {
|
|
},
|
|
requiresReload: true
|
|
})
|
|
game.settings.register('DSA_4-1', 'optional_distanzklassen', {
|
|
name: "Optional: Distanzklassen",
|
|
hint: "Aktiviert Regeln für das Spiel mit Distanzklassen",
|
|
scope: "world",
|
|
config: true,
|
|
type: Boolean,
|
|
default: false,
|
|
onChange: value => {
|
|
},
|
|
requiresReload: true
|
|
})
|
|
|
|
return preloadHandlebarsTemplates();
|
|
})
|
|
|
|
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) => {
|
|
return createTalentMacro(data, slot)
|
|
});
|
|
});
|
|
|
|
|
|
Hooks.on("getActorContextOptions", (application, menuItems) => {
|
|
menuItems.push({
|
|
name: "Import from XML",
|
|
icon: '<i class="fas fa-file"></i>',
|
|
callback: (li) => {
|
|
const actorId = li.getAttribute("data-entry-id")
|
|
const actor = game.actors.get(actorId)
|
|
//actor.import()
|
|
new XmlImportDialog(actor).render(true)
|
|
}
|
|
})
|
|
})
|
|
|
|
async function createTalentMacro(data, slot) {
|
|
if (data.type !== "Item") return;
|
|
|
|
const uuid = foundry.utils.parseUuid(data.uuid)
|
|
|
|
const itemId = uuid.id;
|
|
const actorId = uuid.primaryId;
|
|
const item = await game.actors.get(actorId).items.get(itemId);
|
|
|
|
// Create the macro command
|
|
const command = `game.DSA41.rollItemMacro("${data.uuid}");`;
|
|
|
|
const macro = await Macro.create({
|
|
name: item.name,
|
|
type: "script",
|
|
img: item.img,
|
|
command: command,
|
|
flags: {"dsa41.skillMacro": true}
|
|
});
|
|
|
|
game.user.assignHotbarMacro(macro, slot);
|
|
return false;
|
|
}
|
|
|
|
function rollItemMacro(_uuid) {
|
|
const speaker = ChatMessage.getSpeaker();
|
|
const uuid = foundry.utils.parseUuid(_uuid)
|
|
const itemId = uuid.id;
|
|
const actorId = uuid.primaryId;
|
|
let actor = game.actors.get(actorId);
|
|
const item = actor ? actor.items.get(itemId) : null;
|
|
if (!item) return ui.notifications.warn(`Your controlled Actor does not have an item with id ${itemId}`);
|
|
|
|
return item.system.roll();
|
|
}
|