[mud4j-commit] SF.net SVN: mud4j: [91] trunk/mud4j-core/src/java/net/sf/mud4j/effect
Status: Pre-Alpha
Brought to you by:
mpurland
|
From: <mpu...@us...> - 2007-01-07 20:59:33
|
Revision: 91
http://mud4j.svn.sourceforge.net/mud4j/?rev=91&view=rev
Author: mpurland
Date: 2007-01-07 12:59:30 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
Add effect decorators (may remove later).
Added Paths:
-----------
trunk/mud4j-core/src/java/net/sf/mud4j/effect/CharacterEffectDecorator.java
trunk/mud4j-core/src/java/net/sf/mud4j/effect/LocationEffectDecorator.java
Added: trunk/mud4j-core/src/java/net/sf/mud4j/effect/CharacterEffectDecorator.java
===================================================================
--- trunk/mud4j-core/src/java/net/sf/mud4j/effect/CharacterEffectDecorator.java (rev 0)
+++ trunk/mud4j-core/src/java/net/sf/mud4j/effect/CharacterEffectDecorator.java 2007-01-07 20:59:30 UTC (rev 91)
@@ -0,0 +1,103 @@
+/**
+ * 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);
+ }
+
+}
Added: trunk/mud4j-core/src/java/net/sf/mud4j/effect/LocationEffectDecorator.java
===================================================================
--- trunk/mud4j-core/src/java/net/sf/mud4j/effect/LocationEffectDecorator.java (rev 0)
+++ trunk/mud4j-core/src/java/net/sf/mud4j/effect/LocationEffectDecorator.java 2007-01-07 20:59:30 UTC (rev 91)
@@ -0,0 +1,48 @@
+/**
+ * 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);
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|