This is an overview of the jfreerails source code.

See:
          Description

Packages
experimental Provides a space to put classes that try out concepts and ideas but are not part of the game - classes in other jfreerails packages should not import classes from this package.
jfreerails.client.common Provides classes that are used by the jfreerails client but are not jfreerails specific, that is, ones that could be used in another project: classes in this package should not import any classes from other jfreerails.* packages except jfreerails.util.
jfreerails.client.renderer Provides classes that render/paint/draw the games graphics.
jfreerails.client.top Provides classes that make up the client user interface (implemented using Swing).
jfreerails.client.view Provides classes that make up the jfreerails client user interface that is implemented using Swing components.
jfreerails.controller Provides classes that may be used by the client or the server to operate on the game world, for example, building trains and stations.
jfreerails.launcher Provides the classes the make up the launcher.
jfreerails.move Provides classes that encapsulate changes to the game world.
jfreerails.network Provides classes for sending moves and commands between the client and server.
jfreerails.server Provides classes that will be used by the server but not the client.
jfreerails.server.common Provides classes and interfaces that might be used by the jfreerails.server package as well as some of the other jfreerails.server.* packages.
jfreerails.server.parser Provides classes that parse the xml that defines the cargo types, terrain types etc.
jfreerails.util Provides classes that are used by both the client and the server that are not jfreerails specific, that is, ones that could be used in another project.
jfreerails.world The jfreerails.world.* packages provide the classes that make up the game-world, the classes in these packages will be used by the client and the server.
jfreerails.world.accounts Provides classes to record a players assets (for example, real estate, miles-of-track, cash, and shares) and liabilities (for example, outstanding shares and bonds, and any overdraft).
jfreerails.world.cargo Provides classes that represent the cargo carried by trains.
jfreerails.world.common Provides a space to put classes that can be imported by classes in any of the other jfreerails.world packages.
jfreerails.world.player  
jfreerails.world.station Provides classes that represent stations and their properties, such as station improvements and supply and demand for different cargos.
jfreerails.world.terrain Provides classes that represent terrain and its properties such as right-of-way cost and supply and demand for cargo.
jfreerails.world.top Provides a space to put classes that depend on classes from several other jfreerails.world packages.
jfreerails.world.track Provides classes that represent track and its properties.
jfreerails.world.train Provides classes that represent trains and their properties including train movements.

 

This is an overview of the jfreerails source code.

Other documents

  1. Functional Specification (PDF)
  2. Coding guidelines
  3. People
  4. Key Map

Brief overview of the architecture

  1. The model and the view are separated. The classes that make up the model, referred to as the game world, are in the jfreerails.world.* packages. The view classes are in the jfreerails.client.* packages.
  2. The state of game world is stored by an instance of a class implementing the interface World. This class is mutable - one can think of it as a specialised hashmap. All the objects that represent entities in the world - values in the hashmap - are immutable. It follows that changes to the gameworld involve adding, removing or replacing objects representing entities rather than changing their properties.
  3. The client and server are separate. They communciate by sending objects to each other. This is done either by placing objects on a queue or by sending serialized objects over a network connection. All objects passed between the client and server are immutable and are instances of one of the following:
  4. When a new game starts or a game is loaded, the server sends the client a copy of the World object (using an instance of SetWorldMessage2Client) All changes to the game world that occur after the game has started, referred to as moves, are done using the classes in the package jfreerails.move. Moves are either obtained from a PreMove object or constructed directly.

Dependencies between packages

To keep the code managable, there are rules governing which packages each package may import classes from. The details are here.