From b701662dbed0d3e753f6dd5d77ce67f9fd20f97e Mon Sep 17 00:00:00 2001 From: TJ Date: Fri, 11 Jun 2021 23:30:06 -0500 Subject: [PATCH] Initial commit for getting deployments to display --- module/actor/entity.js | 125 +++++++++--------- .../actors/newActor/parts/swalt-crew.html | 8 ++ 2 files changed, 70 insertions(+), 63 deletions(-) diff --git a/module/actor/entity.js b/module/actor/entity.js index 23080d27..7d0f0045 100644 --- a/module/actor/entity.js +++ b/module/actor/entity.js @@ -1728,71 +1728,70 @@ export default class Actor5e extends Actor { */ async deployInto(target, { coord=false, gunner=false, mech=false, oper=false, pilot=false, tech=false, crew=false, pass=false}={}) { - - // Get the starship Actor data and the new char data - const sship = duplicate(this.toJSON()); - const ssDeploy = sship.data.attributes.deployment; - const char = target; - const charUUID = char.uuid; - const charName = char.data.name; - const charRank = char.data.data.attributes.rank; - let charProf = 0; - if (charRank.total > 0) { - charProf = char.data.data.attributes.prof; + // Get the starship Actor data and the new char data + const sship = duplicate(this.toJSON()); + const ssDeploy = sship.data.attributes.deployment; + const char = target; + const charUUID = char.uuid; + const charName = char.data.name; + const charRank = char.data.data.attributes.rank; + let charProf = 0; + if (charRank === undefined || charRank.total > 0) { + charProf = char.data.data.attributes.prof; + } + + if (coord) { + ssDeploy.coord.uuid = charUUID; + ssDeploy.coord.name = charName; + ssDeploy.coord.rank = charRank ? charRank.coord : 0; + ssDeploy.coord.prof = charProf; + } + + if (gunner) { + ssDeploy.gunner.uuid = charUUID; + ssDeploy.gunner.name = charName; + ssDeploy.gunner.rank = charRank ? charRank.gunner : 0; + ssDeploy.gunner.prof = charProf; + } + + if (mech) { + ssDeploy.mechanic.uuid = charUUID; + ssDeploy.mechanic.name = charName; + ssDeploy.mechanic.rank = charRank ? charRank.mechanic : 0; + ssDeploy.mechanic.prof = charProf; + } + + if (oper) { + ssDeploy.operator.uuid = charUUID; + ssDeploy.operator.name = charName; + ssDeploy.operator.rank = charRank ? charRank.operator : 0; + ssDeploy.operator.prof = charProf; + } + + if (pilot) { + ssDeploy.pilot.uuid = charUUID; + ssDeploy.pilot.name = charName; + ssDeploy.pilot.rank = charRank ? charRank.pilot : 0; + ssDeploy.pilot.prof = charProf; + } + + if (tech) { + ssDeploy.technician.uuid = charUUID; + ssDeploy.technician.name = charName; + ssDeploy.technician.rank = charRank ? charRank.technician : 0; + ssDeploy.technician.prof = charProf; + } + + if (crew) { + ssDeploy.crew.push({ uuid: charUUID, name: charName, rank: charRank, prof: charProf }); + } + + if (pass) { + ssDeploy.passenger.push({ uuid: charUUID, name: charName, rank: charRank, prof: charProf }); + } + this.update({ "data.attributes.deployment": ssDeploy }); } - if (coord){ - ssDeploy.coord.uuid = charUUID; - ssDeploy.coord.name = charName; - ssDeploy.coord.rank = charRank.coord; - ssDeploy.coord.prof = charProf; - } - - if (gunner){ - ssDeploy.gunner.uuid = charUUID; - ssDeploy.gunner.name = charName; - ssDeploy.gunner.rank = charRank.gunner; - ssDeploy.gunner.prof = charProf; - } - - if (mech){ - ssDeploy.mechanic.uuid = charUUID; - ssDeploy.mechanic.name = charName; - ssDeploy.mechanic.rank = charRank.mechanic; - ssDeploy.mechanic.prof = charProf; - } - - if (oper){ - ssDeploy.operator.uuid = charUUID; - ssDeploy.operator.name = charName; - ssDeploy.operator.rank = charRank.operator; - ssDeploy.operator.prof = charProf; - } - - if (pilot){ - ssDeploy.pilot.uuid = charUUID; - ssDeploy.pilot.name = charName; - ssDeploy.pilot.rank = charRank.pilot; - ssDeploy.pilot.prof = charProf; - } - - if (tech){ - ssDeploy.technician.uuid = charUUID; - ssDeploy.technician.name = charName; - ssDeploy.technician.rank = charRank.technician; - ssDeploy.technician.prof = charProf; - } - - if (crew){ - ssDeploy.crew.push({"uuid": charUUID, "name": charName, "rank": charRank, "prof": charProf}); - } - - if (pass){ - ssDeploy.passenger.push({"uuid": charUUID, "name": charName, "rank": charRank, "prof": charProf}); - } - this.update({"data.attributes.deployment": ssDeploy}); - } - /** * Transform this Actor into another one. diff --git a/templates/actors/newActor/parts/swalt-crew.html b/templates/actors/newActor/parts/swalt-crew.html index 79065c42..431444e2 100644 --- a/templates/actors/newActor/parts/swalt-crew.html +++ b/templates/actors/newActor/parts/swalt-crew.html @@ -8,6 +8,14 @@
  • {{localize "SW5E.Reaction"}}
  • +
      +
    1. Coordinator: {{data.attributes.deployment.coord.name}}
    2. +
    3. Gunner: {{data.attributes.deployment.gunner.name}}
    4. +
    5. Mechanic: {{data.attributes.deployment.mechanic.name}}
    6. +
    7. Operator: {{data.attributes.deployment.operator.name}}
    8. +
    9. Pilot: {{data.attributes.deployment.pilot.name}}
    10. +
    11. Technician: {{data.attributes.deployment.technician.name}}
    12. +
      {{#each sections as |section sid|}}