Skip to content

Commit 3ddb79e

Browse files
authored
Targeting is not mandatory to roll for attacks (#47)
1 parent 506cea8 commit 3ddb79e

File tree

3 files changed

+11
-26
lines changed

3 files changed

+11
-26
lines changed

module/config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// Namespace Configuration Values
22
export const DIS = {};
33

4-
DIS.flagScope = "deathinspace"; // must match system namw
5-
DIS.flags = {
6-
DEFENDER_DR: "defenderDR",
7-
};
4+
DIS.flagScope = "deathinspace"; // must match system name
85

96
DIS.itemTypes = {
107
armor: "armor",

module/dialog/attack-dialog.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,16 @@ export default class AttackDialog extends Application {
2323

2424
/** @override */
2525
async getData() {
26-
let target = Array.from(game.user.targets)[0];
26+
let defenderDR = 12; // default
2727

28-
//Checks if target is selected, if not throws a message
29-
if(target == null || target == undefined){
30-
ui.notifications.error("Please select a target.")
31-
}
32-
33-
let targetActorId = target.document.actorId;
34-
let actor = game.actors.get(targetActorId);
35-
let defenderDR = await this.actor.getFlag(
36-
CONFIG.DIS.flagScope,
37-
CONFIG.DIS.flags.DEFENDER_DR
38-
);
39-
defenderDR = actor.system.defenseRating;
40-
41-
if (!defenderDR) {
42-
defenderDR = 12; // default
28+
let target = Array.from(game.user.targets)[0];
29+
if (target) {
30+
//If target is selected, use target defense rating
31+
let targetActorId = target.document.actorId;
32+
let targetActor = game.actors.get(targetActorId);
33+
defenderDR = targetActor.system.defenseRating;
4334
}
35+
4436
return {
4537
defenderDR,
4638
hasVoidPoints: this.actor.hasVoidPoints,
@@ -69,11 +61,7 @@ export default class AttackDialog extends Application {
6961
.find("input[name=use-void-point]")
7062
.is(":checked");
7163
this.close();
72-
await this.actor.setFlag(
73-
CONFIG.DIS.flagScope,
74-
CONFIG.DIS.flags.DEFENDER_DR,
75-
defenderDR
76-
);
64+
7765
if (this.itemId) {
7866
this.actor.rollAttackWithItem(
7967
this.itemId,

system.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"templateVersion": 2,
88
"compatibility": {
99
"minimum": "11.300",
10-
"verified": "11.300"
10+
"verified": "12.331"
1111
},
1212
"authors": [
1313
{

0 commit comments

Comments
 (0)