/** * @see * de.outstare.fortbattleplayer.model.Area#occupy(de.outstare.fortbattleplayer.model.Combatant, * Area) */ public Combatant occupy(final Combatant newOccupier, final Area oldPosition) { Combatant oldOccupier = null; // System.out.println(toString() + " will be occupied by " + newOccupier // + " from " + oldPosition); if (isOccupied() && !occupier.equals(newOccupier)) { if (oldPosition == null) { // IGNORE, because in the initial setup, multiple combatants may // stay in the same area // throw new IllegalStateException( // "This Area is already occupied and no Area for the current occupier was given!"); } else if (oldPosition.isOccupied()) { // IGNORE, for old battles with wrong start positions // throw new IllegalArgumentException(toString() + // " cannot be occupied by " + newOccupier.getName() // + " because " + oldPosition.toString() // + // " (the source Area of the occupier) is not free for the current occupier of this Area!"); } else { // swap places // (TODO this is like a hack, but it is what The West does :-/) oldOccupier = occupier; LOG.fine(occupier.getName() + " and " + newOccupier + " swapping positions"); occupier.move(oldPosition); } } occupier = newOccupier; sector.gainControl(occupier.getSide()); return oldOccupier; }
/** @see de.outstare.fortbattleplayer.model.Area#free() */ public void free() { occupier = null; sector.free(); }
/** * @see * de.outstare.fortbattleplayer.model.Area#getSectorBonus(de.outstare.fortbattleplayer.model.Combatant) */ public SectorBonus getSectorBonus(final Combatant combatant) { return sector.getBonus(combatant.getCharacterClass()); }
/** * Creates a new Area identified by the given location * * @param location * @param sector not <code>null</code> */ public SimpleArea(final Point location, final Sector sector) { this.location = location; this.sector = sector; sector._addArea(this); }
/** @see de.outstare.fortbattleplayer.model.Area#getHeight() */ public int getHeight() { return sector.getHeight(); }