Skip to content

Commit

Permalink
class headers
Browse files Browse the repository at this point in the history
  • Loading branch information
rowsimms42 committed Jun 8, 2020
1 parent 5b6b46d commit bc18c9f
Show file tree
Hide file tree
Showing 23 changed files with 195 additions and 61 deletions.
5 changes: 5 additions & 0 deletions Accusation.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/************************************************************************
* Accusation class is called from Board Panel class and implements two
* runnables for if player accuses correctly or incorrectly.
***********************************************************************/

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
Expand Down
4 changes: 4 additions & 0 deletions BoardPanel.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/******************************************************
* Handles game board logic and character token drawing
*****************************************************/

import javax.swing.*;
import java.awt.*;
import javax.swing.Timer;
Expand Down
5 changes: 5 additions & 0 deletions BoardPanelHelper.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*******************************************************************
* Contains various helper functions that assist Board Panel class.
* Functions are called from Board Panel class.
******************************************************************/

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
Expand Down
4 changes: 4 additions & 0 deletions Card.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/********************************************************
* Super Class that encapsulates a card of the clue game
*******************************************************/

import java.io.Serializable;

public class Card implements Serializable{
Expand Down
5 changes: 5 additions & 0 deletions CharacterSelectFrame.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/************************************************************
* Class communicates with server and allows player to select
* one of the available characters
************************************************************/

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
Expand Down
4 changes: 4 additions & 0 deletions Characters.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/***************************************************
* Class that encapsulates the characters and their
* attributes of the clue goard game
***************************************************/

import java.io.Serializable;

Expand Down
5 changes: 5 additions & 0 deletions Client.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/********************************************************
* This class establishes a connection to server
* and transfers data between server and client side gui
********************************************************/

import java.io.EOFException;
import java.io.IOException;
import java.io.ObjectInputStream;
Expand Down
74 changes: 58 additions & 16 deletions ClientFrame.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/******************************************************
* This class is the base class for the client side gui
******************************************************/

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
Expand Down Expand Up @@ -134,22 +138,60 @@ public MyCards(){
public void actionPerformed(ActionEvent e) {
class GameRules extends JFrame{
public GameRules() {
setResizable(true);
setTitle("Clue Game Rules");
getContentPane().setLayout(new FlowLayout());
setBounds(6,6,494,693);
JPanel gameRulesPanel = new JPanel();
gameRulesPanel.setBounds(6, 6, 450, 691);
JTextArea textArea = new JTextArea(60,50);
textArea.setLineWrap(true);
textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textArea);
scrollPane.setPreferredSize(new Dimension(430, 671));
gameRulesPanel.add(scrollPane);
getContentPane().add(gameRulesPanel);
textArea.setText(ClueGameConstants.gameRulesString);
setLocationRelativeTo(null);
setVisible(true);
getContentPane().setBackground(new Color(255, 255, 255));
setResizable(true);
setTitle("Clue Game Rules");
setBounds(6,6,494,693);
getContentPane().setLayout(null);
JPanel gameRulesPanel = new JPanel();
gameRulesPanel.setBounds(239, 5, 1, 1);
gameRulesPanel.setLayout(null);
getContentPane().add(gameRulesPanel);
JLabel lblRulesObjective = new JLabel("Objective");
lblRulesObjective.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
lblRulesObjective.setBounds(187, 16, 105, 29);
getContentPane().add(lblRulesObjective);
JTextArea rulesObjectiveTxtArea = new JTextArea();
rulesObjectiveTxtArea.setEditable(false);
rulesObjectiveTxtArea.setFont(new Font("Arial", Font.PLAIN, 12));
rulesObjectiveTxtArea.setLineWrap(true);
rulesObjectiveTxtArea.setText(ClueGameConstants.gameRulesObjective);
rulesObjectiveTxtArea.setBackground(new Color(255, 255, 255));
rulesObjectiveTxtArea.setBounds(10, 44, 460, 57);
getContentPane().add(rulesObjectiveTxtArea);
JLabel lblRulesGamePlay = new JLabel("Game Play");
lblRulesGamePlay.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
lblRulesGamePlay.setBounds(181, 95, 129, 24);
getContentPane().add(lblRulesGamePlay);
JTextArea rulesGamePlayTxtArea = new JTextArea();
rulesGamePlayTxtArea.setText(ClueGameConstants.gameRulesGamePlay);
rulesGamePlayTxtArea.setFont(new Font("Arial", Font.PLAIN, 12));
rulesGamePlayTxtArea.setEditable(false);
rulesGamePlayTxtArea.setBackground(new Color(255, 255, 255));
rulesGamePlayTxtArea.setBounds(10, 122, 460, 137);
getContentPane().add(rulesGamePlayTxtArea);
JLabel lblRulesSuggestion = new JLabel("Suggestion");
lblRulesSuggestion.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
lblRulesSuggestion.setBounds(181, 269, 129, 24);
getContentPane().add(lblRulesSuggestion);
JTextArea rulesSuggestionTxtArea = new JTextArea();
rulesSuggestionTxtArea.setEditable(false);
rulesSuggestionTxtArea.setFont(new Font("Arial", Font.PLAIN, 12));
rulesSuggestionTxtArea.setText(ClueGameConstants.gameRulesSuggestion);
rulesSuggestionTxtArea.setBounds(10, 295, 460, 152);
getContentPane().add(rulesSuggestionTxtArea);
JTextArea rulesAccusationTxtArea = new JTextArea();
rulesAccusationTxtArea.setText(ClueGameConstants.gameRulesAccusing);
rulesAccusationTxtArea.setEditable(false);
rulesAccusationTxtArea.setFont(new Font("Arial", Font.PLAIN, 12));
rulesAccusationTxtArea.setBounds(10, 481, 460, 125);
getContentPane().add(rulesAccusationTxtArea);
JLabel lblRulesAccusation = new JLabel("Accusation");
lblRulesAccusation.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
lblRulesAccusation.setBounds(181, 457, 129, 24);
getContentPane().add(lblRulesAccusation);
setLocationRelativeTo(null);
setVisible(true);
}
} //end of inner game rules class
new GameRules();
Expand Down
5 changes: 5 additions & 0 deletions ClientRequestManager.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**************************************************************
* This class contains all functions related to the sending and
* receiving of data between client side gui and server
**************************************************************/

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down
5 changes: 5 additions & 0 deletions ClueClient.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*********************************************
* This class contains the main run method
* to execute the client side gui
********************************************/

import javax.swing.SwingUtilities;

public class ClueClient {
Expand Down
85 changes: 40 additions & 45 deletions ClueGameConstants.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*****************************************************************
* This class contains final variables used throughout server and
* client side portions of the game
****************************************************************/


public final class ClueGameConstants {

public static final int PORT = 6060;
Expand Down Expand Up @@ -282,50 +288,39 @@ public static enum LEGEND{
public int getYCoordLegend() {return y;}
};

public static final String gameRulesString =
"Object of the Game\n"+
"Mr. Boddy is found death in one of the rooms of his mansion. The players" +
" must determine the answers to these three questions:\n"+
"Who killed him? Where? and with What Weapon?"+
"\n \n "+
"Game Play\n"+
"Miss Scarlett opens the game, the turns continue clockwise around the \n"+
"table .On each turn, a player try to reach a different room of the \n"+
"mansion to investigate. To start your turn, move your token by \n"+
"rolling the die or use a Secret Passage when you are in a corner room.\n"+
"If you roll the die, you move your token that many spaces:\n"+
"Horizontally or vertically, forward or backward, but not diagonally.\n"+
"You are not allowed to enter the same space twice on the same turn.\n"+
"You may not enter on a space that is already occupied by another player.\n"+
"If you move through a Secret Passage, you don't need to roll and you can\n"+
" move immediately to the other room. This ends your movement.\n"+
"It is possible that your opponents might block any and all doors and trap \n"+
"you in a room. In that case, you have to wait for someone to move or \n"+
"un-block a door to leave!\n"+
"\n "+
"\n "+
"Suggestions or Guess\n"+
"When you enter a room, you can make a suggestion by naming a suspect, \n"+
"murder weapon and the room you just entered.e.g. 'The crime was \n"+
"committed by Mr. Green in the lounge with a knife'. Then your opponents\n"+
" (starting by the left player) must (if possible) prove that your \n"+
"suggestion is false by showing you one card that matches your suggestion.\n"+
" If the first player can't disprove, the next player must try it, etc...\n"+
" until all players have passed. As soon as someone shows you one of the \n"+
"cards, it is prooved that it can't be in the envelope and you can cross it \n"+
"off in your notebook as a possibility. If no one is able to prove your \n"+
"suggestion false, you may either end your turn or make an accusation.\n"+
"Note: the suggestion is always made for the room your token is at that \n"+
"moment.\n\n "+
"Accusing\n"+
"If you think you have solved the crime by deduction, you can end your turn by\n"+
"making an accusation and name any three elements. you can say: I accuse\n"+
"suspect of committing the crime in the room with the weapon. Then, you\n"+
"must look secretly at the cards in the envelope to check if your suggestion\n"+
"is correct. If you are correct, you can place the 3 cards face-up on the table\n"+
"to prove it and you won the game! \n"+
"\n "+
"Note: You can only make one accusation during a game. If your accusation\n" +
"is wrong, you lost and you must leave the game and board \n";
public static final String gameRulesObjective =
"Mr. Boddy is found dead in one of the rooms of his mansion. The players must "
+ "\r\ndetermine the answers to these three questions: Who killed him? Where? "
+ "\r\nWith what weapon?";
public static final String gameRulesGamePlay =
"Miss Scarlett opens the game. The turns continue clockwise around the table. "
+ "\r\nOn each turn, a player tries to reach a different room of the mansion "
+ "to \r\ninvestigate. To start your turn, move your token by rolling the die. "
+ "If you are in \r\na corner room, you can use a Secret Passage by pressing the "
+ "\"Shortcut\" button. \r\nIf you roll the die, you can move your token that many"
+ " spaces horizontally or \r\nvertically, forward or backward, but not diagonally. "
+ "You may not enter on a space \r\nthat is already occupied by another player. It "
+ "is possible that your opponents might\r\nblock any and all doors and trap you in a "
+ "room. In that case, you have to wait for \r\nsomeone to move. To end your turn, "
+ "hit the \"End Turn\" button.";
public static final String gameRulesSuggestion =
"When you enter a room, you can make a suggestion by naming a suspect, \r\nmurder "
+ "weapon and the room you just entered. e.g. 'The crime was committed \r\nby Mr. Green"
+ " in the lounge with a knife.' Then your opponents (starting by the \r\nleft player) "
+ "must (if possible) prove that your suggestion is false by showing you \r\none card that "
+ "matches your suggestion. If the first player can't disprove, the next \r\nplayer must "
+ "try it, etc... until all players have passed. As soon as someone shows \r\nyou one of "
+ "the cards, it is proven that it can't be in the envelope and you can cross \r\nit off "
+ "in your notebook as a possibility. If no one is able to prove your suggestion\r\nfalse, "
+ "you may either end your turn or make an accusation.\r\nNote: the suggestion is always "
+ "made for the room your token is at that moment.";
public static final String gameRulesAccusing =
"If you think you have solved the crime by deduction, you can end your turn by \r\nmaking "
+ "an accusation and naming any three elements. To do so, press the \r\n\"Accuse\" button "
+ "and pick a suspect, weapon, and room where you think the murder \r\ntook place. Then, you "
+ "must look secretly at the cards in the envelope to check if \r\nyour accusation is correct. "
+ "If you are correct, the winning cards will be shown to \r\nthe rest of the players in the "
+ "game and you win the game. \r\nNote: You can only make one accusation during a game. If your "
+ "accusation is \r\nwrong, you lost and can no longer play in the game.";

}//end class
5 changes: 5 additions & 0 deletions ClueStartFrame.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**********************************************
* Initial gui that is presented to enable start of game and
* connection to server
*********************************************/

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
Expand Down
6 changes: 6 additions & 0 deletions GameState.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/***************************************************
* This class encapsulates the clue game pertaining
* to game functionality
***************************************************/

import java.lang.invoke.StringConcatException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down
4 changes: 4 additions & 0 deletions Message.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/***************************************
* Handles client/cerver communication during game
***************************************/

import java.io.Serializable;

public class Message implements Serializable{
Expand Down
4 changes: 4 additions & 0 deletions MovementOptions.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/******************************************************
* This class handles movement logic for player pieces
*****************************************************/

import java.util.Arrays;
import java.util.HashMap;

Expand Down
5 changes: 5 additions & 0 deletions Player.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*************************************************
* This class contains the attributes of
* a clue game player
************************************************/

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
Expand Down
1 change: 1 addition & 0 deletions Rect.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

public class Rect{

private int xMin, xMax, yMin, yMax;
Expand Down
6 changes: 6 additions & 0 deletions RequestHandler.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*****************************************************
* This class runs on the server side portion of the game.
* It creates a new thread for each client that is connected
* to the server.
*****************************************************/

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Expand Down
5 changes: 5 additions & 0 deletions RoomCard.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**********************************
* Child class of card class.
* Contains attributes of room card
*********************************/

import java.io.Serializable;

public class RoomCard extends Card implements Serializable{
Expand Down
4 changes: 4 additions & 0 deletions ScoreCard.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/***************************
* Score card on gui side
**************************/

import javax.swing.JPanel;
import javax.swing.*;
import java.awt.*;
Expand Down
5 changes: 5 additions & 0 deletions Server.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/***************************************************************
* This class contains the main function to execute the
* server side portion of the game.
**************************************************************/

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
Expand Down
5 changes: 5 additions & 0 deletions SuspectCard.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*********************************************
* Child class of card class.
* Contains the attributes of the suspect card
*********************************************/

import java.io.Serializable;

public class SuspectCard extends Card implements Serializable{
Expand Down
5 changes: 5 additions & 0 deletions WeaponCard.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*********************************************
* Child class of card class.
* Contains the attributes of the weapon card
*********************************************/

import java.io.Serializable;

public class WeaponCard extends Card implements Serializable{
Expand Down

0 comments on commit bc18c9f

Please sign in to comment.