added ability to add/remove type skills

This commit is contained in:
Nick Eimers
2020-06-23 23:26:05 -07:00
parent eaad1b99b9
commit e2cf445ab9
5 changed files with 118 additions and 48 deletions
+9 -10
View File
@@ -1,17 +1,16 @@
# DeltaGreen System
# (Unofficial) Delta Green: The RPG Foundry System
This system is a Delta Green (standalone) system based on the Agent's Handbook from Arc Dream Publishing.
# Delta Green Community License
Published by arrangement with the Delta Green Partnership. The intellectual property known as Delta Green is a trademark and copyright owned by the Delta Green Partnership, who has licensed its use here. The contents of this system are free for public use, excepting those elements that are components of the Delta Green intellectual property.
This is a fan made Foundry system for Delta Green: The RPG, based on the Agent's Handbook from Arc Dream Publishing. It is unaffiliated with Arc Dream Publishing.
# Foundry VTT License
This code uses the Foundry VTT and its API under the terms of the Limited License Agreement for Module Development.
Foundry VTT is a Copyright of Foundry Gaming, LLC.
# Delta Green Foundry System License
The code (HTML, CSS, Javascript, etc.) in this system and any related information are provided under the MIT license, excepting that which comes via Foundry VTT
excepting that which is otherwise covered by the Delta Green Partnership and/or Arc Dream Publishing.
# Delta Green Community License
Published by arrangement with the Delta Green Partnership. The intellectual property known as Delta Green is a trademark and copyright owned by the Delta Green Partnership, who has licensed its use here. The contents of this system are licensed as detailed below, excepting those elements that are components of the Delta Green intellectual property.
# System License
The code (HTML, CSS, Javascript, etc.) in this system and any related information are provided under the MIT license, excepting that which comes via Foundry VTT API.
Copyright 2020 N. Eimers
@@ -21,12 +20,12 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Licenses, Citations and Shoutouts
# Other Licenses, Citations and Shoutouts
System Base Code
This system is built upon on Matt Smith's (AKA Asacolips) excellent Boilerplate System and corresponding tutorial.
https://gitlab.com/asacolips-projects/foundry-mods/foundryvtt-system-tutorial
DIDACT GOTHIC
DIDACT GOTHIC FONT
The font used in many places is Didact Gothic, by Daniel Johnson and Cyreal.
https://fonts.google.com/specimen/Didact+Gothic?query=did#about
+21 -1
View File
@@ -263,7 +263,10 @@ a.btn-tiny{
margin-left: 5px;
margin-right: 5px;
font-size: 13px;
padding: 0px;
padding-top: 1px;
padding-bottom: 1px;
padding-right: 5px;
padding-left: 5px;
text-decoration: none;
background-color: #EEEEEE;
@@ -296,6 +299,16 @@ span.max-attribute-value-label{
.deltagreen .skill-label{
margin: 5px;
align-content: flex-start;
}
.deltagreen .skill-type-label{
margin: 5px;
}
input.percentile-skill-input{
width: 25px;
min-width: 10px;
}
.deltagreen .sheet-header h2.profession{
@@ -308,4 +321,11 @@ span.max-attribute-value-label{
width: 100%;
height: 100%;
margin: 0;
}
.typed-skill-flexrow{
display: flex;
flex-direction: row;
margin: 5px;
padding: 5px;
}
+45
View File
@@ -138,6 +138,51 @@ export class DeltaGreenActorSheet extends ActorSheet {
this.actor.update({"data": updatedData});
});
html.find('.btn-add-typed-skill').click(event => {
event.preventDefault();
let targetskill = event.target.getAttribute("data-typeskill");
let updatedData = duplicate(this.actor.data.data);
// It sucks, but seems like Foundry and/or Handlebars always converts 'types' from an array to an object...
// As such normal array functions like 'push' won't work.
// So just create an array, add all existing items to it, then update the existing object.
// Handlebars doesn't seem to be broken by this sudden change of type from 'Object' to 'Array'.
let typesArr = [];
let x;
for(x in updatedData.type_skills[targetskill].types){
if(Number.isNumeric(x)){
typesArr.push(updatedData.type_skills[targetskill].types[x]);
}
}
typesArr.push({specialization:"New", proficiency: 0, failure: false});
updatedData.type_skills[targetskill].types = typesArr;
this.actor.update({"data": updatedData});
});
html.find('.btn-remove-typed-skill').click(event => {
event.preventDefault();
let targetskill = event.target.getAttribute("data-typeskill");
let skillindex = event.target.getAttribute("data-index");
let updatedData = duplicate(this.actor.data.data);
let typesArr = [];
let x;
for(x in updatedData.type_skills[targetskill].types){
if(Number.isNumeric(x) && x != skillindex){
typesArr.push(updatedData.type_skills[targetskill].types[x]);
}
}
updatedData.type_skills[targetskill].types = typesArr;
this.actor.update({"data": updatedData});
//console.log(targetskill);
//console.log(skillindex);
});
}
/**
+18 -18
View File
@@ -222,52 +222,52 @@
},
"type_skills":{
"art": {
"label": "Art (Type)",
"hasSubtypes": true,
"label": "Art",
"examples": "Sculpting, Painting, Dance, Music, Etc.",
"types":[
{
"specialization": "Painting/Dance/Sculpture/Etc.",
"proficiency": 20,
"specialization": "Painting",
"proficiency": 0,
"failure": false
}
]
},
"craft": {
"label": "Craft (Type)",
"hasSubtypes": true,
"label": "Craft",
"examples": "Mechanic, Carpentry, Electrical, Microelectronics, Locksmith, Gunsmith, Etc.",
"types":[
{
"specialization": "Carpentry/Electrical/Etc.",
"specialization": "Electrical",
"proficiency": 0,
"failure": false
}
]
},
"military_science": {
"label": "Military Science (Type)",
"hasSubtypes": true,
"label": "Military Science",
"examples": "Land, Air, Sea, Etc.",
"types":[
{
"specialization": "Land/Air/Sea/Etc.",
"specialization": "Land",
"proficiency": 0,
"failure": false
}
]
},
"pilot": {
"label": "Pilot (Type)",
"hasSubtypes": true,
"label": "Pilot",
"examples": "Airplane, Drone, Small Boat, Ship, Helicopter, Space Shuttle, etc.",
"types":[
{
"specialization": "Airplane/Small Boat/Helicopter/Etc.",
"specialization": "Airplane",
"proficiency": 0,
"failure": false
}
]
},
"science": {
"label": "Science (Field)",
"hasSubtypes": true,
"label": "Science",
"examples": "Biology, Chemistry, Physics, Astronomy, Geology, Mathematics, etc.",
"types":[
{
"specialization": "Biology/Chemistry/Physics/Etc.",
@@ -278,10 +278,10 @@
},
"foreign_languages": {
"label": "Foreign Languages",
"hasSubtypes": true,
"examples": "Spanish, Yiddish, Aklo, etc.",
"types":[
{
"specialization": "Spanish/Yiddish/Aklo/Etc.",
"specialization": "Spanish",
"proficiency": 0,
"failure": false
}
@@ -289,7 +289,7 @@
},
"other_skills": {
"label": "Other Skills, Specialties, or Training",
"hasSubtypes": true,
"examples": "Lockpicks, SCUBA Diving, Parachuting, Some Exotic Weapon, etc.",
"types":[
{
"specialization": "",
+25 -19
View File
@@ -98,33 +98,39 @@
{{#each data.skills as |skill key|}}
<div class="statistic flexrow flex-group-center">
<label class="rollable skill-label" data-roll="d100" data-target="{{skill.proficiency}}" data-label="{{skill.label}}" title="Click to roll a skill check." for="data.skills.{{key}}.value" >{{skill.label}}</label>
<input type="text" name="data.skills.{{key}}.proficiency" value="{{skill.proficiency}}" data-dtype="Number"/>
<input class="percentile-skill-input" type="text" name="data.skills.{{key}}.proficiency" value="{{skill.proficiency}}" data-dtype="Number"/>
<input type="checkbox" name="data.skills.{{key}}.failure" {{checked skill.failure}} data-dtype="Boolean" {{#if skill.cannotBeImprovedByFailure}} disabled {{/if}} />
</div>
{{/each}}
</div>
<div class="statistics grid grid-2col">
<div class="grid">
{{#each data.type_skills as |typeskill key|}}
<div class="statistic flexrow flex-group-center">
<label class="skill-label">{{typeskill.label}}</label>
{{#each typeskill.types}}
<div class="statistic flexrow flex-group-center">
<label class="skill-label">{{this.specialization}}</label>
<label class="skill-label">{{this}}</label>
<!-- <label class="skill-label">data.type_skills.{{key}}.types[{{@index}}].proficiency</label> -->
<!-- <label class="skill-label">{{actor.data.data.type_skills.art.label}}</label> -->
{{!-- Subtyped Skills take the form: data.type_skills.art.types[0].proficiency where 'types' is an array of object. --}}
<input type="text" name="data.type_skills.{{key}}.types[{{@index}}].proficiency" value="{{this.proficiency}}" data-dtype="Number"/>
<!-- <div class="statistic flexrow flex-group-left"></div> -->
<div class="">
<div>
<label class="skill-type-label" title="{{typeskill.examples}}">{{typeskill.label}}</label>
<a class="btn-tiny btn-add-typed-skill" title="Add another skill." data-typeskill="{{key}}">+</a>
</div>
<div>
{{#each typeskill.types}}
<!-- <div class="flexrow flex-group-center"> -->
<div class="typed-skill-flexrow">
{{!-- Subtyped Skills take the form: data.type_skills.art.types[0].proficiency where 'types' is an array of object. --}}
<a class="btn-tiny btn-remove-typed-skill" title="Add another skill." data-typeskill="{{key}}" data-index="{{@index}}">-</a>
<input type="text" name="data.type_skills.{{key}}.types.{{@index}}.specialization" value="{{this.specialization}}" data-dtype="Text"/>
<input class="percentile-skill-input" type="text" name="data.type_skills.{{key}}.types.{{@index}}.proficiency" value="{{this.proficiency}}" data-dtype="Number"/>
<input type="checkbox" name="data.type_skills.{{key}}.types.{{@index}}.failure" {{checked this.failure}} data-dtype="Boolean" />
</div>
{{/each}}
</div>
{{/each}}
</div>
</div>
{{/each}}
</div>
</div>