Start 0.8 support

This commit is contained in:
sladecraven 2021-05-22 23:42:53 +02:00
parent 6ebc11c518
commit 3d23807820
6 changed files with 57 additions and 42 deletions

View File

@ -175,9 +175,9 @@ export class SoSActorSheet extends ActorSheet {
});
html.find('.consequence-severity').click((event) => {
const li = $(event.currentTarget).parents(".item");
const item = this.actor.getOwnedItem(li.data("item-id"));
const item = this.actor.items.get(li.data("item-id"));
let severity = $(event.currentTarget).val();
this.actor.updateOwnedItem( { id: item.id, 'data.severity': severity});
this.actor.updateEmbeddedDocuments( "Item", [ { _id: item.id, 'data.severity': severity} ] );
this.render(true);
});
html.find('.lock-unlock-sheet').click((event) => {

View File

@ -171,8 +171,8 @@ export class SoSActor extends Actor {
async wornObject( itemID) {
let item = this.getOwnedItem(itemID);
if (item && item.data.data) {
let update = { _id: item._id, "data.worn": !item.data.data.worn };
await this.updateEmbeddedEntity("OwnedItem", update);
let update = { _id: item.id, "data.worn": !item.data.data.worn };
await this.updateEmbeddedDocuments("Item", [update]);
}
}
@ -180,8 +180,8 @@ export class SoSActor extends Actor {
async equipObject(itemID) {
let item = this.getOwnedItem(itemID);
if (item && item.data.data) {
let update = { _id: item._id, "data.equiped": !item.data.data.equiped };
await this.updateEmbeddedEntity("OwnedItem", update);
let update = { _id: item.id, "data.equiped": !item.data.data.equiped };
await this.updateEmbeddedDocuments("Item", [update]);
}
}
@ -222,16 +222,16 @@ export class SoSActor extends Actor {
async updateSkill(skillName, value) {
let skill = this.data.items.find( item => item.name == skillName);
if (skill) {
const update = { _id: skill._id, 'data.value': value };
const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity
const update = { _id: skill.id, 'data.value': value };
const updated = await this.updateEmbeddedDocuments("Item", [ update] ); // Updates one EmbeddedEntity
}
}
/* -------------------------------------------- */
async updateSkillExperience(skillName, value) {
let skill = this.data.items.find( item => item.name == skillName);
if (skill) {
const update = { _id: skill._id, 'data.xp': value };
const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity
const update = { _id: skill.id, 'data.xp': value };
const updated = await this.updateEmbeddedDocuments("Item", [update]); // Updates one EmbeddedEntity
}
}
@ -387,10 +387,10 @@ export class SoSActor extends Actor {
if ( alreadyInside.length >= container.data.container ) {
ui.notifications.warn("Container is already full !");
} else {
await this.updateOwnedItem( { _id: object._id, 'data.containerid':containerId });
await this.updateOwnedItem( { _id: object.id, 'data.containerid':containerId });
}
} else if ( object && object.data.containerid) { // remove from container
await this.updateOwnedItem( { _id: object._id, 'data.containerid':"" });
await this.updateOwnedItem( { _id: object.id, 'data.containerid':"" });
}
}
@ -416,7 +416,7 @@ export class SoSActor extends Actor {
if ( sumWound >= this.data.data.scores.wound.value) {
let bleeding = this.data.items.find( item => item.type == 'consequence' && item.name == 'Bleeding');
let newSeverity = SoSUtility.increaseConsequenceSeverity( bleeding.severity );
await this.updateOwnedItem( { _id: bleeding._id, 'data.severity': newSeverity});
await this.updateOwnedItem( { _id: bleeding.id, 'data.severity': newSeverity});
flipData.isBleeding = newSeverity;
}
// Stun consequence
@ -426,7 +426,7 @@ export class SoSActor extends Actor {
for(i=0; i<flipData.nbStun; i++) {
newSeverity = SoSUtility.increaseConsequenceSeverity( newSeverity );
}
await this.updateOwnedItem( { _id: stun._id, 'data.severity': newSeverity});
await this.updateOwnedItem( { _id: stun.id, 'data.severity': newSeverity});
flipData.isStun = newSeverity;
}
await this.update( { 'data.scores.currentwounds': currentWounds, 'data.wounds': wounds } );

View File

@ -43,15 +43,30 @@ export class SoSItemSheet extends ItemSheet {
/* -------------------------------------------- */
async getData() {
let data = super.getData();
data.isGM = game.user.isGM;
if ( data.item.type == 'skillexperience') {
data.skillList = await SoSUtility.loadCompendiumNames("foundryvtt-shadows-over-sol.skills");
const objectData = SoSUtility.data(this.object);
let formData = {
title: this.title,
id: objectData.id,
type: objectData.type,
img: objectData.img,
name: objectData.name,
editable: this.isEditable,
cssClass: this.isEditable ? "editable" : "locked",
data: foundry.utils.deepClone(this.object.data),
effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)),
limited: this.object.limited,
options: this.options,
owner: this.document.isOwner
};
formData.isGM = game.user.isGM;
if ( objectData.type == 'skillexperience') {
formData.skillList = await SoSUtility.loadCompendiumNames("foundryvtt-shadows-over-sol.skills");
}
if ( data.item.type == 'skill' && this.object.options?.actor) {
data.skillExperienceList = this.object.options.actor.getSkillExperience( data.item.name );
if ( objectData.type == 'skill' && this.object.options?.actor) {
formData.skillExperienceList = this.object.options.actor.getSkillExperience( data.item.name );
}
return data;
return formData;
}
/* -------------------------------------------- */

View File

@ -130,8 +130,8 @@
{{else}}
<span class="skill-label"><a>{{skill.name}}</a></span>
{{/if}}
<input class="skill-value" type="text" skillname="{{skill.name}}" value="{{numberFormat skill.data.value decimals=0}}" data-dtype="number" {{#unless @root.data.editStatSkill}}disabled{{/unless}}/>
<input class="skill-xp" type="text" skillname="{{skill.name}}" value="{{skill.data.xp}}" data-dtype="number" {{#unless @root.data.editStatSkill}}disabled{{/unless}}/>
<input class="skill-value" type="text" skillname="{{skill.name}}" value="{{numberFormat skill.data.data.value decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
<input class="skill-xp" type="text" skillname="{{skill.name}}" value="{{skill.data.data.xp}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
<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>
@ -158,8 +158,8 @@
{{else}}
<span class="skill-label"><a>{{skill.name}}</a></span>
{{/if}}
<input class="skill-value" type="text" skillname="{{skill.name}}" value="{{numberFormat skill.data.value decimals=0}}" data-dtype="number" {{#unless @root.data.editStatSkill}}disabled{{/unless}}/>
<input class="skill-xp" type="text" skillname="{{skill.name}}" value="{{skill.data.xp}}" data-dtype="number" {{#unless @root.data.editStatSkill}}disabled{{/unless}}/>
<input class="skill-value" type="text" skillname="{{skill.name}}" value="{{numberFormat skill.data.data.value decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
<input class="skill-xp" type="text" skillname="{{skill.name}}" value="{{skill.data.data.xp}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
<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>
@ -182,16 +182,16 @@
<ul class="item-list alterne-list">
<li class="item flexrow list-item" data-wound-name="light"><h4>Wounds : </h4></li>
<li class="item flexrow list-item" data-wound-name="light"><span class="skill-label">Light :</span>
<input class="wound-value" type="text" woundname="light" value="{{numberFormat data.wounds.light decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
<input class="wound-value" type="text" woundname="light" value="{{numberFormat data.data.wounds.light decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
</li>
<li class="item flexrow list-item" data-wound-name="moderate"><span class="skill-label">Moderate :</span>
<input class="wound-value" type="text" woundname="moderate" value="{{numberFormat data.wounds.moderate decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
<input class="wound-value" type="text" woundname="moderate" value="{{numberFormat data.data.wounds.moderate decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
</li>
<li class="item flexrow list-item" data-wound-name="severe"><span class="skill-label">Severe :</span>
<input class="wound-value" type="text" woundname="severe" value="{{numberFormat data.wounds.severe decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
<input class="wound-value" type="text" woundname="severe" value="{{numberFormat data.data.wounds.severe decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
</li>
<li class="item flexrow list-item" data-wound-name="critical"><span class="skill-label">Critical :</span>
<input class="wound-value" type="text" woundname="critical" value="{{numberFormat data.wounds.critical decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
<input class="wound-value" type="text" woundname="critical" value="{{numberFormat data.data.wounds.critical decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
</li>
<li class="item flexrow list-item" data-wound-name="critical"><span class="skill-label">Total :</span>
<span class="skill-label">{{data.currentWounds}} / {{data.totalWounds}}</span>
@ -204,8 +204,8 @@
<li class="item flexrow list-item" data-item-id="{{conseq.id}}">
<img class="sheet-skill-img" src="{{conseq.img}}"/>
<span class="conseq-label">{{conseq.name}}</span>
<select class="consequence-severity" type="text" name="conseq.data.severity" value="{{conseq.data.severity}}" data-dtype="String">
{{#select conseq.data.severity}}
<select class="consequence-severity" type="text" name="conseq.data.data.severity" value="{{conseq.data.data.severity}}" data-dtype="String">
{{#select conseq.data.data.severity}}
<option value="none">None</option>
<option value="light">Light</option>
<option value="moderate">Moderate</option>
@ -390,12 +390,12 @@
<hr>
<h3>Biography : </h3>
<div class="form-group editor">
{{editor content=data.history target="data.history" button=true owner=owner editable=editable}}
{{editor content=data.data.history target="data.history" button=true owner=owner editable=editable}}
</div>
<hr>
<h3>Notes : </h3>
<div class="form-group editor">
{{editor content=data.notes target="data.notes" button=true owner=owner editable=editable}}
{{editor content=data.data.notes target="data.notes" button=true owner=owner editable=editable}}
</div>
<hr>
{{>"systems/foundryvtt-shadows-over-sol/templates/editor-notes-gm.html"}}

View File

@ -1,8 +1,8 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{item.img}}" data-edit="img" title="{{item.name}}"/>
<img class="profile-img" src="{{data.img}}" data-edit="img" title="{{data.name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{item.name}}" placeholder="Name"/></h1>
<h1 class="charname"><input name="name" type="text" value="{{data.name}}" placeholder="Name"/></h1>
</div>
</header>
@ -13,8 +13,8 @@
<div class="flexcol">
<label class="generic-label">Severity</label>
<div class="form-group small-editor">
<select class="stat-value flexrow" type="text" name="data.severity" value="{{data.severity}}" data-dtype="String">
{{#select data.severity}}
<select class="stat-value flexrow" type="text" name="data.severity" value="{{data.data.severity}}" data-dtype="String">
{{#select data.data.severity}}
<option value="none">None</option>
<option value="light">Light</option>
<option value="moderate">Moderate</option>
@ -27,7 +27,7 @@
<div class="flexcol">
<label class="generic-label">Description</label>
<div class="form-group medium-editor">
{{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
{{editor content=data.data.description target="data.description" button=true owner=owner editable=editable}}
</div>
</div>
</div>

View File

@ -1,8 +1,8 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{item.img}}" data-edit="img" title="{{item.name}}"/>
<img class="profile-img" src="{{data.img}}" data-edit="img" title="{{data.name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{item.name}}" placeholder="Name"/></h1>
<h1 class="charname"><input name="name" type="text" value="{{data.name}}" placeholder="Name"/></h1>
</div>
</header>
@ -11,7 +11,7 @@
<div class="tab" data-group="primary">
<ul>
<li class="flexrow"><label class="generic-label">Value</label><input type="text" name="data.value" value="{{data.value}}" data-dtype="Number"/></li>
<li class="flexrow"><label class="generic-label">Value</label><input type="text" name="data.data.value" value="{{data.data.value}}" data-dtype="Number"/></li>
<ul class="stat-list alternate-list">
<li class="stat flexrow list-item" data-attribute="{{key}}">
<span class="generic-label flexrow tooltip tooltip-nobottom" name="">Experiences list : </span>
@ -27,7 +27,7 @@
{{/each}}
</ul>
<label class="generic-label">Description</label>
{{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
{{editor content=data.data.description target="data.description" button=true owner=owner editable=editable}}
</div>
</section>