Java Programming Project; Political Rumble, A Client/Server Game
Descrição do Produto
POLITICAL RUMBLE, A JAVA CLIENT/SERVER APPLICATION 101
Running head: POLITICAL RUMBLE, A JAVA CLIENT/SERVER APPLICATION 1
POLITICAL RUMBLE, A JAVA CLIENT/SERVER APPLICATION 2
Political Rumble, A Java Client/Server Application
Daniel J. LeBlanc, James Hamidou, Mark Brazinski, John Hanna
National University
Software Architecture Application
SEN632
Walter Wesley, PhD
November 23, 2014
Table of Contents
Table of Contents
Project Requirements 4
Deliverables: 6
readme.txt 7
About Game Play 8
Extra Credit Features 9
To Start the Game 10
Importing a Project To NetBeans 11
How we met the Operation Requirements 13
Java Server Code 18
Java Client Code 56
Source Files 74
UML Diagrams 77
Application Screenshots 85
Political Rumble, A Java Client/Server Application
Project Requirements
This assignment involved the development and production of a Java-based, Client/Server combat-style game for multiple players in a threaded environment. The virtual server acts as a moderator, connecting a minimum of two players in a combat-style environment. All of the I/O functions are carried out by the server and the data is passed to the clients as needed for game play. The project deliverables are as follows;
Operational Requirements:
1 Role of the Combat Moderator server application: The Combat Moderator shall wait and listen for Warriors to request to register and engage in combat. The Combat Moderator subsequently manages the combat operation exchanges between the various Warriors currently within the battlefield.
2 Role of the Warrior client: The Warrior client application registers itself with the Combat Moderator (which it identifies via an IP address provided by the user). The Warrior client displays the current status of its attributes to the user. The Warrior client enables the user to specify a target Warrior and combat operation to be directed at that target Warrior.
3 Warrior Object Creation: A Warrior shall be created and initialized from an associated data file within the current working directory. Warrior files shall be designated by an extension of ".wdat". The filename (text before the extension) shall used as the name of the Warrior. The file itself shall contain a set of data fields. At a minimum, the data fields supplied shall be the health-level, place of origin, and personal description of the Warrior. the health-level, which is an integer value from 0 to 100, inclusive (a value of 100 denotes a fully healthy Warrior, and a value of 0 denotes a dead Warrior). When a Warrior object is created, the user shall be given the opportunity to select the file he/she wishes to open. The selected file shall be opened and read via an input stream. The data shall be parsed and used to initialize the data fields of the Warrior object.
4 Registration Protocol: Upon establishing a socket connection with a Warrior Combatant, the Warrior Combatant shall provide name and health-level information to the Combat Moderator. The Combat Moderator shall then welcome the Warrior by name to the field of battle, and shall provide the Warrior with a series of names and associated health-levels, places of origin, descriptions, etc. of Warriors who are currently present in the field of battle.
5 Battle Protocol:
5.1 The user who has created a Warrior shall be able to select and thereby challenge another Warrior. The user shall also be able to select one of at least three possible combat operations, i.e. attacks or defenses. You may decide what sorts of attacks or defenses you will support. Examples of attacks and defenses are: slash, stab, parry, block, sidestep, laser, particle beam, rail-gun, shield, temporary de-materialization, etc.. You may create attacks and defenses of your own.
5.2 Upon completion of a combat operation by an attacking Warrior, the designated attack or defense and the name of the target Warrior shall be passed along to the Combat Moderator. The Combat Moderator shall then notify the target Warrior that he/she is being engaged in conflict. The user in control of the target Warrior shall be able to select one of the possible combat operations (as stipulated above, c.f. 4.1).
5.3 Upon completion of a combat operation by a Warrior that is being attacked, the designated attack or defense and the name of the target Warrior shall be passed along to the Combat Moderator.
5.4 Upon receipt of the combat operation response from a Warrior that is being attacked, the Combat Moderator shall perform the necessary logic to determine whether and by how much the health-levels of the battling Warriors is to be changed. The Combat Moderator shall then enforce the determined changes upon the battling Warriors.
5.5 If the Warrior's health-level changes such that it is less than or equal to zero, then the Warrior will notify the Combat Moderator that it is at the point of death, whereupon the Warrior and the Combat Moderator will close the socket, and the Warrior client will exit. Note that the responsibility for declaring point of death is with the Warrior, not the Combat Moderator. This allows the software to be extended, by subclassing and polymorphic, method overriding such that Zombie Warriors can be allowed to participate. Zombie Warriors are not required, however.
5.6 When a Warrior object is destroyed, either because it has reached a point of death or because the Warrior client application has exited, the Warrior state information (i.e. field values) will be written out to its associated file.
Deliverables:
1. A UML diagram of the system.
2. A sequence diagram of the Battle Protocol.
3. All source code files (.class files), and compiled files (.class files).
4. At least two sample ".wdat" files.
5. Screenshots of the client and server applications in operation.
6. Since there may be significant differences from one implementation to another, please provide a readme.txt file that lists the other member(s) of your team, and explains how to launch the server and client applications.
7. If you add extra features, please explain those as well. Note that any extra feature shall add, not detract from the other requirements or features.
readme.txt
The Envisage Team consists of 4 members; Daniel LeBlanc, James Hamidou, Mark Brazinski and John Hanna.
About the resource files: There are 3 .wdat resource files that must be installed with the server.java file in order for the application to run. The .wdat resource files are as follows;
1. characters.wdat - Contains the data for the possible game characters
2. smear.wdat - Contains the data for the possible smear campaigns
3. tvads.wdat - Contains the data for the possible television ad campaigns
The server, during game play, creates it's own .wdat files called; player1.wdat and player2.wdat where the chosen character data is stored. These files will be created automatically by the server so there is no need to install these.
The client, during game play, creates it's own .wdat files called; player1.wdat and player2.wdat. Because the server .wdat files are different than the client version it is important that the client is installed in a separate directory structure than the server. This necessitates creating two separate packages; one for the server and one for the client.
About Game Play
When both players are connected and have chosen a character, player 1 is prompted to make the first combat attack and is presented with the "Combat Menu". A player can select one of the combat approaches from the list of 4 possible combat functions. A submenu under each of the combat functions presents the player with a list of possible attacks to send to player 2. These submenu attack possibilities are tailored to whichever character a players opponent has chosen. If a player enters one of these submenus and decides they want to try a different type of attack then they can simply enter BACK or back at the 'Enter Selection' field and return to the initial Combat Menu. Similarly, if a player wishes to end the game before the energy is depleted for either players then they can simply enter END or end in the 'Enter Selection' field to end the game. After an attack is sent, both players are alerted to the end results of the campaign and control is switch to the defending player; the attacking player is told to wait while it is the other players turn. Game play continues back and forth with each player getting a turn in order until one or both of the players runs out of energy. The game can end with a winner and a loser or in a tie if both players run out of energy in the same play.
Extra Credit Features
1. There are 4 combat functions in the 'Combat Menu' as opposed to the required 3.
2. Warriors can taunt one another.
3. A 'BACK' function was implemented to allow a player to return to an upper menu.
4. An 'END' function was implemented to allow a player to end the game early.
5. The application implements 3 resource files and creates resource files on it's own.
6. Attacks are tailored to whatever character the opponent has chosen for game play.
How to Load the Files in Eclipse.
1. Create a new java project called "PoliticianRumble".
2. Create a new package under the PoliticianRumble project called "politicianrumbletestclient".
3. Create a second package called "politicianrumbletestserver".
4. Right click on the politicianrumbletestclient and select "import".
5. Select "File System" and browse to the location of the PoliticianRumbleTestClient.java file and select to import the file.
6. Right click on the politicianrumbletestserver and select "import"
7. Select "File System" and browse to the location of the PoliticianRumbleTestServer.java file and select to import the file.
8. Right click on the PoliticianRumble project folder and select "import".
9. Select "File System" and browse to the location of the "Characters.wdat; smear.wdat; and tvads.wdat" files and select to import the files.
10. Note: If you are using Windows you will need to go to open the PoliticianRumbleTestClient and either delete or comment out (Placing // before) the import command:
"import static sun.lwawt.macosx.CWrapper.NSView.frame;"
To Start the Game
1. Right click on the PoliticianRumbleTestServer.java file and select "Run-as"
a. In the console screen you should see:
i. "Politician Rumble Server is Running"
b. At this point the Server is running and waiting for clients.
2. Right click on the PoliticianRumbleTestClient.java file and select "Run-as).
3. The client GUI will appear, you may need to accept the security warning depending on your security. Select a character for player 1 before launching the second client.
4. Repeat step two to create a second player.
NOTE: It is important that the first player chooses a character before the second player connects. If the second player connects before the first player has chosen a character then they will be presented with a blank GUI until the first player has completed character selection. A fully multi-threaded version would eliminate this issue but at this time, although the application is threaded, the first player must connect and chose a character before the second player connects.
Importing a Project To NetBeans
This section shows you how to handle the initial importing of projects into the IDE.
Importing an Eclipse Workspace Into NetBeans
For Eclipse projects, you can use the Import Eclipse Project wizard to help you create NetBeans projects from projects in an Eclipse workspace and import the project classpaths and other settings. When you use the Import Eclipse Project wizard, you do not need to use create and configure the NetBeans project manually. Open the wizard by choosing File > Import Project > Eclipse Project. See Importing Eclipse Projects into NetBeans IDE for information on how the wizard works and how you can work simultaneously in Eclipse and NetBeans projects.
Setting Up a Java Project Based on Existing Sources in NetBeans
For other Java projects developed outside of NetBeans, you use an "Existing Sources" template in the New Project wizard to make a NetBeans project. In the wizard, you identify the location of the sources and specify a location for the NetBeans project metadata. You then use the Project Properties dialog box to configure the project.
To set up a NetBeans project for an existing Java application:
Choose File > New Project (Ctrl-Shift-N on Windows/Cmd-Shift-N on OS X).
Choose Java > Java Project with Existing Sources. Click Next.
In the Name and Location page of the wizard, follow these steps:
Type a project name.
(Optional) Change the location of the project folder.
(Optional) Change the name of the build script used by the IDE. This might be desirable if there is already a build script called build.xml that is used to build the sources.
(Optional) Select the Use Dedicated Folder for Storing Libraries checkbox and specify the location for the libraries folder. See Sharing Project Libraries for more information on this option.
(Optional) Select the Set as Main Project checkbox. When you select this option, keyboard shortcuts for commands such as Clean and Build Main Project (Shift-F11) apply to this project.
Click Next to advance to the Existing Sources page of the wizard.
In the Source Packages Folder pane, click Add Folder. Then navigate to your sources and select the source roots, click Open.
When you add a folder containing source code, you must add the folder that contains the highest folder in your package tree. For example, for the com.mycompany.myapp.ui package, you add the folder that contains the com folder.
(Optional) In the Test Package Folders pane, click Add Folder to select the folder containing the JUnit package folders.
Click Next to advance to the Includes & Excludes page of the wizard.
(Optional) In the Includes & Excludes page of the wizard, enter file name patterns for any files that should be included or excluded from the project. By default, all files in your source roots are included.
Click Finish.
How we met the Operation Requirements
Operational Requirements:
1 Role of the Combat Moderator server application: The Combat Moderator shall wait and listen for Warriors to request to register and engage in combat. The Combat Moderator subsequently manages the combat operation exchanges between the various Warriors currently within the battlefield.
*** A separate server and client application were implemented;
PoliticianRumbleTestServer
PoliticianRumbleTestClient
2 Role of the Warrior client: The Warrior client application registers itself with the Combat Moderator (which it identifies via an IP address provided by the user). The Warrior client displays the current status of its attributes to the user. The Warrior client enables the user to specify a target Warrior and combat operation to be directed at that target Warrior.
*** As soon as the client is launched it connects to the server and is presented with a list of possible characters from the server. After the player selects a character they are
prompted to wait for an opponent to connect to the server. Once an opponent
connects to the server and selects a character for game play, player 1 is notified of
their own identity as well as the opponents character identity.
3 Warrior Object Creation: A Warrior shall be created and initialized from an associated data file within the current working directory. Warrior files shall be designated by an extension of ".wdat". The filename (text before the extension) shall used as the name of the Warrior. The file itself shall contain a set of data fields. At a minimum, the data fields supplied shall be the health-level, place of origin, and personal description of the Warrior. the health-level, which is an integer value from 0 to 100, inclusive (a value of 100 denotes a fully healthy Warrior, and a value of 0 denotes a dead Warrior). When a Warrior object is created, the user shall be given the opportunity to select the file he/she wishes to open. The selected file shall be opened and read via an input stream. The data shall be parsed and used to initialize the data fields of the Warrior object.
*** Once connected to the server a client is presented with the list of possible characters
from the servers .wdat file. Future enhancements can include additional
characters for game play which would be included in this file.
4 Registration Protocol: Upon establishing a socket connection with a Warrior Combatant, the Warrior Combatant shall provide name and health-level information to the Combat Moderator. The Combat Moderator shall then welcome the Warrior by name to the field of battle, and shall provide the Warrior with a series of names and associated health-levels, places of origin, descriptions, etc. of Warriors who are currently present in the field of battle.
*** As per the operational requirements, our project is for two players. With time constraints and the skill level of our team members, it was not possible to implement a fully multi-threaded design, although our design does implement threading for two players.
5 Battle Protocol:
5.1 The user who has created a Warrior shall be able to select and thereby challenge another Warrior. The user shall also be able to select one of at least three possible combat operations, i.e. attacks or defenses. You may decide what sorts of attacks or defenses you will support. Examples of attacks and defenses are: slash, stab, parry, block, sidestep, laser, particle beam, rail-gun, shield, temporary de-materialization, etc.. You may create attacks and defenses of your own.
*** Our server sends a 'Combat Menu' to each player when it is their turn at game play.
The combat functions are as follows;
1. Taunt your opponent
2. Launch a smear campaign against your opponent
3. Run a television ad berating your opponent
4. Host a political fund raising event
5.2 Upon completion of a combat operation by an attacking Warrior, the designated attack or defense and the name of the target Warrior shall be passed along to the Combat Moderator. The Combat Moderator shall then notify the target Warrior that he/she is being engaged in conflict. The user in control of the target Warrior shall be able to select one of the possible combat operations (as stipulated above, c.f. 4.1).
*** A player is notified of an attack.
5.3 Upon completion of a combat operation by a Warrior that is being attacked, the designated attack or defense and the name of the target Warrior shall be passed along to the Combat Moderator.
*** A player notifies the server of an attack.
5.4 Upon receipt of the combat operation response from a Warrior that is being attacked, the Combat Moderator shall perform the necessary logic to determine whether and by how much the health-levels of the battling Warriors is to be changed. The Combat Moderator shall then enforce the determined changes upon the battling Warriors.
*** The server performs the logic to determine the results of the attack.
5.5 If the Warrior's health-level changes such that it is less than or equal to zero, then the Warrior will notify the Combat Moderator that it is at the point of death, whereupon the Warrior and the Combat Moderator will close the socket, and the Warrior client will exit. Note that the responsibility for declaring point of death is with the Warrior, not the Combat Moderator. This allows the software to be extended, by subclassing and polymorphic, method overriding such that Zombie Warriors can be allowed to participate. Zombie Warriors are not required, however.
*** Both the player and the server monitor the energy level and depending on the point at which a players energy drops to or below 0, the players are notified that the game has ended.
5.6 When a Warrior object is destroyed, either because it has reached a point of death or because the Warrior client application has exited, the Warrior state information (i.e. field values) will be written out to its associated file.
*** At each stage of the game, including the ending, warrior state is written out to .wdat files at both the server and the client end. These warrior state files are called player1.wdat and player2.wdat, respectively. The server maintains both of these files at it's end.
Java Server Code
/**********************************************************************************
**********************************************************************************
**** Programmer: Daniel LeBlanc, James Hamidou, Mark Brazinski, John Hanna *****
**** Assignment: SEN632 Final Project SERVER Test *****
**** Company Name: Envisage *****
**** Political Rumble Server Test v015 *****
**** Created: November 02, 2014 *****
**** Compiler Used: Eclipse *****
**********************************************************************************
**********************************************************************************/
package politicianrumbletestserver;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Formatter;
import java.util.Random;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
/**************************************************************************
**************************************************************************
***** PROJECT DESCRIPTION *****
***** *****
***** Implement a multiplayer, network-based, Warrior-Combat *****
***** game. The architecture shall make use of a client-server *****
***** model, with the server being the combat moderator, and *****
***** the various clients being the warrior combatants. *****
**************************************************************************
**************************************************************************/
public class PoliticianRumbleTestServer
{//Start class PoliticianRumbleTestServer
public static int gameState = 0;
public static String player1CharacterNum;
public static String player2CharacterNum;
public static String player1CharacterName;
public static String player2CharacterName;
public static int player1Energy = 100;
public static int player2Energy = 100;
public static String taunt1 = "";
public static String taunt2 = "";
public static String smear1 = "";
public static String smear2 = "";
public static String smear3 = "";
public static String tvad1 = "";
public static String tvad2 = "";
public static String tvad3 = "";
public static String tvad4 = "";
public static String tvad5 = "";
public static String tvad6 = "";
public static Random randomNumbers = new Random();
public static boolean messageQue = false;
public static String messageHeader = "";
public static String message = "";
public static String messageCost = "";
/**
* Runs the application. Pairs up clients that connect.
*/
/**
* @param args the command line arguments
* @throws java.lang.Exception
*/
public static void main(String[] args)
throws Exception
{ // Begin PoliticianRumbleTestServer Main
ServerSocket listener = new ServerSocket(8901);
System.out.println("Politician Rumble Server is Running");
try {
while (true) {
Game game = new Game();
Game.Player player1 = game.new Player(listener.accept(), '1');
Game.Player player2 = game.new Player(listener.accept(), '2');
player1.setOpponent(player2);
player2.setOpponent(player1);
game.currentPlayer = player1;
player1.start();
System.out.println("Player1 Started");
player2.start();
System.out.println("Player2 Started");
}
} finally {
listener.close();
}
} // End PoliticianRumbleTestServer Main
}
/**
* A two-player game.
*/
class Game {
/**
** Each Player begins the game with 100 points of energy.
** The object of the game is to force the opponent to go broke.
**/
/**
* The current player.
*/
Player currentPlayer;
/**
* Returns whether the current state of the game is such that one
* of the players is a winner.
*/
public boolean hasWinner() {
return
(PoliticianRumbleTestServer.player1Energy = 0) {
return false;
}
return true;
}
/**
* Called by the player threads when a player tries to make a
* move. This method checks to see if the move is legal. If the move is legal the game state is updated
* (the square is set and the next player becomes current) and
* the other player is notified of the move so it can update its
* client.
*/
public synchronized boolean legalMove(int location, Player player) {
if (player == currentPlayer) {
//board[location] = currentPlayer;
currentPlayer = currentPlayer.opponent;
currentPlayer.otherPlayerMoved(location);
return true;
}
return false;
}
/**
* The class for the helper threads in this multithreaded server
* application. A Player is identified by a character mark
* which is either '1' or '2'. For communication with the
* client the player has a socket with its input and output
* streams. Since only text is being communicated we use a
* reader and a writer.
*/
class Player extends Thread {
public ArrayList characterList = new ArrayList(30);
public ArrayList smearList = new ArrayList(30);
public ArrayList tvadsList = new ArrayList(30);
char mark;
Player opponent;
Socket socket;
BufferedReader input;
PrintWriter output;
public Formatter fileOut;
public Scanner fileIn;
/**
* Constructs a handler thread for a given socket and mark
* initializes the stream fields, displays the first two
* welcoming messages.
*/
public Player(Socket socket, char mark) {
this.socket = socket;
this.mark = mark;
try {//Start Try Block for Welcome and Character Selection Routine
input = new BufferedReader(
new InputStreamReader(socket.getInputStream()));
output = new PrintWriter(socket.getOutputStream(), true);
output.println("WELCOME " + mark);
System.out.println("SENT WELCOME: " + mark);
output.println("MESSAGE Waiting for opponent to connect");
System.out.println("SENT MESSAGE: Waiting for opponent to connect");
System.out.println("gameState = " + PoliticianRumbleTestServer.gameState);
//Character Selection Routine
FileInputStream input2 = new FileInputStream("characters.wdat");
BufferedReader br = new BufferedReader(new InputStreamReader(input2));
String strLine;
while((strLine = br.readLine()) !=null)
{
characterList.add(strLine);
}input2.close();
System.out.println(characterList);
output.println("CHARACTERS " + characterList);
//Wait for character selection
String command = input.readLine();
if (command.startsWith("CHARACTER")){// Start if (command.startsWith("CHARACTER"))
System.out.println("Character selected: " + command.substring(9));
//Set Player1 Chosen Character Number and Character Name
if (PoliticianRumbleTestServer.gameState == 0)
{// Start if (PoliticianRumbleTestServer.gameState == 0)
PoliticianRumbleTestServer.player1CharacterNum = command.substring(9);
System.out.println("player1Character = " + PoliticianRumbleTestServer.player1CharacterNum);
if ("1".equals(PoliticianRumbleTestServer.player1CharacterNum))
{//Start if ("1".equals(PoliticianRumbleTestServer.player1CharacterNum))
PoliticianRumbleTestServer.player1CharacterName = characterList.get(0);
System.out.println("player1CharacterName = " + PoliticianRumbleTestServer.player1CharacterName);
}//End if ("1".equals(PoliticianRumbleTestServer.player1CharacterNum))
else if ("2".equals(PoliticianRumbleTestServer.player1CharacterNum))
{//Start if ("2".equals(PoliticianRumbleTestServer.player1CharacterNum))
PoliticianRumbleTestServer.player1CharacterName = characterList.get(3);
System.out.println("player1CharacterName = " + PoliticianRumbleTestServer.player1CharacterName);
}//End if ("2".equals(PoliticianRumbleTestServer.player1CharacterNum))
else if ("3".equals(PoliticianRumbleTestServer.player1CharacterNum))
{//Start if ("3".equals(PoliticianRumbleTestServer.player1CharacterNum))
PoliticianRumbleTestServer.player1CharacterName = characterList.get(6);
System.out.println("player1CharacterName = " + PoliticianRumbleTestServer.player1CharacterName);
}//End if ("3".equals(PoliticianRumbleTestServer.player1CharacterNum))
else if ("4".equals(PoliticianRumbleTestServer.player1CharacterNum))
{//Start if ("4".equals(PoliticianRumbleTestServer.player1CharacterNum))
PoliticianRumbleTestServer.player1CharacterName = characterList.get(9);
System.out.println("player1CharacterName = " + PoliticianRumbleTestServer.player1CharacterName);
}//End if ("4".equals(PoliticianRumbleTestServer.player1CharacterNum))
sendCharacter();
sendEnergy(PoliticianRumbleTestServer.player1Energy);
}// End if (PoliticianRumbleTestServer.gameState == 0)
//Set Player2 Chosen Character Number and Character Name
if (PoliticianRumbleTestServer.gameState == 1)
{// Start if (PoliticianRumbleTestServer.gameState == 1)
PoliticianRumbleTestServer.player2CharacterNum = command.substring(9);
System.out.println("player2Character = " + PoliticianRumbleTestServer.player2CharacterNum);
if ("1".equals(PoliticianRumbleTestServer.player2CharacterNum))
{//Start if ("1".equals(PoliticianRumbleTestServer.player2CharacterNum))
PoliticianRumbleTestServer.player2CharacterName = characterList.get(0);
System.out.println("player2CharacterName = " + PoliticianRumbleTestServer.player2CharacterName);
}//End if ("1".equals(PoliticianRumbleTestServer.player2CharacterNum))
else if ("2".equals(PoliticianRumbleTestServer.player2CharacterNum))
{//Start if ("2".equals(PoliticianRumbleTestServer.player2CharacterNum))
PoliticianRumbleTestServer.player2CharacterName = characterList.get(3);
System.out.println("player2CharacterName = " + PoliticianRumbleTestServer.player2CharacterName);
}//End if ("2".equals(PoliticianRumbleTestServer.player2CharacterNum))
else if ("3".equals(PoliticianRumbleTestServer.player2CharacterNum))
{//Start if ("3".equals(PoliticianRumbleTestServer.player2CharacterNum))
PoliticianRumbleTestServer.player2CharacterName = characterList.get(6);
System.out.println("player2CharacterName = " + PoliticianRumbleTestServer.player2CharacterName);
}//End if ("3".equals(PoliticianRumbleTestServer.player2CharacterNum))
else if ("4".equals(PoliticianRumbleTestServer.player2CharacterNum))
{//Start if ("4".equals(PoliticianRumbleTestServer.player2CharacterNum))
PoliticianRumbleTestServer.player2CharacterName = characterList.get(9);
System.out.println("player2CharacterName = " + PoliticianRumbleTestServer.player2CharacterName);
}//End if ("4".equals(PoliticianRumbleTestServer.player2CharacterNum))
sendCharacter();
sendEnergy(PoliticianRumbleTestServer.player2Energy);
}// End if (PoliticianRumbleTestServer.gameState == 1)
PoliticianRumbleTestServer.gameState = PoliticianRumbleTestServer.gameState + 1;
System.out.println("gameState = " + PoliticianRumbleTestServer.gameState);
}// End if (command.startsWith("CHARACTER"))
} catch (IOException e) {
System.out.println("Player died: " + e);
}//End Try Block for Welcome and Character Selection Routine
}
/**
* Accepts notification of who the opponent is.
*/
public void setOpponent(Player opponent) {
this.opponent = opponent;
}
/**
* Handles the otherPlayerMoved message.
*/
public void otherPlayerMoved(int location) {
output.println("OPPONENT_MOVED " + location);
if (!(hasWinner()))
{
} else { if (1 == mark)
{
System.out.println("1: Game Completed (line 296) player1Energy = " + PoliticianRumbleTestServer.player1Energy);
System.out.println("1: Game Completed (line 297) player2Energy = " + PoliticianRumbleTestServer.player2Energy);
sendEnergy(PoliticianRumbleTestServer.player1Energy);
if (PoliticianRumbleTestServer.player1Energy
Lihat lebih banyak...
Comentários