View Javadoc

1   /**
2    * Copyright 2006 Matthew Purland (m.purland@gmail.com)
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  
17  package net.sf.mud4j.effect;
18  
19  import net.sf.mud4j.world.item.Item;
20  
21  /**
22   * Abstract item effect imlementation to implement all
23   * necessary functionality for an extending class to use
24   * and implement business item effect data.  Extending
25   * from this class will provide the class with core item
26   * effect functionality.
27   * 
28   * @author Matthew Purland
29   */
30  public class AbstractItemEffect extends AbstractEffect implements ItemEffect {
31      // Item that the effect will affect.
32      private Item item;
33      
34      public AbstractItemEffect(Item item) {
35          setItem(item);
36      }
37  
38      /**
39       * {@inheritDoc}
40       */
41      public void setItem(Item item) {
42          this.item = item;
43      }    
44      
45      /**
46       * {@inheritDoc}
47       */
48      @Override
49      public void apply() throws EffectException {
50          item.getEffectBehavior().addEffect(this);
51      }
52  
53      /**
54       * {@inheritDoc}
55       */
56      @Override
57      public void undo() throws EffectException {
58          item.getEffectBehavior().removeEffect(this);
59      }
60  
61      /**
62       * {@inheritDoc}
63       */
64      public boolean isPermanent() {
65          // TODO Auto-generated method stub
66          return false;
67      }
68  
69  
70  }