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