Skip to content

An open implementation of Settlers of Catan, a fork of sourceforge.net/projects/jsettlers2 which is a fork of sourceforge.net/projects/jsettlers, the PhD thesis of Robert Thomas.

License

nsp/OpenSettlers

Repository files navigation

README.developer - Notes and current status of 2010 OpenSettlers development
    http://github.com/nsp/OpenSettlers

The main server class is soc.server.SOCServer.
The client communication is soc.client.PlayerClient, and in-game interface is in soc.client.PlayerInterface.
Game state is held at the server in soc.game.Game and its fields.  Partial game state is known at clients.
Communication is described in soc.message.Message.
Robots talk with the server like normal human clients.
Most robot messages are per-game; instead of being handled in RobotClient,
these are handled in a loop in RobotBrain.run().

Coding is done in Java 1.6
The build system is Ant, which is natively understood by Eclipse.  Use any IDE you want, including vi.
Use spaces, not tabs.  Please try to keep the other conventions of the code already there.
(See "Coding Style" below for more details.)
When adding new methods or fields, describe them in javadoc and the one-sentence summary (even though some old methods don't have that summary).

See VERSIONS.txt for recent changes.

For debugging, if you want to inspect the game state at the server or robot:
    Set a breakpoint at SOCServer.processDebugCommand, or at "case SOCMessage.GAMETEXTMSG"
      send a text msg from a client (the chat textfield), and inspect the game obj at that point
    To inspect game state at robot, breakpoint robotcli.treat and send a text msg like *BOTLIST* or robot2:current-plans

The rotated 3:1 port hexes' font is Optima Bold, 21 pt.


Coding Style
------------
This is the project's coding style, based on the original authors' style.
Although we may not agree with every detail of it, for consistency's sake,
please keep the conventions of the code that's already there.

Use spaces, not tabs.  The basic indent is 4.  Place braces on their own line.

Use 1 blank line between methods.  If you have nested classes, use 3 blank 
lines between them, and comment each one's closing brace with the class name.
If you have a long method whose work can be divided into "sections",
preface each section with a /** javadoc-style */ multi-line comment.

In emacs, you can place this in your .emacs file to use spaces instead of tabs:
(setq-default c-basic-offset 4)
(setq indent-tabs-mode nil)
    [ courtesy http://www.jwz.org/doc/tabs-vs-spaces.html, which also mentions vi ]
You will also want this to have this, which disables auto-reindenting:
(setq-default c-electric-flag nil)


In eclipse, here's how to set up the coding style:

    window -> preferences -> general -> editors -> text editors:
    [x] insert spaces for tabs
    displayed tab width: 8

    window -> preferences -> java -> code style -> formatter -> Click "Configure Project Specific Settings"
    {
        based on Eclipse built-in standard

        Profile name: 'osettlers' (apply)

        (Indentation)
        Tab policy: Spaces only
        Indentation: 4
        Tab size: 4
        confirm is unchecked under Indent: [ ] empty lines

        (Braces)
        All 'next line' except:
        Blocks in case statement: Next line indented
        Array init: Next line indented
        [X] Keep empty array initializer on one line

        (Control Statements)
        [X] New line before else in if
        [X] New line before catch in try
        [X] New line before finally in try
        [ ] New line before while in do
        [X] Keep 'else if' on one line
        [ ] (all other options)

        (All other tabs)
        Take defaults

    }

    Hit OK
    Make sure the formatter "active profile" is jsettlers
    restart eclipse

    go to prefs -> java -> code style -> formatter
      if it's not active: set active profile to jsettlers & restart eclipse

    window -> preferences -> java -> editor -> typing
        Verify tab 8 spaces, indent 4 spaces:
   [x] Tab key adjusts indentation of current line
   "The tab display value (currently 8) and whether spaces are used to indent lines
    are configured on the formatter preference page.  The current indentation size
    is 4, using spaces."

When you hit enter and insert a new line in Eclipse, watch the whitespace, it
will add whitespace to the blank line to match the current indent.

If desired, in Eclipse preferences, you can bind a key combination to Remove Trailing Whitespace.
This will trim it from the entire file when the key is pressed.

About

An open implementation of Settlers of Catan, a fork of sourceforge.net/projects/jsettlers2 which is a fork of sourceforge.net/projects/jsettlers, the PhD thesis of Robert Thomas.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages