Package org.groovymud.object

Examples of org.groovymud.object.MudObject


   *            index of object to remove
   * @return the removed object
   */
  public MudObject removeMudObject(String objectName, int index) {
    List<MudObject> list = new ArrayList<MudObject>(getMudObjectHashSets().get(objectName));
    MudObject obj = null;
    obj = list.get(index);

    removeMudObject(obj);

    return (MudObject) obj;
View Full Code Here


  private static final Logger logger = Logger.getLogger(BeanBuilderDomainManager.class);
  private String preloadedDomains;

  public MudObject getObject(String handle) {
    MudObject bean = (MudObject) getApplicationContext().getBean(handle);
    return bean;
  }
View Full Code Here

    int i = 0;
    while (keys.hasNext()) {
      String key = (String) keys.next();
      HashSet set = (HashSet) contentCopy.get(key);
      Iterator x = set.iterator();
      MudObject obj = (MudObject) x.next();
      if (set.size() > 1) {
        description.append(pluralize(key, i, (i == 0)));
      }
      if (set.size() == 1) {
        if (obj.isArticleRequired()) {
          key = affixIndefiniteArticle(key, i == 0);
        }
        description.append(key);
      }
      if (keys.hasNext()) {
View Full Code Here

   * @param ObjectLocation
   *            location - representing where the object can be found in the
   *            spring container
   */
  public MudObject load(ObjectLocation location) {
    MudObject obj = null;
    if (!getApplicationContext().containsBean(location.getBeanId())) {
      loadDefinition(location.getDefinition());
    }
    String beanId = location.getBeanId();
    if (!getApplicationContext().containsBean(location.getBeanId())) {
View Full Code Here

    Iterator x = objects.iterator();
    int count = 0;
    while (x.hasNext()) {
      Object object = x.next();
      if (object instanceof MudObject) {
        MudObject mudObject = (MudObject) object;
        if (messageFor.equals(mudObject)) {
          message = message.replaceFirst("\\%" + count++, "You");
        } else {
          String name = (String) mudObject.getShortNames().toArray()[0];
          message = message.replaceAll("\\%" + count++, (mudObject.isArticleRequired() ? WordUtils.affixIndefiniteArticle(name) : name));
        }
      }
    }
    return message;
  }
View Full Code Here

 
 
  public void testAddMudObjectStringMudObject() {
    InventoryHandler hand = new InventoryHandler();
    MockControl ctrl = MockControl.createNiceControl(MudObject.class);
    MudObject obj = (MudObject) ctrl.getMock();
    obj.getName();
    ctrl.setDefaultReturnValue("name");
    obj.getShortNames();
    ctrl.setDefaultReturnValue(new LinkedList());
    ctrl.replay();
   
    hand.addMudObject(obj);
    assertTrue(hand.size() == 1);
    hand.addMudObject(obj);
    assertTrue(hand.size() == 1);
    ctrl.verify();
   
    MockControl ctrl2 = MockControl.createNiceControl(MudObject.class);
    MudObject obj2 = (MudObject) ctrl2.getMock();
    obj2.getName();
    ctrl2.setDefaultReturnValue("name");
    obj2.getShortNames();
    ctrl2.setDefaultReturnValue(new LinkedList());
    ctrl2.replay();
    hand.addMudObject(obj2);
    assertTrue(hand.size() == 2);
View Full Code Here

  public void testRemoveMudObjectMudObject() {
    InventoryHandler hand = new InventoryHandler();
   
    MockControl ctrl = MockControl.createNiceControl(MudObject.class);
    MudObject obj = (MudObject) ctrl.getMock();
    obj.getName();
    ctrl.setDefaultReturnValue("name");
    obj.getShortNames();
    ctrl.setDefaultReturnValue(new LinkedList());
    ctrl.replay();
   
    hand.addMudObject(obj);
   
View Full Code Here

  }

  public void testRemoveMudObjectStringInt() {
    InventoryHandler hand = new InventoryHandler();
    MockControl ctrl = MockControl.createNiceControl(MudObject.class);
    MudObject obj = (MudObject) ctrl.getMock();
    obj.getName();
    ctrl.setDefaultReturnValue("obj");
    obj.getShortNames();
    ctrl.setDefaultReturnValue(new LinkedList());
    ctrl.replay();
    hand.addMudObject(obj);

    MockControl ctrl2 = MockControl.createNiceControl(MudObject.class);
    MudObject obj2 = (MudObject) ctrl2.getMock();
    obj2.getName();
    ctrl2.setDefaultReturnValue("obj");
    obj2.getShortNames();
    ctrl2.setDefaultReturnValue(new LinkedList());   
    ctrl2.replay();
    hand.addMudObject(obj2);
   
    assertTrue(hand.size() == 2);
View Full Code Here

  protected void initialise() {
    Observable o = null;
    if (getInformer() == null) {
      try {
        getAttendant().load(getShutDownInformer());
        MudObject obj = getAttendant().cloneObject(getShutDownInformer().getHandle());
        if (obj instanceof Observable) {
          o = (Observable) obj;
          o.addObserver(attendant.getObjectRegistry());
          setInformer(o);
        } else {
View Full Code Here

  public void handleShutdown() {
    if (shutdownHeartBeats++ == getMaxShutdownHeartBeats()) {
      if (informer != null) {
        String message = "";
        if (informer instanceof MudObject) {
          MudObject obj = (MudObject) informer;
          message += obj.getName() + " shouts:";
        }
        message += "Mud shutting down NOW!!";
        MessengerUtils.sendMessageToMud(informer, "", message);
      }
      logger.info("Shutdown NOW!");
View Full Code Here

TOP

Related Classes of org.groovymud.object.MudObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.