Calm + Weight Settings 0.0.6

This commit is contained in:
Martin Jencka
2020-11-21 21:15:18 -07:00
parent 35666a0faa
commit dbc9ff70cd
9 changed files with 164 additions and 50 deletions
+30
View File
@@ -30,6 +30,13 @@ export class MothershipActorSheet extends ActorSheet {
this._prepareCharacterItems(data);
}
if (data.data.settings == null) {
data.data.settings = {};
}
data.data.settings.useCalm = game.settings.get("mothership", "useCalm");
data.data.settings.hideWeight = game.settings.get("mothership", "hideWeight");
return data;
}
@@ -224,6 +231,18 @@ export class MothershipActorSheet extends ActorSheet {
});
// Rollable Item/Anything with a description that we want to click on.
html.find('.calm-roll').click(ev => {
const attribute = this.actor.data.data.other.stress;
attribute.label = "Calm";
this.actor.rollStress(attribute);
});
// Rollable Item/Anything with a description that we want to click on.
html.find('.stress-roll').click(ev => {
const attribute = this.actor.data.data.other.stress;
attribute.label = "Stress";
this.actor.rollStress(attribute);
});
}
/* -------------------------------------------- */
@@ -305,4 +324,15 @@ export class MothershipActorSheet extends ActorSheet {
}
}
async _updateObject(event, formData) {
const actor = this.object;
const updateData = expandObject(formData);
await actor.update(updateData, {
diff: false
});
}
}
+45 -3
View File
@@ -20,6 +20,8 @@ export class MothershipActor extends Actor {
else if (actorData.type === 'creature') this._prepareCreatureData(actorData);
else if (actorData.type === 'ship') this._prepareShipData(actorData);
}
/**
* Prepare Character type specific data
@@ -86,6 +88,37 @@ export class MothershipActor extends Actor {
d.render(true);
}
rollStress(attribute) {
//this.rollAttribute(attribute, "none");
let rollOver = true;
if(attribute.label == "Calm")
rollOver = false;
let attLabel = attribute.label?.charAt(0).toUpperCase() + attribute.label?.toLowerCase().slice(1);
if (!attribute.label && isNaN(attLabel))
attLabel = attribute.charAt(0)?.toUpperCase() + attribute.toLowerCase().slice(1);
let d = new Dialog({
title: "Select Roll Type",
content: "<h2> Advantages/Disadvantage </h2> <select style='margin-bottom:10px;'name='advantage' id='advantage'> <option value='none'>None</option> <option value='advantage'>Advantage/Disadvantage</option></select> <br/>",
buttons: {
roll: {
icon: '<i class="fas fa-check"></i>',
label: "Roll",
callback: (html) => this.rollAttribute(attribute, html.find('[id=\"advantage\"]')[0].value, '', rollOver)
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: "Cancel",
callback: () => { }
}
},
default: "roll",
close: () => { }
});
d.render(true);
}
rollWeapon(itemId, options = { event: null }) {
let item = duplicate(this.getEmbeddedEntity("OwnedItem", itemId));
@@ -189,7 +222,7 @@ export class MothershipActor extends Actor {
t.render(true);
}
rollAttribute(attribute, advantage, item = "") {
rollAttribute(attribute, advantage, item = "", rollOver = false) {
let attributeName = attribute.label?.charAt(0).toUpperCase() + attribute.label?.toLowerCase().slice(1);
if (!attribute.label && isNaN(attributeName))
attributeName = attribute.charAt(0)?.toUpperCase() + attribute.toLowerCase().slice(1);
@@ -197,7 +230,7 @@ export class MothershipActor extends Actor {
console.log("Got here baybee");
// Roll
let diceformular = "1d100";
let diceformular = "1d100-1";
console.log(attribute);
@@ -207,6 +240,8 @@ export class MothershipActor extends Actor {
let r = new Roll(diceformular, {});
r.roll();
console.log(r);
//Advantage roll
let a = new Roll(diceformular, {});
a.roll();
@@ -226,6 +261,13 @@ export class MothershipActor extends Actor {
let targetValue = attribute.value + mod + (item == "" ? 0 : item.data.bonus);
//Here's where we handle the result text.
let resultText = (r._total < targetValue ? "Success" : "Failure");
if(rollOver == true)
resultText = (r._total > targetValue ? "Success" : "Failure");
console.log(attribute.value + attribute.mod);
var templateData = {
actor: this,
stat: {
@@ -239,7 +281,7 @@ export class MothershipActor extends Actor {
damageRoll: damageRoll
},
resultText: {
value: (r._total < attribute.value + attribute.mod ? "Success" : "Failure")
value: resultText
},
isCreature: {
value: this.data.type == "creature" ? true : false
+7
View File
@@ -30,6 +30,13 @@ export class MothershipShipSheet extends ActorSheet {
this._prepareShipItems(data);
}
if (data.data.settings == null) {
data.data.settings = {};
}
data.data.settings.useCalm = game.settings.get("mothership", "useCalm");
data.data.settings.hideWeight = game.settings.get("mothership", "hideWeight");
return data;
}
+5
View File
@@ -5,6 +5,9 @@ import { MothershipCreatureSheet } from "./actor/creature-sheet.js";
import { MothershipShipSheet } from "./actor/ship-sheet.js";
import { MothershipItem } from "./item/item.js";
import { MothershipItemSheet } from "./item/item-sheet.js";
import {
registerSettings
} from "./settings.js";
Hooks.once('init', async function () {
@@ -26,6 +29,8 @@ Hooks.once('init', async function () {
CONFIG.Actor.entityClass = MothershipActor;
CONFIG.Item.entityClass = MothershipItem;
registerSettings();
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
+18
View File
@@ -0,0 +1,18 @@
export const registerSettings = function () {
game.settings.register('mothership', 'useCalm', {
name: "Use Calm?",
hint: "Uses the traaa.sh Calm system instead of Stress.",
default: false,
scope: 'world',
type: Boolean,
config: true
});
game.settings.register('mothership', 'hideWeight', {
name: "Hide Weight",
hint: "Hide weight in the items list for players and ships?",
default: false,
scope: 'world',
type: Boolean,
config: true
});
};
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "mothership",
"title": "Mothership",
"description": "The Mothership system for FoundryVTT!",
"version": "0.0.5",
"version": "0.0.6",
"minimumCoreVersion": "0.5.5",
"compatibleCoreVersion": "0.5.5",
"templateVersion": 2,
+6 -1
View File
@@ -24,6 +24,10 @@
],
"biography": "",
"notes": "",
"settings" : {
"useCalm" : false
},
"class": {
"value": ""
},
@@ -78,7 +82,8 @@
"other": {
"stress": {
"value": 2,
"min": 0
"min": 0,
"label" : "Stress"
},
"resolve": {
"value": 0
+51 -14
View File
@@ -96,9 +96,26 @@
<div class="healthmaxtext">Maximum</div>
</div>
{{#if data.settings.useCalm}}
<!-- Calm -->
<div class="resource healthspread minmaxtopstat">
<label for="data.other.stress.value" class="resource-label minmaxtext rollable calm-roll">Calm</label>
<div class="minmaxwrapper">
<input class="maxhealth-input darkGreyText" type="text" name="data.other.stress.value" value="{{data.other.stress.value}}"
data-dtype="Number" />
<div class="slant" style="transform: skewX(0deg);"></div>
<input class="maxhealth-input darkGreyText" type="text" name="data.other.stress.min"
value="{{data.other.stress.min}}" data-dtype="Number" />
</div>
<div class="healthmaxtext">Current</div>
<div class="healthmaxtext">Maximum</div>
</div>
{{else}}
<!-- Stress -->
<div class="resource healthspread minmaxtopstat">
<label for="data.other.stress.value" class="resource-label minmaxtext">Stress</label>
<label for="data.other.stress.value" class="resource-label minmaxtext rollable stress-roll">Stress</label>
<div class="minmaxwrapper">
<input class="maxhealth-input darkGreyText" type="text" name="data.other.stress.value" value="{{data.other.stress.value}}"
@@ -111,6 +128,7 @@
<div class="healthmaxtext">Current</div>
<div class="healthmaxtext">Minimum</div>
</div>
{{/if}}
<!-- Resolve -->
<div class="resource healthspread minmaxtopstat">
@@ -310,26 +328,45 @@
<div class="item-image"></div>
<div class="skill-stat">Item Name</div>
<div class="skill-stat">Quantity</div>
{{#if data.settings.hideWeight}}
{{else}}
<div class="skill-stat">Weight</div>
{{/if}}
<div class="skill-stat">Value</div>
<div class="item-controls">
<a class="item-control item-create" title="Create Item" data-type="item"><i class="fas fa-plus"></i> Add
Item</a>
</div>
</li>
{{#each actor.gear as |item id|}}
<li class="item flexrow" data-item-id="{{item._id}}">
<div class="item-image"><img src="{{item.img}}" title="{{item.name}}" width="24" height="24" /></div>
<h4 class="skill-name list-roll description-roll">{{item.name}}</h4>
<div class="skill-stat list-roll item-quantity">{{item.data.quantity}}</div>
<div class="skill-stat">{{item.data.weight}}</div>
<div class="skill-stat">{{item.data.cost}}</div>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
{{#if actor.data.settings.hideWeight}}
{{#each actor.gear as |item id|}}
<li class="item flexrow" data-item-id="{{item._id}}">
<div class="item-image"><img src="{{item.img}}" title="{{item.name}}" width="24" height="24" /></div>
<h4 class="skill-name list-roll description-roll">{{item.name}}</h4>
<div class="skill-stat list-roll item-quantity">{{item.data.quantity}}</div>
<div class="skill-stat">{{item.data.cost}}</div>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
{{else}}
{{#each actor.gear as |item id|}}
<li class="item flexrow" data-item-id="{{item._id}}">
<div class="item-image"><img src="{{item.img}}" title="{{item.name}}" width="24" height="24" /></div>
<h4 class="skill-name list-roll description-roll">{{item.name}}</h4>
<div class="skill-stat list-roll item-quantity">{{item.data.quantity}}</div>
<div class="skill-stat">{{item.data.weight}}</div>
<div class="skill-stat">{{item.data.cost}}</div>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
{{/if}}
</ol>
</div>
{{!-- Owned Skills Tab --}}
+1 -31
View File
@@ -12,7 +12,7 @@
</div>
<div class="description">
<div class="body">{{{item.data.description}}}</div>
<br/>
<br />
</div>
{{else}}
{{#if isWeapon}}
@@ -37,36 +37,6 @@
{{else}}
<div class="roll-result">{{data.diceTotal.value}}</div>
{{/if}}
{{#if data.isCreature.value}}
<div class="gmonly">
<span class="tooltiptext">
{{#each diceData.dice}}
<div class="{{#if this.dice}}dice{{else}}modifier{{/if}}">
<label style="color:{{this.color}};">
{{this.result}}
</label>
{{#if this.img}}
<img src='{{this.img}}' />
{{/if}}
</div>
{{/each}}
</span>
</div>
{{else}}
<span class="tooltiptext">
{{#each diceData.dice}}
<div class="{{#if this.dice}}dice{{else}}modifier{{/if}}">
<label style="color:{{this.color}};">
{{this.result}}
</label>
{{#if this.img}}
<img src='{{this.img}}' />
{{/if}}
</div>
{{/each}}
</span>
{{/if}}
</div>
<div class="roll-target">
<div class="valuetext">Target:</div>