wyvern.kernel.maps
Class PythonMapWriter

java.lang.Object
  extended bywyvern.kernel.maps.MapWriter
      extended bywyvern.kernel.maps.PythonMapWriter

public class PythonMapWriter
extends MapWriter

Writes a map out to a python file.

Version:
1.0, Mar 9, 2001
Author:
Steve Yegge

Field Summary
 
Fields inherited from class wyvern.kernel.maps.MapWriter
cache_, externCache_, filename_, out_, terrainCache_
 
Constructor Summary
PythonMapWriter()
           
 
Method Summary
protected  java.lang.String getPyClassName(java.lang.String filename)
          Returns the name of the python class to use (same as filename).
protected  void printConstructor(GameMap map)
          Prints the __init__ function for the python map.
protected  java.lang.String printMapProperty(java.lang.String name, java.lang.Object value)
          Prints a property of the map.
protected  void printMapProps(GameMap map, java.io.PrintWriter out)
          Generates code that adds the map properties.
 void writeMap(GameMap map, java.lang.String filename)
          Writes a map as python code.
protected  void writeObject(GameObject obj, int x, int y)
          Writes python version of a single object.
protected  void writeRectangle(GameObject obj, int x, int y, int w, int h)
          Writes out a rectangle in the map containing the passed object at every location in the rectangle.
 
Methods inherited from class wyvern.kernel.maps.MapWriter
compareObjects, extendLeftRight, extendUpDown, findClone, getMapClassName, iterateObjects, openFile, overlapping, writeDenseMap, writeLocalArchetypes, writeObject, writeObjectAndNeighbors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PythonMapWriter

public PythonMapWriter()
Method Detail

writeMap

public void writeMap(GameMap map,
                     java.lang.String filename)
              throws java.io.IOException
Writes a map as python code.

Overrides:
writeMap in class MapWriter
Parameters:
map - the map to write
filename - the file to write it to
Throws:
java.io.IOException - if the write fails

getPyClassName

protected java.lang.String getPyClassName(java.lang.String filename)
Returns the name of the python class to use (same as filename).

Parameters:
filename - full path to the file

printConstructor

protected void printConstructor(GameMap map)
Prints the __init__ function for the python map.


printMapProps

protected void printMapProps(GameMap map,
                             java.io.PrintWriter out)
Generates code that adds the map properties.

Overrides:
printMapProps in class MapWriter
Parameters:
map - the map
out - file output stream

printMapProperty

protected java.lang.String printMapProperty(java.lang.String name,
                                            java.lang.Object value)
Prints a property of the map.

Parameters:
name - the property name
value - the property value

writeObject

protected void writeObject(GameObject obj,
                           int x,
                           int y)
Writes python version of a single object.

Overrides:
writeObject in class MapWriter
Parameters:
obj - the object to write into the map
x - the x location for the object
y - the y location for the object

writeRectangle

protected void writeRectangle(GameObject obj,
                              int x,
                              int y,
                              int w,
                              int h)
Writes out a rectangle in the map containing the passed object at every location in the rectangle.

Overrides:
writeRectangle in class MapWriter
Parameters:
obj - the object to write into the map
x - rectangle left
y - rectangle top
w - rectangle width
h - rectangle height