/** Test of package info */ import java.util.*; import java.text.*; /** class Game is the main class */ public class Game { /** One of the five values for a terrain spot in a Location object; unset means it has not yet been given a value */ public static final int TERRAIN_UNSET = 0; /** One of the five values for a terrain spot in a Location object; this indicates the location is a mountain */ public static final int TERRAIN_MOUNTAIN = 1; /** One of the five values for a terrain spot in a Location object; this indicates the location is a forest */ public static final int TERRAIN_FOREST = 2; /** One of the five values for a terrain spot in a Location object; this indicates the location is a grassland */ public static final int TERRAIN_GRASSLAND = 3; /** How many days it takes to move through one square of each terrain type */ public static final double MOVEMENT_COST_MOUNTAIN = 5.0; /** How many days it takes to move through one square of each terrain type */ public static final double MOVEMENT_COST_FOREST = 4.0; /** How many days it takes to move through one square of each terrain type */ public static final double MOVEMENT_COST_GRASSLAND = 2.0; /** The chance (out of 1) that a depot will occur on a given location */ public static final double DEPOT_CHANCE = 0.05; /** The default amount of food that each depot will have */ public static final int DEFAULT_FOOD_AMOUNT = 1000; /** The default amount of oxen that each depot will have */ public static final int DEFAULT_OXEN_AMOUNT = 100; /** The default amount of ammo that each depot will have */ public static final int DEFAULT_AMMO_AMOUNT = 100; /** The amount that food costs (not counting the price factors of depots) */ public static final double DEFAULT_FOOD_COST = 1; /** The amount that oxen costs (not counting the price factors of depots) */ public static final double DEFAULT_OXEN_COST = 10; /** The amount that ammo costs (not counting the price factors of depots) */ public static final double DEFAULT_AMMO_COST = 3; /** The density of forest squares -- the percent (out of 1) of overall squares that will be forests. * Forests and mountains are placed first, then the remaining squares are grassland. */ public static final double DENSITY_FOREST = 0.3; /** The density of mountain squares -- the percent (out of 1) of overall squares that will be mountains. * Forests and mountains are placed first, then the remaining squares are grassland. */ public static final double DENSITY_MOUNTAIN = 0.2; /** The width of the board/map, in columns. */ public static final int BOARD_WIDTH = 10; /** The height of the board/map, in rows. */ public static final int BOARD_HEIGHT = 10; /** The starting row coordinate of the player. It will automatically have a depot. */ public static final int START_ROW_COORD = BOARD_WIDTH-1; /** The starting column coordinate of the player. It will automatically have a depot. */ public static final int START_COL_COORD = BOARD_HEIGHT-1; /** The ending column coordinate for the game. */ public static final int FINISH_ROW_COORD = 0; /** The ending row coordinate for the game. */ public static final int FINISH_COL_COORD = 0; /** The value returned by Parser.getMoveDirection() when the player chooses to move north. */ public static final int MOVE_NORTH = 1; /** The value returned by Parser.getMoveDirection() when the player chooses to move south. */ public static final int MOVE_SOUTH = 2; /** The value returned by Parser.getMoveDirection() when the player chooses to move east. */ public static final int MOVE_EAST = 3; /** The value returned by Parser.getMoveDirection() when the player chooses to move west. */ public static final int MOVE_WEST = 4; /** The amount of money that the player starts with. */ public static final double STARTING_MONEY = 1000; /** The number of squares, in each direction, that the player can see the terrain type (and depot status) of. */ public static final int DEFAULT_VISIBILITY = 2; /** The party size, counting the leader. */ public static final int DEFAULT_PARTY_SIZE = 5; /** A constant to modify the price factor of depots. * This is computed by dividing the distance from the starting location to the depot, and then dividing by this amount. */ public static final double PRICE_FACTOR_MODIFIER = 10.0; /** The maximum (and starting) health of the people in the party. */ public static final int MAX_HEALTH = 10; /** The amount of health points recovered for each day of rest. */ public static final int REST_HEALTH_RATE = 1; /** The chance (out of 1) that a health 'problem' will occur on a given turn. */ public static final double HEALTH_PROBLEM_CHANCE = 0.5; /** A constant to determine how fast one can travel with oxen. * With 1/OXEN_SPEEND_FACTOR oxen, it will take as many days to move through a terrain type as the MOVEMENT_COST_* constant. */ public static final double OXEN_SPEED_FACTOR = 0.25; /** How many pounds of food each person consumes per day. */ public static final int FOOD_CONSUMPTION_RATE = 2; /** The amount of health points lost when there is not enough food. */ public static final int STARVATION_HEALTH_COST = 2; /** The number of units between successive squares. */ public static final int DISTANCE_BETWEEN_SQUARES = 20; /** The particular unit (miles, kilometers, parsecs, etc.) that the DISTANCE_BETWEEN_SQUARES is stated in. */ public static final String DISTANCE_UNIT = "miles"; /** The time unit (days, hours, etc.) -- how long travel takes is stated in this unit. */ public static final String TIME_UNIT = "days"; /** The main Map object that the game uses */ public static Map map = null; /** The main Vehicle object that represents the player */ public static Vehicle player = null; /** A random number generator, it's purpose here is to ensure that there is only one Random object declared in the game */ public static final Random random = new Random(); /** We mixed up whether to call it rand or random, so there are two references to the same object */ public static final Random rand = random; /** Holds whether or not cheat mode has been enabled */ public static boolean cheatModeEnabled = false; /** A general purpose number formatter */ public static NumberFormat style = NumberFormat.getNumberInstance(); public static void main (String args[]) { // sets the maximum decimal places for numbers to 2 style.setMaximumFractionDigits(2); style.setMinimumFractionDigits(2); System.out.println ("Welcome to the game!\n"); map = new Map(); map.populate(); MapPrinter.printMap(); player = new Vehicle(DEFAULT_PARTY_SIZE); player.setLocation(map.getLocationAt(START_ROW_COORD,START_COL_COORD)); Control.takeTurn(); } }