diff --git a/lang/en.json b/lang/en.json new file mode 100644 index 0000000..e69de29 diff --git a/less/character-sheet.less b/less/character-sheet.less new file mode 100644 index 0000000..83295bc --- /dev/null +++ b/less/character-sheet.less @@ -0,0 +1,7 @@ +// main: ./pokemon.less +.pokemon.sheet.charactersheet { + .sheet { + width: 500px; + height: 500px; + }; +} \ No newline at end of file diff --git a/less/pokemon.less b/less/pokemon.less new file mode 100644 index 0000000..fdfa27e --- /dev/null +++ b/less/pokemon.less @@ -0,0 +1,2 @@ +// relativeUrls: true, out: ../pokemon.css +@import "./character-sheet.less"; \ No newline at end of file diff --git a/modules/config.js b/modules/config.js new file mode 100644 index 0000000..478c206 --- /dev/null +++ b/modules/config.js @@ -0,0 +1,5 @@ +export const POKEMON = {}; + +POKEMON.attributes = { + Test: "TEST!" +} \ No newline at end of file diff --git a/modules/dialog.js b/modules/dialog.js new file mode 100644 index 0000000..e69de29 diff --git a/modules/dice.js b/modules/dice.js new file mode 100644 index 0000000..e69de29 diff --git a/modules/listenerFunction.js b/modules/listenerFunction.js new file mode 100644 index 0000000..e69de29 diff --git a/modules/objects/pokemonActor.js b/modules/objects/pokemonActor.js new file mode 100644 index 0000000..fa4b210 --- /dev/null +++ b/modules/objects/pokemonActor.js @@ -0,0 +1,34 @@ +export default class pokemonActor extends Actor { + preparedata() { + + // In case some steps need to be overwritten later + + super.preparedata(); + } + + prepareDerivedData() { + const actorData = this.system; + + this._preparePlayerCharacterData(actorData); + } + + _preparePlayerCharacterData(actorData) { + this._setCharacterValues(actorData); + } + + async _setCharacterValues(data) { + // Calculations of values here + } + + setNote(note) { + this.update({"system.note ": note}); + } + + addLogEntry(entry) { + // Add a log entry to the character event log + + let log = this.system.log; + log.push(entry); + this.update({"system.log": log}) + } +} \ No newline at end of file diff --git a/modules/sheets/PokemonItemSheet.js b/modules/sheets/PokemonItemSheet.js deleted file mode 100644 index 142abe6..0000000 --- a/modules/sheets/PokemonItemSheet.js +++ /dev/null @@ -1,5 +0,0 @@ -export default class PokemonItemSheet extends foundry.appv1.sheets.ItemSheet { - get template() { - return `systems/pokemon/templates/sheets/${this.item.type}-sheet.html` - } -} \ No newline at end of file diff --git a/modules/sheets/pokemonCharacterSheet.js b/modules/sheets/pokemonCharacterSheet.js new file mode 100644 index 0000000..95f1101 --- /dev/null +++ b/modules/sheets/pokemonCharacterSheet.js @@ -0,0 +1,80 @@ +const api = foundry.applications.api; +const sheets = foundry.applications.sheets; + +export default class pokemonCharacterSheet extends api.HandlebarApplicationMixin(sheets.ActorSheetV2) { + + sheetContext = {}; + + static DEFAULT_OPTIONS = { + tag: "form", + classes: ["pokemon", "sheet", "characterSheet"], + actions: { + + }, + form: { + submitOnChange: true, + closeOnSubmit: false + }, + position: { + width: 650 + } + } + + static PARTS = { + header: { template: "systems/pokemon/templates/sheets/character/header.hbs" }, + sidebar: { template: "systems/pokemon/templates/sheets/character/sidebar.hbs" } + } + + get title() { + return this.actor.name; + } + + /** @override */ + _configureRenderOptions(options) { + super._configureRenderOptions(options); + + if (this.document.limited) options.parts = ["header"] + else options.parts = ["header", "sidebar"]; + } + + /** @override */ + async _prepareContext(options) { + + // ################################################################################################# + // ################################################################################################# + // ## ## + // ## Creates Basic Datamodel, which is used to fill the HTML together with Handelbars with Data. ## + // ## ## + // ################################################################################################# + // ################################################################################################# + + const baseData = await super._prepareContext(); + + let context = { + + // Set General Values + owner: baseData.document.isOwner, + editable: baseData.editable, + actor: baseData.document, + system: baseData.document.system, + items: baseData.document.items, + config: CONFIG.POKEMON, + isGM: baseData.user.isGM, + effects: baseData.document.effects + }; + + this.sheetContext = context; + + return context; + } + + /** @override */ + _onRender(context, options) { + + const tabs = new foundry.applications.ux.Tabs({navSelector: ".tabs", contentSelector: ".content", initial: "tab1"}); + tabs.bind(this.element); + + const tabs2 = new foundry.applications.ux.Tabs({navSelector: ".tabs2", contentSelector: ".content2", initial: "tab2-1"}); + tabs2.bind(this.element); + } +} \ No newline at end of file diff --git a/modules/utils.js b/modules/utils.js new file mode 100644 index 0000000..e69de29 diff --git a/pokemon.css b/pokemon.css new file mode 100644 index 0000000..32a3301 --- /dev/null +++ b/pokemon.css @@ -0,0 +1,4 @@ +.pokemon.sheet.charactersheet .sheet { + width: 500px; + height: 500px; +} diff --git a/pokemon.js b/pokemon.js index 052f644..7acc167 100644 --- a/pokemon.js +++ b/pokemon.js @@ -1,8 +1,103 @@ -import PokemonItemSheet from "./modules/sheets/PokemonItemSheet.js"; +import { POKEMON } from "./modules/config.js"; +import pokemonActor from "./modules/objects/pokemonActor.js"; +import pokemonCharacterSheet from "./modules/sheets/pokemonCharacterSheet.js"; -Hooks.once("init", function() { - console.log("pokemon | Initializing the Pokémon system"); +Hooks.once("init", async () => { - foundry.documents.collections.Items.unregisterSheet("core", foundry.appv1.sheets.ItemSheet); - foundry.documents.collections.Items.registerSheet("pokemon", PokemonItemSheet, { makeDefault: true }); -}); \ No newline at end of file + console.log("POKEMON | Initalizing Pokémon System"); + + // Setting up the Global Configuration Object + CONFIG.POKEMON = POKEMON; + CONFIG.INIT = true; + CONFIG.Actor.documentClass = pokemonActor; + + // Register custom Sheets and unregister the start Sheets + // Items.unregisterSheet("core", ItemSheet); + + const DocumentSheetConfig = foundry.applications.apps.DocumentSheetConfig; + DocumentSheetConfig.unregisterSheet(Actor, "core", foundry.appv1.sheets.ActorSheet); + DocumentSheetConfig.registerSheet(Actor, "pokemon", pokemonCharacterSheet, { + types: ["character"], + makeDefault: true, + label: "POKEMON.SheetClassCharacter" + }) + + // Load all Partial-Handlebar Files + preloadHandlebarsTemplates(); + + // Register Additional Handelbar Helpers + registerHandlebarsHelpers(); +}); + +Hooks.once("ready", async () => { + + // Finished Initalization Phase and release lock + CONFIG.INIT = false; + + // Only execute when run as Gamemaster + if(!game.user.isGM) return; +}); + +function preloadHandlebarsTemplates() { + + const templatePaths = [ + + "systems/pokemon/templates/partials/character-sheet-character.hbs", + "systems/pokemon/templates/partials/character-sheet-background.hbs", + "systems/pokemon/templates/partials/character-sheet-moves.hbs" + + ]; + + return foundry.applications.handlebars.loadTemplates(templatePaths); +}; + +function registerHandlebarsHelpers() { + + Handlebars.registerHelper("equals", function(v1, v2) { return (v1 === v2)}); + + Handlebars.registerHelper("contains", function(element, search) { return (element.includes(search))}); + + Handlebars.registerHelper("concat", function(s1, s2, s3 = "") { return s1 + s2 + s3;}); + + Handlebars.registerHelper("isGreater", function(p1, p2) { return (p1 > p2)}); + + Handlebars.registerHelper("isEqualORGreater", function(p1, p2) { return (p1 >= p2)}); + + Handlebars.registerHelper("ifOR", function(conditional1, conditional2) { return (conditional1 || conditional2)}); + + Handlebars.registerHelper("doLog", function(value) { console.log(value)}); + + Handlebars.registerHelper("toBoolean", function(string) { return (string === "true")}); + + Handlebars.registerHelper('for', function(from, to, incr, content) { + + let result = ""; + + for(let i = from; i < to; i += incr) + result += content.fn(i); + + return result; + }); + + Handlebars.registerHelper("times", function(n, content) { + + let result = ""; + + for(let i = 0; i < n; i++) + result += content.fn(i); + + return result; + }); + + Handlebars.registerHelper("notEmpty", function(value) { + + if (value == 0 || value == "0") return true; + if (value == null|| value == "") return false; + return true; + }); +} + + +/* -------------------------------------------- */ +/* General Functions */ +/* -------------------------------------------- */ \ No newline at end of file diff --git a/system.json b/system.json index 70447bf..57cfd95 100644 --- a/system.json +++ b/system.json @@ -1,5 +1,5 @@ { - "version": "0.0.7", + "version": "0.0.8", "id": "pokemon", "title": "Pokémon TTRPG", "description": "A Pokémon TTRPG", @@ -19,11 +19,23 @@ "esmodules": [ "pokemon.js" ], - "styles": [], + "styles": [ + "pokemon.css" + ], "packs": [], - "languages": [], + "languages": [ + { + "lang": "en", + "name": "English", + "path": "lang/en.json" + } + ], "socket": false, - "url": "https://git.ingemanngade.net/NikolajDanger/pokemon-foundry/raw/branch/main/", + "grid": { + "distance": 5, + "units": "ft" + }, + "url": "https://git.ingemanngade.net/NikolajDanger/pokemon-foundry/", "manifest": "https://git.ingemanngade.net/NikolajDanger/pokemon-foundry/raw/branch/main/system.json", "download": "https://git.ingemanngade.net/NikolajDanger/pokemon-foundry/raw/branch/main/system.zip" } \ No newline at end of file diff --git a/template.json b/template.json index 0005648..11cf7bc 100644 --- a/template.json +++ b/template.json @@ -1,16 +1,86 @@ { - "Actor": {}, - "Item": { - "types": ["item"], - "templates": { - "base": { - "description": "" - } + "Actor": { + + "types": [ + "character" + ], + + "character": { + "species": "", + + "experience": { + "level": 1, + "EXP": 0 + }, + + "armor class": 0, + "stats": { + "attack": { + "value": 0, + "modifier": 0 + }, + "defense": { + "value": 0, + "modifier": 0 + }, + "move": { + "value": 0, + "modifier": 0 + }, + "hp": { + "value": 0, + "modifier": 0 + } + }, + "speed": 0, + "hp": { + "max": 0, + "current": 0 + }, + "moves": { + "move 1": { + "category": 0, + "type": 0, + "description": "" + }, + "move 2": { + "category": 0, + "type": 0, + "description": "" + }, + "move 3": { + "category": 0, + "type": 0, + "description": "" + }, + "move 4": { + "category": 0, + "type": 0, + "description": "" + } + } + } }, - "item": { - "templates": ["base"], - "quantity": 1, - "weight": 0 + + "Item": { + + "types":[ + "Item" + ], + + "templates": { + + "generalItems": { + "weight": 10, + "value": 100, + "description": "" + } + }, + + "Item": { + "templates": ["generalItems"], + "type": "item", + "quantity": 1 + } } - } } \ No newline at end of file diff --git a/templates/sheets/character/header.hbs b/templates/sheets/character/header.hbs new file mode 100644 index 0000000..57e6d84 --- /dev/null +++ b/templates/sheets/character/header.hbs @@ -0,0 +1,17 @@ +
+ + {{!--
+
{{localize "POKEMON.SystemName"}}
+
--}} + +
+ +
+
{{localize "POKEMON.System.LevelShort"}}
+
{{system.experience.level}}
+
+
+
{{system.experience.EXP}} EXP
+
+
+
\ No newline at end of file diff --git a/templates/sheets/character/sidebar b/templates/sheets/character/sidebar new file mode 100644 index 0000000..325893d --- /dev/null +++ b/templates/sheets/character/sidebar @@ -0,0 +1,89 @@ +
+
+ +
+ +
+
HP
{{system.hp.current}}
+
Max
{{system.hp.max}}
+
+
{{localize "POKEMON.System.Attack"}}
{{system.stats}}
+
+ + + +
+
+
+ {{> "systems/nether/templates/partials/character-sheet-character.hbs"}} +
+ +
+ {{> "systems/nether/templates/partials/character-sheet-background.hbs"}} +
+ +
+ {{> "systems/nether/templates/partials/character-sheet-skill.hbs"}} +
+ +
+ {{> "systems/nether/templates/partials/character-sheet-combat.hbs"}} +
+ +
+ {{> "systems/nether/templates/partials/character-sheet-progression.hbs"}} +
+ +
+ Pfade +
+ +
+ Settings +
+
+
+
\ No newline at end of file diff --git a/templates/sheets/item-sheet.html b/templates/sheets/item-sheet.html deleted file mode 100644 index 090a776..0000000 --- a/templates/sheets/item-sheet.html +++ /dev/null @@ -1,7 +0,0 @@ -
-
- -

-
-

HELLO TEST

-
\ No newline at end of file