Skip to content

Commit

Permalink
Small changes were done.
Browse files Browse the repository at this point in the history
  • Loading branch information
boianaradkova committed Feb 4, 2019
1 parent 5ca0d8b commit 394c180
Show file tree
Hide file tree
Showing 28 changed files with 89 additions and 90 deletions.
Empty file added data/gameinfo.txt
Empty file.
5 changes: 2 additions & 3 deletions src/edu/asu/stratego/Client.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package edu.asu.stratego;

import javafx.application.Application;
import javafx.stage.Stage;

import java.io.IOException;

import edu.asu.stratego.game.ClientGameManager;
import edu.asu.stratego.game.Game;
import edu.asu.stratego.gui.ClientStage;
import javafx.application.Application;
import javafx.stage.Stage;

/**
* Client desktop application entry point.
Expand Down
1 change: 0 additions & 1 deletion src/edu/asu/stratego/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
Expand Down
2 changes: 1 addition & 1 deletion src/edu/asu/stratego/game/BattleOutcome.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
*/
public enum BattleOutcome {
WIN, LOSE, DRAW;
}
}
18 changes: 13 additions & 5 deletions src/edu/asu/stratego/game/ClientFileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@
import java.io.FileWriter;
import java.util.Scanner;

/**
* Helper class for file system manipulation.
*
* @author Curtis Sapp
*/
public class ClientFileManager {
private final static String GAME_INFO_PATH = "gameinfo.txt";
//TODO It will be changed with Android Shared Praferences.

/** Full file path and name for the game information. */
private final static String GAME_INFO_FILE = "./data/gameinfo.txt";

public static String getLastGameIp() {
File file = new File(GAME_INFO_PATH);
File file = new File(GAME_INFO_FILE);
Scanner scanner;
try {
scanner = new Scanner(file);
Expand All @@ -25,7 +33,7 @@ public static String getLastGameIp() {
}

public static int getLastPort() {
File file = new File(GAME_INFO_PATH);
File file = new File(GAME_INFO_FILE);
Scanner scanner;
try {
scanner = new Scanner(file);
Expand All @@ -41,7 +49,7 @@ public static int getLastPort() {
}

public static int getLastGameId() {
File file = new File(GAME_INFO_PATH);
File file = new File(GAME_INFO_FILE);
Scanner scanner;
try {
scanner = new Scanner(file);
Expand Down Expand Up @@ -74,7 +82,7 @@ public static void writeSessionData(String ip, int port, int sessionId) {
}

public static boolean doesGameInfoExist() {
File file = new File(GAME_INFO_PATH);
File file = new File(GAME_INFO_FILE);
try {
return file.exists();
} catch (Exception e) {
Expand Down
9 changes: 3 additions & 6 deletions src/edu/asu/stratego/game/ClientGameManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package edu.asu.stratego.game;

//hello
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
Expand All @@ -11,7 +10,6 @@
import java.io.ObjectOutputStream;
import java.util.ArrayList;

import edu.asu.stratego.Session;
import edu.asu.stratego.game.board.ClientSquare;
import edu.asu.stratego.gui.BoardScene;
import edu.asu.stratego.gui.ClientStage;
Expand All @@ -34,6 +32,8 @@

/**
* Task to handle the Stratego game on the client-side.
*
* @author Curtis Sapp
*/
public class ClientGameManager implements Runnable {

Expand Down Expand Up @@ -71,7 +71,6 @@ public void run() {
sendIsReconnectData();
playGame(true);
} else {

connectToServer();
sendIsReconnectData();
waitForOpponent();
Expand Down Expand Up @@ -117,7 +116,6 @@ private void sendIsReconnectData() {
} catch (Exception e) {
System.out.println(e);
}

}

private boolean isReconnectingFromPreviousGame() {
Expand Down Expand Up @@ -237,7 +235,6 @@ private void setupBoard() {

private void playGame(boolean wasReconnect) {
if (!wasReconnect) {

// Remove setup panel
Platform.runLater(() -> {
BoardScene.getRootPane().getChildren().remove(BoardScene.getSetupPanel());
Expand Down Expand Up @@ -524,7 +521,7 @@ else if (Game.getMove().getStart().x < Game.getMove().getEnd().x)
win = true;
}

File file = new File("Players.sav");
File file = new File("./data/Players.sav");
file.createNewFile();
BufferedReader stdin = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
ArrayList<String> list = new ArrayList<String>();
Expand Down
7 changes: 5 additions & 2 deletions src/edu/asu/stratego/game/ClientSocket.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package edu.asu.stratego.game;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.io.*;
import java.util.*;

import edu.asu.stratego.gui.ConnectionScene;

Expand Down
2 changes: 0 additions & 2 deletions src/edu/asu/stratego/game/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.io.Serializable;

import edu.asu.stratego.game.PieceColor;

/**
* Contains information about a player.
*/
Expand Down
1 change: 0 additions & 1 deletion src/edu/asu/stratego/game/ServerGameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.net.Socket;
import java.util.ArrayList;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;

import edu.asu.stratego.Server;
import edu.asu.stratego.Session;
Expand Down
9 changes: 4 additions & 5 deletions src/edu/asu/stratego/gui/BoardScene.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package edu.asu.stratego.gui;

import edu.asu.stratego.game.Game;
import edu.asu.stratego.gui.board.BoardTurnIndicator;
import edu.asu.stratego.gui.board.setup.SetupPanel;
import edu.asu.stratego.media.ImageConstants;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Rectangle;
import edu.asu.stratego.game.Game;
import edu.asu.stratego.gui.board.BoardTurnIndicator;
import edu.asu.stratego.gui.board.setup.SetupPanel;
import edu.asu.stratego.media.ImageConstants;
import edu.asu.stratego.media.PlaySound;

/**
* Wrapper class for a JavaFX scene. Contains a scene UI and its associated
Expand Down
17 changes: 10 additions & 7 deletions src/edu/asu/stratego/gui/ConnectionScene.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package edu.asu.stratego.gui;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.UnknownHostException;
import java.io.*;
import java.util.*;
import java.util.ArrayList;

import edu.asu.stratego.game.ClientSocket;
import edu.asu.stratego.game.Game;
import javafx.application.Platform;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
Expand All @@ -15,9 +21,6 @@
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;

import edu.asu.stratego.game.ClientSocket;
import edu.asu.stratego.game.Game;

/**
* Wrapper class for a JavaFX scene. Contains a scene UI and its associated
* event handlers for retrieving network connection information from the player
Expand Down Expand Up @@ -58,7 +61,7 @@ public class ConnectionScene {
ConnectionScene() throws IOException {

// reads from saved ips file and stores in ArrayList
serverFile = new File("Servers.sav");
serverFile = new File("./data/Servers.sav");
serverFile.createNewFile();
BufferedReader stdin = new BufferedReader(new InputStreamReader(new FileInputStream(serverFile)));
serverList = new ArrayList<String>();
Expand All @@ -71,7 +74,7 @@ public class ConnectionScene {
stdin.close();

// reads from saved players file and stores in ArrayList
playerFile = new File("Players.sav");
playerFile = new File("./data/Players.sav");
playerFile.createNewFile();
BufferedReader stdin2 = new BufferedReader(new InputStreamReader(new FileInputStream(playerFile)));
playerList = new ArrayList<String>();
Expand Down
3 changes: 1 addition & 2 deletions src/edu/asu/stratego/gui/board/BoardEventPane.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package edu.asu.stratego.gui.board;

import javafx.scene.layout.GridPane;

import edu.asu.stratego.game.board.ClientBoard;
import javafx.scene.layout.GridPane;

/**
* Layered directly on top of the BoardPane. Allows the player to interact with
Expand Down
3 changes: 1 addition & 2 deletions src/edu/asu/stratego/gui/board/BoardPane.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package edu.asu.stratego.gui.board;

import javafx.scene.layout.GridPane;

import edu.asu.stratego.game.board.ClientBoard;
import edu.asu.stratego.media.ImageConstants;
import javafx.scene.layout.GridPane;

/**
* A graphical representation of the Stratego board.
Expand Down
13 changes: 6 additions & 7 deletions src/edu/asu/stratego/gui/board/BoardSquareEventPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
import java.util.ArrayList;
import java.util.Arrays;

import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.effect.Glow;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.GridPane;

import edu.asu.stratego.game.ClientGameManager;
import edu.asu.stratego.game.Game;
import edu.asu.stratego.game.GameStatus;
Expand All @@ -23,6 +16,12 @@
import edu.asu.stratego.gui.board.setup.SetupPieces;
import edu.asu.stratego.media.ImageConstants;
import edu.asu.stratego.util.HashTables;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.effect.Glow;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.GridPane;

/**
* A single square within the BoardEventPane.
Expand Down
2 changes: 0 additions & 2 deletions src/edu/asu/stratego/gui/board/BoardSquarePane.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;

import edu.asu.stratego.gui.board.BoardSquareType;

/**
* JavaFX StackPane to graphically represent the individual squares of the
* Stratego board.
Expand Down
6 changes: 3 additions & 3 deletions src/edu/asu/stratego/gui/board/BoardTurnIndicator.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package edu.asu.stratego.gui.board;

import edu.asu.stratego.game.Game;
import edu.asu.stratego.game.PieceColor;
import edu.asu.stratego.gui.ClientStage;
import javafx.animation.FillTransition;
import javafx.application.Platform;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;
import edu.asu.stratego.game.Game;
import edu.asu.stratego.game.PieceColor;
import edu.asu.stratego.gui.ClientStage;

/**
* JavaFX rectangle that is layered behind the semi-transparent board border to
Expand Down
9 changes: 4 additions & 5 deletions src/edu/asu/stratego/gui/board/setup/SetupPanel.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package edu.asu.stratego.gui.board.setup;

import edu.asu.stratego.game.ClientGameManager;
import edu.asu.stratego.game.Game;
import edu.asu.stratego.gui.ClientStage;
import edu.asu.stratego.media.ImageConstants;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
Expand All @@ -14,11 +18,6 @@
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import edu.asu.stratego.game.ClientGameManager;
import edu.asu.stratego.game.Game;
import edu.asu.stratego.gui.ClientStage;
import edu.asu.stratego.media.ImageConstants;
import edu.asu.stratego.media.PlaySound;

/**
* The panel that is shown during the SETTING_UP phase of a Stratego game.
Expand Down
11 changes: 5 additions & 6 deletions src/edu/asu/stratego/gui/board/setup/SetupPieces.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

import java.util.HashMap;

import edu.asu.stratego.game.Game;
import edu.asu.stratego.game.PieceType;
import edu.asu.stratego.gui.ClientStage;
import edu.asu.stratego.util.HashTables;
import edu.asu.stratego.util.MutableBoolean;
import javafx.event.EventHandler;
import javafx.scene.control.Label;
import javafx.scene.effect.ColorAdjust;
Expand All @@ -11,12 +16,6 @@
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import edu.asu.stratego.game.Game;
import edu.asu.stratego.game.PieceType;
import edu.asu.stratego.gui.ClientStage;

import edu.asu.stratego.util.HashTables;
import edu.asu.stratego.util.MutableBoolean;

/**
* Pieces in the SetupPanel that the player can select when setting up the game.
Expand Down
5 changes: 2 additions & 3 deletions src/edu/asu/stratego/gui/board/setup/SetupTimer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package edu.asu.stratego.gui.board.setup;

import edu.asu.stratego.gui.ClientStage;
import edu.asu.stratego.gui.board.BoardSquareEventPane;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
Expand All @@ -13,9 +15,6 @@
import javafx.scene.text.Font;
import javafx.util.Duration;

import edu.asu.stratego.gui.ClientStage;
import edu.asu.stratego.gui.board.BoardSquareEventPane;

/**
* A setup timer. This timer counts down from a start time.
*/
Expand Down
3 changes: 1 addition & 2 deletions src/edu/asu/stratego/media/PlaySound.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package edu.asu.stratego.media;

import javafx.scene.media.AudioClip;

import edu.asu.stratego.util.HashTables;
import javafx.scene.media.AudioClip;

public class PlaySound {
public static void playMusic(String file, int Volume) {
Expand Down
2 changes: 0 additions & 2 deletions src/edu/asu/stratego/media/SoundConstants.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package edu.asu.stratego.media;

import javafx.scene.media.AudioClip;

public class SoundConstants {
// TODO Sound constant disabled
// public final static AudioClip CORNFIELD = new
Expand Down
Loading

0 comments on commit 394c180

Please sign in to comment.