[mud4j-commit] SF.net SVN: mud4j: [114] trunk/mud4j-core/src
Status: Pre-Alpha
Brought to you by:
mpurland
From: <mpu...@us...> - 2007-01-14 18:47:11
|
Revision: 114 http://mud4j.svn.sourceforge.net/mud4j/?rev=114&view=rev Author: mpurland Date: 2007-01-14 10:47:07 -0800 (Sun, 14 Jan 2007) Log Message: ----------- Remove CharacterEffect interface. Fix javadoc on classes. Add new mock test to provide new goal of testing of effect package. Modified Paths: -------------- trunk/mud4j-core/src/java/net/sf/mud4j/effect/AbstractCharacterEffect.java trunk/mud4j-core/src/java/net/sf/mud4j/effect/Effect.java trunk/mud4j-core/src/test/unit/net/mud4j/game/ability/MockCharacterAbility.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/test/unit/net/mud4j/game/effect/MockCharacterEffectLevel.java Removed Paths: ------------- trunk/mud4j-core/src/java/net/sf/mud4j/effect/CharacterEffect.java Modified: trunk/mud4j-core/src/java/net/sf/mud4j/effect/AbstractCharacterEffect.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/effect/AbstractCharacterEffect.java 2007-01-14 18:45:05 UTC (rev 113) +++ trunk/mud4j-core/src/java/net/sf/mud4j/effect/AbstractCharacterEffect.java 2007-01-14 18:47:07 UTC (rev 114) @@ -19,39 +19,29 @@ import net.sf.mud4j.character.Character; /** + * Abstract character effect implementation for injecting a character on to + * an effect. + * * @author Matthew Purland * */ -public abstract class AbstractCharacterEffect extends AbstractEffect implements CharacterEffect { +public abstract class AbstractCharacterEffect extends AbstractEffect { private Character character; + /** + * Constructor to inject effect with a character. + * + * @param character + */ public AbstractCharacterEffect(Character character) { - setCharacter(character); + this.character = character; } - + /** - * {@inheritDoc} + * Get character for the effect. + * @return Returns the character for the effect. */ - public void setCharacter(Character character) { - this.character = character; - } -// -// /** -// * {@inheritDoc} -// */ -// @Override -// public void apply() { -// character.getEffectBehavior().addEffect(this); -// } -// -// /** -// * {@inheritDoc} -// */ -// @Override -// public void undo() { -// character.getEffectBehavior().removeEffect(this); -// } - - - + public Character getCharacter() { + return character; + } } Deleted: trunk/mud4j-core/src/java/net/sf/mud4j/effect/CharacterEffect.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/effect/CharacterEffect.java 2007-01-14 18:45:05 UTC (rev 113) +++ trunk/mud4j-core/src/java/net/sf/mud4j/effect/CharacterEffect.java 2007-01-14 18:47:07 UTC (rev 114) @@ -1,33 +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.character.Character; - -/** - * Effect that adds effects to characters. - * - * @author Matthew Purland - */ -public interface CharacterEffect extends Effect { - - /** - * Set the character on the object. - * @param character Character to set. - */ - public void setCharacter(Character character); -} Modified: trunk/mud4j-core/src/java/net/sf/mud4j/effect/Effect.java =================================================================== --- trunk/mud4j-core/src/java/net/sf/mud4j/effect/Effect.java 2007-01-14 18:45:05 UTC (rev 113) +++ trunk/mud4j-core/src/java/net/sf/mud4j/effect/Effect.java 2007-01-14 18:47:07 UTC (rev 114) @@ -28,12 +28,14 @@ /** * Apply effect on the target. * @param target Target object to apply effect on. + * @throws EffectException in case of an apply failure. */ public void apply() throws EffectException; /** * Undo the effect from the target. * @param target Target object to remove effect from. + * @throws EffectException in case of an undo failure. */ public void undo() throws EffectException; @@ -46,11 +48,13 @@ /** * Determine if the effect is permanent. Permanent status means * that the effect cannot be removed. + * @return Retruns whether the effect is a permanent effect and cannot expire. */ public boolean isPermanent(); /** - * Get name of the effect + * Get name of the effect. + * @return Returns the name of the effect. */ public String getName(); } Modified: trunk/mud4j-core/src/test/unit/net/mud4j/game/ability/MockCharacterAbility.java =================================================================== --- trunk/mud4j-core/src/test/unit/net/mud4j/game/ability/MockCharacterAbility.java 2007-01-14 18:45:05 UTC (rev 113) +++ trunk/mud4j-core/src/test/unit/net/mud4j/game/ability/MockCharacterAbility.java 2007-01-14 18:47:07 UTC (rev 114) @@ -34,8 +34,10 @@ super(character); } - /* (non-Javadoc) - * @see net.sf.mud4j.ability.CharacterAbility#run(net.sf.mud4j.character.Character) + /** + * Test a character ability by testing through messaging the character. + * + * {@inheritDoc} */ public void run() throws AbilityException { try { 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-01-14 18:45:05 UTC (rev 113) +++ trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/CharacterEffectTest.java 2007-01-14 18:47:07 UTC (rev 114) @@ -15,6 +15,8 @@ */ package net.mud4j.game.effect; +import java.util.Iterator; + import net.mud4j.test.MudTestCase; import net.sf.mud4j.character.Character; import net.sf.mud4j.effect.DefaultEffectBehavior; @@ -42,6 +44,9 @@ effect = new MockCharacterEffect(character); } + /** + * Test the effect name. + */ public void testCharacterEffect() { assertEquals(effect.getName(), "MockCharacterEffect"); } @@ -58,8 +63,13 @@ } + // Assert that the effect behavior contains the effect + assertTrue(character.getEffectBehavior().getEffects().contains(effect)); - assertTrue(character.getEffectBehavior().getEffects().contains(effect)); + effectBehavior.clear(); + + // Assert that the effect behavior now DOES NOT contain the effect + assertFalse(character.getEffectBehavior().getEffects().contains(effect)); } /** @@ -74,6 +84,26 @@ } + // Assert that the effect behavior DOES NOT contain the effect assertFalse(character.getEffectBehavior().getEffects().contains(effect)); } + + /** + * Test the effect of permanent/non-permanent effects. + */ + public void testCharacterEffectPermanent() { + try { + effect.apply(); + effectBehavior.addEffect(effect); + } + catch (EffectException ex) { + + } + + // Iterate through all effects and make sure all are not permanent. + for (Effect effect : effectBehavior.getEffects()) { + assertFalse(effect.isPermanent()); + } + + } } 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-01-14 18:45:05 UTC (rev 113) +++ trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/MockCharacterEffect.java 2007-01-14 18:47:07 UTC (rev 114) @@ -25,10 +25,17 @@ */ public class MockCharacterEffect extends AbstractCharacterEffect { + /** + * Constructor to provide injection for character on to effect. + * @param character Character to set for the effect. + */ public MockCharacterEffect(Character character) { super(character); } + /** + * {@inheritDoc} + */ public String getName() { return "MockCharacterEffect"; } @@ -55,7 +62,7 @@ * {@inheritDoc} */ public boolean isPermanent() { - // TODO Auto-generated method stub + // Place this effect as non permanent. return false; } Added: trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/MockCharacterEffectLevel.java =================================================================== --- trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/MockCharacterEffectLevel.java (rev 0) +++ trunk/mud4j-core/src/test/unit/net/mud4j/game/effect/MockCharacterEffectLevel.java 2007-01-14 18:47:07 UTC (rev 114) @@ -0,0 +1,68 @@ +/** + * 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.mud4j.game.effect; + +import net.sf.mud4j.character.Character; +import net.sf.mud4j.effect.AbstractCharacterEffect; + +/** + * Mock character effect to test to increase level of character. + * + * @author Matthew Purland + */ +public class MockCharacterEffectLevel extends AbstractCharacterEffect { + + /** + * Constructor to provide injection for character on to effect. + * @param character Character to set for the effect. + */ + public MockCharacterEffectLevel(Character character) { + super(character); + } + + /** + * {@inheritDoc} + */ + public String getName() { + return "MockCharacterEffectLevel"; + } + + /** + * {@inheritDoc} + */ + @Override + public void apply() { + + } + + /** + * {@inheritDoc} + */ + @Override + public void undo() { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public boolean isPermanent() { + // Place this effect as non permanent. + return false; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |