v10 branch - Update manifest
This commit is contained in:
@ -23,7 +23,7 @@ export class SoSActorSheet extends ActorSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getData() {
|
||||
const objectData = SoSUtility.data(this.object);
|
||||
const objectData = this.object
|
||||
let formData = {
|
||||
title: this.title,
|
||||
id: objectData.id,
|
||||
@ -32,7 +32,7 @@ export class SoSActorSheet extends ActorSheet {
|
||||
name: objectData.name,
|
||||
editable: this.isEditable,
|
||||
cssClass: this.isEditable ? "editable" : "locked",
|
||||
data: foundry.utils.deepClone(this.object.data),
|
||||
data: foundry.utils.deepClone(this.object.system),
|
||||
effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)),
|
||||
limited: this.object.limited,
|
||||
options: this.options,
|
||||
@ -44,52 +44,52 @@ export class SoSActorSheet extends ActorSheet {
|
||||
formData.edgecard = this.actor.getEdgesCard();
|
||||
formData.deckSize = this.actor.getDeckSize();
|
||||
|
||||
formData.skills = this.actor.data.items.filter( item => item.type == 'skill').sort( (a, b) => {
|
||||
formData.skills = this.actor.items.filter( item => item.type == 'skill').sort( (a, b) => {
|
||||
if ( a.name > b.name ) return 1;
|
||||
return -1;
|
||||
});
|
||||
|
||||
formData.skill1 = formData.skills.slice(0, Math.ceil(formData.skills.length/2) )
|
||||
formData.skill2 = formData.skills.slice(Math.ceil(formData.skills.length/2), formData.skills.length )
|
||||
formData.consequences = this.actor.data.items.filter( item => item.type == 'consequence').sort( (a, b) => {
|
||||
formData.consequences = this.actor.items.filter( item => item.type == 'consequence').sort( (a, b) => {
|
||||
if ( a.name > b.name ) return 1;
|
||||
return -1;
|
||||
});
|
||||
formData.gears = this.actor.data.items.filter( item => item.type == 'gear').concat( this.actor.data.items.filter( item => item.type == 'container') );
|
||||
formData.gears = this.actor.items.filter( item => item.type == 'gear').concat( this.actor.items.filter( item => item.type == 'container') );
|
||||
|
||||
// Build the gear tree
|
||||
formData.gearsRoot = formData.gears.filter(item => item.data.data.containerid == "");
|
||||
formData.gearsRoot = formData.gears.filter(item => item.system.containerid == "");
|
||||
for ( let container of formData.gearsRoot) {
|
||||
if ( container.type == 'container') {
|
||||
container.data.contains = []
|
||||
container.data.containerEnc = 0;
|
||||
for (let gear of formData.gears) {
|
||||
console.log("GEAR", gear, container)
|
||||
if ( gear.data.data.containerid == container.id) {
|
||||
if ( gear.system.containerid == container.id) {
|
||||
container.data.contains.push( gear )
|
||||
if ( !gear.data.data.neg && !gear.data.data.software ) {
|
||||
container.data.containerEnc += (gear.data.data.big > 0) ? gear.data.data.big : 1;
|
||||
if ( !gear.system.neg && !gear.system.software ) {
|
||||
container.system.containerEnc += (gear.system.big > 0) ? gear.system.big : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
formData.weapons = this.actor.data.items.filter( item => item.type == 'weapon');
|
||||
formData.armors = this.actor.data.items.filter( item => item.type == 'armor');
|
||||
formData.totalEncumbrance = SoSUtility.computeEncumbrance(this.actor.data.items);
|
||||
formData.wounds = duplicate(this.actor.data.data.wounds);
|
||||
formData.weapons = this.actor.items.filter( item => item.type == 'weapon');
|
||||
formData.armors = this.actor.items.filter( item => item.type == 'armor');
|
||||
formData.totalEncumbrance = SoSUtility.computeEncumbrance(this.actor.items);
|
||||
formData.wounds = duplicate(this.actor.system.wounds);
|
||||
formData.isGM = game.user.isGM;
|
||||
formData.currentWounds = this.actor.computeCurrentWounds();
|
||||
formData.totalWounds = this.actor.data.data.scores.wound.value;
|
||||
formData.totalWounds = this.actor.system.scores.wound.value;
|
||||
|
||||
formData.subcultureList = this.actor.data.items.filter( item => item.type == 'subculture');
|
||||
formData.subcultureList = this.actor.items.filter( item => item.type == 'subculture');
|
||||
if ( formData.subculture != "" ) { // background.subculture contains the main subculture ID
|
||||
formData.mainSubculture = formData.subcultureList.find( subc => subc._id == data.data.subculture);
|
||||
formData.mainSubculture = formData.subcultureList.find( subc => subc._id == this.actor.system.subculture);
|
||||
}
|
||||
formData.languageList = this.actor.data.items.filter( item => item.type == 'language');
|
||||
formData.weaknessList = this.actor.data.items.filter( item => item.type == 'weakness');
|
||||
formData.geneline = this.actor.data.items.find( item => item.type == 'geneline');
|
||||
formData.languageList = this.actor.items.filter( item => item.type == 'language');
|
||||
formData.weaknessList = this.actor.items.filter( item => item.type == 'weakness');
|
||||
formData.geneline = this.actor.items.find( item => item.type == 'geneline');
|
||||
formData.editStatSkill = this.options.editStatSkill;
|
||||
|
||||
console.log("stats", formData);
|
||||
@ -178,7 +178,7 @@ export class SoSActorSheet extends ActorSheet {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const item = this.actor.items.get(li.data("item-id"));
|
||||
let severity = $(event.currentTarget).val();
|
||||
this.actor.updateEmbeddedDocuments( "Item", [ { _id: item.id, 'data.severity': severity} ] );
|
||||
this.actor.updateEmbeddedDocuments( "Item", [ { _id: item.id, 'system.severity': severity} ] );
|
||||
this.render(true);
|
||||
});
|
||||
html.find('.lock-unlock-sheet').click((event) => {
|
||||
|
132
module/actor.js
132
module/actor.js
@ -63,7 +63,7 @@ export class SoSActor extends Actor {
|
||||
checkDeck() {
|
||||
if ( !this.cardDeck && this.hasPlayerOwner ) {
|
||||
this.cardDeck = new SoSCardDeck();
|
||||
this.cardDeck.initCardDeck( this, this.data.data.internals.deck );
|
||||
this.cardDeck.initCardDeck( this, this.system.internals.deck );
|
||||
}
|
||||
if ( !this.hasPlayerOwner ) {
|
||||
this.cardDeck = game.system.sos.gmDeck.GMdeck;
|
||||
@ -87,7 +87,7 @@ export class SoSActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
resetDeckFull( ) {
|
||||
this.cardDeck.shuffleDeck();
|
||||
this.cardDeck.drawEdge( this.data.data.scores.edge.value );
|
||||
this.cardDeck.drawEdge( this.system.scores.edge.value );
|
||||
this.saveDeck();
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
@ -123,55 +123,55 @@ export class SoSActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getDefense( ) {
|
||||
return this.data.data.scores.defense;
|
||||
return this.system.scores.defense;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
computeDefense() {
|
||||
return { value: Math.ceil((this.data.data.stats.speed.value + this.data.data.stats.perception.value + this.data.data.stats.dexterity.value) / 2) + this.data.data.scores.defense.bonusmalus,
|
||||
critical: this.data.data.stats.speed.value + this.data.data.stats.perception.value + this.data.data.stats.dexterity.value + this.data.data.scores.defense.bonusmalus
|
||||
return { value: Math.ceil((this.system.stats.speed.value + this.system.stats.perception.value + this.system.stats.dexterity.value) / 2) + this.system.scores.defense.bonusmalus,
|
||||
critical: this.system.stats.speed.value + this.system.stats.perception.value + this.system.stats.dexterity.value + this.system.scores.defense.bonusmalus
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getEdge( ) {
|
||||
return this.data.data.scores.edge.value;
|
||||
return this.system.scores.edge.value;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getEncumbrance( ) {
|
||||
return this.data.data.scores.encumbrance.value;
|
||||
return this.system.scores.encumbrance.value;
|
||||
}
|
||||
computeEncumbrance( ) {
|
||||
return this.data.data.stats.strength.value + this.data.data.scores.encumbrance.bonusmalus;
|
||||
return this.system.stats.strength.value + this.system.scores.encumbrance.bonusmalus;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeEdge( ) {
|
||||
return Math.ceil( (this.data.data.stats.intelligence.value + this.data.data.stats.charisma.value) / 2) + this.data.data.scores.edge.bonusmalus;
|
||||
return Math.ceil( (this.system.stats.intelligence.value + this.system.stats.charisma.value) / 2) + this.system.scores.edge.bonusmalus;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getShock( ) {
|
||||
return this.data.data.scores.shock.value;
|
||||
return this.system.scores.shock.value;
|
||||
}
|
||||
computeShock() {
|
||||
return Math.ceil( this.data.data.stats.endurance.value + this.data.data.stats.determination.value + this.data.data.scores.dr.value) + this.data.data.scores.shock.bonusmalus;
|
||||
return Math.ceil( this.system.stats.endurance.value + this.system.stats.determination.value + this.system.scores.dr.value) + this.system.scores.shock.bonusmalus;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getWound( ) {
|
||||
return this.data.data.scores.wound.value;
|
||||
return this.system.scores.wound.value;
|
||||
}
|
||||
computeWound() {
|
||||
return Math.ceil( (this.data.data.stats.strength.value + this.data.data.stats.endurance.value) / 2) + this.data.data.scores.wound.bonusmalus;
|
||||
return Math.ceil( (this.system.stats.strength.value + this.system.stats.endurance.value) / 2) + this.system.scores.wound.bonusmalus;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getSkillExperience( skillName ) {
|
||||
return this.data.items.filter( item => item.type == 'skillexperience' && item.data.skill == skillName);
|
||||
return this.items.filter( item => item.type == 'skillexperience' && item.system.skill == skillName);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async wornObject( itemID) {
|
||||
let item = this.items.get(itemID);
|
||||
if (item && item.data.data) {
|
||||
let update = { _id: item.id, "data.worn": !item.data.data.worn };
|
||||
if (item && item.system) {
|
||||
let update = { _id: item.id, "system.worn": !item.system.worn };
|
||||
await this.updateEmbeddedDocuments("Item", [update]);
|
||||
}
|
||||
}
|
||||
@ -179,8 +179,8 @@ export class SoSActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async equipObject(itemID) {
|
||||
let item = this.items.get(itemID)
|
||||
if (item && item.data.data) {
|
||||
let update = { _id: item.id, "data.equiped": !item.data.data.equiped };
|
||||
if (item && item.system) {
|
||||
let update = { _id: item.id, "system.equiped": !item.system.equiped };
|
||||
await this.updateEmbeddedDocuments("Item", [update]);
|
||||
}
|
||||
}
|
||||
@ -198,7 +198,7 @@ export class SoSActor extends Actor {
|
||||
await this.update( {'data.scores.edge.value': this.computeEdge()});
|
||||
}
|
||||
// Encumbrance
|
||||
if ( this.getEncumbrance() != this.data.data.stats.strength.value ) {
|
||||
if ( this.getEncumbrance() != this.system.stats.strength.value ) {
|
||||
await this.update( {'data.scores.encumbrance.value': this.computeEncumbrance() });
|
||||
}
|
||||
// Shock
|
||||
@ -213,31 +213,31 @@ export class SoSActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateWound(woundName, value) {
|
||||
let wounds = duplicate(this.data.data.wounds)
|
||||
let wounds = duplicate(this.system.wounds)
|
||||
wounds[woundName] = value;
|
||||
await this.update( { 'data.wounds': wounds } );
|
||||
await this.update( { 'system.wounds': wounds } );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateSkill(skillName, value) {
|
||||
let skill = this.data.items.find( item => item.name == skillName);
|
||||
let skill = this.items.find( item => item.name == skillName);
|
||||
if (skill) {
|
||||
const update = { _id: skill.id, 'data.value': value };
|
||||
const update = { _id: skill.id, 'system.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);
|
||||
let skill = this.items.find( item => item.name == skillName);
|
||||
if (skill) {
|
||||
const update = { _id: skill.id, 'data.xp': value };
|
||||
const update = { _id: skill.id, 'system.xp': value };
|
||||
const updated = await this.updateEmbeddedDocuments("Item", [update]); // Updates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getApplicableConsequences( ) {
|
||||
let consequences = this.data.items.filter( item => item.type == 'consequence' && item.data.severity != 'none');
|
||||
let consequences = this.items.filter( item => item.type == 'consequence' && item.system.severity != 'none');
|
||||
return consequences;
|
||||
}
|
||||
|
||||
@ -246,13 +246,13 @@ export class SoSActor extends Actor {
|
||||
|
||||
let flipData = {
|
||||
mode: 'stat',
|
||||
stat: duplicate(this.data.data.stats[statKey]),
|
||||
stat: duplicate(this.system.stats[statKey]),
|
||||
actor: this,
|
||||
modifierList: SoSUtility.fillRange(-10, +10),
|
||||
tnList: SoSUtility.fillRange(6, 20),
|
||||
consequencesList: duplicate( this.getApplicableConsequences() ),
|
||||
weaknessList: this.data.items.filter( item => item.type == 'weakness' ),
|
||||
wounds: duplicate( this.data.data.wounds),
|
||||
weaknessList: this.items.filter( item => item.type == 'weakness' ),
|
||||
wounds: duplicate( this.system.wounds),
|
||||
malusConsequence: 0,
|
||||
bonusConsequence: 0,
|
||||
woundMalus: 0
|
||||
@ -265,10 +265,10 @@ export class SoSActor extends Actor {
|
||||
async rollSkill( skill ) {
|
||||
let flipData = {
|
||||
mode: 'skill',
|
||||
statList: duplicate(this.data.data.stats),
|
||||
statList: duplicate(this.system.stats),
|
||||
selectedStat: 'strength',
|
||||
consequencesList: duplicate( this.getApplicableConsequences() ),
|
||||
wounds: duplicate( this.data.data.wounds),
|
||||
wounds: duplicate( this.system.wounds),
|
||||
skillExperienceList: this.getSkillExperience( skill.name),
|
||||
skill: duplicate(skill),
|
||||
actor: this,
|
||||
@ -288,26 +288,26 @@ export class SoSActor extends Actor {
|
||||
async rollWeapon( weapon ) {
|
||||
let target = SoSUtility.getTarget();
|
||||
let skill, selectedStatName;
|
||||
if ( weapon.data.data.category == 'ballistic' || weapon.data.data.category == 'laser' ) {
|
||||
skill = this.data.items.find( item => item.name == 'Guns');
|
||||
if ( weapon.system.category == 'ballistic' || weapon.system.category == 'laser' ) {
|
||||
skill = this.items.find( item => item.name == 'Guns');
|
||||
selectedStatName = 'dexterity';
|
||||
} else if ( weapon.data.data.category == 'melee' ) {
|
||||
skill = this.data.items.find( item => item.name == 'Melee');
|
||||
} else if ( weapon.system.category == 'melee' ) {
|
||||
skill = this.items.find( item => item.name == 'Melee');
|
||||
selectedStatName = 'dexterity';
|
||||
} else if ( weapon.data.data.category == 'grenade' ) {
|
||||
skill = this.data.items.find( item => item.name == 'Athletics');
|
||||
} else if ( weapon.system.category == 'grenade' ) {
|
||||
skill = this.items.find( item => item.name == 'Athletics');
|
||||
selectedStatName = 'dexterity';
|
||||
}
|
||||
|
||||
let flipData = {
|
||||
mode: 'weapon',
|
||||
weapon: duplicate(weapon.data),
|
||||
statList: duplicate(this.data.data.stats),
|
||||
weapon: duplicate(weapon),
|
||||
statList: duplicate(this.system.stats),
|
||||
target: target,
|
||||
selectedStat: selectedStatName,
|
||||
consequencesList: duplicate( this.getApplicableConsequences() ),
|
||||
skillExperienceList: this.getSkillExperience( skill.name),
|
||||
wounds: duplicate( this.data.data.wounds),
|
||||
wounds: duplicate( this.system.wounds),
|
||||
skill: duplicate(skill),
|
||||
actor: this,
|
||||
modifierList: SoSUtility.fillRange(-10, +10),
|
||||
@ -327,12 +327,12 @@ export class SoSActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async checkDeath( ) {
|
||||
if ( this.data.data.scores.currentwounds.value >= this.data.data.scores.wound.value*2) {
|
||||
if ( this.system.scores.currentwounds.value >= this.system.scores.wound.value*2) {
|
||||
let woundData = {
|
||||
name: this.name,
|
||||
wounds: this.data.data.wounds,
|
||||
currentWounds: this.data.data.scores.currentwounds.value,
|
||||
totalWounds: this.data.data.scores.wound.value
|
||||
wounds: this.system.wounds,
|
||||
currentWounds: this.system.scores.currentwounds.value,
|
||||
totalWounds: this.system.scores.wound.value
|
||||
}
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-character-death.html', woundData );
|
||||
ChatMessage.create( { content: html, whisper: [ChatMessage.getWhisperRecipients(this.name), ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
@ -341,7 +341,7 @@ export class SoSActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeCurrentWounds( ) {
|
||||
let wounds = this.data.data.wounds;
|
||||
let wounds = this.system.wounds;
|
||||
return wounds.light + (wounds.moderate*2) + (wounds.severe*3) + (wounds.critical*4);
|
||||
}
|
||||
|
||||
@ -349,14 +349,14 @@ export class SoSActor extends Actor {
|
||||
async applyConsequenceWound( severity, consequenceName) {
|
||||
if ( severity == 'none') return; // Nothing !
|
||||
|
||||
let wounds = duplicate(this.data.data.wounds);
|
||||
let wounds = duplicate(this.system.wounds);
|
||||
if (severity == 'light' ) wounds.light += 1;
|
||||
if (severity == 'moderate' ) wounds.moderate += 1;
|
||||
if (severity == 'severe' ) wounds.severe += 1;
|
||||
if (severity == 'critical' ) wounds.critical += 1;
|
||||
|
||||
let sumWound = wounds.light + (wounds.moderate*2) + (wounds.severe*3) + (wounds.critical*4);
|
||||
let currentWounds = duplicate(this.data.data.scores.currentwounds);
|
||||
let currentWounds = duplicate(this.system.scores.currentwounds);
|
||||
currentWounds.value = sumWound;
|
||||
await this.update( { 'data.scores.currentwounds': currentWounds, 'data.wounds': wounds } );
|
||||
|
||||
@ -366,7 +366,7 @@ export class SoSActor extends Actor {
|
||||
severity: severity,
|
||||
wounds: wounds,
|
||||
currentWounds: sumWound,
|
||||
totalWounds: this.data.data.scores.wound.value
|
||||
totalWounds: this.system.scores.wound.value
|
||||
}
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-damage-consequence.html', woundData );
|
||||
ChatMessage.create( { content: html, whisper: ChatMessage.getWhisperRecipients(this.name).concat(ChatMessage.getWhisperRecipients("GM")) } );
|
||||
@ -376,22 +376,22 @@ export class SoSActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addObjectToContainer( itemId, containerId ) {
|
||||
let container = this.data.items.find( item => item.id == containerId && item.type == 'container')
|
||||
let object = this.data.items.find( item => item.id == itemId )
|
||||
let container = this.items.find( item => item.id == containerId && item.type == 'container')
|
||||
let object = this.items.find( item => item.id == itemId )
|
||||
console.log("Found", container, object)
|
||||
if ( container ) {
|
||||
if ( object.type == 'container') {
|
||||
ui.notifications.warn("Only 1 level of container... sorry");
|
||||
return
|
||||
}
|
||||
let alreadyInside = this.data.items.filter( item => item.data.data.containerid && item.data.data.containerid == containerId);
|
||||
if ( alreadyInside.length >= container.data.data.container ) {
|
||||
let alreadyInside = this.items.filter( item => item.system.containerid && item.system.containerid == containerId);
|
||||
if ( alreadyInside.length >= container.system.container ) {
|
||||
ui.notifications.warn("Container is already full !");
|
||||
} else {
|
||||
await this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'data.containerid':containerId }]);
|
||||
await this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'system.containerid':containerId }]);
|
||||
}
|
||||
} else if ( object && object.data.data.containerid) { // remove from container
|
||||
await this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'data.containerid':"" }]);
|
||||
} else if ( object && object.system.containerid) { // remove from container
|
||||
await this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'system.containerid':"" }]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -403,7 +403,7 @@ export class SoSActor extends Actor {
|
||||
return;
|
||||
}
|
||||
|
||||
let wounds = duplicate(this.data.data.wounds);
|
||||
let wounds = duplicate(this.system.wounds);
|
||||
for (let wound of flipData.woundsList ) {
|
||||
if (wound == 'L' ) wounds.light += 1;
|
||||
if (wound == 'M' ) wounds.moderate += 1;
|
||||
@ -412,30 +412,30 @@ export class SoSActor extends Actor {
|
||||
}
|
||||
// Compute total
|
||||
let sumWound = wounds.light + (wounds.moderate*2) + (wounds.severe*3) + (wounds.critical*4);
|
||||
let currentWounds = duplicate(this.data.data.scores.currentwounds);
|
||||
let currentWounds = duplicate(this.system.scores.currentwounds);
|
||||
currentWounds.value = sumWound;
|
||||
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.data.severity );
|
||||
await this.updateEmbeddedDocuments( "Item", [ { _id: bleeding.id, 'data.severity': newSeverity} ] );
|
||||
if ( sumWound >= this.system.scores.wound.value) {
|
||||
let bleeding = this.items.find( item => item.type == 'consequence' && item.name == 'Bleeding');
|
||||
let newSeverity = SoSUtility.increaseConsequenceSeverity( bleeding.system.severity );
|
||||
await this.updateEmbeddedDocuments( "Item", [ { _id: bleeding.id, 'system.severity': newSeverity} ] );
|
||||
flipData.isBleeding = newSeverity;
|
||||
}
|
||||
// Stun consequence
|
||||
if ( flipData.nbStun > 0) {
|
||||
let stun = this.data.items.find( item => item.type == 'consequence' && item.name == 'Stun');
|
||||
let newSeverity = stun.data.severity;
|
||||
let stun = this.items.find( item => item.type == 'consequence' && item.name == 'Stun');
|
||||
let newSeverity = stun.system.severity;
|
||||
for(let i=0; i<flipData.nbStun; i++) {
|
||||
newSeverity = SoSUtility.increaseConsequenceSeverity( newSeverity );
|
||||
}
|
||||
await this.updateEmbeddedDocuments( "Item", [ { _id: stun.id, 'data.severity': newSeverity} ] );
|
||||
await this.updateEmbeddedDocuments( "Item", [ { _id: stun.id, 'system.severity': newSeverity} ] );
|
||||
flipData.isStun = newSeverity;
|
||||
}
|
||||
await this.update( { 'data.scores.currentwounds': currentWounds, 'data.wounds': wounds } );
|
||||
await this.update( { 'data.scores.currentwounds': currentWounds, 'system.wounds': wounds } );
|
||||
|
||||
flipData.defenderName = this.name;
|
||||
flipData.wounds = wounds;
|
||||
flipData.currentWounds = sumWound;
|
||||
flipData.totalWounds = this.data.data.scores.wound.value;
|
||||
flipData.totalWounds = this.system.scores.wound.value;
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-damage-taken.html', flipData );
|
||||
ChatMessage.create( { content: html, whisper: [ChatMessage.getWhisperRecipients(this.name), ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
|
||||
|
@ -43,7 +43,7 @@ export class SoSItemSheet extends ItemSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
const objectData = SoSUtility.data(this.object);
|
||||
const objectData = this.object
|
||||
let formData = {
|
||||
title: this.title,
|
||||
id: objectData.id,
|
||||
@ -52,8 +52,8 @@ export class SoSItemSheet extends ItemSheet {
|
||||
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)),
|
||||
data: foundry.utils.deepClone(this.object.system),
|
||||
effects: this.object.effects.map(e => foundry.utils.deepClone(e.system)),
|
||||
limited: this.object.limited,
|
||||
options: this.options,
|
||||
owner: this.document.isOwner
|
||||
@ -61,10 +61,10 @@ export class SoSItemSheet extends ItemSheet {
|
||||
|
||||
formData.isGM = game.user.isGM;
|
||||
if ( objectData.type == 'skillexperience') {
|
||||
formData.skillList = await SoSUtility.loadCompendiumNames("foundryvtt-shadows-over-sol.skills");
|
||||
formData.skillList = await SoSUtility.loadCompendiumNames("foundryvtt-shadows-over-sol.skills")
|
||||
}
|
||||
if ( objectData.type == 'skill' && this.object.options?.actor) {
|
||||
formData.skillExperienceList = this.object.options.actor.getSkillExperience( data.item.name );
|
||||
formData.skillExperienceList = this.object.options.actor.getSkillExperience( objectData.name )
|
||||
}
|
||||
return formData;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ export class SoSCombat extends Combat {
|
||||
for( let combatant of this.combatants) {
|
||||
this.setInitiative(combatant._id, -1 ); // Reset init
|
||||
let uniq = randomID(16);
|
||||
const name = combatant.actor ? combatant.actor.data.name : combatant.name;
|
||||
const name = combatant.actor ? combatant.actor.name : combatant.name;
|
||||
if ( combatant.players[0]) {
|
||||
// A player controls this combatant -> message !
|
||||
ChatMessage.create( { content: `New round ! Click on the button below to declare the actions of ${name} for round ${this.round} !<br>
|
||||
|
@ -30,7 +30,7 @@ export class SoSFlipDialog extends Dialog {
|
||||
if ( this.flipData.mode == 'skill' || this.flipData.mode == 'weapon' ) {
|
||||
let statKey = $('#statSelect').val();
|
||||
this.flipData.stat = duplicate( this.flipData.statList[ statKey ] );
|
||||
scoreBase = Math.floor(this.flipData.statList[ statKey ].value / 2) + this.flipData.skill.data.value;
|
||||
scoreBase = Math.floor(this.flipData.statList[ statKey ].value / 2) + this.flipData.skill.system.value
|
||||
} else { //Stat mode
|
||||
let statKey = $('#statSelect').val();
|
||||
scoreBase = this.flipData.stat.value;
|
||||
@ -62,7 +62,7 @@ export class SoSFlipDialog extends Dialog {
|
||||
$('.edge-card').click((event) => {
|
||||
let flipData = this.flipData;
|
||||
flipData.modifier = $('#modifier').val();
|
||||
flipData.tn = (flipData.target) ? flipData.target.actor.data.data.scores.defense.value : $('#tn').val();
|
||||
flipData.tn = (flipData.target) ? flipData.target.actor.system.scores.defense.value : $('#tn').val();
|
||||
flipData.edgeName = event.currentTarget.attributes['data-edge-card'].value;
|
||||
flipData.edgeLuck = $('#edge-luck').is(":checked");
|
||||
flipData.cardOrigin = "Edge";
|
||||
@ -94,7 +94,7 @@ export class SoSFlipDialog extends Dialog {
|
||||
for (let consequenceId of this.flipData.consequencesSelected) {
|
||||
let consequence = this.flipData.consequencesList.find( item => item._id == consequenceId);
|
||||
console.log(consequence, consequenceId);
|
||||
malusConsequence += SoSUtility.getConsequenceMalus( consequence.data.severity );
|
||||
malusConsequence += SoSUtility.getConsequenceMalus( consequence.system.severity );
|
||||
}
|
||||
$('#consequence-malus').text(malusConsequence);
|
||||
this.flipData.malusConsequence = malusConsequence;
|
||||
@ -108,7 +108,7 @@ export class SoSFlipDialog extends Dialog {
|
||||
for (let consequenceId of this.flipData.consequencesSelected) {
|
||||
let consequence = this.flipData.consequencesList.find( item => item._id == consequenceId);
|
||||
console.log(consequence, consequenceId);
|
||||
bonusConsequence += SoSUtility.getConsequenceBonus( consequence.data.severity );
|
||||
bonusConsequence += SoSUtility.getConsequenceBonus( consequence.system.severity );
|
||||
}
|
||||
$('#consequence-bonus').text(bonusConsequence);
|
||||
this.flipData.bonusConsequence = bonusConsequence;
|
||||
@ -164,7 +164,7 @@ export class SoSFlipDialog extends Dialog {
|
||||
flipData.stat = duplicate( flipData.statList[ statKey ] );
|
||||
}
|
||||
flipData.cardOrigin = "Deck";
|
||||
flipData.tn = (flipData.target) ? flipData.target.actor.data.data.scores.defense.value : $('#tn').val();
|
||||
flipData.tn = (flipData.target) ? flipData.target.actor.system.scores.defense.value : $('#tn').val();
|
||||
dialog.flipData.actor.cardDeck.doFlipFromDeckOrEdge(flipData);
|
||||
dialog.onFlipClose();
|
||||
});
|
||||
|
@ -97,6 +97,7 @@ function registerUsageCount( registerKey ) {
|
||||
name: "Unique world key",
|
||||
scope: "world",
|
||||
config: false,
|
||||
default: "XXX",
|
||||
type: String
|
||||
});
|
||||
|
||||
@ -106,7 +107,7 @@ function registerUsageCount( registerKey ) {
|
||||
game.settings.set(registerKey, "world-key", worldKey )
|
||||
}
|
||||
// Simple API counter
|
||||
let regURL = `https://www.uberwald.me/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.data.version}"`
|
||||
let regURL = `https://www.uberwald.me/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.version}"`
|
||||
$.ajax(regURL)
|
||||
/* -------------------------------------------- */
|
||||
}
|
||||
|
@ -55,20 +55,6 @@ export class SoSUtility {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static data(it) {
|
||||
if (it instanceof Actor || it instanceof Item || it instanceof Combatant) {
|
||||
return it.data;
|
||||
}
|
||||
return it;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static templateData(it) {
|
||||
return SoSUtility.data(it)?.data ?? {}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async loadCompendiumData(compendium) {
|
||||
const pack = game.packs.get(compendium);
|
||||
@ -411,13 +397,14 @@ export class SoSUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async processItemDropEvent(actorSheet, event) {
|
||||
let dragData = JSON.parse(event.dataTransfer.getData("text/plain"));
|
||||
let dropID = $(event.target).parents(".item").attr("data-item-id"); // Only relevant if container drop
|
||||
let objectID = dragData.id || dragData.data._id;
|
||||
//console.log("drag/drop", dragData, actorSheet.actor._id, dropID, objectID);
|
||||
if (dragData.type == 'Item' && dropID) {
|
||||
actorSheet.actor.addObjectToContainer(objectID, dropID );
|
||||
const item = fromUuidSync(dragData.uuid)
|
||||
let dropId = $(event.target).parents(".item").attr("data-item-id"); // Only relevant if container drop
|
||||
let objectId = item.id
|
||||
console.log("ID", dragData, dropId, objectId)
|
||||
if (dragData.type == 'Item' && dropId) {
|
||||
actorSheet.actor.addObjectToContainer(objectId, dropId );
|
||||
}
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user