public void playDefenseCards(List<Card> card) throws IllegalActionException { for (Card defenseCard : card) { if (defenseCard instanceof LeaderCard) { activeCombat.addDefenseCard(defenseCard); } else if (defenseCard instanceof UnitCard) { UnitCard unitCard = (UnitCard) defenseCard; if (unitCard.getCode().startsWith(activeCombat.getTargetUnit().getCode()) && unitCard.getDefense() > 0) { activeCombat.addDefenseCard(defenseCard); } } else { throw new IllegalActionException("Invalid defense card"); } } }
public boolean tryDamageSkill(String rem, String cut, String output) { if (cut.length() > 0) if (rem.indexOf(cut) == 0) { rem = rem.substring(cut.length(), rem.length()); rem = Utility.clearWhiteSpace(rem); } target = owner.getRoom().findEntity(owner, rem); if ((target == null) && (owner.getPlayerState() == Utility.PSTATE_FIGHTING)) target = owner.getTarget(); if (target == null) { owner.echo(output); return false; } if (!Combat.canAttack(owner, target, false, true)) return false; tn = target.getName(); Tn = target.getPName(); ty = Utility.possessive(tn); Ty = Utility.possessive(Tn); return true; }
private static void attackIfApplicable(Signal[] signals) throws GameActionException { if (rc.isWeaponReady()) { Combat.shootAtNearbyEnemies(); } if (rc.isWeaponReady()) { shootWithoutThinking(signals); } }
public boolean itemCast(String rem, Item I, boolean first) { createEffect(); boolean OK = false; target = caster.getRoom().findEntity(caster, rem); if (rem.length() <= 0) caster.echo("Who do you want to use it on?"); else if (target == null) caster.echo("There's nobody around by that name."); else if (caster.getRoom().getFlag(Room.FLAG_NO_MAGIC)) caster.echo("Your magic doesn't seem to work here."); else OK = true; if (target != caster) { if ((first) && ((effect.getHarmful()) && (!Combat.canAttack(caster, target, true, true)))) return false; if ((!first) && ((effect.getHarmful()) && (!Combat.canAttackSilent(caster, target, true, true)))) return false; } if (!OK) return false; initEffect(); tn = target.getName(); Tn = target.getPName(); ty = Utility.possessive(tn); Ty = Utility.possessive(Tn); boolean self = (target == caster); if (first) tryItemUse(I); appendOutput(self, false); return true; }
public boolean cast(String rem) { createEffect(); boolean OK = false; target = caster.getRoom().findEntity(caster, rem); if (rem.length() <= 0) caster.echo("Who do you want to cast it on?"); else if (target == null) caster.echo("There's nobody around by that name."); else if (caster.getRoom().getFlag(Room.FLAG_NO_MAGIC)) caster.echo("Your magic doesn't seem to work here."); else if (caster.getCurrentMN() < manacost) caster.echo("You don't have enough mana to cast " + name + "."); else if ((effect.getHarmful()) && (!Combat.canAttack(caster, target, true, true))) OK = false; else OK = true; if (!OK) return false; initEffect(); if (effect.getHarmful()) Combat.engage(caster, target, false); caster.setCurrentMN(caster.getCurrentMN() - manacost); tn = target.getName(); Tn = target.getPName(); ty = Utility.possessive(tn); Ty = Utility.possessive(Tn); boolean self = (target == caster); updateOutput(self); appendOutput(self, true); return true; }
public void withdraw(HQCard card) { activeCombat.finish(); map.withdraw(activeCombat.getTargetSquare()); }