shoddybattle
Class UpgradeModFile

java.lang.Object
  extended by shoddybattle.UpgradeModFile

public class UpgradeModFile
extends java.lang.Object

This class upgrades a mod file written for the NetBattle program to one usable with Shoddy Battle. The class does not perform any sophisticated redundancy eliminations.

The class is directly executable in the following manner:

java -cp dist/ShoddyBattle.jar shoddybattle.UpgradeModFile SPECIES [FILE [DEST]]

where SPECIES is a species database, FILE is the file to upgrade, and DEST is the output file name. If the destination file is omitted then the program writes to the standard output. If both the destination and the file are omitted then the program reads from the standard input as well as writing to the standard output. Error messages are always written to the standard error stream.

Note that the class depends on the species file in order to load the pokemon database. This database is required because the NetBattle syntax for abilities requires knowledge of the original abilities. Therefore a species database (e.g. dpspecies.db) must be available in order to use this class.

Note also that abilities will probably not be converted correctly because NetBattle's syntax assumes that they are listed in a particular order in the database. It is likely that for many pokemon this order will not be the same in Shoddy Battle. Adding a second ability to a pokemon that had only one was the most common use of NetBattle's ability feature and a statement doing that will upgrade correctly. Statements changing abilities may not work as expected, however.

See Also:
ModData

Constructor Summary
UpgradeModFile(PokemonSpeciesData data, java.io.InputStreamReader stream)
          Read a NetBattle mod file and build an internal representation of it.
 
Method Summary
 void handleLine(PokemonSpeciesData data, java.lang.String line)
          Handle a line from the NetBattle mod file.
static void main(java.lang.String[] args)
          Upgrade a NetBattle mod file to a Shoddy Battle patch file.
 void saveFile(java.io.OutputStreamWriter stream)
          Save the mod file to disc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UpgradeModFile

public UpgradeModFile(PokemonSpeciesData data,
                      java.io.InputStreamReader stream)
               throws java.io.FileNotFoundException,
                      java.io.IOException
Read a NetBattle mod file and build an internal representation of it.

Parameters:
data - species database (used for abilities)
stream - the stream to read from
Throws:
java.io.FileNotFoundException - if the file does not exist
java.io.IOException - if an error occurs while reading from the file
Method Detail

main

public static void main(java.lang.String[] args)
Upgrade a NetBattle mod file to a Shoddy Battle patch file. See class description for an overview of the parameters.

Parameters:
args - arguments passed on the command line

saveFile

public void saveFile(java.io.OutputStreamWriter stream)
              throws java.io.IOException
Save the mod file to disc.

Parameters:
stream - stream to save to
Throws:
java.io.IOException - if an error occurred while writing to the stream

handleLine

public void handleLine(PokemonSpeciesData data,
                       java.lang.String line)

Handle a line from the NetBattle mod file.

The syntax for a valid line is as follows:

Class, Pokemon, Argument 1 [, Argument 2, ...]

where Class is one of

Note that the "slot number" required for the Trait statement class is arbitrary. Shoddy Battle's database does not duplicate the database of NetBattle exactly so the meaning of all Trait statements will not be the same as it was in NetBattle. This is unlikely to have a significant effect on most mod files. In particular, if a pokemon normally has only one ability, or if both abilitiy slots are set, then statements of the Trait class are guaranteed to do the same thing they did in NetBattle.

Parameters:
data - species data to get abilities from
line - line to handle