Skip to content

Commit

Permalink
weapon imports for martial arts
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliharu committed Mar 3, 2024
1 parent ef1432a commit ee8a214
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 22 deletions.
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"Ex3.InitiativeIconColor": "Initiative Icon Color",
"Ex3.Flowing": "Flowing",
"Ex3.Still": "Still",
"Ex3.Both": "Both",
"Ex3.ActivateAura": "Activate Aura",
"Ex3.Aura": "Aura",
"Ex3.HasAura": "Has Aura",
Expand Down
40 changes: 24 additions & 16 deletions module/apps/template-importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ export default class TemplateImporter extends FormApplication {


async createOther(html) {
const martialArtsWeapons = await foundry.utils.fetchJsonWithTimeout('systems/exaltedthird/module/data/martialArtsWeapons.json', {}, { int: 30000 });
var textArray = html.find('#template-text').val().split(/\r?\n/);
var itemType = html.find('#itemType').val();
var index = 0;
Expand Down Expand Up @@ -490,22 +491,14 @@ export default class TemplateImporter extends FormApplication {
itemData.img = "systems/exaltedthird/assets/icons/punch-blast.svg";
itemData.type = 'customability';
itemData.system.abilitytype = 'martialart';
// const weaponMatches = description.match(/Weapons:(.*?)Armor:/s);
// if (weaponMatches) {
// const extractedText = weaponMatches[1].trim().replace(/[^\w\s]/gi, '').toLowerCase();
// var weaponsList = [];
// for (const weapon of Object.keys(weapons)) {
// if (extractedText.includes(weapon)) {
// weaponsList.push(weapon);
// }
// }
// itemData.system.traits = {
// "weapons": {
// "value": weaponsList,
// "custom": ""
// }
// }
// }
if (martialArtsWeapons[itemData.name]) {
itemData.system.traits = {
weapons: {
"value": martialArtsWeapons[itemData.name],
"custom": ""
}
}
}
const armorMatches = description.match(/Armor:(.*)/);
if (armorMatches) {
const extractedText = armorMatches[1].trim().toLowerCase();
Expand All @@ -522,6 +515,21 @@ export default class TemplateImporter extends FormApplication {
itemData.system.armorallowance = "none";
}
}

const natureMatches = description.match(/Nature:(.*)/);
if (natureMatches) {
const extractedText = natureMatches[1].trim().toLowerCase();
itemData.system.siderealmartialart = true;
if (extractedText.includes('still') && extractedText.includes('flowing')) {
itemData.system.nature = 'both';
}
else if (extractedText.includes('still')) {
itemData.system.nature = 'still';
}
else if (extractedText.includes('flowing')) {
itemData.system.nature = 'flowing';
}
}
}
itemData.system.description = description;
if (folder) {
Expand Down
179 changes: 179 additions & 0 deletions module/data/martialArtsWeapons.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
{
"Air Dragon Style": [
"chakrams",
"unarmed"
],
"Bear Style": [
"unarmed"
],
"Black Claw Style": [
"unarmed"
],
"Centipede Style": [
"fightingchains",
"hookswords",
"ironboots",
"sevenectionstaffs",
"unarmed"
],
"Charcoal March of Spiders Style": [
"fightingchains",
"knives",
"meteorhammers",
"nunchakus",
"ropedarts",
"sevenectionstaffs",
"unarmed",
"whips"
],
"Citrine Poxes of Contagion Style": [
"handneedles",
"ropedarts",
"unarmed"
],
"Crane Style": [
"hookswords",
"unarmed",
"warfans"
],
"Earth Dragon Style": [
"tetsubos",
"unarmed"
],
"Ebon Shadow Style": [
"knives",
"sais",
"tigerclaws",
"unarmed"
],
"Emerald Gyre of Aeons Style": [
"kusarigamas",
"melee",
"nunchakus",
"ropedarts",
"sevenectionstaffs",
"staffs",
"unarmed",
"windandfirewheels"
],
"Falcon Style": [
"cestus",
"improvised",
"ironboots",
"tigerclaws",
"unarmed"
],
"Fire Dragon Style": [
"shortswords",
"unarmed"
],
"Golden Janissary Style": [
"spears",
"staffs",
"unarmed"
],
"Laughing Monster Style": [
"staffs",
"unarmed",
"warfans",
"whips"
],
"Mantis Style": [
"batons",
"kamas",
"nunchakus",
"sevenectionstaffs",
"unarmed",
"warfans"
],
"Monkey Style": [
"batons",
"improvised",
"sevenectionstaffs",
"staffs",
"unarmed"
],
"Obsidian Shards of Infinity Style": [
"khatars",
"knives",
"sais",
"unarmed"
],
"Prismatic Arrangement of Creation Style": [],
"Rat Style": [
"knives",
"tigerclaws",
"unarmed"
],
"Righteous Devil Style": [
"flame"
],
"Silver-Voiced Nightingale Style": [
"kiais",
"unarmed"
],
"Single Point Shining Into the Void Style": [
"slashingswords"
],
"Snake Style": [
"hookswords",
"sevenectionstaffs",
"unarmed"
],
"Steel Devil Style": [
"dualswords"
],
"Swaying Grass Dance Style": [
"batons",
"ironboots",
"knives",
"unarmed"
],
"Thousand Blades Style": [
"melee"
],
"Throne Shadow Style": [
"fightingchains",
"ropedarts",
"sevenectionstaffs",
"staffs",
"unarmed",
"windandfirewheels"
],
"Tiger Style": [
"tigerclaws",
"unarmed"
],
"Toad Style": [
"unarmed"
],
"Violet Bier of Sorrows Style": [
"choppingswords",
"greatswords",
"knives",
"sevenectionstaffs",
"straightswords",
"staffs",
"unarmed"
],
"Water Dragon Style": [
"tigerclaws",
"unarmed"
],
"White Reaper Style": [
"scythes",
"spears",
"staffs",
"unarmed"
],
"White Veil Style": [
"garrotes",
"handneedles",
"unarmed"
],
"Wood Dragon Style": [
"bows",
"staffs",
"unarmed"
]
}
12 changes: 8 additions & 4 deletions module/exaltedthird.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ Hooks.once('init', async function () {
Die.prototype.doubleSuccess = function (modifier) {
const rgx = /(?:ds)([<>=]+)?([0-9]+)?/i;
const match = modifier.match(rgx);
if ( !match ) return false;
if (!match) return false;
let [comparison, target] = match.slice(1);
comparison = comparison || "=";
target = parseInt(target) ?? this.faces;
for ( let r of this.results ) {
for (let r of this.results) {
let success = DiceTerm.compareResult(r.result, comparison, target);
if(!r.success) {
if (!r.success) {
r.success = success;
}
r.count += (success ? 1 : 0);
Expand Down Expand Up @@ -1140,7 +1140,11 @@ Hooks.once("ready", async function () {
ui.notifications.notify(`Migration Complete`);
await game.settings.set("exaltedthird", "systemMigrationVersion", game.system.version);
}

const map = {}
for (const martialArt of game.items.filter(item => item.type === 'customability' && item.system.abilitytype === 'martialart')) {
map[martialArt.name] = martialArt.system.traits.weapons.value;
}
console.log(map);
// for(const martialArt of CONFIG.exaltedthird.martialarts) {
// console.log(martialArt);
// let folder = game.folders.filter(folder => folder.name === 'Martial Arts')[0];
Expand Down
1 change: 1 addition & 0 deletions template.json
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@
"siderealmartialart": false,
"excellency": false,
"armorallowance": "",
"nature": "",
"traits": {
"weapons": {
"value": [],
Expand Down
17 changes: 15 additions & 2 deletions templates/item/item-customability-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,27 @@ <h1 class="itemname"><input name="name" type="text" value="{{item.name}}" placeh
<div class="resource-label">{{localize "Ex3.Favored"}}</div>
<input name="system.favored" type="checkbox" value="system.favored" {{checked system.favored}}>
</div>
<div>
<div class="resource-label">{{localize "Ex3.Excellency"}}</div>
<input name="system.excellency" type="checkbox" value="system.excellency" {{checked system.excellency}}>
</div>
<div>
<div class="resource-label">{{localize "Ex3.SiderealMartialArt"}}</div>
<input name="system.siderealmartialart" type="checkbox" value="system.siderealmartialart" {{checked system.siderealmartialart}}>
</div>
{{#if system.siderealmartialart}}
<div>
<div class="resource-label">{{localize "Ex3.Excellency"}}</div>
<input name="system.excellency" type="checkbox" value="system.excellency" {{checked system.excellency}}>
<div class="resource-label">{{localize "Ex3.Nature"}}</div>
<select name="system.nature" data-type="String">
{{#select system.nature}}
<option value="">{{localize "Ex3.None"}}</option>
<option value="flowing">{{localize "Ex3.Flowing"}}</option>
<option value="still">{{localize "Ex3.Still"}}</option>
<option value="both">{{localize "Ex3.Both"}}</option>
{{/select}}
</select>
</div>
{{/if}}
</div>
{{> systems/exaltedthird/templates/actor/active-effects.html}}
</div>
Expand Down

0 comments on commit ee8a214

Please sign in to comment.