added biography section fields

This commit is contained in:
The Last Scrub
2020-06-27 13:34:13 -07:00
parent 86e42dea4e
commit 2a4209b1a7
4 changed files with 139 additions and 52 deletions
+37 -3
View File
@@ -13,6 +13,12 @@
cursor: pointer;
}
.grid-1col{
display: grid;
grid-column: span 1 / span 1;
gap: 10px;
}
.grid,
.grid-2col {
display: grid;
@@ -306,6 +312,12 @@ span.max-attribute-value-label{
margin: 5px;
}
.typed-skill-flexrow{
display: flex;
flex-direction: row;
margin: 1px;
}
input.percentile-skill-input{
width: 50px;
margin-right: 5px;
@@ -324,8 +336,30 @@ input.percentile-skill-input{
margin: 0;
}
.typed-skill-flexrow{
div .simple-centered-flex-div{
display: flex;
flex-direction: row;
align-items: center;
}
div input.fill-remaining-space{
flex: 1;
margin: 1px;
}
text-align: left;
}
div span.bio-grid-label{
margin: 1px;
text-align: left;
}
.bio-grid-2col{
display: grid;
grid-template-columns: 100px auto;
align-items: center;
}
.bio-grid-5col{
display: grid;
grid-template-columns: 100px auto 20px 100px auto;
align-items: center;
}
+46 -23
View File
@@ -142,25 +142,9 @@ export class DeltaGreenActorSheet extends ActorSheet {
event.preventDefault();
let targetskill = event.target.getAttribute("data-typeskill");
let updatedData = duplicate(this.actor.data.data);
//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});
this._showNewTypeSkillDialog(targetskill);
});
html.find('.btn-remove-typed-skill').click(event => {
@@ -171,20 +155,55 @@ export class DeltaGreenActorSheet extends ActorSheet {
let typesArr = [];
let x;
for(x in updatedData.type_skills[targetskill].types){
for(x in updatedData.type_skills[targetskill].subskills){
if(Number.isNumeric(x) && x != skillindex){
typesArr.push(updatedData.type_skills[targetskill].types[x]);
typesArr.push(updatedData.type_skills[targetskill].subskills[x]);
}
}
updatedData.type_skills[targetskill].types = typesArr;
updatedData.type_skills[targetskill].subskills = typesArr;
this.actor.update({"data": updatedData});
//console.log(targetskill);
//console.log(skillindex);
});
}
_showNewTypeSkillDialog(targetskill){
new Dialog({
content:`<div><input type="text" name="new-type-skill-label" /></div>`,
title: "Add New Skill",
buttons: {
add:{
label: "Add Skill",
callback: btn =>{
let newTypeSkillLabel = btn.find("[name='new-type-skill-label']").val();
this._addNewTypedSkill(targetskill, newTypeSkillLabel);
}
}
}
}).render(true);
}
_addNewTypedSkill(targetskill, newTypeSkillLabel){
// It sucks, but seems like Foundry and/or Handlebars somehow converts 'types' from being typed as an array to an object...
// As such, normal array functions like 'push' won't work which makes doing the update difficult...
// So just create an array, add all existing items to it, then use that to update the existing object.
// Handlebars doesn't seem to be broken by this sudden update of the type from 'Object' to 'Array'.
let updatedData = duplicate(this.actor.data.data);
let typesArr = [];
let x;
for(x in updatedData.type_skills[targetskill].subskills){
if(Number.isNumeric(x)){
typesArr.push(updatedData.type_skills[targetskill].subskills[x]);
}
}
typesArr.push({specialization:newTypeSkillLabel, proficiency: 40, failure: false});
updatedData.type_skills[targetskill].subskills = typesArr;
this.actor.update({"data": updatedData});
}
/**
* Handle creating a new Owned Item for the actor using initial data defined in the HTML dataset
* @param {Event} event The originating click event
@@ -255,6 +274,10 @@ export class DeltaGreenActorSheet extends ActorSheet {
let currentBreakingPoint = 0;
currentBreakingPoint = this.actor.data.data.sanity.value - this.actor.data.data.statistics.pow.value;
if(currentBreakingPoint < 0){
currentBreakingPoint = 0;
}
let updatedData = duplicate(this.actor.data.data);
updatedData.sanity.currentBreakingPoint = currentBreakingPoint;
+23 -12
View File
@@ -1,8 +1,7 @@
{
"Actor": {
"types": [
"agent",
"npc"
"agent"
],
"templates": {
"base": {
@@ -224,7 +223,7 @@
"art": {
"label": "Art",
"examples": "Sculpting, Painting, Dance, Music, Etc.",
"types":[
"subskills":[
{
"specialization": "Painting",
"proficiency": 0,
@@ -235,7 +234,7 @@
"craft": {
"label": "Craft",
"examples": "Mechanic, Carpentry, Electrical, Microelectronics, Locksmith, Gunsmith, Etc.",
"types":[
"subskills":[
{
"specialization": "Electrical",
"proficiency": 0,
@@ -246,7 +245,7 @@
"military_science": {
"label": "Military Science",
"examples": "Land, Air, Sea, Etc.",
"types":[
"subskills":[
{
"specialization": "Land",
"proficiency": 0,
@@ -257,7 +256,7 @@
"pilot": {
"label": "Pilot",
"examples": "Airplane, Drone, Small Boat, Ship, Helicopter, Space Shuttle, etc.",
"types":[
"subskills":[
{
"specialization": "Airplane",
"proficiency": 0,
@@ -268,7 +267,7 @@
"science": {
"label": "Science",
"examples": "Biology, Chemistry, Physics, Astronomy, Geology, Mathematics, etc.",
"types":[
"subskills":[
{
"specialization": "Biology/Chemistry/Physics/Etc.",
"proficiency": 0,
@@ -279,7 +278,7 @@
"foreign_languages": {
"label": "Foreign Languages",
"examples": "Spanish, Yiddish, Aklo, etc.",
"types":[
"subskills":[
{
"specialization": "Spanish",
"proficiency": 0,
@@ -290,7 +289,7 @@
"other_skills": {
"label": "Other Skills, Specialties, or Training",
"examples": "Lockpicks, SCUBA Diving, Parachuting, Some Exotic Weapon, etc.",
"types":[
"subskills":[
{
"specialization": "",
"proficiency": 0,
@@ -311,11 +310,23 @@
"value": 100,
"currentBreakingPoint": 101,
"adaptations": {
"violence": 0,
"helplessness": 0
"violence": [
false,
false,
false
],
"helplessness": [
false,
false,
false
]
}
},
"physicalDescription": "",
"physical":{
"description": "(Physical description of agent)",
"wounds": "",
"firstAidAttempted": false
},
"biography": {
"profession": "",
"employer": "",
+33 -14
View File
@@ -72,7 +72,7 @@
<span >({{numberFormat statistic.x5 decimals=0 sign=false}}%)</span>
</div>
<div >
<input type="text" name="data.statistics.{{key}}.distinguishing_feature" value="{{statistic.distinguishing_feature}}" data-dtype="Text" />
<input type="text" name="data.statistics.{{key}}.distinguishing_feature" value="{{statistic.distinguishing_feature}}" data-dtype="String" />
</div>
</div>
</div>
@@ -85,8 +85,8 @@
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="skills">Skills</a>
<a class="item" data-tab="gear">Gear</a>
<a class="item" data-tab="physical-description">Description</a>
<a class="item" data-tab="bonds">Bonds</a>
<a class="item" data-tab="bio">Biography</a>
<a class="item" data-tab="bonds">Motivations</a>
</nav>
{{!-- Sheet Body --}}
@@ -94,9 +94,9 @@
{{!-- Skills Tab --}}
<div class="tab skills" data-group="primary" data-tab="skills">
<div class="statistics grid grid-3col">
<div class="grid grid-3col">
{{#each data.skills as |skill key|}}
<div class="statistic flexrow flex-group-center">
<div class="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 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}} />
@@ -107,24 +107,21 @@
<div class="grid">
{{#each data.type_skills as |typeskill key|}}
<!-- <div class="statistic flexrow flex-group-left"></div> -->
<div class="">
<div class="flexrow flex-group-center">
<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}}
{{#each typeskill.subskills as |subskill index|}}
<!-- <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" />
<span class="rollable" data-roll="d100" data-target="{{this.proficiency}}" data-label="{{this.specialization}}" title="Click to roll a skill check." name="data.type_skills.{{key}}.subskills.{{@index}}.specialization" >{{this.specialization}}</span>
<input class="percentile-skill-input" type="text" name="data.type_skills.{{key}}.subskills.{{@index}}.proficiency" value="{{this.proficiency}}" data-dtype="Number"/>
<input type="checkbox" name="data.type_skills.{{key}}.subskills.{{@index}}.failure" {{checked this.failure}} data-dtype="Boolean" />
</div>
{{/each}}
@@ -159,7 +156,29 @@
</div>
{{!-- Description Tab --}}
<div class="tab physical-description" data-group="primary" data-tab="physical-description">
<div class="tab bio" data-group="primary" data-tab="bio">
<div class="bio-grid-5col">
<span>Sex</span>
<input class="fill-remaining-space" type="text" name="data.biography.sex" value="{{data.biography.sex}}" data-dtype="String" placeholder="Sex" />
<span></span>
<span class="bio-grid-label">Age And D.O.B</span>
<input class="fill-remaining-space" type="text" name="data.biography.sex" value="{{data.biography.sex}}" data-dtype="String" placeholder="Age & Date of Birth" />
</div>
<div class="bio-grid-2col">
<span>Employer</span>
<input class="fill-remaining-space" type="text" name="data.biography.employer" value="{{data.biography.employer}}" data-dtype="String" placeholder="Employer or Work History" />
<span>Nationality</span>
<input class="fill-remaining-space" type="text" name="data.biography.nationality" value="{{data.biography.nationality}}" data-dtype="String" placeholder="Nationality" />
</div>
<div class="bio-grid-2col">
<span>Education</span>
<input class="fill-remaining-space" type="text" name="data.biography.education" value="{{data.biography.education}}" data-dtype="String" placeholder="Education and occupational history" />
</div>
{{editor content=data.physicalDescription target="data.physicalDescription" button=true owner=owner editable=editable}}
</div>