Skip to content

Commit

Permalink
Armor Total & Quick Roll - 0.1.6
Browse files Browse the repository at this point in the history
- Total armor value now shown underneath the armor stat.
- You can now shift click attributes to roll them straight with no advantage or disadvantage.
  • Loading branch information
Futil committed Nov 9, 2021
1 parent 9b6727c commit b4103aa
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 30 deletions.
19 changes: 19 additions & 0 deletions css/mosh.css
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,24 @@
font-weight: bold;
text-align: center;
}

.mosh .armor-mod {
margin: -8px;
height: 24px;
width: 35px;
/* padding: 0; */
border: 3px solid #111;
background-color: #111;
border-radius: 0.6em;
font-size: 0.9rem;
font-weight: bold;
text-align: center;
position: relative;
color: white;
top: 8px;
right: -19px;
}

.mosh .savetext {
display: block;
margin-bottom: .2em;
Expand Down Expand Up @@ -929,6 +947,7 @@
grid-column: 2/span 2;
}


.mosh .roll-target {
box-sizing: border-box;
display: grid;
Expand Down
48 changes: 45 additions & 3 deletions module/actor/actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,15 @@ export class MothershipActorSheet extends ActorSheet {
weapon.sheet.render(true);
});

// Rollable Attributes

html.find('.stat-roll').click(ev => {
const div = $(ev.currentTarget);
const statName = div.data("key");
const attribute = this.actor.data.data.stats[statName];
this.actor.rollStat(attribute);
var shifted = false;
if (ev.shiftKey) shifted = true;

this.actor.rollStat(attribute, shifted);
});

// Rollable Skill
Expand Down Expand Up @@ -284,6 +287,7 @@ export class MothershipActorSheet extends ActorSheet {
* @private
*/
_onItemCreate(event) {

event.preventDefault();
const header = event.currentTarget;
// Get the type of item to create.
Expand All @@ -298,9 +302,11 @@ export class MothershipActorSheet extends ActorSheet {
type: type,
data: data
};

// Remove the type from the dataset since it's in the itemData.type prop.
delete itemData.data["type"];


// Finally, create the item!
return this.actor.createOwnedItem(itemData);
}
Expand Down Expand Up @@ -328,8 +334,44 @@ export class MothershipActorSheet extends ActorSheet {
// Remove the type from the dataset since it's in the itemData.type prop.
delete itemData.data["type"];

let d = new Dialog({
title: "New Skill",
content: "<h2> Name </h2>\
<input type='text' id='name' name='name' value='New Skill'>\
<h2> Rank </h2> <select style='margin-bottom:10px;'name='rank' id='rank'>\
<option value='Trained'>Trained</option>\
<option value='Expert'>Expert</option>\
<option value='Master'>Master</option></select> <br/>",
buttons: {
roll: {
icon: '<i class="fas fa-check"></i>',
label: "Create",
callback: (html) => {
var rank = html.find('[id=\"rank\"]')[0].value;
if(rank == "Trained")
itemData.data.bonus = 10;
if(rank == "Expert")
itemData.data.bonus = 15;
if(rank == "Master")
itemData.data.bonus = 20;

itemData.data.rank = rank;
itemData.name = html.find('[id=\"name\"]')[0].value
this.actor.createOwnedItem(itemData);}
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: "Cancel",
callback: () => { }
}
},
default: "roll",
close: () => { }
});
d.render(true);

// Finally, create the item!
return this.actor.createOwnedItem(itemData);
return ;
}


Expand Down
47 changes: 26 additions & 21 deletions module/actor/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ export class MothershipActor extends Actor {
const armors = this.getEmbeddedCollection("Item").filter(e => "armor" === e.type);

for (let armor of armors) {
console.log(armor);
if (armor.data.data.equipped) {
armorBonus += armor.data.data.bonus;
}
}
data.stats.armor.mod = armorBonus;
data.stats.armor.total = armorBonus+data.stats.armor.value;

}

/**
Expand Down Expand Up @@ -80,34 +81,38 @@ export class MothershipActor extends Actor {
d.render(true);
}

rollStat(attribute) {
rollStat(attribute, shifted = false) {
console.log(attribute);

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);

//this.rollAttribute(attribute, "none");

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)
if(shifted){
this.rollAttribute(attribute, 'None');
}
else {
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)
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: "Cancel",
callback: () => { }
}
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: "Cancel",
callback: () => { }
}
},
default: "roll",
close: () => { }
});
d.render(true);
default: "roll",
close: () => { }
});
d.render(true);
}
}

rollStress(attribute) {
Expand Down
6 changes: 5 additions & 1 deletion module/actor/creature-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ export class MothershipCreatureSheet extends ActorSheet {
const div = $(ev.currentTarget);
const statName = div.data("key");
const attribute = this.actor.data.data.stats[statName];
this.actor.rollStat(attribute);

var shifted = false;
if (ev.shiftKey) shifted = true;

this.actor.rollStat(attribute, shifted);
});

//Weapons
Expand Down
4 changes: 2 additions & 2 deletions system.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "mosh",
"title": "MoSh - Unofficial Mothership",
"description": "The unofficial Mothership system for FoundryVTT.",
"version": "0.1.5b",
"version": "0.1.6",
"minimumCoreVersion": "0.8.6",
"compatibleCoreVersion": "0.8.6",
"compatibleCoreVersion": "0.8.9",
"templateVersion": 2,
"author": "Futilrevenge",
"esmodules": ["module/mosh.js"],
Expand Down
6 changes: 4 additions & 2 deletions templates/actor/actor-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@
data-target="{{data.stats.armor.value}}" data-label="Armor">ARMOR</span>
<input class="square-input" type="text" name="data.stats.armor.value" value="{{data.stats.armor.value}}"
data-dtype="Number" />
<div class="armor-mod" type="text" name="data.stats.armor.total" value=""
data-dtype="Number" >{{data.stats.armor.total}}</div>
</div>
</div>

Expand All @@ -284,11 +286,11 @@

{{!-- Biography Tab --}}
<div class="tab biography" data-group="primary" data-tab="description">
{{editor content=data.biography target="data.biography" button=true owner=owner editable=editable}}
{{editor content=data.biography target="data.biography" button=true owner=owner editable=true}}
</div>
{{!-- Notes Tab --}}
<div class="tab biography" data-group="primary" data-tab="notes">
{{editor content=data.notes target="data.notes" button=true owner=owner editable=editable}}
{{editor content=data.notes target="data.notes" button=true owner=owner editable=true}}
</div>
{{!-- Owned Items Tab --}}
<div class="tab items" data-group="primary" data-tab="items">
Expand Down
2 changes: 1 addition & 1 deletion templates/actor/ship-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@

{{!-- Biography Tab --}}
<div class="tab biography" data-group="primary" data-tab="description">
{{editor content=data.biography target="data.biography" button=true owner=owner editable=editable}}
{{editor content=data.biography target="data.biography" button=true owner=owner editable=true}}
</div>

{{!-- Layout Tab --}}
Expand Down

0 comments on commit b4103aa

Please sign in to comment.