Skip to content

Commit a4e431c

Browse files
committed
fix: error codes for PWR_DISRUPT_TERMINAL and PWR_FORTIFY
DEV-390
1 parent a77b86c commit a4e431c

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/game/creeps.js

+22
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,13 @@ exports.make = function(_runtimeData, _intents, _register, _globals) {
581581
return C.ERR_INVALID_TARGET;
582582
}
583583

584+
if(target.structureType == 'terminal') {
585+
var effect = _.find(target.effects, {power: C.PWR_DISRUPT_TERMINAL});
586+
if(effect && effect.ticksRemaining > 0) {
587+
return C.ERR_INVALID_TARGET;
588+
}
589+
}
590+
584591
if(target.my === false && _.any(target.pos.lookFor('structure'), i => i.structureType == C.STRUCTURE_RAMPART && !i.my && !i.isPublic)) {
585592
return C.ERR_NOT_OWNER;
586593
}
@@ -726,6 +733,12 @@ exports.make = function(_runtimeData, _intents, _register, _globals) {
726733
register.assertTargetObject(target);
727734
return C.ERR_INVALID_TARGET;
728735
}
736+
737+
var effect = _.find(target.effects, {power: C.PWR_FORTIFY});
738+
if(effect && effect.ticksRemaining > 0) {
739+
return C.ERR_INVALID_TARGET;
740+
}
741+
729742
if(!target.pos.isNearTo(this.pos)) {
730743
return C.ERR_NOT_IN_RANGE;
731744
}
@@ -758,6 +771,10 @@ exports.make = function(_runtimeData, _intents, _register, _globals) {
758771
return C.ERR_NOT_IN_RANGE;
759772
}
760773

774+
var effect = _.find(target.effects, {power: C.PWR_FORTIFY});
775+
if(effect && effect.ticksRemaining > 0) {
776+
return C.ERR_INVALID_TARGET;
777+
}
761778

762779
intents.set(this.id, 'rangedAttack', {id: target.id});
763780
return C.OK;
@@ -1142,6 +1159,11 @@ exports.make = function(_runtimeData, _intents, _register, _globals) {
11421159
return C.ERR_NO_BODYPART;
11431160
}
11441161

1162+
var effect = _.find(target.effects, {power: C.PWR_FORTIFY});
1163+
if(effect && effect.ticksRemaining > 0) {
1164+
return C.ERR_INVALID_TARGET;
1165+
}
1166+
11451167
intents.set(this.id, 'dismantle', {id: target.id});
11461168
return C.OK;
11471169
});

src/processor/intents/creeps/dismantle.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ module.exports = function(object, intent, scope) {
3434
amount = Math.min(power, target.hits),
3535
energyGain = Math.floor(amount * C.DISMANTLE_COST);
3636

37-
var effect = _.find(target.effects, {power: C.PWR_SHIELD});
38-
if(effect && effect.endTime >= gameTime) {
37+
var effect = _.find(target.effects, e => e.endTime >= gameTime && (e.power == C.PWR_SHIELD || e.power == C.PWR_FORTIFY));
38+
if(effect) {
3939
energyGain = 0;
4040
}
4141

@@ -50,4 +50,4 @@ module.exports = function(object, intent, scope) {
5050

5151
require('../_damage')(object, target, amount, C.EVENT_ATTACK_TYPE_DISMANTLE, scope);
5252
}
53-
};
53+
};

0 commit comments

Comments
 (0)