From 6e5bb5da3263bc4de379ca28d6fe0005890aa34d Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Thu, 25 May 2023 16:22:02 +0200 Subject: [PATCH] v10/v11 compat --- module/actor-sheet.js | 6 +++--- module/sample-code.js | 24 ------------------------ module/sos-card-deck.js | 6 +++--- module/sos-combat.js | 2 +- module/sos-utility.js | 36 ++++++++++++++++++------------------ system.json | 4 ++-- 6 files changed, 27 insertions(+), 51 deletions(-) delete mode 100644 module/sample-code.js diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 1be1bf4..92958ef 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -64,12 +64,12 @@ export class SoSActorSheet extends ActorSheet { 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; + container.system.contains = [] + container.system.containerEnc = 0; for (let gear of formData.gears) { console.log("GEAR", gear, container) if ( gear.system.containerid == container.id) { - container.data.contains.push( gear ) + container.system.contains.push( gear ) if ( !gear.system.neg && !gear.system.software ) { container.system.containerEnc += (gear.system.big > 0) ? gear.system.big : 1; } diff --git a/module/sample-code.js b/module/sample-code.js deleted file mode 100644 index 29980c7..0000000 --- a/module/sample-code.js +++ /dev/null @@ -1,24 +0,0 @@ - html.find('.item .item-name h4').click(event => this._onItemSummary(event)); - - /** - * Handle toggling of an item from the Actor sheet - * @private - */ - _onItemSummary(event) { - event.preventDefault(); - let li = $(event.currentTarget).parents(".item"), - item = this.actor.getOwnedItem(li.data("item-id")); - - // Toggle summary - if (item.data.data.description !== undefined && item.data.data.description !== null){ - if ( li.hasClass("expanded") ) { - let summary = li.children(".item-summary"); - summary.slideUp(200, () => summary.remove()); - } else { - let div = $(`
${item.data.data.description}
`); - li.append(div.hide()); - div.slideDown(200); - } - li.toggleClass("expanded"); - } - } \ No newline at end of file diff --git a/module/sos-card-deck.js b/module/sos-card-deck.js index 756979f..1bd8fea 100644 --- a/module/sos-card-deck.js +++ b/module/sos-card-deck.js @@ -247,7 +247,7 @@ export class SoSCardDeck { if ( flipData.mode == 'stat' || flipData.mode == 'weapon' ) { flipData.baseScore = flipData.stat.value + flipData.malusConsequence + flipData.bonusConsequence + flipData.woundMalus; } else if (flipData.mode == 'skill') { - flipData.baseScore = Math.floor(flipData.stat.value/2) + flipData.skill.data.value + flipData.malusConsequence + flipData.bonusConsequence + flipData.woundMalus; + flipData.baseScore = Math.floor(flipData.stat.value/2) + flipData.skill.system.value + flipData.malusConsequence + flipData.bonusConsequence + flipData.woundMalus; } flipData.finalScore = flipData.baseScore + flipData.cardTotal + Number(flipData.modifier); flipData.magnitude = flipData.finalScore - flipData.tn; @@ -272,10 +272,10 @@ export class SoSCardDeck { async processWeapon( flipData ) { flipData.damageCardsuit = flipData.cardSlot[flipData.cardSlotIndex].cardsuit; let damageKey = 'damage_'+ flipData.damageCardsuit; - flipData.damageString = flipData.weapon.data[damageKey]; + flipData.damageString = flipData.weapon.system[damageKey]; if (flipData.damageString.includes('Str') ) { let damageRegexp = flipData.damageString.match( /Str([\d])?\+?([\d])?([LMSC])/i ); - flipData.damageValue = (flipData.actor.data.data.stats.strength.value * Number(damageRegexp[1]?damageRegexp[1]:1)) + Number(damageRegexp[2]?damageRegexp[2]:0); + flipData.damageValue = (flipData.actor.system.stats.strength.value * Number(damageRegexp[1]?damageRegexp[1]:1)) + Number(damageRegexp[2]?damageRegexp[2]:0); flipData.damageSeverity = damageRegexp[3]; } else { let damageRegexp = flipData.damageString.match( /(\d*)([LMSC])/i ); diff --git a/module/sos-combat.js b/module/sos-combat.js index 24c5db7..47ae6e6 100644 --- a/module/sos-combat.js +++ b/module/sos-combat.js @@ -16,7 +16,7 @@ export class SoSCombat extends Combat { this.setInitiative(combatant.id, -1); // Reset init let uniq = randomID(16) const name = combatant.actor ? combatant.actor.name : combatant.name; - if (combatant.players && combatant.players[0]) { + if (combatant.players && 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} !
diff --git a/module/sos-utility.js b/module/sos-utility.js index 0809f09..243c8bb 100644 --- a/module/sos-utility.js +++ b/module/sos-utility.js @@ -122,7 +122,7 @@ export class SoSUtility { 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.software) && (!object.data.implant) && (!object.data.containerid || object.data.containerid == "") ) { + if ( (!object.system.worn) && (!object.system.neg) && (!object.system.software) && (!object.system.implant) && (!object.system.containerid || object.system.containerid == "") ) { sumEnc += (object.big > 0) ? object.big : 1; } } @@ -275,20 +275,20 @@ export class SoSUtility { } // DR management - let armor = flipData.target.actor.data.items.find( item => item.type == 'armor' && item.data.worn); - flipData.armorDR = armor ? armor.data.dr : 0; - flipData.armorGel = armor ?armor.data.gel : 0; - flipData.armorReflect = armor ? armor.data.reflect : 0; - let dr = flipData.target.actor.data.data.scores.dr.value + flipData.armorDR; - if (flipData.weapon.data.category == 'ballistic') { + let armor = flipData.target.actor.system.items.find( item => item.type == 'armor' && item.system.worn); + flipData.armorDR = armor ? armor.system.dr : 0; + flipData.armorGel = armor ?armor.system.gel : 0; + flipData.armorReflect = armor ? armor.system.reflect : 0; + let dr = flipData.target.actor.system.scores.dr.value + flipData.armorDR; + if (flipData.weapon.system.category == 'ballistic') { dr += flipData.armorGel; } - if (flipData.weapon.data.category == 'laser') { + if (flipData.weapon.system.category == 'laser') { dr += flipData.armorReflect; } - let shock = flipData.target.actor.data.data.scores.shock.value || 1; - let defenseCritical = flipData.target.actor.data.data.scores.defense.critical; + let shock = flipData.target.actor.system.scores.shock.value || 1; + let defenseCritical = flipData.target.actor.system.scores.defense.critical; flipData.damageStatus = 'apply_damage'; flipData.targetShock = shock; @@ -341,17 +341,17 @@ export class SoSUtility { // Is target able to dodge ?? let defender = game.actors.get( flipData.target.actor._id); - flipData.coverConsequence = defender.data.items.find( item => item.type == 'consequence' && item.name == 'Cover'); - flipData.APavailable = game.combat.getAPFromActor( defender.data._id ); + flipData.coverConsequence = defender.items.find( item => item.type == 'consequence' && item.name == 'Cover'); + flipData.APavailable = game.combat.getAPFromActor( defender._id ); console.log("FLIPDATE : ", flipData); if ( !flipData.isReaction && flipData.APavailable > 0) { - if ( (flipData.weapon.data.category == 'melee' ) || ( (flipData.weapon.data.category == 'laser' || flipData.weapon.data.category == 'ballistic') && - flipData.coverConsequence.data.severity != 'none') ) { - flipData.coverSeverityLevel = this.getConsequenceSeverityLevel( flipData.coverConsequence.data.severity ) * 2; + if ( (flipData.weapon.system.category == 'melee' ) || ( (flipData.weapon.system.category == 'laser' || flipData.weapon.system.category == 'ballistic') && + flipData.coverConsequence.system.severity != 'none') ) { + flipData.coverSeverityLevel = this.getConsequenceSeverityLevel( flipData.coverConsequence.system.severity ) * 2; flipData.coverSeverityFlag = (flipData.coverSeverityLevel > 0); - flipData.isMelee = (flipData.weapon.data.category == 'melee' ); - let melee = defender.data.items.find( item => item.type == 'skill' && item.name == 'Melee'); - flipData.defenderMelee = melee.data.value; + flipData.isMelee = (flipData.weapon.system.category == 'melee' ); + let melee = defender.items.find( item => item.type == 'skill' && item.name == 'Melee'); + flipData.defenderMelee = melee.system.value; flipData.uniqId = randomID(16); this.registry[flipData.uniqId] = flipData; let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-damage-request-dodge.html', flipData ); diff --git a/system.json b/system.json index 4b38e28..3f38e1b 100644 --- a/system.json +++ b/system.json @@ -4,7 +4,7 @@ "description": "Shadows over Sol for FoundryVTT", "url": "https://www.uberwald.me/gitea/public/foundryvtt-shadows-over-sol/", "license": "LICENSE.txt", - "version": "11.0.0", + "version": "11.0.1", "compatibility": { "minimum": "10", "verified": "10", @@ -109,7 +109,7 @@ ], "socket": true, "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-shadows-over-sol/raw/branch/v10/system.json", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-shadows-over-sol/archive/foundryvtt-shadows-over-sol-11.0.0.zip", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-shadows-over-sol/archive/foundryvtt-shadows-over-sol-11.0.1.zip", "gridDistance": 5, "gridUnits": "ft" } \ No newline at end of file