Upgrade
This commit is contained in:
@ -36,6 +36,11 @@ export class SoSActorSheet extends ActorSheet {
|
||||
if ( a.name > b.name ) return 1;
|
||||
return -1;
|
||||
});
|
||||
data.data.gears = this.actor.data.items.filter( item => item.type == 'gear');
|
||||
data.data.weapons = this.actor.data.items.filter( item => item.type == 'weapon');
|
||||
data.data.armors = this.actor.data.items.filter( item => item.type == 'armor');
|
||||
data.data.totalEncumbrance = SoSUtility.computeEncumbrance(this.actor.data.items);
|
||||
|
||||
data.data.subculture = this.actor.data.items.find( item => item.type == 'subculture');
|
||||
data.data.geneline = this.actor.data.items.find( item => item.type == 'geneline');
|
||||
data.data.editStatSkill = this.options.editStatSkill;
|
||||
@ -67,7 +72,17 @@ export class SoSActorSheet extends ActorSheet {
|
||||
const item = this.actor.getOwnedItem(li.data("item-id"));
|
||||
item.sheet.render(true);
|
||||
});
|
||||
|
||||
html.find('.item-equip').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const item = this.actor.equipObject( li.data("item-id") );
|
||||
this.render(true);
|
||||
});
|
||||
html.find('.item-worn').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const item = this.actor.wornObject( li.data("item-id") );
|
||||
this.render(true);
|
||||
});
|
||||
|
||||
// Delete Inventory Item
|
||||
html.find('.item-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
@ -83,6 +98,16 @@ export class SoSActorSheet extends ActorSheet {
|
||||
const skill = this.actor.getOwnedItem(li.data("item-id"));
|
||||
this.actor.rollSkill(skill);
|
||||
});
|
||||
html.find('.skill-value').change((event) => {
|
||||
let skillName = event.currentTarget.attributes.skillname.value;
|
||||
//console.log("Competence changed :", skillName);
|
||||
this.actor.updateSkill(skillName, parseInt(event.target.value));
|
||||
});
|
||||
html.find('.skill-xp').change((event) => {
|
||||
let skillName = event.currentTarget.attributes.skillname.value;
|
||||
//console.log("Competence changed :", skillName);
|
||||
this.actor.updateSkillExperience(skillName, parseInt(event.target.value));
|
||||
});
|
||||
html.find('.reset-deck-full').click((event) => {
|
||||
this.actor.resetDeckFull();
|
||||
this.render(true);
|
||||
@ -124,7 +149,6 @@ export class SoSActorSheet extends ActorSheet {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
_updateObject(event, formData) {
|
||||
|
@ -128,7 +128,25 @@ export class SoSActor extends Actor {
|
||||
computeWound() {
|
||||
return Math.ceil( (this.data.data.stats.strength.value + this.data.data.stats.endurance.value) / 2);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async controlScores() {
|
||||
// Defense check
|
||||
@ -155,6 +173,29 @@ 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
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getApplicableConsequences( ) {
|
||||
let consequences = this.data.items.filter( item => item.type == 'consequence' && item.data.severity != 'none');
|
||||
return consequences;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollStat( statKey ) {
|
||||
|
||||
@ -163,7 +204,9 @@ export class SoSActor extends Actor {
|
||||
stat: duplicate(this.data.data.stats[statKey]),
|
||||
actor: this,
|
||||
modifierList: SoSUtility.fillRange(-10, +10),
|
||||
tnList: SoSUtility.fillRange(6, 20)
|
||||
tnList: SoSUtility.fillRange(6, 20),
|
||||
consequencesList: duplicate( this.getApplicableConsequences() ),
|
||||
malusConsequence: 0
|
||||
}
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html', flipData);
|
||||
new SoSFlipDialog(flipData, html).render(true);
|
||||
@ -175,10 +218,12 @@ export class SoSActor extends Actor {
|
||||
let flipData = {
|
||||
mode: 'skill',
|
||||
statList: duplicate(this.data.data.stats),
|
||||
consequencesList: duplicate( this.getApplicableConsequences() ),
|
||||
skill: duplicate(skill),
|
||||
actor: this,
|
||||
modifierList: SoSUtility.fillRange(-10, +10),
|
||||
tnList: SoSUtility.fillRange(6, 20)
|
||||
tnList: SoSUtility.fillRange(6, 20),
|
||||
malusConsequence: 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);
|
||||
|
@ -220,9 +220,9 @@ export class SoSCardDeck {
|
||||
|
||||
// Compute final result and compare
|
||||
if ( flipData.mode == 'stat' ) {
|
||||
flipData.baseScore = flipData.stat.value;
|
||||
flipData.baseScore = flipData.stat.value + flipData.malusConsequence;
|
||||
} else if (flipData.mode == 'skill') {
|
||||
flipData.baseScore = Math.floor(flipData.stat.value/2) + flipData.skill.data.value;
|
||||
flipData.baseScore = Math.floor(flipData.stat.value/2) + flipData.skill.data.value + flipData.malusConsequence
|
||||
}
|
||||
flipData.finalScore = flipData.baseScore + flipData.cardTotal + Number(flipData.modifier);
|
||||
flipData.magnitude = flipData.finalScore - flipData.tn;
|
||||
|
@ -47,7 +47,7 @@ export class SoSCombat extends Combat {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async nextTurn() {
|
||||
console.log("Goingo to phase !", this.phaseNumber );
|
||||
console.log("Going to phase !", this.phaseNumber );
|
||||
// Get all actions for this phase
|
||||
let phaseIndex = this.phaseNumber - 1;
|
||||
let actionList = [];
|
||||
|
@ -5,12 +5,14 @@ export class SoSDialogCombatActions extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async create( combatId, combatantId, round, uniqId ) {
|
||||
|
||||
let combat = game.combats.get( combatId);
|
||||
|
||||
let combatActions = {
|
||||
actionsList: await SoSUtility.loadCompendium( 'foundryvtt-shadows-over-sol.combat-actions' ),
|
||||
actionPoints: SoSUtility.fillRange(0, 6),
|
||||
combatId: combatId,
|
||||
combatId: combatId,
|
||||
combatantId: combatantId,
|
||||
combatantsList: combat.data.combatants,
|
||||
uniqId: uniqId,
|
||||
round: round
|
||||
}
|
||||
@ -22,7 +24,7 @@ export class SoSDialogCombatActions extends Dialog {
|
||||
|
||||
//console.log("ACTIONS", combatActions.actionsList );
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-combat-actions.html', combatActions);
|
||||
return new SoSDialogCombatActions(combatActions, html );
|
||||
return new SoSDialogCombatActions(combatActions, html , { width: 640, height: 320} );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -56,6 +58,10 @@ export class SoSDialogCombatActions extends Dialog {
|
||||
let action2 = duplicate(this.combatActions.actionsList[action2Index]);
|
||||
let action1Index = $('#action1').val();
|
||||
let action1 = duplicate(this.combatActions.actionsList[action1Index]);
|
||||
|
||||
let combatant3Id = $('#combatant3').val();
|
||||
let combatant2Id = $('#combatant2').val();
|
||||
let combatant1Id = $('#combatant1').val();
|
||||
|
||||
let msgdata = {
|
||||
combatId: this.combatActions.combatId,
|
||||
@ -63,6 +69,7 @@ export class SoSDialogCombatActions extends Dialog {
|
||||
uniqId: this.combatActions.uniqId,
|
||||
userId: game.userId,
|
||||
phaseArray: [ action1, action2, action3],
|
||||
targetArray: [ combatant1Id, combatant2Id, combatant3Id],
|
||||
remainingAP: ap
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { SoSUtility } from "./sos-utility.js";
|
||||
|
||||
export class SoSFlipDialog extends Dialog {
|
||||
|
||||
@ -11,7 +12,7 @@ export class SoSFlipDialog extends Dialog {
|
||||
},
|
||||
default: 'flip'
|
||||
};
|
||||
super(conf, { classes: ["sosdialog"], width: 800, height: 800 });
|
||||
super(conf, { classes: ["sosdialog"], width: 800 });
|
||||
|
||||
this.flipData = flipData;
|
||||
}
|
||||
@ -21,15 +22,32 @@ export class SoSFlipDialog extends Dialog {
|
||||
this.close();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
updateScoreBase( ) {
|
||||
let scoreBase = 0;
|
||||
if ( this.flipData.mode == 'skill') {
|
||||
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;
|
||||
} else { //Stat mode
|
||||
let statKey = $('#statSelect').val();
|
||||
scoreBase = this.flipData.stat.value;
|
||||
}
|
||||
scoreBase += this.flipData.malusConsequence;
|
||||
$('#score-base').text( scoreBase);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateFlip( flipData ) {
|
||||
console.log("UPDATE !!!", flipData);
|
||||
//console.log("UPDATE !!!", flipData);
|
||||
$('.view-deck').remove();
|
||||
$("#view-deck").append(await flipData.actor.cardDeck.getDeckHTML());
|
||||
|
||||
$('.view-edge').remove();
|
||||
$("#view-edge").append(await flipData.actor.cardDeck.getEdgeHTML());
|
||||
|
||||
this.updateScoreBase();
|
||||
|
||||
$('.edge-card').click((event) => {
|
||||
let flipData = duplicate(this.flipData);
|
||||
flipData.modifier = $('#modifier').val();
|
||||
@ -45,6 +63,20 @@ export class SoSFlipDialog extends Dialog {
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
updateConsequence(event) {
|
||||
this.flipData.consequencesSelected = $('#consequenceSelect').val();
|
||||
let malusConsequence = 0;
|
||||
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 );
|
||||
}
|
||||
$('#consequence-malus').text(malusConsequence);
|
||||
this.flipData.malusConsequence = malusConsequence;
|
||||
this.updateScoreBase();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
@ -64,6 +96,14 @@ export class SoSFlipDialog extends Dialog {
|
||||
// Setup everything onload
|
||||
$(function () { onLoad(); });
|
||||
|
||||
html.find('#statSelect').change((event) => {
|
||||
this.updateFlip(dialog.flipData );
|
||||
} );
|
||||
|
||||
html.find('#consequenceSelect').change((event) => {
|
||||
this.updateConsequence( event );
|
||||
} );
|
||||
|
||||
html.find('.class-view-deck').click((event) => {
|
||||
let flipData = duplicate(this.flipData);
|
||||
flipData.modifier = html.find('#modifier').val();
|
||||
|
@ -2,7 +2,10 @@
|
||||
import { SoSDialogCombatActions } from "./sos-dialog-combat-actions.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class SoSUtility {
|
||||
const severity2malus = { "none": 0, "light": -1, "moderate": -2, "severe": -3, "critical": -4};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class SoSUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async preloadHandlebarsTemplates() {
|
||||
@ -16,6 +19,8 @@ import { SoSDialogCombatActions } from "./sos-dialog-combat-actions.js";
|
||||
'systems/foundryvtt-shadows-over-sol/templates/item-sheet.html',
|
||||
'systems/foundryvtt-shadows-over-sol/templates/item-geneline-sheet.html',
|
||||
'systems/foundryvtt-shadows-over-sol/templates/item-subculture-sheet.html',
|
||||
'systems/foundryvtt-shadows-over-sol/templates/item-weapon-sheet.html',
|
||||
'systems/foundryvtt-shadows-over-sol/templates/item-commongear-sheet.html',
|
||||
|
||||
'systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html'
|
||||
]
|
||||
@ -82,6 +87,23 @@ import { SoSDialogCombatActions } from "./sos-dialog-combat-actions.js";
|
||||
d.render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getConsequenceMalus(severity) {
|
||||
return severity2malus[severity] ?? 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeEncumbrance( items) {
|
||||
let trappings = items.filter( item => item.type == 'gear' || item.type == 'armor' || item.type == 'weapon' );
|
||||
let sumEnc = 0;
|
||||
for (let object of trappings) {
|
||||
if ( (!object.data.worn) && (!object.data.neg) && (!object.data.containerid || object.data.containerid == "") ) {
|
||||
sumEnc += (object.big > 0) ? object.big : 1;
|
||||
}
|
||||
}
|
||||
return sumEnc;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static closeAction(event) {
|
||||
let uniqId = event.currentTarget.attributes['data-uniq-id'].value;
|
||||
|
Reference in New Issue
Block a user