240 lines
8.4 KiB
JavaScript
240 lines
8.4 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";
|
|
|
|
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-equipment-group-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,
|
|
}
|
|
|
|
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'
|
|
})
|
|
|
|
// Register sheet application classes
|
|
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'
|
|
})
|
|
|
|
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.on('dropActorSheetData', (actor, sheet, data) => {
|
|
if (data.uuid) {
|
|
if (actor.type === "character") {
|
|
return CharacterSheet.onDroppedData(actor, sheet, data);
|
|
} else {
|
|
return GroupSheet.onDroppedData(actor, sheet, data);
|
|
}
|
|
}
|
|
})
|
|
|
|
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)
|
|
});
|
|
});
|
|
|
|
async function createTalentMacro(data, slot) {
|
|
console.log(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();
|
|
}
|