Class games.Battle.shared.sys.Common
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class games.Battle.shared.sys.Common

java.lang.Object
   |
   +----games.Battle.shared.sys.Common

public class Common
extends Object
Common is a collection of static functions that perform a packing and unpacking services for both the client and server side.

Constructor Index

 o Common()

Method Index

 o RCtoIndex(int, int)
converts a (row,col) tuple to a unique index in a contiguous array
 o exit(int)
wraps System.exit() to be friendly as a standlaone application and as an applet.
 o extractCount(byte)
extract the run length encoding count from a packed byte.
 o extractOccupancy(byte)
extract the occupancy from a packed byte
 o extractPipes(byte)
extract the pipes froma packed byte.
 o extractTerrain(byte)
extract the terrain fom a packed byte
 o extractTroops(byte)
extract the number of troops from a packed byte
 o getRandomCol()
returns a random column
 o getRandomRow()
returns a random row
 o indexToCol(int)
converts an index to a column
 o indexToRow(int)
converts an index to a row
 o isPlayer(int)
return whether the number representing a cell occupancy is a player (not invisible, not unoccupied and not unchanged)
 o stuffOccupancyAndCount(int, int)
stuffs occupancy and a 4-bit counter int a byte
 o stuffOccupancyAndTerrain(int, int)
stuffs occupancy in bits 7-5, and terrain in bits 4-2
 o stuffOccupancyAndTroops(int, int)
stuffs occupancy and troops
 o stuffPipes(int)
stuffs pipes into hi byte

Constructors

 o Common
  public Common()

Methods

 o isPlayer
  public final static boolean isPlayer(int occupancy)
return whether the number representing a cell occupancy is a player (not invisible, not unoccupied and not unchanged)
Parameters:
occupancy - a particular cell's occupancy
 o extractOccupancy
  public final static int extractOccupancy(byte b)
extract the occupancy from a packed byte
 o extractTerrain
  public final static int extractTerrain(byte b)
extract the terrain fom a packed byte
 o extractTroops
  public final static int extractTroops(byte b)
extract the number of troops from a packed byte
 o extractPipes
  public final static int extractPipes(byte b)
extract the pipes froma packed byte.
 o extractCount
  public final static int extractCount(byte b)
extract the run length encoding count from a packed byte.
 o stuffOccupancyAndTerrain
  public final static byte stuffOccupancyAndTerrain(int o,
                                                    int t)
stuffs occupancy in bits 7-5, and terrain in bits 4-2
 o stuffOccupancyAndCount
  public final static byte stuffOccupancyAndCount(int o,
                                                  int c)
stuffs occupancy and a 4-bit counter int a byte
 o stuffOccupancyAndTroops
  public final static byte stuffOccupancyAndTroops(int o,
                                                   int t)
stuffs occupancy and troops
 o stuffPipes
  public final static byte stuffPipes(int p)
stuffs pipes into hi byte
 o RCtoIndex
  public final static int RCtoIndex(int r,
                                    int c)
converts a (row,col) tuple to a unique index in a contiguous array
 o indexToRow
  public final static int indexToRow(int index)
converts an index to a row
 o indexToCol
  public final static int indexToCol(int index)
converts an index to a column
 o getRandomRow
  public final static int getRandomRow()
returns a random row
 o getRandomCol
  public final static int getRandomCol()
returns a random column
 o exit
  public final static void exit(int code)
wraps System.exit() to be friendly as a standlaone application and as an applet.

All Packages  Class Hierarchy  This Package  Previous  Next  Index