Added Icons - Format Changes

This commit is contained in:
Martin Jencka
2020-11-20 09:31:06 -07:00
parent e7ea15e654
commit 28cfcb0175
653 changed files with 476 additions and 75 deletions
+43 -16
View File
@@ -80,14 +80,14 @@ export class MothershipActorSheet extends ActorSheet {
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
// Update Inventory Item
html.find('.item-equip').click(ev => {
const li = $(ev.currentTarget).parents(".item");
const item = duplicate(this.actor.getEmbeddedEntity("OwnedItem", li.data("itemId")))
// Update Inventory Item
html.find('.item-equip').click(ev => {
const li = $(ev.currentTarget).parents(".item");
const item = duplicate(this.actor.getEmbeddedEntity("OwnedItem", li.data("itemId")))
item.data.equipped = !item.data.equipped;
this.actor.updateEmbeddedEntity('OwnedItem', item);
});
item.data.equipped = !item.data.equipped;
this.actor.updateEmbeddedEntity('OwnedItem', item);
});
// Add Inventory Item
html.find('.item-create').click(this._onItemCreate.bind(this));
@@ -99,6 +99,22 @@ export class MothershipActorSheet extends ActorSheet {
item.sheet.render(true);
});
//Quantity adjuster
html.on('mousedown', '.item-quantity', ev => {
const li = ev.currentTarget.closest(".item");
const item = duplicate(this.actor.getEmbeddedEntity("OwnedItem", li.dataset.itemId))
let amount = item.data.quantity;
if (event.button == 0) {
item.data.quantity = Number(amount) + 1;
} else if (event.button == 2) {
item.data.quantity = Number(amount) - 1;
}
this.actor.updateEmbeddedEntity('OwnedItem', item);
});
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
@@ -150,8 +166,15 @@ export class MothershipActorSheet extends ActorSheet {
this.actor.rollWeapon(li.dataset.itemId, {
event: ev
});
});String
});
// Rollable Item/Anything with a description that we want to click on.
html.find('.description-roll').click(ev => {
const li = ev.currentTarget.closest(".item");
this.actor.printDescription(li.dataset.itemId, {
event: ev
});
});
html.on('mousedown', '.weapon-ammo', ev => {
const li = ev.currentTarget.closest(".item");
@@ -170,18 +193,22 @@ export class MothershipActorSheet extends ActorSheet {
this.actor.updateEmbeddedEntity('OwnedItem', item);
});
//Reload Shots
html.on('mousedown', '.weapon-reload', ev => {
const li = ev.currentTarget.closest(".item");
const item = duplicate(this.actor.getEmbeddedEntity("OwnedItem", li.dataset.itemId))
if (event.button == 0) {
item.data.ammo += item.data.curShots;
let reloadAmount = Math.min(item.data.ammo, item.data.shots);
item.data.curShots = reloadAmount;
if (!item.data.useAmmo) {
item.data.curShots = item.data.shots;
} else {
item.data.ammo += item.data.curShots;
let reloadAmount = Math.min(item.data.ammo, item.data.shots);
item.data.curShots = reloadAmount;
item.data.ammo -= reloadAmount;
item.data.ammo -= reloadAmount;
}
}
this.actor.updateEmbeddedEntity('OwnedItem', item);
@@ -190,11 +217,11 @@ export class MothershipActorSheet extends ActorSheet {
let speaker = ChatMessage.getSpeaker({ actor });
ChatMessage.create({
speaker,
content: `Reloading ` + item.name +"...",
content: `Reloading ` + item.name + "...",
type: CHAT_MESSAGE_TYPES.EMOTE
},
{ chatBubble: true });
{ chatBubble: true });
});
}
+71 -16
View File
@@ -91,22 +91,31 @@ export class MothershipActor extends Actor {
console.log(item);
if (item.data.useAmmo == true) {
if (item.data.curShots > 0) {
item.data.curShots -= 1;
console.log("Unloading Shots");
this.updateEmbeddedEntity('OwnedItem', item);
}
else {
let actor = this;
let speaker = ChatMessage.getSpeaker({ actor });
ChatMessage.create({
speaker,
content: item.data.ammo > 0 ? `I need to reload my ` + item.name + "!" : "I'm out of ammo!",
type: CHAT_MESSAGE_TYPES.EMOTE
},
{ chatBubble: true });
return;
if (item.data.useAmmo == true || item.data.shots > 0) {
if (item.data.shots == 0) {
if (item.data.ammo > 0) {
item.data.ammo -= 1;
this.updateEmbeddedEntity('OwnedItem', item);
} else {
return;
}
} else {
if (item.data.curShots > 0) {
item.data.curShots -= 1;
console.log("Unloading Shots");
this.updateEmbeddedEntity('OwnedItem', item);
}
else {
let actor = this;
let speaker = ChatMessage.getSpeaker({ actor });
ChatMessage.create({
speaker,
content: item.data.ammo > 0 ? `I need to reload my ` + item.name + "!" : "I'm out of ammo!",
type: CHAT_MESSAGE_TYPES.EMOTE
},
{ chatBubble: true });
return;
}
}
}
@@ -135,6 +144,11 @@ export class MothershipActor extends Actor {
t.render(true);
}
printDescription(itemId, options = { event: null }) {
let item = duplicate(this.getEmbeddedEntity("OwnedItem", itemId));
this.chatDesc(item);
}
rollSkill(itemId, options = { event: null }) {
let item = duplicate(this.getEmbeddedEntity("OwnedItem", itemId));
@@ -340,4 +354,45 @@ export class MothershipActor extends Actor {
return diceData;
}
// Print the item description into the chat.
chatDesc(item) {
let itemName = item.name?.charAt(0).toUpperCase() + item.name?.toLowerCase().slice(1);
if (!item.name && isNaN(itemName))
itemName = item.charAt(0)?.toUpperCase() + item.toLowerCase().slice(1);
var templateData = {
actor: this,
stat: {
name: itemName.toUpperCase()
},
item: item,
onlyDesc: true,
};
let chatData = {
user: game.user._id,
speaker: {
actor: this._id,
token: this.token,
alias: this.name
}
};
let rollMode = game.settings.get("core", "rollMode");
if (["gmroll", "blindroll"].includes(rollMode)) chatData["whisper"] = ChatMessage.getWhisperRecipients("GM");
/*
if (this.data.type == "creature") {
chatData.whisper = game.user._id;
}
*/
let template = 'systems/mothership/templates/chat/statroll.html';
renderTemplate(template, templateData).then(content => {
chatData.content = content;
ChatMessage.create(chatData);
});
}
}
+17 -5
View File
@@ -114,7 +114,7 @@ export class MothershipCreatureSheet extends ActorSheet {
this.actor.rollWeapon(li.dataset.itemId, {
event: ev
});
}); String
});
html.on('mousedown', '.weapon-ammo', ev => {
@@ -141,11 +141,15 @@ export class MothershipCreatureSheet extends ActorSheet {
const item = duplicate(this.actor.getEmbeddedEntity("OwnedItem", li.dataset.itemId))
if (event.button == 0) {
item.data.ammo += item.data.curShots;
let reloadAmount = Math.min(item.data.ammo, item.data.shots);
item.data.curShots = reloadAmount;
if (!item.data.useAmmo) {
item.data.curShots = item.data.shots;
} else {
item.data.ammo += item.data.curShots;
let reloadAmount = Math.min(item.data.ammo, item.data.shots);
item.data.curShots = reloadAmount;
item.data.ammo -= reloadAmount;
item.data.ammo -= reloadAmount;
}
}
this.actor.updateEmbeddedEntity('OwnedItem', item);
@@ -161,6 +165,14 @@ export class MothershipCreatureSheet extends ActorSheet {
});
// Rollable Item/Anything with a description that we want to click on.
html.find('.description-roll').click(ev => {
const li = ev.currentTarget.closest(".item");
this.actor.printDescription(li.dataset.itemId, {
event: ev
});
});
}
/* -------------------------------------------- */
+37 -10
View File
@@ -47,6 +47,7 @@ export class MothershipShipSheet extends ActorSheet {
const abilities = [];
const weapons = [];
const cargo = [];
const modules = [];
// Iterate through items, allocating to containers
// let totalWeight = 0;
@@ -60,6 +61,8 @@ export class MothershipShipSheet extends ActorSheet {
weapons.push(i);
} else if (i.type === 'item') {
cargo.push(i);
} else if (i.type === 'module') {
modules.push(i);
}
}
@@ -67,6 +70,7 @@ export class MothershipShipSheet extends ActorSheet {
actorData.abilities = abilities;
actorData.weapons = weapons;
actorData.cargo = cargo;
actorData.modules = modules;
}
@@ -77,6 +81,8 @@ export class MothershipShipSheet extends ActorSheet {
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
// Create inventory item.
html.find('.item-create').click(this._onItemCreate.bind(this));
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
@@ -91,6 +97,20 @@ export class MothershipShipSheet extends ActorSheet {
item.sheet.render(true);
});
//Quantity adjuster
html.on('mousedown', '.item-quantity', ev => {
const li = ev.currentTarget.closest(".item");
const item = duplicate(this.actor.getEmbeddedEntity("OwnedItem", li.dataset.itemId))
let amount = item.data.quantity;
if (event.button == 0) {
item.data.quantity = Number(amount) + 1;
} else if (event.button == 2) {
item.data.quantity = Number(amount) - 1;
}
this.actor.updateEmbeddedEntity('OwnedItem', item);
});
// Rollable Attributes
html.find('.stat-roll').click(ev => {
@@ -103,24 +123,19 @@ export class MothershipShipSheet extends ActorSheet {
//Weapons
// Add Inventory Item
html.find('.weapon-create').click(this._onItemCreate.bind(this));
// Update Inventory Item
html.find('.weapon-edit').click(ev => {
const liWeapon = $(ev.currentTarget).parents(".item");
const weapon = this.actor.getOwnedItem(liWeapon.data("itemId"));
weapon.sheet.render(true);
});
// Rollable Weapon
html.find('.weapon-roll').click(ev => {
const li = ev.currentTarget.closest(".item");
this.actor.rollWeapon(li.dataset.itemId, {
event: ev
});
}); String
});
html.on('mousedown', '.weapon-ammo', ev => {
const li = ev.currentTarget.closest(".item");
@@ -146,11 +161,15 @@ export class MothershipShipSheet extends ActorSheet {
const item = duplicate(this.actor.getEmbeddedEntity("OwnedItem", li.dataset.itemId))
if (event.button == 0) {
item.data.ammo += item.data.curShots;
let reloadAmount = Math.min(item.data.ammo, item.data.shots);
item.data.curShots = reloadAmount;
if (!item.data.useAmmo) {
item.data.curShots = item.data.shots;
} else {
item.data.ammo += item.data.curShots;
let reloadAmount = Math.min(item.data.ammo, item.data.shots);
item.data.curShots = reloadAmount;
item.data.ammo -= reloadAmount;
item.data.ammo -= reloadAmount;
}
}
this.actor.updateEmbeddedEntity('OwnedItem', item);
@@ -166,6 +185,14 @@ export class MothershipShipSheet extends ActorSheet {
});
// Rollable Item/Anything with a description that we want to click on.
html.find('.description-roll').click(ev => {
const li = ev.currentTarget.closest(".item");
this.actor.printDescription(li.dataset.itemId, {
event: ev
});
});
}
/* -------------------------------------------- */