Skip to content

Commit

Permalink
Merge pull request #192 from SolarBear/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
SolarBear committed Jul 3, 2021
2 parents 60f4d92 + f1f0e85 commit d680c4c
Show file tree
Hide file tree
Showing 20 changed files with 334 additions and 193 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
node_modules
dist/
*.css
!lib/**/*.css
*.zip
*.code-workspace
11 changes: 11 additions & 0 deletions module/actor/sheets/NumeneraCommunityActorSheet.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { removeHtmlTags } from "../../utils.js";

/**
* Extend the basic ActorSheet class to do all the Numenera things!
*
Expand Down Expand Up @@ -26,6 +28,9 @@ export class NumeneraCommunityActorSheet extends ActorSheet {
* @type {String}
*/
get template() {
if (this.actor.getUserLevel() < CONST.ENTITY_PERMISSIONS.OBSERVER)
return "systems/numenera/templates/actor/communitySheetLimited.html";

return "systems/numenera/templates/actor/communitySheet.html";
}

Expand All @@ -40,6 +45,12 @@ export class NumeneraCommunityActorSheet extends ActorSheet {
if (game.data.version.startsWith("0.8."))
sheetData.data = sheetData.data.data;

if (this.actor.getUserLevel() < CONST.ENTITY_PERMISSIONS.OBSERVER)
{
sheetData.data.overview = removeHtmlTags(sheetData.data.overview);
this.position.height = 350;
}

return sheetData;
}
}
10 changes: 10 additions & 0 deletions module/actor/sheets/NumeneraNPCActorSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { onItemCreateGenerator, onItemDeleteGenerator, onItemEditGenerator, sort

import { NUMENERA } from "../../config.js";
import { NumeneraNpcAttackItem } from "../../item/NumeneraNPCAttack.js";
import { removeHtmlTags } from "../../utils.js";

/**
* Extend the basic ActorSheet class to do all the Numenera things!
Expand Down Expand Up @@ -39,6 +40,9 @@ export class NumeneraNPCActorSheet extends ActorSheet {
* @type {String}
*/
get template() {
if (this.actor.getUserLevel() < CONST.ENTITY_PERMISSIONS.OBSERVER)
return "systems/numenera/templates/actor/npcSheetLimited.html";

return "systems/numenera/templates/actor/npcSheet.html";
}

Expand All @@ -63,6 +67,12 @@ export class NumeneraNPCActorSheet extends ActorSheet {
//if (!sheetData.data.attacks)
sheetData.data.attacks = items.filter(i => i.type === NumeneraNpcAttackItem.type).sort(sortFunction);

if (this.actor.getUserLevel() < CONST.ENTITY_PERMISSIONS.OBSERVER)
{
sheetData.data.notes = removeHtmlTags(sheetData.data.notes);
this.position.height = 350;
}

return sheetData;
}

Expand Down
34 changes: 22 additions & 12 deletions module/actor/sheets/NumeneraPCActorSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ export class NumeneraPCActorSheet extends ActorSheet {
if (game.data.version.startsWith("0.7."))
return "systems/numenera/templates/actor/characterSheet07.html";

if (this.actor.getUserLevel() < CONST.ENTITY_PERMISSIONS.OBSERVER)
return "systems/numenera/templates/actor/characterSheetLimited.html";

return "systems/numenera/templates/actor/characterSheet.html";
}

Expand All @@ -150,11 +153,17 @@ export class NumeneraPCActorSheet extends ActorSheet {
if (game.data.version.startsWith("0.8."))
sheetData.data = sheetData.data.data;

this._setLabelsData(sheetData);
this._setCypherTypeData(sheetData);
this._setIconSettingsData(sheetData);
this._setComputedValuesData(sheetData);
this._setItemsData(sheetData);
if (this.actor.getUserLevel() >= CONST.ENTITY_PERMISSIONS.OBSERVER) {
this._setLabelsData(sheetData);
this._setCypherTypeData(sheetData);
this._setIconSettingsData(sheetData);
this._setComputedValuesData(sheetData);
this._setItemsData(sheetData);
}
else {
sheetData.data.background = removeHtmlTags(sheetData.data.background);
this.position.height = 400;
}

return sheetData;
}
Expand Down Expand Up @@ -376,7 +385,7 @@ export class NumeneraPCActorSheet extends ActorSheet {
if (game.data.version.startsWith("0.7."))
oddity.data.notes = removeHtmlTags(oddity.data.notes);
else
oddity.data.notes = removeHtmlTags(oddity.data.notes);
oddity.data.data.notes = removeHtmlTags(oddity.data.data.notes);
return oddity;
});

Expand All @@ -400,7 +409,7 @@ export class NumeneraPCActorSheet extends ActorSheet {
if (game.data.version.startsWith("0.7."))
powerShift.data.notes = removeHtmlTags(powerShift.data.notes);
else
powerShift.data.notes = removeHtmlTags(powerShift.data.notes);
powerShift.data.data.notes = removeHtmlTags(powerShift.data.data.notes);
return powerShift;
});

Expand Down Expand Up @@ -500,7 +509,7 @@ export class NumeneraPCActorSheet extends ActorSheet {
if (game.data.version.startsWith("0.7."))
weapon.data.notes = removeHtmlTags(weapon.data.notes);
else
weapon.data.notes = removeHtmlTags(weapon.data.notes);
weapon.data.data.notes = removeHtmlTags(weapon.data.data.notes);
return weapon;
});

Expand All @@ -509,7 +518,7 @@ export class NumeneraPCActorSheet extends ActorSheet {
if (game.data.version.startsWith("0.7."))
armor.data.notes = removeHtmlTags(armor.data.notes);
else
armor.data.notes = removeHtmlTags(armor.data.notes);
armor.data.data.notes = removeHtmlTags(armor.data.data.notes);
return armor;
});

Expand All @@ -518,7 +527,7 @@ export class NumeneraPCActorSheet extends ActorSheet {
if (game.data.version.startsWith("0.7."))
equipment.data.notes = removeHtmlTags(equipment.data.notes);
else
equipment.data.notes = removeHtmlTags(equipment.data.notes);
equipment.data.data.notes = removeHtmlTags(equipment.data.data.notes);
return equipment;
});

Expand All @@ -541,7 +550,7 @@ export class NumeneraPCActorSheet extends ActorSheet {
sheetData.abilityTypes = NUMENERA.abilityTypes;

sheetData.data.abilities = sheetData.data.abilities.map(ability => {
const abilityData = game.data.version.startsWith("0.7.") ? ability.data : ability.data;
const abilityData = game.data.version.startsWith("0.7.") ? ability.data : ability.data.data;
ability.nocost = (abilityData.cost.amount <= 0);
ability.ranges = NUMENERA.optionalRanges;
ability.stats = NUMENERA.stats;
Expand All @@ -562,7 +571,7 @@ export class NumeneraPCActorSheet extends ActorSheet {
*/
_setSkillsData(sheetData) {
sheetData.data.skills = sheetData.data.skills.map(skill => {
const skillData = game.data.version.startsWith("0.7.") ? skill.data : skill.data;
const skillData = game.data.version.startsWith("0.7.") ? skill.data : skill.data.data;
skill.stats = NUMENERA.stats;
skill.showIcon = skill.img && sheetData.settings.icons.skills;
skill.untrained = skillData.skillLevel == 0;
Expand Down Expand Up @@ -590,6 +599,7 @@ export class NumeneraPCActorSheet extends ActorSheet {
const abilitiesTable = html.find("table.abilities");
abilitiesTable.on("click", ".ability-create", this.onAbilityCreate.bind(this));
abilitiesTable.on("click", ".ability-delete", this.onAbilityDelete.bind(this));
abilitiesTable.on("click", ".ability-to-chat", this.onAbilityDelete.bind(this));
abilitiesTable.on("blur", "input,select,textarea", this.onAbilityEdit.bind(this));
abilitiesTable.on("click", "a.rollable", this.onAbilityUse.bind(this));

Expand Down
4 changes: 2 additions & 2 deletions module/item/NumeneraArtifactItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export class NumeneraArtifactItem extends Item {
}
else {
if (actor === null)
artifactItem = await actor.createEmbeddedDocuments("Item", [this.object]);
else
artifactItem = new Item(this.object);
else
artifactItem = await actor.createEmbeddedDocuments("Item", [this.object]);
}

artifactItem.data._id = ownedItem._id;
Expand Down
4 changes: 2 additions & 2 deletions module/item/NumeneraCypherItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export class NumeneraCypherItem extends Item {
}
else {
if (actor === null)
cypherItem = await actor.createEmbeddedDocuments("Item", [this.object]);
else
cypherItem = new Item(this.object);
else
cypherItem = await actor.createEmbeddedDocuments("Item", [this.object]);
}

cypherItem.data._id = ownedItem._id;
Expand Down
15 changes: 7 additions & 8 deletions module/item/NumeneraSkillItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ export class NumeneraSkillItem extends Item {
skillItem = await actor.createEmbeddedDocuments("Item", [this.object]);
}

skillItem._data._id = ownedItem._id;
skillItem._data.name = ownedItem.name;
skillItem._data.data = ownedItem.data.data || {};
skillItem._data.data.notes = ownedItem.data.notes;
skillItem._data.data.relatedAbilityId = ownedItem.data.relatedAbilityId;
skillItem._data.data.stat = ownedItem.data.data.stat;
skillItem._data.data.inability = ownedItem.data.data.inability;
skillItem._data.data.skillLevel = ownedItem.data.data.skillLevel;
skillItem.data._id = ownedItem._id;
skillItem.data.name = ownedItem.name;
skillItem.data.notes = ownedItem.data.notes;
skillItem.data.relatedAbilityId = ownedItem.data.relatedAbilityId;
skillItem.data.stat = ownedItem.data.data.stat;
skillItem.data.inability = ownedItem.data.data.inability;
skillItem.data.skillLevel = ownedItem.data.data.skillLevel;

skillItem.prepareData();

Expand Down
4 changes: 4 additions & 0 deletions module/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ export const preloadHandlebarsTemplates = async() => {
}
else {
templatePaths.push("systems/numenera/templates/actor/characterSheet.html",
"systems/numenera/templates/actor/characterSheetLimited.html",
"systems/numenera/templates/actor/communitySheet.html",
"systems/numenera/templates/actor/communitySheetLimited.html",
"systems/numenera/templates/actor/npcSheet.html",
"systems/numenera/templates/actor/npcSheetLimited.html",
"systems/numenera/templates/actor/partials/artifacts.html",
"systems/numenera/templates/actor/partials/cyphers.html",
"systems/numenera/templates/actor/partials/features.html",
"systems/numenera/templates/actor/partials/oddities.html",
"systems/numenera/templates/actor/partials/pcHeader.html",
"systems/numenera/templates/actor/partials/powerShifts.html",
"systems/numenera/templates/actor/partials/recursions.html",
"systems/numenera/templates/actor/partials/weapons.html",
Expand Down
8 changes: 8 additions & 0 deletions numenera.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ Hooks.once("ready", numeneraSocketListeners);

//Random hooks should go in there
Hooks.once("ready", registerHooks);

Hooks.once("ready", function() {
if (game.data.version.startsWith("0.7."))
ui.notifications.warn("Hello! SolarBear, the system author, here.<br><br>I try to make compatibility between older version of Foundry a priority but due to the heavy changes and resulting bugs between versions 0.7 and 0.8, "+
"I have decided to remove 0.7 support soon. If you Foundry 0.7 is important to you, contact me ASAP on the <a href=\"https://discord.gg/foundryvtt\">Foundry Discord</a> (@SolarBear) to let me know, otherwise this support " +
" will be removed around the middle of July. Cheers and happy gaming!",
{permanent: true});
});
Loading

0 comments on commit d680c4c

Please sign in to comment.