Class Settings

java.lang.Object
  extended by Settings

public class Settings
extends java.lang.Object

The settings class holds and changes the settings for the games. ----------------------------------------------------------------------- VARIABLE SETTINGS The time variable describes the length of each round in seconds. The rounds variable describes the number of rounds in a game. The players variable describes how many human players are in the game, such that human players + ai players = 4. The controls are initialized in the array such that { up control, down control, left control, right control, fire control } -----------------------------------------------------------------------

Author:
daniel

Field Summary
private  int[] p1Control
           
private  int[] p2Control
           
private  int[] p3Control
           
private  int[] p4Control
           
private  int players
           
private  int rounds
           
private  int time
           
 
Constructor Summary
Settings()
          Creates a default settings object with 5 minutes of time, 3 rounds, and 1 human player.
 
Method Summary
 int[] getP1Control()
          Gets the set of keyboard code assignments for Player 1.
 int[] getP2Control()
          Gets the set of keyboard code assignments for Player 2.
 int[] getP3Control()
          Gets the set of keyboard code assignments for Player 3.
 int[] getP4Control()
          Gets the set of keyboard code assignments for Player 3.
 int getPlayers()
          Gets the number of players.
 int getRounds()
          Gets the number of rounds.
 int getTime()
          Gets the time.
private  boolean isNotTaken(int keyCode)
          Returns true if the given keycode is not already in use by any player.
 boolean setDnControl(int keyCode, int player)
          Sets the dn-command for the Player to the given keyCode, if the keyCode is not already taken.
 boolean setFrControl(int keyCode, int player)
          Sets the fr-command for the Player to the given keyCode, if the keyCode is not already taken.
 boolean setLtControl(int keyCode, int player)
          Sets the lt-command for the Player to the given keyCode, if the keyCode is not already taken.
 void setP1Control(int[] p1Control)
          Assigns Player 1's keyboard controls to the key codes in the given array.
 void setP2Control(int[] p2Control)
          Assigns Player 2's keyboard controls to the key codes in the given array.
 void setP3Control(int[] p3Control)
          Assigns Player 3's keyboard controls to the key codes in the given array.
 void setP4Control(int[] p4Control)
          Assigns Player 4's keyboard controls to the key codes in the given array.
 void setPlayers(int players)
          Sets the number of players.
 void setRounds(int rounds)
          Sets the number of rounds.
 boolean setRtControl(int keyCode, int player)
          Sets the rt-command for the Player to the given keyCode, if the keyCode is not already taken.
 void setTime(int time)
          Sets the time.
 boolean setUpControl(int keyCode, int player)
          Sets the up-command for the Player to the given keyCode, if the keyCode is not already taken.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

time

private int time

rounds

private int rounds

players

private int players

p1Control

private int[] p1Control

p2Control

private int[] p2Control

p3Control

private int[] p3Control

p4Control

private int[] p4Control
Constructor Detail

Settings

public Settings()
Creates a default settings object with 5 minutes of time, 3 rounds, and 1 human player.

Method Detail

setTime

public void setTime(int time)
Sets the time.

Parameters:
time - in seconds

getTime

public int getTime()
Gets the time.

Returns:
time in seconds

setRounds

public void setRounds(int rounds)
Sets the number of rounds.

Parameters:
rounds -

getRounds

public int getRounds()
Gets the number of rounds.

Returns:
rounds

setPlayers

public void setPlayers(int players)
Sets the number of players.

Parameters:
players -

getPlayers

public int getPlayers()
Gets the number of players.

Returns:
number of players

setP1Control

public void setP1Control(int[] p1Control)
Assigns Player 1's keyboard controls to the key codes in the given array.

Parameters:
p1Control - keyboard codes

getP1Control

public int[] getP1Control()
Gets the set of keyboard code assignments for Player 1.

Returns:
key codes for Player 1

setP2Control

public void setP2Control(int[] p2Control)
Assigns Player 2's keyboard controls to the key codes in the given array.

Parameters:
p2Control - keyboard codes

getP2Control

public int[] getP2Control()
Gets the set of keyboard code assignments for Player 2.

Returns:
key codes for Player 2

setP3Control

public void setP3Control(int[] p3Control)
Assigns Player 3's keyboard controls to the key codes in the given array.

Parameters:
p3Control - keyboard codes

getP3Control

public int[] getP3Control()
Gets the set of keyboard code assignments for Player 3.

Returns:
key codes for Player 3

setP4Control

public void setP4Control(int[] p4Control)
Assigns Player 4's keyboard controls to the key codes in the given array.

Parameters:
p4Control - keyboard codes

getP4Control

public int[] getP4Control()
Gets the set of keyboard code assignments for Player 3.

Returns:
key codes for Player 3

isNotTaken

private boolean isNotTaken(int keyCode)
Returns true if the given keycode is not already in use by any player.

Parameters:
keyCode - keyCode to check for
Returns:
true if keyCode is not currently assigned to any player

setUpControl

public boolean setUpControl(int keyCode,
                            int player)
Sets the up-command for the Player to the given keyCode, if the keyCode is not already taken.

Parameters:
keyCode - key code to assign to player's up
player - player whose up is to be changed
Returns:
true if keyCode was assigned, false if not

setDnControl

public boolean setDnControl(int keyCode,
                            int player)
Sets the dn-command for the Player to the given keyCode, if the keyCode is not already taken.

Parameters:
keyCode - key code to assign to player's down
player - player whose down is to be changed
Returns:
true if keyCode was assigned, false if not

setLtControl

public boolean setLtControl(int keyCode,
                            int player)
Sets the lt-command for the Player to the given keyCode, if the keyCode is not already taken.

Parameters:
keyCode - key code to assign to player's left
player - player whose left is to be changed
Returns:
true if keyCode was assigned, false if not

setRtControl

public boolean setRtControl(int keyCode,
                            int player)
Sets the rt-command for the Player to the given keyCode, if the keyCode is not already taken.

Parameters:
keyCode - key code to assign to player's right
player - player whose right is to be changed
Returns:
true if keyCode was assigned, false if not

setFrControl

public boolean setFrControl(int keyCode,
                            int player)
Sets the fr-command for the Player to the given keyCode, if the keyCode is not already taken.

Parameters:
keyCode - key code to assign to player's Fire
player - player whose fire is to be changed
Returns:
true if keyCode was assigned, false if not