Foundry v13 migrtion
This commit is contained in:
@@ -14,8 +14,8 @@ export class SoSActor extends Actor {
|
||||
/**
|
||||
* Override the create() function to provide additional SoS functionality.
|
||||
*
|
||||
* This overrided create() function adds initial items
|
||||
* Namely: Basic skills, money,
|
||||
* This overrided create() function adds initial items
|
||||
* Namely: Basic skills, money,
|
||||
*
|
||||
* @param {Object} data Barebones actor data which this function adds onto.
|
||||
* @param {Object} options (Unused) Additional options which customize the creation workflow.
|
||||
@@ -64,7 +64,7 @@ export class SoSActor extends Actor {
|
||||
if ( !this.system.cardDeck && this.hasPlayerOwner ) {
|
||||
this.system.cardDeck = new SoSCardDeck();
|
||||
this.system.cardDeck.initCardDeck( this, this.system.internals.deck );
|
||||
}
|
||||
}
|
||||
if ( !this.hasPlayerOwner ) {
|
||||
this.system.cardDeck = game.system.sos.gmDeck.GMdeck;
|
||||
console.log("DECK : ", this.system.cardDeck);
|
||||
@@ -91,28 +91,28 @@ export class SoSActor extends Actor {
|
||||
this.saveDeck();
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
drawNewEdge( ) {
|
||||
drawNewEdge( ) {
|
||||
this.system.cardDeck.drawEdge( 1 );
|
||||
this.saveDeck();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
discardEdge( cardName ) {
|
||||
discardEdge( cardName ) {
|
||||
this.system.cardDeck.discardEdge( cardName );
|
||||
this.saveDeck();
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
resetDeck( ) {
|
||||
this.system.cardDeck.resetDeck();
|
||||
this.saveDeck();
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
saveDeck( ) {
|
||||
let deck = { deck: foundry.utils.duplicate(this.system.cardDeck.data.deck),
|
||||
let deck = { deck: foundry.utils.duplicate(this.system.cardDeck.data.deck),
|
||||
discard: foundry.utils.duplicate(this.system.cardDeck.data.discard),
|
||||
cardEdge: foundry.utils.duplicate(this.system.cardDeck.data.cardEdge)
|
||||
cardEdge: foundry.utils.duplicate(this.system.cardDeck.data.cardEdge)
|
||||
}
|
||||
if ( this.hasPlayerOwner ) {
|
||||
this.update( { 'system.internals.deck': deck });
|
||||
@@ -123,22 +123,22 @@ export class SoSActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getDefense( ) {
|
||||
return this.system.scores.defense;
|
||||
}
|
||||
return this.system.scores.defense;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
computeDefense() {
|
||||
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.system.scores.edge.value;
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getEncumbrance( ) {
|
||||
return this.system.scores.encumbrance.value;
|
||||
}
|
||||
}
|
||||
computeEncumbrance( ) {
|
||||
return this.system.stats.strength.value + this.system.scores.encumbrance.bonusmalus;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ export class SoSActor extends Actor {
|
||||
computeWound() {
|
||||
return Math.ceil( (this.system.stats.strength.value + this.system.stats.endurance.value) / 2) + this.system.scores.wound.bonusmalus;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getSkillExperience( skillName ) {
|
||||
return this.items.filter( item => item.type == 'skillexperience' && item.system.skill == skillName);
|
||||
@@ -170,21 +170,21 @@ export class SoSActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async wornObject( itemID) {
|
||||
let item = this.items.get(itemID);
|
||||
if (item && item.system) {
|
||||
if (item?.system) {
|
||||
let update = { _id: item.id, "system.worn": !item.system.worn };
|
||||
await this.updateEmbeddedDocuments("Item", [update]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async equipObject(itemID) {
|
||||
let item = this.items.get(itemID)
|
||||
if (item && item.system) {
|
||||
if (item?.system) {
|
||||
let update = { _id: item.id, "system.equiped": !item.system.equiped };
|
||||
await this.updateEmbeddedDocuments("Item", [update]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async controlScores() {
|
||||
// Defense check
|
||||
@@ -257,10 +257,10 @@ export class SoSActor extends Actor {
|
||||
bonusConsequence: 0,
|
||||
woundMalus: 0
|
||||
}
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html', flipData);
|
||||
let html = await foundry.applications.handlebars.renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html', flipData);
|
||||
new SoSFlipDialog(flipData, html).render(true);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollSkill( skill ) {
|
||||
let flipData = {
|
||||
@@ -280,10 +280,10 @@ export class SoSActor extends Actor {
|
||||
bonusSkillXP: 0
|
||||
}
|
||||
flipData.statList['nostat'] = { label: "No stat (ie defaulting skills)", value: 0, cardsuit: "none" }
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html', flipData);
|
||||
let html = await foundry.applications.handlebars.renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html', flipData);
|
||||
new SoSFlipDialog(flipData, html).render(true);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollWeapon( weapon ) {
|
||||
let target = SoSUtility.getTarget();
|
||||
@@ -321,7 +321,7 @@ export class SoSActor extends Actor {
|
||||
console.log(flipData);
|
||||
|
||||
flipData.statList['nostat'] = { label: "No stat (ie defaulting skills)", value: 0, cardsuit: "none" }
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html', flipData);
|
||||
let html = await foundry.applications.handlebars.renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html', flipData);
|
||||
new SoSFlipDialog(flipData, html).render(true);
|
||||
}
|
||||
|
||||
@@ -329,12 +329,12 @@ export class SoSActor extends Actor {
|
||||
async checkDeath( ) {
|
||||
if ( this.system.scores.currentwounds.value >= this.system.scores.wound.value*2) {
|
||||
let woundData = {
|
||||
name: this.name,
|
||||
name: this.name,
|
||||
wounds: this.system.wounds,
|
||||
currentWounds: this.system.scores.currentwounds.value,
|
||||
totalWounds: this.system.scores.wound.value
|
||||
totalWounds: this.system.scores.wound.value
|
||||
}
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-character-death.html', woundData );
|
||||
let html = await foundry.applications.handlebars.renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-character-death.html', woundData );
|
||||
ChatMessage.create( { content: html, whisper: ChatMessage.getWhisperRecipients(this.name).concat(ChatMessage.getWhisperRecipients("GM") ) } )
|
||||
}
|
||||
}
|
||||
@@ -360,15 +360,15 @@ export class SoSActor extends Actor {
|
||||
currentWounds.value = sumWound;
|
||||
await this.update( { 'data.scores.currentwounds': currentWounds, 'data.wounds': wounds } );
|
||||
|
||||
let woundData = {
|
||||
name: this.name,
|
||||
let woundData = {
|
||||
name: this.name,
|
||||
consequenceName: consequenceName,
|
||||
severity: severity,
|
||||
severity: severity,
|
||||
wounds: wounds,
|
||||
currentWounds: sumWound,
|
||||
totalWounds: this.system.scores.wound.value
|
||||
}
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-damage-consequence.html', woundData );
|
||||
let html = await foundry.applications.handlebars.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")) } )
|
||||
|
||||
this.checkDeath();
|
||||
@@ -387,10 +387,10 @@ export class SoSActor extends Actor {
|
||||
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 {
|
||||
} else {
|
||||
setTimeout(function() { this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'system.containerid':containerId }])}, 800 )
|
||||
}
|
||||
} else if ( object && object.system.containerid) { // remove from container
|
||||
} else if ( object?.system?.containerid) { // remove from container
|
||||
setTimeout(function() { this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'system.containerid':"" }])}, 800 )
|
||||
}
|
||||
}
|
||||
@@ -398,8 +398,8 @@ export class SoSActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async applyWounds( flipData ) {
|
||||
if ( flipData.damageStatus == 'no_damage') {
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-nodamage-taken.html', flipData );
|
||||
ChatMessage.create( { content: html, whisper: ChatMessage.getWhisperRecipients(this.name).concat(ChatMessage.getWhisperRecipients("GM")) } );
|
||||
let html = await foundry.applications.handlebars.renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-nodamage-taken.html', flipData );
|
||||
ChatMessage.create( { content: html, whisper: ChatMessage.getWhisperRecipients(this.name).concat(ChatMessage.getWhisperRecipients("GM")) } );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ export class SoSActor extends Actor {
|
||||
flipData.wounds = wounds;
|
||||
flipData.currentWounds = sumWound;
|
||||
flipData.totalWounds = this.system.scores.wound.value;
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-damage-taken.html', flipData );
|
||||
let html = await foundry.applications.handlebars.renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-damage-taken.html', flipData );
|
||||
ChatMessage.create( { content: html, whisper: ChatMessage.getWhisperRecipients(this.name).concat(ChatMessage.getWhisperRecipients("GM")) } );
|
||||
|
||||
this.checkDeath();
|
||||
|
||||
Reference in New Issue
Block a user