[mud4j-commit] SF.net SVN: mud4j: [159] trunk/mud4j-core/src/java/net/sf/mud4j
Status: Pre-Alpha
Brought to you by:
mpurland
|
From: <mpu...@us...> - 2007-11-01 00:01:54
|
Revision: 159
http://mud4j.svn.sourceforge.net/mud4j/?rev=159&view=rev
Author: mpurland
Date: 2007-10-31 17:01:48 -0700 (Wed, 31 Oct 2007)
Log Message:
-----------
Add Startup.
Add link/one-way and two-way location links.
Added Paths:
-----------
trunk/mud4j-core/src/java/net/sf/mud4j/startup/Startup.java
trunk/mud4j-core/src/java/net/sf/mud4j/world/link/LocationLink.java
trunk/mud4j-core/src/java/net/sf/mud4j/world/link/LocationLinkManager.java
trunk/mud4j-core/src/java/net/sf/mud4j/world/link/OneWayLocationLink.java
trunk/mud4j-core/src/java/net/sf/mud4j/world/link/TileLocationLink.java
trunk/mud4j-core/src/java/net/sf/mud4j/world/link/TwoWayLocationLink.java
Added: trunk/mud4j-core/src/java/net/sf/mud4j/startup/Startup.java
===================================================================
--- trunk/mud4j-core/src/java/net/sf/mud4j/startup/Startup.java (rev 0)
+++ trunk/mud4j-core/src/java/net/sf/mud4j/startup/Startup.java 2007-11-01 00:01:48 UTC (rev 159)
@@ -0,0 +1,19 @@
+package net.sf.mud4j.startup;
+
+import net.sf.mud4j.scheduling.QuartzSchedulingService;
+import net.sf.mud4j.util.SpringHelper;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Startup {
+ public static void main(String[] args) {
+ final boolean saveData = true;
+ ClassPathXmlApplicationContext appContext = SpringHelper.getClassPathXmlApplicationContext(saveData);
+ QuartzSchedulingService schedulingService = (QuartzSchedulingService) appContext.getBean("schedulingService");
+
+// String[] groupNames = schedulingService.getGroupNames();
+// for (String groupName : groupNames) {
+// System.out.println(groupName);
+// }
+ }
+}
Property changes on: trunk/mud4j-core/src/java/net/sf/mud4j/startup/Startup.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/mud4j-core/src/java/net/sf/mud4j/world/link/LocationLink.java
===================================================================
--- trunk/mud4j-core/src/java/net/sf/mud4j/world/link/LocationLink.java (rev 0)
+++ trunk/mud4j-core/src/java/net/sf/mud4j/world/link/LocationLink.java 2007-11-01 00:01:48 UTC (rev 159)
@@ -0,0 +1,29 @@
+package net.sf.mud4j.world.link;
+
+import java.util.Set;
+
+import net.sf.mud4j.world.Location;
+import net.sf.mud4j.world.MoveableException;
+import net.sf.mud4j.world.Placeable;
+
+/**
+ * Link between a set of {@link Location} objects.
+ *
+ * @author Matthew Purland
+ */
+public interface LocationLink<L extends Location> {
+ /**
+ * Get set of locations that are linked.
+ */
+ Set<L> getLocations();
+
+ /**
+ * Move a placeable using the link to the appropriate location.
+ *
+ * @param placeable
+ * The placeable
+ * @throws MoveableException
+ * when the given placeable is not in the source location.
+ */
+ void move(Placeable placeable) throws MoveableException;
+}
Property changes on: trunk/mud4j-core/src/java/net/sf/mud4j/world/link/LocationLink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/mud4j-core/src/java/net/sf/mud4j/world/link/LocationLinkManager.java
===================================================================
--- trunk/mud4j-core/src/java/net/sf/mud4j/world/link/LocationLinkManager.java (rev 0)
+++ trunk/mud4j-core/src/java/net/sf/mud4j/world/link/LocationLinkManager.java 2007-11-01 00:01:48 UTC (rev 159)
@@ -0,0 +1,20 @@
+package net.sf.mud4j.world.link;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sf.mud4j.world.Location;
+
+public class LocationLinkManager {
+ Map<Location, LocationLink> locationToLocationLinkMap = new HashMap<Location, LocationLink>();
+
+ public void addLink(Location location, LocationLink locationLink) {
+ locationToLocationLinkMap.put(location, locationLink);
+ }
+
+ public void removeLink(LocationLink locationLink) {
+ locationToLocationLinkMap.remove(locationLink);
+ }
+
+ //public Set<LocationLink>
+}
Property changes on: trunk/mud4j-core/src/java/net/sf/mud4j/world/link/LocationLinkManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/mud4j-core/src/java/net/sf/mud4j/world/link/OneWayLocationLink.java
===================================================================
--- trunk/mud4j-core/src/java/net/sf/mud4j/world/link/OneWayLocationLink.java (rev 0)
+++ trunk/mud4j-core/src/java/net/sf/mud4j/world/link/OneWayLocationLink.java 2007-11-01 00:01:48 UTC (rev 159)
@@ -0,0 +1,15 @@
+package net.sf.mud4j.world.link;
+
+import net.sf.mud4j.world.Location;
+
+/**
+ * One-way link between a source and destination location.
+ *
+ * @author Matthew Purland
+ *
+ * @param <T>
+ */
+public interface OneWayLocationLink <T extends Location> extends LocationLink<T> {
+
+
+}
Property changes on: trunk/mud4j-core/src/java/net/sf/mud4j/world/link/OneWayLocationLink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/mud4j-core/src/java/net/sf/mud4j/world/link/TileLocationLink.java
===================================================================
--- trunk/mud4j-core/src/java/net/sf/mud4j/world/link/TileLocationLink.java (rev 0)
+++ trunk/mud4j-core/src/java/net/sf/mud4j/world/link/TileLocationLink.java 2007-11-01 00:01:48 UTC (rev 159)
@@ -0,0 +1,74 @@
+package net.sf.mud4j.world.link;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import net.sf.mud4j.world.Direction;
+import net.sf.mud4j.world.MoveableException;
+import net.sf.mud4j.world.Placeable;
+import net.sf.mud4j.world.TileLocation;
+
+public class TileLocationLink implements TwoWayLocationLink<TileLocation> {
+
+ private TileLocation sourceLocation;
+ private TileLocation destLocation;
+ private Direction directionFromSourceLocation;
+ private Set<TileLocation> locationSet;
+
+ public TileLocationLink(TileLocation sourceLocation,
+ TileLocation destLocation, Direction directionFromSourceLocation) {
+ this.sourceLocation = sourceLocation;
+ this.destLocation = destLocation;
+ this.directionFromSourceLocation = directionFromSourceLocation;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<TileLocation> getLocations() {
+ if (locationSet == null) {
+ locationSet = new HashSet<TileLocation>();
+ locationSet.add(sourceLocation);
+ locationSet.add(destLocation);
+ }
+ return locationSet;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public TileLocation getDestination() {
+ return destLocation;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public TileLocation getSource() {
+ return sourceLocation;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void move(Placeable placeable) throws MoveableException {
+ boolean inSourceLocation = placeable.getCurrentLocation() != null
+ && placeable.getCurrentLocation().equals(sourceLocation);
+ boolean inDestLocation = placeable.getCurrentLocation() != null
+ && placeable.getCurrentLocation().equals(destLocation);
+
+ if (inSourceLocation) {
+ placeable.place(destLocation);
+ } else if (inDestLocation) {
+ placeable.place(sourceLocation);
+ } else {
+ throw new MoveableException("Placeable " + placeable
+ + " is not in source or destination location in link.");
+ }
+ }
+
+}
Property changes on: trunk/mud4j-core/src/java/net/sf/mud4j/world/link/TileLocationLink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/mud4j-core/src/java/net/sf/mud4j/world/link/TwoWayLocationLink.java
===================================================================
--- trunk/mud4j-core/src/java/net/sf/mud4j/world/link/TwoWayLocationLink.java (rev 0)
+++ trunk/mud4j-core/src/java/net/sf/mud4j/world/link/TwoWayLocationLink.java 2007-11-01 00:01:48 UTC (rev 159)
@@ -0,0 +1,17 @@
+package net.sf.mud4j.world.link;
+
+import net.sf.mud4j.world.Location;
+
+/**
+ * Two-way link between a source and destination location. The term of source
+ * and destination is simply used to represent two locations.
+ *
+ * @author Matthew Purland
+ *
+ * @param <T>
+ */
+public interface TwoWayLocationLink<T extends Location> extends LocationLink<T> {
+ T getSource();
+
+ T getDestination();
+}
Property changes on: trunk/mud4j-core/src/java/net/sf/mud4j/world/link/TwoWayLocationLink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|