[mud4j-commit] SF.net SVN: mud4j: [148] trunk/mud4j-core/src
Status: Pre-Alpha
Brought to you by:
mpurland
From: <mpu...@us...> - 2007-10-04 21:42:14
|
Revision: 148 http://mud4j.svn.sourceforge.net/mud4j/?rev=148&view=rev Author: mpurland Date: 2007-10-04 14:42:11 -0700 (Thu, 04 Oct 2007) Log Message: ----------- Add behaviors for mud4j core, effectable, and tests Add prompt shell for telnet server. Add line terminal input handler. Start fixing terminal screen buffer. Modified Paths: -------------- trunk/mud4j-core/src/java/net/sf/mud4j/ability/CharacterAbility.java trunk/mud4j-core/src/java/net/sf/mud4j/damage/AbstractDamageBehavior.java trunk/mud4j-core/src/java/net/sf/mud4j/damage/DamageBehavior.java trunk/mud4j-core/src/java/net/sf/mud4j/damage/DamageListener.java trunk/mud4j-core/src/java/net/sf/mud4j/effect/AbstractEffect.java trunk/mud4j-core/src/java/net/sf/mud4j/effect/AbstractItemEffect.java trunk/mud4j-core/src/java/net/sf/mud4j/effect/Effect.java trunk/mud4j-core/src/java/net/sf/mud4j/world/Direction.java trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/CharacterEffectTest.java trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/MockCharacterEffect.java Added Paths: ----------- trunk/mud4j-core/src/java/net/sf/mud4j/ability/TestBehavior.java trunk/mud4j-core/src/java/net/sf/mud4j/behavior/ trunk/mud4j-core/src/java/net/sf/mud4j/behavior/Behavior.java trunk/mud4j-core/src/java/net/sf/mud4j/behavior/BehaviorManager.java trunk/mud4j-core/src/java/net/sf/mud4j/damage/PointDamageEvent.java trunk/mud4j-core/src/java/net/sf/mud4j/effect/EffectableBehavior.java trunk/mud4j-core/src/java/net/sf/mud4j/map/ZoneMap.java trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/EffectableBehaviorTest.java trunk/mud4j-core/src/test/unit/net/sf/ trunk/mud4j-core/src/test/unit/net/sf/mud4j/ trunk/mud4j-core/src/test/unit/net/sf/mud4j/behavior/ Removed Paths: ------------- trunk/mud4j-core/src/java/net/sf/mud4j/effect/CharacterEffectDecorator.java trunk/mud4j-core/src/java/net/sf/mud4j/effect/LocationEffectDecorator.java trunk/mud4j-core/src/java/net/sf/mud4j/map/AreaMap.java Modified: trunk/mud4j-core/src/java/net/sf/mud4j/ability/CharacterAbility.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/ability/CharacterAbility.java 2007-10-04 21:41:58 UTC (rev 147) +++ trunk/mud4j-core/src/java/net/sf/mud4j/ability/CharacterAbility.java 2007-10-04 21:42:11 UTC (rev 148) @@ -45,7 +45,7 @@ */ public Character getCharacter() { return this.character; - } + } /** * {@inheritDoc} Added: trunk/mud4j-core/src/java/net/sf/mud4j/ability/TestBehavior.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/ability/TestBehavior.java (rev 0) +++ trunk/mud4j-core/src/java/net/sf/mud4j/ability/TestBehavior.java 2007-10-04 21:42:11 UTC (rev 148) @@ -0,0 +1,131 @@ +package net.sf.mud4j.ability; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import net.sf.mud4j.behavior.BehaviorManager; +import net.sf.mud4j.effect.Effect; +import net.sf.mud4j.effect.EffectException; +import net.sf.mud4j.effect.EffectableBehavior; + +public class TestBehavior { + + + // Adds behaviorability to a person + public class PersonBehaviorDecorator extends BehaviorManager implements Person { + private Person person; + + public PersonBehaviorDecorator(Person person) { + this.person = person; + } + + public String getName() { + return person.getName(); + } + } + + public interface PersonBehavior { + Person getPerson(); + } + + public interface Person { + String getName(); + } + + public class PersonA implements Person { + private String name; + + public PersonA(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } + + public interface PersonFlyEffect extends Effect { + } + + public class PersonFlyWithWingsEffect implements PersonFlyEffect { + private Person person; + + public PersonFlyWithWingsEffect(Person person) { + this.person = person; + } + + private void applyFlying(Person person) { + System.out.println("Person: " + person.getName() + " is now flying with wings."); + } + + public void apply() throws EffectException { + applyFlying(person); + } + + public String getName() { + // TODO Auto-generated method stub + return null; + } + + public boolean hasExpired() { + // TODO Auto-generated method stub + return false; + } + + public boolean isPermanent() { + // TODO Auto-generated method stub + return false; + } + + public void undo() throws EffectException { + System.out.println("Person: " + person.getName() + " is not flying with wings."); + } + } + + public class DefaultEffectableBehavior implements EffectableBehavior { + + Map<Class<? extends Effect>, Effect> effectMap = new HashMap<Class<? extends Effect>, Effect>(); + + public void addEffect(Class<? extends Effect> effectClass, Effect effect) { + effectMap.put(effectClass, effect); + } + + public boolean hasEffect(Class<? extends Effect> effectClass) { + return effectMap.containsKey(effectClass); + } + + public void removeEffect(Class<? extends Effect> effectClass) { + effectMap.remove(effectClass); + } + + public <E extends Effect> E getEffect(Class<E> effectClass) { + return (E) effectMap.get(effectClass); + } + } + + public void run() { + Person personA = new PersonA("PersonA"); + PersonBehaviorDecorator personAWithBehaviorable = new PersonBehaviorDecorator(personA); + personAWithBehaviorable.addBehavior(EffectableBehavior.class, new DefaultEffectableBehavior()); + EffectableBehavior effectableBehavior = personAWithBehaviorable.getBehavior(EffectableBehavior.class); + + PersonFlyWithWingsEffect personCanFlyEffect = new PersonFlyWithWingsEffect(personA); + effectableBehavior.addEffect(PersonFlyEffect.class, personCanFlyEffect); + + personCanFlyEffect.apply(); + if (effectableBehavior.hasEffect(PersonFlyEffect.class)) { + System.out.println("Has fly effect."); + //PersonFlyEffect effect = effectableBehavior.getEffect(PersonFlyEffect.class); + effectableBehavior.removeEffect(PersonFlyEffect.class); + } + + System.out.println("A"); + } + + public static void main(String[] args) { + TestBehavior testBehavior = new TestBehavior(); + testBehavior.run(); + } +} Property changes on: trunk/mud4j-core/src/java/net/sf/mud4j/ability/TestBehavior.java ___________________________________________________________________ Name: svn:keywords + "Author Date Id Revision" Name: svn:eol-style + native Added: trunk/mud4j-core/src/java/net/sf/mud4j/behavior/Behavior.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/behavior/Behavior.java (rev 0) +++ trunk/mud4j-core/src/java/net/sf/mud4j/behavior/Behavior.java 2007-10-04 21:42:11 UTC (rev 148) @@ -0,0 +1,5 @@ +package net.sf.mud4j.behavior; + +// Marker interface +public interface Behavior { +} Property changes on: trunk/mud4j-core/src/java/net/sf/mud4j/behavior/Behavior.java ___________________________________________________________________ Name: svn:keywords + "Author Date Id Revision" Name: svn:eol-style + native Added: trunk/mud4j-core/src/java/net/sf/mud4j/behavior/BehaviorManager.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/behavior/BehaviorManager.java (rev 0) +++ trunk/mud4j-core/src/java/net/sf/mud4j/behavior/BehaviorManager.java 2007-10-04 21:42:11 UTC (rev 148) @@ -0,0 +1,24 @@ +package net.sf.mud4j.behavior; + +import java.util.HashMap; +import java.util.Map; + +public class BehaviorManager implements Behaviorable { + Map<Class<? extends Behavior>, Behavior> behaviorMap = new HashMap<Class<? extends Behavior>, Behavior>(); + + public void addBehavior(Class<? extends Behavior> behaviorClass, Behavior behavior) { + behaviorMap.put(behaviorClass, behavior); + } + + public boolean hasBehavior(Class<? extends Behavior> behaviorClass) { + return behaviorMap.containsKey(behaviorClass); + } + + public void removeBehavior(Class<? extends Behavior> behaviorClass) { + behaviorMap.remove(behaviorClass); + } + + public <E extends Behavior> E getBehavior(Class<E> behaviorClass) { + return (E)behaviorMap.get(behaviorClass); + } +} Property changes on: trunk/mud4j-core/src/java/net/sf/mud4j/behavior/BehaviorManager.java ___________________________________________________________________ Name: svn:keywords + "Author Date Id Revision" Name: svn:eol-style + native Modified: trunk/mud4j-core/src/java/net/sf/mud4j/damage/AbstractDamageBehavior.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/damage/AbstractDamageBehavior.java 2007-10-04 21:41:58 UTC (rev 147) +++ trunk/mud4j-core/src/java/net/sf/mud4j/damage/AbstractDamageBehavior.java 2007-10-04 21:42:11 UTC (rev 148) @@ -24,8 +24,8 @@ * * @author Matthew Purland */ -public abstract class AbstractDamageBehavior implements DamageBehavior { - private List<DamageListener> damageListeners; +public abstract class AbstractDamageBehavior<D extends DamageListener> implements DamageBehavior<D> { + private List<D> damageListeners; private boolean isDestroyed; /** @@ -40,7 +40,7 @@ isDestroyed = true; // Iterate through list of damage listeners - for (DamageListener listener : damageListeners) { + for (D listener : damageListeners) { DamageEvent event = new DamageEvent(this); event.setDestroyed(isDestroyed); listener.damageDestroyed(event); @@ -57,14 +57,14 @@ /** * {@inheritDoc} */ - public void removeDamageListener(DamageListener listener) { + public void removeDamageListener(D listener) { damageListeners.remove(listener); } /** * {@inheritDoc} */ - public void addDamageListener(DamageListener listener) { + public void addDamageListener(D listener) { damageListeners.add(listener); } } Modified: trunk/mud4j-core/src/java/net/sf/mud4j/damage/DamageBehavior.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/damage/DamageBehavior.java 2007-10-04 21:41:58 UTC (rev 147) +++ trunk/mud4j-core/src/java/net/sf/mud4j/damage/DamageBehavior.java 2007-10-04 21:42:11 UTC (rev 148) @@ -23,7 +23,7 @@ * @author Matthew Purland * @see PointDamageBehavior */ -public interface DamageBehavior { +public interface DamageBehavior<D extends DamageListener> { /** * Inflict damage on the object. */ @@ -42,10 +42,10 @@ /** * Add a damage listener to this damage behavior. */ - public void addDamageListener(DamageListener listener); + public void addDamageListener(D listener); /** * Remove a damage listener from this damage behavior. */ - public void removeDamageListener(DamageListener listener); + public void removeDamageListener(D listener); } Modified: trunk/mud4j-core/src/java/net/sf/mud4j/damage/DamageListener.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/damage/DamageListener.java 2007-10-04 21:41:58 UTC (rev 147) +++ trunk/mud4j-core/src/java/net/sf/mud4j/damage/DamageListener.java 2007-10-04 21:42:11 UTC (rev 148) @@ -21,17 +21,17 @@ /** * The listener interface for receiving damage events. */ -public interface DamageListener extends EventListener { +public interface DamageListener<E extends DamageEvent> extends EventListener { /** * Event called when damage is inflicted. */ - public void damageInflicted(DamageEvent event); + public void damageInflicted(E event); /** * Event called when enough damage is done that destroys the object. */ - public void damageDestroyed(DamageEvent event); + public void damageDestroyed(E event); } Added: trunk/mud4j-core/src/java/net/sf/mud4j/damage/PointDamageEvent.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/damage/PointDamageEvent.java (rev 0) +++ trunk/mud4j-core/src/java/net/sf/mud4j/damage/PointDamageEvent.java 2007-10-04 21:42:11 UTC (rev 148) @@ -0,0 +1,5 @@ +package net.sf.mud4j.damage; + +public class PointDamageEvent { + +} Property changes on: trunk/mud4j-core/src/java/net/sf/mud4j/damage/PointDamageEvent.java ___________________________________________________________________ Name: svn:keywords + "Author Date Id Revision" Name: svn:eol-style + native Modified: trunk/mud4j-core/src/java/net/sf/mud4j/effect/AbstractEffect.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/effect/AbstractEffect.java 2007-10-04 21:41:58 UTC (rev 147) +++ trunk/mud4j-core/src/java/net/sf/mud4j/effect/AbstractEffect.java 2007-10-04 21:42:11 UTC (rev 148) @@ -58,4 +58,9 @@ * {@inheritDoc} */ abstract public void apply() throws EffectException; + + /** + * {@inheritDoc} + */ + abstract public boolean isPermanent(); } Modified: trunk/mud4j-core/src/java/net/sf/mud4j/effect/AbstractItemEffect.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/effect/AbstractItemEffect.java 2007-10-04 21:41:58 UTC (rev 147) +++ trunk/mud4j-core/src/java/net/sf/mud4j/effect/AbstractItemEffect.java 2007-10-04 21:42:11 UTC (rev 148) @@ -19,7 +19,7 @@ import net.sf.mud4j.world.item.Item; /** - * Abstract item effect imlementation to implement all + * Abstract item effect implementation to implement all * necessary functionality for an extending class to use * and implement business item effect data. Extending * from this class will provide the class with core item @@ -57,14 +57,4 @@ public void undo() throws EffectException { item.getEffectBehavior().removeEffect(this); } - - /** - * {@inheritDoc} - */ - public boolean isPermanent() { - // TODO Auto-generated method stub - return false; - } - - } Deleted: trunk/mud4j-core/src/java/net/sf/mud4j/effect/CharacterEffectDecorator.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/effect/CharacterEffectDecorator.java 2007-10-04 21:41:58 UTC (rev 147) +++ trunk/mud4j-core/src/java/net/sf/mud4j/effect/CharacterEffectDecorator.java 2007-10-04 21:42:11 UTC (rev 148) @@ -1,103 +0,0 @@ -/** - * Copyright 2006 Matthew Purland (m.p...@gm...) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.mud4j.effect; - -import java.io.IOException; -import java.util.List; - -import net.sf.mud4j.ability.CharacterAbility; -import net.sf.mud4j.character.Character; -import net.sf.mud4j.damage.DamageBehavior; -import net.sf.mud4j.world.item.Item; - -/** - * Provide effects as a decorator to a character. - * - * @author Matthew Purland - */ -public abstract class CharacterEffectDecorator implements Character, Effectable { - - // Character to decorate - private Character character; - - public CharacterEffectDecorator(Character character) { - this.character = character; - } - - /** - * {@inheritDoc} - */ - public List<CharacterAbility> getAbilities() { - return character.getAbilities(); - } - - /** - * {@inheritDoc} - */ - public List<Item> getItems() { - return character.getItems(); - } - - /** - * {@inheritDoc} - */ - public int getLevel() { - return character.getLevel(); - } - - /** - * {@inheritDoc} - */ - public String getName() { - return character.getName(); - } - - /** - * {@inheritDoc} - */ - public boolean hasAbility(CharacterAbility ability) { - return character.hasAbility(ability); - } - - /** - * {@inheritDoc} - */ - public boolean hasItem(Item item) { - return character.hasItem(item); - } - - /** - * {@inheritDoc} - */ - public DamageBehavior getDamageBehavior() { - return character.getDamageBehavior(); - } - - /** - * {@inheritDoc} - */ - public void setDamageBehavior(DamageBehavior damageBehavior) { - character.setDamageBehavior(damageBehavior); - } - - /** - * {@inheritDoc} - */ - public void message(String message) throws IOException { - character.message(message); - } - -} Modified: trunk/mud4j-core/src/java/net/sf/mud4j/effect/Effect.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/effect/Effect.java 2007-10-04 21:41:58 UTC (rev 147) +++ trunk/mud4j-core/src/java/net/sf/mud4j/effect/Effect.java 2007-10-04 21:42:11 UTC (rev 148) @@ -29,21 +29,21 @@ * * @throws EffectException in case of an apply failure. */ - public void apply() throws EffectException; + void apply() throws EffectException; /** * Undo the effect from the target. * * @throws EffectException in case of an undo failure. */ - public void undo() throws EffectException; + void undo() throws EffectException; /** * Determine if the effect has expired duration. * * @return Returns whether the effect has expired yet. */ - public boolean hasExpired(); + boolean hasExpired(); /** * Determine if the effect is permanent. Permanent status means that the @@ -52,12 +52,12 @@ * @return Retruns whether the effect is a permanent effect and cannot * expire. */ - public boolean isPermanent(); + boolean isPermanent(); /** * Get name of the effect. * * @return Returns the name of the effect. */ - public String getName(); + String getName(); } Added: trunk/mud4j-core/src/java/net/sf/mud4j/effect/EffectableBehavior.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/effect/EffectableBehavior.java (rev 0) +++ trunk/mud4j-core/src/java/net/sf/mud4j/effect/EffectableBehavior.java 2007-10-04 21:42:11 UTC (rev 148) @@ -0,0 +1,10 @@ +package net.sf.mud4j.effect; + +import net.sf.mud4j.behavior.Behavior; + +public interface EffectableBehavior extends Behavior { + boolean hasEffect(Class<? extends Effect> effectClass); + void addEffect(Class<? extends Effect> effectClass, Effect effect); + void removeEffect(Class<? extends Effect> effectClass); + <E extends Effect> E getEffect(Class<E> effectClass); +} \ No newline at end of file Property changes on: trunk/mud4j-core/src/java/net/sf/mud4j/effect/EffectableBehavior.java ___________________________________________________________________ Name: svn:keywords + "Author Date Id Revision" Name: svn:eol-style + native Deleted: trunk/mud4j-core/src/java/net/sf/mud4j/effect/LocationEffectDecorator.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/effect/LocationEffectDecorator.java 2007-10-04 21:41:58 UTC (rev 147) +++ trunk/mud4j-core/src/java/net/sf/mud4j/effect/LocationEffectDecorator.java 2007-10-04 21:42:11 UTC (rev 148) @@ -1,48 +0,0 @@ -/** - * Copyright 2006 Matthew Purland (m.p...@gm...) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.mud4j.effect; - -import net.sf.mud4j.world.Location; -import net.sf.mud4j.world.Placeable; - -/** - * Provide effect decorator/wrapping around a {@link Location}. Will delegate - * {@link Location} interface to wrapped object. - * - * @author Matthew Purland - */ -public abstract class LocationEffectDecorator implements Effectable, Location { - - // Location that is being decorated - private Location location; - - /** - * Constructor to create an effect decorating a given location. - * - * @param location Location to decorate. - */ - public LocationEffectDecorator(Location location) { - this.location = location; - } - - /** - * {@inheritDoc} - */ - public void move(Placeable placeable) { - location.move(placeable); - } - -} Deleted: trunk/mud4j-core/src/java/net/sf/mud4j/map/AreaMap.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/map/AreaMap.java 2007-10-04 21:41:58 UTC (rev 147) +++ trunk/mud4j-core/src/java/net/sf/mud4j/map/AreaMap.java 2007-10-04 21:42:11 UTC (rev 148) @@ -1,27 +0,0 @@ -/** - * Copyright 2006 Matthew Purland (m.p...@gm...) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.mud4j.map; - -/** - * Game map of - * - * @author Matthew Purland - * - */ -public interface AreaMap { - -} Copied: trunk/mud4j-core/src/java/net/sf/mud4j/map/ZoneMap.java (from rev 146, trunk/mud4j-core/src/java/net/sf/mud4j/map/AreaMap.java) =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/map/ZoneMap.java (rev 0) +++ trunk/mud4j-core/src/java/net/sf/mud4j/map/ZoneMap.java 2007-10-04 21:42:11 UTC (rev 148) @@ -0,0 +1,27 @@ +/** + * Copyright 2006 Matthew Purland (m.p...@gm...) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.sf.mud4j.map; + +/** + * Map of a zone containing rooms. + * + * @author Matthew Purland + * + */ +public interface ZoneMap { + +} Modified: trunk/mud4j-core/src/java/net/sf/mud4j/world/Direction.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/world/Direction.java 2007-10-04 21:41:58 UTC (rev 147) +++ trunk/mud4j-core/src/java/net/sf/mud4j/world/Direction.java 2007-10-04 21:42:11 UTC (rev 148) @@ -23,8 +23,25 @@ * @author Matthew Purland */ public class Direction { + + public enum DirectionName { + NORTH("north"), + EAST("east"), + WEST("west"), + SOUTH("south"); + + private String directionName; + + DirectionName(String directionName) { + this.directionName = directionName; + } + + public String getDirectionName() { + return directionName; + } + } - private String directionName; + private DirectionName directionName; /** * Direction is from source to target location. Example. If direction is @@ -40,7 +57,7 @@ * @param sourceLocation Source of the location to the target * @param targetLocation Target of the location from the source */ - public Direction(String directionName, TileLocation sourceLocation, + public Direction(DirectionName directionName, TileLocation sourceLocation, TileLocation targetLocation) { this.directionName = directionName; this.sourceLocation = sourceLocation; @@ -50,7 +67,7 @@ /** * Get name of direction. */ - public String getDirectionName() { + public DirectionName getDirectionName() { return directionName; } Modified: trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/CharacterEffectTest.java =================================================================== --- trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/CharacterEffectTest.java 2007-10-04 21:41:58 UTC (rev 147) +++ trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/CharacterEffectTest.java 2007-10-04 21:42:11 UTC (rev 148) @@ -54,14 +54,9 @@ /** * Test the ability to apply an effect on a character. */ - public void testCharacterEffectApply() { - try { - effect.apply(); - effectBehavior.addEffect(effect); - } - catch (EffectException ex) { - - } + public void testCharacterEffectApply() throws EffectException { + effect.apply(); + effectBehavior.addEffect(effect); // Assert that the effect behavior contains the effect assertTrue(character.getEffectBehavior().getEffects().contains(effect)); @@ -75,15 +70,16 @@ /** * Test the ability to undo an effect on a character. */ - public void testCharacterEffectUndo() { - try { - effect.undo(); - effectBehavior.removeEffect(effect); - } - catch (EffectException ex) { - - } + public void testCharacterEffectUndo() throws EffectException { + effect.apply(); + effectBehavior.addEffect(effect); + + // Assert that the effect behavior contains the effect + assertTrue(character.getEffectBehavior().getEffects().contains(effect)); + effect.undo(); + effectBehavior.removeEffect(effect); + // Assert that the effect behavior DOES NOT contain the effect assertFalse(character.getEffectBehavior().getEffects().contains(effect)); } @@ -91,19 +87,13 @@ /** * Test the effect of permanent/non-permanent effects. */ - public void testCharacterEffectPermanent() { - try { - effect.apply(); - effectBehavior.addEffect(effect); - } - catch (EffectException ex) { - - } + public void testCharacterEffectPermanent() throws EffectException { + effect.apply(); + effectBehavior.addEffect(effect); // Iterate through all effects and make sure all are not permanent. for (Effect effect : effectBehavior.getEffects()) { assertFalse(effect.isPermanent()); - } - + } } } Added: trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/EffectableBehaviorTest.java =================================================================== --- trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/EffectableBehaviorTest.java (rev 0) +++ trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/EffectableBehaviorTest.java 2007-10-04 21:42:11 UTC (rev 148) @@ -0,0 +1,6 @@ +package net.mud4j.game.effect; + + +public class EffectableBehaviorTest { + +} Property changes on: trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/EffectableBehaviorTest.java ___________________________________________________________________ Name: svn:keywords + "Author Date Id Revision" Name: svn:eol-style + native Modified: trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/MockCharacterEffect.java =================================================================== --- trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/MockCharacterEffect.java 2007-10-04 21:41:58 UTC (rev 147) +++ trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/MockCharacterEffect.java 2007-10-04 21:42:11 UTC (rev 148) @@ -24,7 +24,12 @@ * @author Matthew Purland */ public class MockCharacterEffect extends AbstractCharacterEffect { - + + // Effect as non permanent by default. + private boolean isPermanent = false; + private boolean isApplied = false; + + /** * Constructor to provide injection for character on to effect. * @param character Character to set for the effect. @@ -45,8 +50,7 @@ */ @Override public void apply() { - // TODO Auto-generated method stub - + isApplied = true; } /** @@ -54,16 +58,21 @@ */ @Override public void undo() { - // TODO Auto-generated method stub - + isApplied = false; } /** * {@inheritDoc} */ public boolean isPermanent() { - // Place this effect as non permanent. - return false; + return isPermanent; } + + /** + * Set permanent to true. + */ + public void setPermanent() { + isPermanent = true; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |