From: Deluge <ant...@us...> - 2013-08-08 23:39:10
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/entity In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv26528/src/games/stendhal/server/entity Modified Files: RPEntity.java Log Message: Added methods for setting, getting & checking immunities. Index: RPEntity.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/RPEntity.java,v retrieving revision 1.421 retrieving revision 1.422 diff -C2 -d -r1.421 -r1.422 *** RPEntity.java 8 Aug 2013 22:43:36 -0000 1.421 --- RPEntity.java 8 Aug 2013 23:39:06 -0000 1.422 *************** *** 41,44 **** --- 41,45 ---- import games.stendhal.server.entity.slot.EntitySlot; import games.stendhal.server.entity.status.Status; + import games.stendhal.server.entity.status.StatusAttacker; import games.stendhal.server.events.AttackEvent; import games.stendhal.server.events.SoundEvent; *************** *** 192,200 **** // /** Container for statuses inflicted on entity */ private List<Status> statuses; private boolean statusChanged = false; ! /** Immunities to statuses */ private List<String> resistances; --- 193,204 ---- // + /** Immunites to statuses */ + private List<String> immunities; + /** Container for statuses inflicted on entity */ private List<Status> statuses; private boolean statusChanged = false; ! /** Resistances to statuses */ private List<String> resistances; *************** *** 283,286 **** --- 287,291 ---- totalDamageReceived = 0; ignoreCollision = false; + immunities = new LinkedList<String>(); statuses = new LinkedList<Status>(); resistances = new LinkedList<String>(); *************** *** 295,298 **** --- 300,304 ---- totalDamageReceived = 0; ignoreCollision = false; + immunities = new LinkedList<String>(); statuses = new LinkedList<Status>(); resistances = new LinkedList<String>(); *************** *** 2999,3003 **** // ! // START: Status effects // --- 3005,3009 ---- // ! // XXX START: Status effects // *************** *** 3148,3151 **** --- 3154,3173 ---- /** + * Check if entity is immune to specified status attack. + * + * @param attack + * Status attack type + * @return + * Entity is immune + */ + public boolean isImmune(final StatusAttacker attack) { + final String statusName = attack.getName(); + if (immunities.contains(statusName)) { + return true; + } + return false; + } + + /** * Status effects that cannot be inflicted on entity * *************** *** 3163,3166 **** --- 3185,3226 ---- /** + * Remove any immunity of specified status effect from entity. + * + * @param attack + * Status attack type + */ + public void removeImmunity(final StatusAttacker attack) { + String statusName = attack.getName(); + if (immunities.contains(statusName)) { + immunities.remove(statusName); + } + sendPrivateText("You are not immune to " + statusName + " anymore."); + } + + /** + * Make entity immune to a specified status attack. + * + * @param attack + * Status attack type + */ + public void setImmune(final StatusAttacker attack) { + String statusName = attack.getName(); + + // Remove any current instances of the status attribute + if (has("status_" + statusName)) { + remove("status_" + statusName); + } + + // FIXME: should clear any consumable statuses + attack.clearConsumables(this); + + // Add to list of immunities + if (!immunities.contains(statusName)) { + immunities.add(statusName); + } + } + + + /** * Removes a single instance of a status from entity * |