Better import and various stuff

This commit is contained in:
LeRatierBretonnien 2024-08-10 09:48:43 +02:00
parent 2b1da44f3a
commit aad90144fe
22 changed files with 97 additions and 75 deletions

View File

@ -27,6 +27,12 @@ export class RMSSActor extends Actor {
_prepareCharacterData(actorData) { _prepareCharacterData(actorData) {
if (actorData.type !== "character") return; if (actorData.type !== "character") return;
console.log("*****Flag", this.getFlag("world", "importing"));
if (this.getFlag("world", "importing")) {
return; // Don't calculate skill bonuses if we are importing
}
this.calculateBasicStatBonus(actorData); this.calculateBasicStatBonus(actorData);
// Calculate Stat Bonuses for the Actor // Calculate Stat Bonuses for the Actor
@ -233,9 +239,7 @@ export class RMSSActor extends Actor {
for (const item of this.items) { for (const item of this.items) {
if (item.type === "skill") { if (item.type === "skill") {
console.log(`rmss | actor.js | Calculating skill bonus for Skill: ${item.name}`); console.log(`rmss | actor.js | Calculating skill bonus for Skill: ${item.name}`);
console.log(`rmss | actor.js | Updating Skill Category Bonus for Skill: ${item.name}`);
item.calculateSelectedSkillCategoryBonus(item); item.calculateSelectedSkillCategoryBonus(item);
console.log(`rmss | actor.js | Updating Skill Total Bonus for Skill: ${item.name}`);
item.calculateSkillTotalBonus(item); item.calculateSkillTotalBonus(item);
} }
} }

View File

@ -46,10 +46,11 @@ export class RMSSItem extends Item {
prepareDerivedData() { prepareDerivedData() {
const itemData = this; const itemData = this;
const systemData = itemData.system; const systemData = itemData.system;
const flags = itemData.flags.rmss || {};
if (this.parent?.getFlag("world", "importing")) {
return; // Don't calculate skill bonuses if we are importing
}
// Make separate methods for each item type to keep things organized. // Make separate methods for each item type to keep things organized.
if (itemData.type === "skill") { if (itemData.type === "skill") {
this._prepareSkillCategoryData(itemData); this._prepareSkillCategoryData(itemData);
} }
@ -68,6 +69,7 @@ export class RMSSItem extends Item {
_prepareSkillData(itemData) { _prepareSkillData(itemData) {
if (itemData.type !== "skill") return; if (itemData.type !== "skill") return;
console.log(`rmss | item.js | Preparing Skill Data for: ${itemData.name}`); console.log(`rmss | item.js | Preparing Skill Data for: ${itemData.name}`);
// Make modifications to data here. For example: // Make modifications to data here. For example:
// const systemData = itemData.system; // const systemData = itemData.system;
@ -103,12 +105,18 @@ export class RMSSItem extends Item {
calculateSelectedSkillCategoryBonus(itemData) { calculateSelectedSkillCategoryBonus(itemData) {
// Find the relevant skill category // Find the relevant skill category
if (!this.parent) { return; } // Only if attached to an actor
let skillC = this.parent?.items || RFRPUtility.getSkillCategories(); let skillC = this.parent?.items || RFRPUtility.getSkillCategories();
if (skillC) { if (skillC) {
let item = skillC.find(it => it.type == "skill_category" && it.name.toLowerCase() == itemData.system.category.toLowerCase()); let item = skillC.find(it => it.type == "skill_category" && it.name.toLowerCase() == itemData.system.category.toLowerCase());
if (item) {
this.system.category_bonus = item.system.total_bonus; this.system.category_bonus = item.system.total_bonus;
} else { } else {
ui.notifications.warn("No Skill Categories found. Please create a Skill Category."); ui.notifications.warn(`Skill Category ${itemData.system.category} not found for Skill ${itemData.name}`);
}
} else {
ui.notifications.info("No Skill Categories found. Please create a Skill Category.");
} }
} }
} }

View File

@ -90,11 +90,11 @@ export default class RMSSPlayerSheet extends ActorSheet {
context.system.attributes.power_points.modifier = "PP Exhaustion Penalty: -20 "; context.system.attributes.power_points.modifier = "PP Exhaustion Penalty: -20 ";
break; break;
case (powerpointPercentage < 75): case (powerpointPercentage < 75):
console.log("Less than 75"); //console.log("Less than 75");
context.system.attributes.power_points.modifier = "PP Exhaustion Penalty: -10 "; context.system.attributes.power_points.modifier = "PP Exhaustion Penalty: -10 ";
break; break;
default: default:
console.log("Setting Default"); //console.log("Setting Default");
context.system.attributes.power_points.modifier = "PP Exhaustion Penalty: 0 "; context.system.attributes.power_points.modifier = "PP Exhaustion Penalty: 0 ";
} }
@ -117,11 +117,11 @@ export default class RMSSPlayerSheet extends ActorSheet {
context.system.attributes.exhaustion_points.modifier = "Exhaustion Penalty: -15 "; context.system.attributes.exhaustion_points.modifier = "Exhaustion Penalty: -15 ";
break; break;
case (exhaustionPercentage < 75): case (exhaustionPercentage < 75):
console.log("Less than 75"); //console.log("Less than 75");
context.system.attributes.exhaustion_points.modifier = "Exhaustion Penalty: -5 "; context.system.attributes.exhaustion_points.modifier = "Exhaustion Penalty: -5 ";
break; break;
default: default:
console.log("Setting Default"); //console.log("Setting Default");
context.system.attributes.exhaustion_points.modifier = "Exhaustion Penalty: 0 "; context.system.attributes.exhaustion_points.modifier = "Exhaustion Penalty: 0 ";
} }
@ -175,28 +175,17 @@ export default class RMSSPlayerSheet extends ActorSheet {
s.skills.push(sk); s.skills.push(sk);
} }
} }
// Sort skills with localcompare
s.skills.sort((a, b) => a.name.localeCompare(b.name));
} }
// Sort Skill/Skillcat Arrays // Sort all items
skillcat.sort(function(a, b) { skillcat.sort((a, b) => a.name.localeCompare(b.name));
if (a.name < b.name) { gear.sort((a, b) => a.name.localeCompare(b.name));
return -1; weapons.sort((a, b) => a.name.localeCompare(b.name));
} armor.sort((a, b) => a.name.localeCompare(b.name));
if (a.name > b.name) { herbs.sort((a, b) => a.name.localeCompare(b.name));
return 1; spells.sort((a, b) => a.name.localeCompare(b.name));
}
return 0;
});
playerskill.sort(function(a, b) {
if (a.name < b.name) {
return -1;
}
if (a.name > b.name) {
return 1;
}
return 0;
});
// Assign and return // Assign and return
context.gear = gear; context.gear = gear;

View File

@ -11,6 +11,7 @@ export default class RMSSToolsSCImporter extends FormApplication {
static get defaultOptions() { static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, { return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["form"], classes: ["form"],
width: 520,
popOut: true, popOut: true,
title: "Import Skill Categories", title: "Import Skill Categories",
template: "systems/fvtt-rolemaster-frp/templates/sheets/apps/app_skill_category_importer.html" template: "systems/fvtt-rolemaster-frp/templates/sheets/apps/app_skill_category_importer.html"
@ -29,34 +30,38 @@ export default class RMSSToolsSCImporter extends FormApplication {
} }
async _updateObject(event, formData) { async _updateObject(event, formData) {
//console.log("Update ", event, formData); await this.character.setFlag("world", "importing", true);
let itemType = event.submitter.value; let itemType = event.submitter.value;
let toDelete = []; let toDelete = [];
for (const item of this.character.items) { for (const item of this.character.items) {
if (item.type === itemType) { if (item.type === itemType) {
toDelete.push(item.id); toDelete.push(item.id);
} }
if (itemType == "skill_category" && item.type === "skill") {
toDelete.push(item.id); // Delete also skill when re-importing skill categories.
} }
this.character.deleteEmbeddedDocuments("Item", toDelete); }
await this.character.deleteEmbeddedDocuments("Item", toDelete);
let comp = (itemType == "skill") ? formData.selectOptionsSkills : formData.selectOptionsCategories; let comp = (itemType == "skill") ? formData.selectOptionsSkills : formData.selectOptionsCategories;
const pack = game.packs.get(comp); const pack = game.packs.get(comp);
const skillCategoryData = await pack.getIndex(); const skillCategoryData = await pack.getIndex();
console.log("Importing New Skills/Skill Categories."); console.log("Importing New Skills/Skill Categories.");
let newDocuments = [];
let gameSystem = RFRPUtility.getGameSystem(); let gameSystem = RFRPUtility.getGameSystem();
for (const sc of skillCategoryData) { for (const sc of skillCategoryData) {
const newitem = await pack.getDocument(sc._id); const newitem = await pack.getDocument(sc._id);
let newDocuments = [];
if (newitem.type === itemType && (newitem.system.game_system === "common" || newitem.system.game_system === gameSystem)) { if (newitem.type === itemType && (newitem.system.game_system === "common" || newitem.system.game_system === gameSystem)) {
//console.log(newitem);
newDocuments.push(newitem); newDocuments.push(newitem);
} }
}
if (newDocuments.length > 0) { if (newDocuments.length > 0) {
await Item.createDocuments(newDocuments, {parent: this.character}); await Item.createDocuments(newDocuments, {parent: this.character});
} }
}
await this.character.setFlag("world", "importing", false);
} }
} }

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
MANIFEST-000129 MANIFEST-000137

View File

@ -1,8 +1,15 @@
2024/08/10-00:24:43.914226 7f928cc006c0 Recovering log #127 2024/08/10-08:47:18.899008 7f9286a006c0 Recovering log #135
2024/08/10-00:24:43.924061 7f928cc006c0 Delete type=3 #125 2024/08/10-08:47:18.967334 7f9286a006c0 Delete type=3 #133
2024/08/10-00:24:43.924114 7f928cc006c0 Delete type=0 #127 2024/08/10-08:47:18.967424 7f9286a006c0 Delete type=0 #135
2024/08/10-00:25:55.309370 7f9285a006c0 Level-0 table #132: started 2024/08/10-09:47:32.985517 7f9285a006c0 Level-0 table #140: started
2024/08/10-00:25:55.309406 7f9285a006c0 Level-0 table #132: 0 bytes OK 2024/08/10-09:47:32.989699 7f9285a006c0 Level-0 table #140: 25092 bytes OK
2024/08/10-00:25:55.315743 7f9285a006c0 Delete type=0 #130 2024/08/10-09:47:32.997934 7f9285a006c0 Delete type=0 #138
2024/08/10-00:25:55.337699 7f9285a006c0 Manual compaction at level-0 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end) 2024/08/10-09:47:33.008747 7f9285a006c0 Manual compaction at level-0 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)
2024/08/10-00:25:55.337766 7f9285a006c0 Manual compaction at level-1 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end) 2024/08/10-09:47:33.020954 7f9285a006c0 Manual compaction at level-1 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at '!items!yRIFroc5VC9Oj3qY' @ 192 : 1
2024/08/10-09:47:33.020989 7f9285a006c0 Compacting 1@1 + 1@2 files
2024/08/10-09:47:33.025637 7f9285a006c0 Generated table #141@1: 57 keys, 26383 bytes
2024/08/10-09:47:33.025675 7f9285a006c0 Compacted 1@1 + 1@2 files => 26383 bytes
2024/08/10-09:47:33.032592 7f9285a006c0 compacted to: files[ 0 0 1 0 0 0 0 ]
2024/08/10-09:47:33.032827 7f9285a006c0 Delete type=2 #80
2024/08/10-09:47:33.033191 7f9285a006c0 Delete type=2 #140
2024/08/10-09:47:33.050945 7f9285a006c0 Manual compaction at level-1 from '!items!yRIFroc5VC9Oj3qY' @ 192 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)

View File

@ -1,8 +1,8 @@
2024/08/10-00:20:42.417666 7f9287e006c0 Recovering log #123 2024/08/10-00:31:40.615380 7f9287e006c0 Recovering log #131
2024/08/10-00:20:42.428409 7f9287e006c0 Delete type=3 #121 2024/08/10-00:31:40.668948 7f9287e006c0 Delete type=3 #129
2024/08/10-00:20:42.428461 7f9287e006c0 Delete type=0 #123 2024/08/10-00:31:40.669000 7f9287e006c0 Delete type=0 #131
2024/08/10-00:24:00.419073 7f9285a006c0 Level-0 table #128: started 2024/08/10-08:46:35.462850 7f9285a006c0 Level-0 table #136: started
2024/08/10-00:24:00.419133 7f9285a006c0 Level-0 table #128: 0 bytes OK 2024/08/10-08:46:35.462903 7f9285a006c0 Level-0 table #136: 0 bytes OK
2024/08/10-00:24:00.425273 7f9285a006c0 Delete type=0 #126 2024/08/10-08:46:35.469319 7f9285a006c0 Delete type=0 #134
2024/08/10-00:24:00.455588 7f9285a006c0 Manual compaction at level-0 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end) 2024/08/10-08:46:35.492643 7f9285a006c0 Manual compaction at level-0 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)
2024/08/10-00:24:00.455633 7f9285a006c0 Manual compaction at level-1 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end) 2024/08/10-08:46:35.510777 7f9285a006c0 Manual compaction at level-1 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)

Binary file not shown.

Binary file not shown.

BIN
packs/skills/000047.ldb Normal file

Binary file not shown.

View File

@ -1 +1 @@
MANIFEST-000035 MANIFEST-000043

View File

@ -1,8 +1,15 @@
2024/08/10-00:24:43.926981 7f9286a006c0 Recovering log #33 2024/08/10-08:47:18.971370 7f928cc006c0 Recovering log #41
2024/08/10-00:24:43.937803 7f9286a006c0 Delete type=3 #31 2024/08/10-08:47:19.065211 7f928cc006c0 Delete type=3 #39
2024/08/10-00:24:43.937890 7f9286a006c0 Delete type=0 #33 2024/08/10-08:47:19.065338 7f928cc006c0 Delete type=0 #41
2024/08/10-00:25:55.315915 7f9285a006c0 Level-0 table #38: started 2024/08/10-09:47:33.068934 7f9285a006c0 Level-0 table #46: started
2024/08/10-00:25:55.315952 7f9285a006c0 Level-0 table #38: 0 bytes OK 2024/08/10-09:47:33.075322 7f9285a006c0 Level-0 table #46: 140828 bytes OK
2024/08/10-00:25:55.322635 7f9285a006c0 Delete type=0 #36 2024/08/10-09:47:33.081650 7f9285a006c0 Delete type=0 #44
2024/08/10-00:25:55.337719 7f9285a006c0 Manual compaction at level-0 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end) 2024/08/10-09:47:33.090270 7f9285a006c0 Manual compaction at level-0 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)
2024/08/10-00:25:55.337776 7f9285a006c0 Manual compaction at level-1 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end) 2024/08/10-09:47:33.097522 7f9285a006c0 Manual compaction at level-1 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at '!items!zYdJP3YQjsK9c3kh' @ 574 : 1
2024/08/10-09:47:33.097537 7f9285a006c0 Compacting 1@1 + 1@2 files
2024/08/10-09:47:33.105028 7f9285a006c0 Generated table #47@1: 260 keys, 146683 bytes
2024/08/10-09:47:33.105065 7f9285a006c0 Compacted 1@1 + 1@2 files => 146683 bytes
2024/08/10-09:47:33.111688 7f9285a006c0 compacted to: files[ 0 0 1 0 0 0 0 ]
2024/08/10-09:47:33.111910 7f9285a006c0 Delete type=2 #10
2024/08/10-09:47:33.112302 7f9285a006c0 Delete type=2 #46
2024/08/10-09:47:33.126561 7f9285a006c0 Manual compaction at level-1 from '!items!zYdJP3YQjsK9c3kh' @ 574 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)

View File

@ -1,8 +1,8 @@
2024/08/10-00:20:42.430762 7f9286a006c0 Recovering log #29 2024/08/10-00:31:40.672178 7f9286a006c0 Recovering log #37
2024/08/10-00:20:42.440202 7f9286a006c0 Delete type=3 #27 2024/08/10-00:31:40.729626 7f9286a006c0 Delete type=3 #35
2024/08/10-00:20:42.440254 7f9286a006c0 Delete type=0 #29 2024/08/10-00:31:40.729689 7f9286a006c0 Delete type=0 #37
2024/08/10-00:24:00.432479 7f9285a006c0 Level-0 table #34: started 2024/08/10-08:46:35.486154 7f9285a006c0 Level-0 table #42: started
2024/08/10-00:24:00.432516 7f9285a006c0 Level-0 table #34: 0 bytes OK 2024/08/10-08:46:35.486208 7f9285a006c0 Level-0 table #42: 0 bytes OK
2024/08/10-00:24:00.438691 7f9285a006c0 Delete type=0 #32 2024/08/10-08:46:35.492434 7f9285a006c0 Delete type=0 #40
2024/08/10-00:24:00.455614 7f9285a006c0 Manual compaction at level-0 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end) 2024/08/10-08:46:35.510744 7f9285a006c0 Manual compaction at level-0 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)
2024/08/10-00:24:00.455646 7f9285a006c0 Manual compaction at level-1 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end) 2024/08/10-08:46:35.510832 7f9285a006c0 Manual compaction at level-1 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)

Binary file not shown.

Binary file not shown.

View File

@ -3,7 +3,7 @@
"title": "Rolemaster FRP System", "title": "Rolemaster FRP System",
"description": "The Rolemaster FRP system for FoundryVTT.", "description": "The Rolemaster FRP system for FoundryVTT.",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-rolemaster-frp/raw/branch/develop/system.json", "manifest": "https://www.uberwald.me/gitea/public/fvtt-rolemaster-frp/raw/branch/develop/system.json",
"download": "https://www.uberwald.me/gitea/public/fvtt-rolemaster-frp/archive/v12.0.15.zip", "download": "https://www.uberwald.me/gitea/public/fvtt-rolemaster-frp/archive/v12.0.16.zip",
"authors": [ "authors": [
{ {
"name": "Cynicide", "name": "Cynicide",
@ -14,7 +14,7 @@
"email": "" "email": ""
} }
], ],
"version": "12.0.15", "version": "12.0.16",
"compatibility": { "compatibility": {
"minimum": "12", "minimum": "12",
"verified": "12" "verified": "12"

View File

@ -3,8 +3,10 @@
<h3>Import Skill Categories/Skills</h3> <h3>Import Skill Categories/Skills</h3>
<div> <div>
<span>
WARNING: This will erase your existing Skill Categories or Skills and import all Skill Categories/Skills from the selected Compendium. WARNING: This will erase your existing Skill Categories or Skills and import all Skill Categories/Skills from the selected Compendium.
Note that the import will select only skills and categories matching the "Common" items and the selected game system. Note that the import will select only skills and categories matching the "Common" items and the selected game system.
</span>
</div> </div>
<div class="flexrow"> <div class="flexrow">
<span >Select Skill Categories Compendium:</span> <span >Select Skill Categories Compendium:</span>