Skip to content

Commit 8daf90f

Browse files
committed
Added rifle requirement to Precision Shot
1 parent ef47ab9 commit 8daf90f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

core/src/main/java/com/pipai/wf/battle/action/PrecisionShotAction.java

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.pipai.wf.battle.damage.TargetedActionCalculator;
99
import com.pipai.wf.battle.damage.WeaponDamageFunction;
1010
import com.pipai.wf.battle.log.BattleEvent;
11+
import com.pipai.wf.battle.weapon.Rifle;
1112
import com.pipai.wf.battle.weapon.Weapon;
1213
import com.pipai.wf.exception.IllegalActionException;
1314
import com.pipai.wf.unit.ability.Ability;
@@ -57,6 +58,9 @@ protected void performImpl() throws IllegalActionException {
5758
}
5859
Agent target = getTarget();
5960
Weapon w = a.getCurrentWeapon();
61+
if (!(w instanceof Rifle)) {
62+
throw new IllegalActionException("Rifle needed to use Precision Shot");
63+
}
6064
if (w.needsAmmunition() && w.currentAmmo() == 0) {
6165
throw new IllegalActionException("Not enough ammo to fire " + w.name());
6266
}

core/src/main/java/com/pipai/wf/gui/BattleGui.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.pipai.wf.battle.map.MapGraph;
3737
import com.pipai.wf.battle.spell.FireballSpell;
3838
import com.pipai.wf.battle.vision.FogOfWar;
39+
import com.pipai.wf.battle.weapon.Rifle;
3940
import com.pipai.wf.battle.weapon.SpellWeapon;
4041
import com.pipai.wf.battle.weapon.Weapon;
4142
import com.pipai.wf.exception.IllegalActionException;
@@ -639,7 +640,7 @@ public void onKeyDown(int keycode) {
639640
// Skill
640641
if (this.mode == Mode.MOVE) {
641642
for (Ability a : selectedAgent.getAgent().getAbilities()) {
642-
if (a instanceof PrecisionShotAbility && !a.isOnCooldown()) {
643+
if (a instanceof PrecisionShotAbility && !a.isOnCooldown() && selectedAgent.getAgent().getCurrentWeapon() instanceof Rifle) {
643644
this.switchToTargetMode((PrecisionShotAbility) a);
644645
break;
645646
}

0 commit comments

Comments
 (0)