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.world;
18  
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  import net.sf.mud4j.effect.EffectBehavior;
23  
24  
25  /**
26   * Defines rooms interface as a location that events happen within.
27   * 
28   * TODO implement events for when a Placeable becomes moved
29   * TODO keep internal list of Placeables within room
30   * 
31   * @author Matthew Purland
32   */
33  public class Room implements TileLocation {
34  
35      // List of directions
36      private List<Direction> directionList = new ArrayList<Direction>();
37      private EffectBehavior effectBehavior;
38      private String roomName;
39      
40      public Room() {
41      }
42      
43      /**
44       * Get the name of the location.
45       */
46      public String getName() {
47          return roomName;
48      }
49      
50      /**
51       * Set the name of the location;
52       */
53      public void setName(String name) {
54          this.roomName = name;
55      }
56      
57      /**
58       * {@inheritDoc}
59       */
60      public void addDirection(Direction direction) {
61          directionList.add(direction);
62      }
63  
64      /**
65       * {@inheritDoc}
66       */
67      public void removeDirection(Direction direction) {
68          directionList.remove(direction);
69      }    
70      
71      /**
72       * {@inheritDoc}
73       */
74      public List<Direction> getDirections() {
75          return directionList;
76      }
77  
78      /**
79       * {@inheritDoc}
80       */
81      public void move(Placeable placeable) {
82          
83          placeable.place(this);
84      }
85  
86      /**
87       * {@inheritDoc}
88       */
89      public EffectBehavior getEffectBehavior() {
90          return effectBehavior;
91      }
92  
93      /**
94       * {@inheritDoc}
95       */
96      public void setEffectBehavior(EffectBehavior effectBehavior) {
97          this.effectBehavior = effectBehavior;
98      }
99  }