Skip to content

Commit

Permalink
Add Loot Sheet as actor sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyMonette committed Jun 18, 2021
1 parent efeacd0 commit 46b691d
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 7 deletions.
13 changes: 12 additions & 1 deletion module/sheets/WitcherActorSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default class WitcherActorSheet extends ActorSheet {
data.weapons = data.items.filter(function(item) {return item.type=="weapon"});
data.armors = data.items.filter(function(item) {return item.type=="armor" || item.type == "enhancement"});
data.components = data.items.filter(function(item) {return item.type=="component" && item.data.type!="substances"});
data.allComponents = data.items.filter(function(item) {return item.type=="component"});
data.valuables = data.items.filter(function(item) {return item.type=="valuable" || item.type == "mount" || item.type =="alchemical" || item.type =="mutagen" });
data.diagrams = data.items.filter(function(item) {return item.type=="diagrams"});
data.spells = data.items.filter(function(item) {return item.type=="spell"});
Expand Down Expand Up @@ -62,6 +63,15 @@ export default class WitcherActorSheet extends ActorSheet {
}
return Math.ceil(total)
}
Array.prototype.cost = function () {
var total = 0
for ( var i = 0, _len = this.length; i < _len; i++ ) {
if (this[i]["data"]["cost"] && this[i]["data"]["quantity"]){
total += Number(this[i]["data"]["quantity"]) * Number(this[i]["data"]["cost"])
}
}
return Math.ceil(total)
}

data.totalStats = this.calc_total_stats(data)
data.totalSkills = this.calc_total_skills(data)
Expand Down Expand Up @@ -89,7 +99,8 @@ export default class WitcherActorSheet extends ActorSheet {
data.loots = data.items.filter(function(item) {return item.type=="component" || item.type == "valuable" || item.type=="diagrams" || item.type=="armor" || item.type=="alchemical"});
data.notes = data.items.filter(function(item) {return item.type=="note"});

data.TotalWeight = data.items.weight();
data.totalWeight = data.items.weight();
data.totalCost = data.items.cost();

data.noviceSpells = data.items.filter(function(item) {return item.type=="spell" && item.data.level=="novice" && (item.data.class=="Spells" || item.data.class=="Invocations" || item.data.class=="Witcher")});
data.journeymanSpells = data.items.filter(function(item) {return item.type=="spell" && item.data.level=="journeyman" && (item.data.class=="Spells" || item.data.class=="Invocations" || item.data.class=="Witcher")});
Expand Down
1 change: 1 addition & 0 deletions scripts/TheWitcherTRPG.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ async function preloadHandlebarsTemplates(){
const templatePath =[
"systems/TheWitcherTRPG/templates/sheets/actor/character-sheet.html",
"systems/TheWitcherTRPG/templates/sheets/actor/monster-sheet.html",
"systems/TheWitcherTRPG/templates/sheets/actor/loot-sheet.html",
"systems/TheWitcherTRPG/templates/partials/character-header.html",
"systems/TheWitcherTRPG/templates/partials/tab-skills.html",
"systems/TheWitcherTRPG/templates/partials/tab-profession.html",
Expand Down
6 changes: 6 additions & 0 deletions styles/system-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -690,4 +690,10 @@ input.luck-value {

.spacer {
height: 55px;
}

.left-loot-border {
border-right: solid 1px;
width: 150px;
height: 100%;
}
2 changes: 1 addition & 1 deletion system.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "TheWitcherTRPG",
"title": "TheWitcherTRPG - fvtt",
"description": "Many details here.",
"version": 0.19,
"version": 0.20,
"author": "TechAntho",
"scripts": [
],
Expand Down
7 changes: 6 additions & 1 deletion template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"Actor": {
"types": [
"character",
"monster"
"monster",
"loot"
],
"templates":{
"baseActor": {
Expand Down Expand Up @@ -589,6 +590,10 @@
"monsterLore": "",
"monsterLoreSkillValue": "",
"customStat": false
},
"loot": {
"templates": ["baseActor"],
"description":""
}
},
"Item": {
Expand Down
8 changes: 4 additions & 4 deletions templates/partials/tab-inventory.html
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,12 @@ <h2>Components <a class="add-item" data-itemType="component"><i class="fas fa-pl
</div>

<div class="weight-value">
<span>{{TotalWeight}}/{{data.coreStats.enc.value}} </span>
<span>{{totalWeight}}/{{data.coreStats.enc.value}} </span>
</div>

{{#if (gte TotalWeight data.coreStats.enc.value)}}
{{#if (gte totalWeight data.coreStats.enc.value)}}
<div class="weightbar-overweight"></div>
{{/if}}
{{#if (lt TotalWeight data.coreStats.enc.value)}}
<progress class="weightbar" value="{{TotalWeight}}" max="{{data.coreStats.enc.value}}"></progress>
{{#if (lt totalWeight data.coreStats.enc.value)}}
<progress class="weightbar" value="{{totalWeight}}" max="{{data.coreStats.enc.value}}"></progress>
{{/if}}
3 changes: 3 additions & 0 deletions templates/sheets/actor/actor-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
{{#if (eq actor.type "monster")}}
{{> "systems/TheWitcherTRPG/templates/sheets/actor/monster-sheet.html"}}
{{/if}}
{{#if (eq actor.type "loot")}}
{{> "systems/TheWitcherTRPG/templates/sheets/actor/loot-sheet.html"}}
{{/if}}
</form>

110 changes: 110 additions & 0 deletions templates/sheets/actor/loot-sheet.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<h1><input name="name" type="text" value="{{actor.name}}" placeholder="Name" /></h1>
<div class="flex">
<div class="flex left-loot-border">
<div>
<div>
<label>Total Weight:</label>
</div>
<div>
<span>{{totalWeight}}</span>
</div>
<div>
<label>Total Cost:</label>
</div>
<div>
<span>{{totalCost}}</span>
</div>
</div>
</div>
<di>
<h2>Weapons <a class="add-item" data-itemType="weapon"><i class="fas fa-plus"></i></a></h2>
<table class="weapon-table">
<tr>
<td></td>
<td></td>
<td><b>Qty</b></td>
<td><b>Name</b></td>
<td><b>Weight</b></td>
<td><b>Cost</b></td>
<td></td>
</tr>
{{#each weapons as |item id|}}
<tbody class="item" data-item-id="{{item._id}}">
<tr>
<td><a class="item-edit"><i class="fas fa-edit"></i></a></td>
<td><img src="{{item.img}}" class="item-img" /></td>
<td><input class="inline-edit item-quantity" data-field="data.quantity" type="text" value="{{item.data.quantity}}" data-dtype="Number"/></td>
<td><input class="inline-edit item-name" data-field="name" type="text" value="{{item.name}}" data-dtype="Number"/></td>
<td><input class="inline-edit Weight-info" data-field="data.weight" type="text" value="{{item.data.weight}}" placeholder="" /></td>
<td><input class="inline-edit Cost-info" data-field="data.cost" type="text" value="{{item.data.cost}}" placeholder="" /></td>
<td><a class="item-delete"><i class="fas fa-trash-alt"></i></a></td>
</tr>
</tbody>
{{/each}}
</table>
<h2>Armors <a class="add-item" data-itemType="armor"><i class="fas fa-plus"></i></a></h2>
<table class="armor-table">
{{#each armors as |item id|}}
<tbody class="item" data-item-id="{{item._id}}">
<tr>
<td><a class="item-edit"><i class="fas fa-edit"></i></a></td>
<td><img src="{{item.img}}" class="item-img" /></td>
<td><input class="inline-edit item-quantity" data-field="data.quantity" type="text" value="{{item.data.quantity}}" data-dtype="Number"/></td>
<td><input class="inline-edit" data-field="name" type="text" value="{{item.name}}" placeholder="name" /></td>
<td><input class="inline-edit Weight-info" data-field="data.weight" type="text" value="{{item.data.weight}}" placeholder="" /></td>
<td><input class="inline-edit cost-info" data-field="data.cost" type="text" value="{{item.data.cost}}" data-dtype="Number"/></td>
<td><a class="item-delete"><i class="fas fa-trash-alt"></i></a></td>
</tr>
</tbody>
{{/each}}
</table>
<h2>Valuables <a class="add-item" data-itemType="valuable"><i class="fas fa-plus"></i></a></h2>
<table class="armor-table">
{{#each valuables as |item id|}}
<tbody class="item" data-item-id="{{item._id}}">
<tr>
<td><a class="item-edit"><i class="fas fa-edit"></i></a></td>
<td><img src="{{item.img}}" class="item-img" /></td>
<td><input class="inline-edit item-quantity" data-field="data.quantity" type="text" value="{{item.data.quantity}}" data-dtype="Number"/></td>
<td><input class="inline-edit" data-field="name" type="text" value="{{item.name}}" placeholder="name" /></td>
<td><input class="inline-edit Weight-info" data-field="data.weight" type="text" value="{{item.data.weight}}" placeholder="" /></td>
<td><input class="inlinefas--edit cost-info" data-field="data.cost" type="text" value="{{item.data.cost}}" data-dtype="Number"/></td>
<td><a class="item-delete"><i class="fas fa-trash-alt"></i></a></td>
</tr>
</tbody>
{{/each}}
</table>
<h2>Diagrams <a class="add-item" data-itemType="diagrams"><i class="fas fa-plus"></i></a></h2>
<table class="armor-table">
{{#each diagrams as |item id|}}
<tbody class="item" data-item-id="{{item._id}}">
<tr>
<td><a class="item-edit"><i class="fas fa-edit"></i></a></td>
<td><img src="{{item.img}}" class="item-img" /></td>
<td><input class="inline-edit item-quantity" data-field="data.quantity" type="text" value="{{item.data.quantity}}" data-dtype="Number"/></td>
<td><input class="inline-edit" data-field="name" type="text" value="{{item.name}}" placeholder="name" /></td>
<td><input class="inline-edit Weight-info" data-field="data.weight" type="text" value="{{item.data.weight}}" placeholder="" /></td>
<td><input class="inlinefas--edit cost-info" data-field="data.cost" type="text" value="{{item.data.cost}}" data-dtype="Number"/></td>
<td><a class="item-delete"><i class="fas fa-trash-alt"></i></a></td>
</tr>
</tbody>
{{/each}}
</table>
<h2>Components <a class="add-item" data-itemType="component"><i class="fas fa-plus"></i></a></h2>
<table class="armor-table">
{{#each allComponents as |item id|}}
<tbody class="item" data-item-id="{{item._id}}">
<tr>
<td><a class="item-edit"><i class="fas fa-edit"></i></a></td>
<td><img src="{{item.img}}" class="item-img" /></td>
<td><input class="inline-edit item-quantity" data-field="data.quantity" type="text" value="{{item.data.quantity}}" data-dtype="Number"/></td>
<td><input class="inline-edit" data-field="name" type="text" value="{{item.name}}" placeholder="name" /></td>
<td><input class="inline-edit Weight-info" data-field="data.weight" type="text" value="{{item.data.weight}}" placeholder="" /></td>
<td><input class="inlinefas--edit cost-info" data-field="data.cost" type="text" value="{{item.data.cost}}" data-dtype="Number"/></td>
<td><a class="item-delete"><i class="fas fa-trash-alt"></i></a></td>
</tr>
</tbody>
{{/each}}
</table>
</di>
</div>

0 comments on commit 46b691d

Please sign in to comment.