Skip to content

Commit

Permalink
Merge pull request #414 from shadowfoundry/dev
Browse files Browse the repository at this point in the history
v11.0.1
  • Loading branch information
karmaroms committed Jul 31, 2023
2 parents 35b59df + 9e6a4f4 commit d1b8e7b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 58 deletions.
14 changes: 8 additions & 6 deletions scripts/entities/actors/entityActor.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class SR5Actor extends Actor {

// Initialize empty items
data.items = [];
data.effects = []

// Handle special create method
let dialogData = {lists: SR5_EntityHelpers.sortTranslations(SR5),};
Expand Down Expand Up @@ -151,6 +152,11 @@ export class SR5Actor extends Actor {
"type": "baseDevice",
}
data.items.push(baseItems);
let effect = await _getSRStatusEffect("matrixInit");
let initiativeEffect = new CONFIG.ActiveEffect.documentClass(effect);
const effects = data.effects.map(e => e.toObject());
effects.push(initiativeEffect.toObject());
mergeObject(data, {"effects": effects });
super.create(data, options);
break;
case "actorGrunt":
Expand Down Expand Up @@ -218,17 +224,12 @@ export class SR5Actor extends Actor {
break;
case "actorDevice":
case "actorSprite":
case "actorAgent":
case "actorAgent":
mergeObject(createData, {
"prototypeToken.lockRotation": true,
"prototypeToken.actorLink": actorLink,
"prototypeToken.bar2": {attribute: "statusBars.matrix",},
});
let effect = await _getSRStatusEffect("matrixInit");
let initiativeEffect = new CONFIG.ActiveEffect.documentClass(effect);
const effects = this.effects.map(e => e.toObject());
effects.push(initiativeEffect.toObject());
mergeObject(createData, {"effects": effects });
break;
default :
SR5_SystemHelpers.srLog(1, `Unknown '${this.type}' type in 'base _preCreate()'`);
Expand Down Expand Up @@ -662,6 +663,7 @@ export class SR5Actor extends Actor {
} else if (actor.type === "actorDevice"){
SR5_CharacterUtility.generateDeviceMatrix(actor, iData);
SR5_CharacterUtility.generateMatrixResistances(actor, i);
SR5_CharacterUtility.generateDeviceMatrixActions(actor);
SR5_CharacterUtility.generateMatrixActionsDefenses(actor);
if (actorData.matrix.deviceType === "ice") SR5_CharacterUtility.updateInitiativeMatrix(actor);
} else if (actor.type === "actorSprite"){
Expand Down
29 changes: 28 additions & 1 deletion scripts/entities/actors/utilityActor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3649,6 +3649,33 @@ export class SR5_CharacterUtility extends Actor {
}
}

static generateDeviceMatrixActions(actor){
let actorData = actor.system, matrix = actorData.matrix, matrixAttributes = matrix.attributes, matrixActions = matrix.actions;

for (let key of Object.keys(SR5.matrixActions)) {
if (matrixActions[key].test !== undefined) {
SR5_EntityHelpers.updateModifier(matrixActions[key].test, game.i18n.localize('SR5.DeviceRating'), "linkedAttribute", matrix.deviceRating);
SR5_EntityHelpers.updateModifier(matrixActions[key].test, game.i18n.localize('SR5.DeviceRating'), "linkedAttribute", matrix.deviceRating);
// test
if (matrix.runningSilent) {
SR5_EntityHelpers.updateModifier(matrixActions[key].test, game.i18n.localize('SR5.RunningSilent'), "silentMode", -2);
}
if (matrix.userMode === "hotsim") {
SR5_EntityHelpers.updateModifier(matrixActions[key].test, game.i18n.localize('SR5.VirtualRealityHotSimShort'), "matrixUserMode", 2);
}
if (matrixActions[key].specialization){
SR5_EntityHelpers.updateModifier(matrixActions[key].test, `${game.i18n.localize('SR5.Specialization')}`, "specialization", 2, false, true);
}
SR5_EntityHelpers.updateDicePool(matrixActions[key].test, 0);
// limits
let linkedAttribute = matrixActions[key].limit.linkedAttribute;
matrixActions[key].limit.base = 0;
SR5_EntityHelpers.updateModifier(matrixActions[key].limit, game.i18n.localize(SR5.matrixAttributes[linkedAttribute]), "linkedAttribute", matrixAttributes[linkedAttribute].value);
SR5_EntityHelpers.updateValue(matrixActions[key].limit, 0);
}
}
}

static generateMatrixActionsDefenses(actor) {
let actorData = actor.system, matrix = actorData.matrix, matrixAttributes = matrix.attributes, matrixActions = matrix.actions;
let intuitionValue, willpowerValue, logicValue, firewallValue, sleazeValue, dataProcessingValue, attackValue;
Expand Down Expand Up @@ -4147,7 +4174,7 @@ export class SR5_CharacterUtility extends Actor {

static async updateMatrixEffect(actor){
let status, isStatusEffectOn, statusEffects = [];
isStatusEffectOn = actor.effects.find(e => e.flags.core?.statusId === "matrixInit");
isStatusEffectOn = actor.effects.find(e => e.statuses.has("matrixInit"));
if (!actor.system.isDirectlyConnected) {
if (!isStatusEffectOn){
status = await _getSRStatusEffect("matrixInit");
Expand Down
2 changes: 0 additions & 2 deletions scripts/rolls/roll-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,6 @@ export class SR5_RollTest {
borderColor: userActive.color,
};

console.log(chatData.flags.sr5data);

//Handle Dice so Nice
if (cardData.roll.originalRoll) await SR5_RollTest.showDiceSoNice(cardData.roll.originalRoll, cardData.roll.rollMode);

Expand Down
Loading

0 comments on commit d1b8e7b

Please sign in to comment.