Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f27e65c
Added inprogress Server implementation
DevRuto Nov 13, 2017
3f0b8de
Rebased files
DevRuto Nov 13, 2017
54ee649
Updated .gitignore
DevRuto Nov 13, 2017
9f037d9
Update .gitignore
Nov 15, 2017
cec54b6
Added new protocols
DevRuto Nov 29, 2017
0e9ca66
Create temp
Dec 1, 2017
a2dd9bf
Add files via upload
Dec 1, 2017
64e878b
Create createjar.sh
DevRuto Dec 1, 2017
e184256
Update README.md
DevRuto Dec 1, 2017
9c51d2a
Create createjar.sh
DevRuto Dec 1, 2017
6694bd2
Update createjar.sh
DevRuto Dec 1, 2017
5f71eba
Update createjar.sh
DevRuto Dec 1, 2017
6ec6cda
Update README.md
DevRuto Dec 1, 2017
477cc77
Delete temp
DevRuto Dec 1, 2017
ae27ab5
Create README.md
DevRuto Dec 1, 2017
20027bd
Update MemoryGame.java
DevRuto Dec 1, 2017
38e8583
Update README.md
DevRuto Dec 1, 2017
eeb11dc
Update README.md
DevRuto Dec 1, 2017
d62f1b4
Create gendocs.sh
DevRuto Dec 1, 2017
a270c02
Create gendocs.sh
DevRuto Dec 1, 2017
b6efc19
Update README.md
DevRuto Dec 1, 2017
a604616
Update MemoryGame.java
clm2755 Dec 6, 2017
dbdfdaa
Update GameServer.java
clm2755 Dec 6, 2017
581a47a
Update MemoryGame.java
Dec 9, 2017
e31d4b7
Update Card.java
Dec 9, 2017
109a3ad
Updated Protocol.java
Dec 9, 2017
d07c425
Added changes to client
Dec 9, 2017
dd47bf4
Added changes to server
Dec 9, 2017
b7da54f
Added different colors for players
DevRuto Dec 11, 2017
33551a8
Added variable for board number count
DevRuto Dec 12, 2017
2287499
Added JavaDocs and Cleaned code
Dec 12, 2017
6d1005a
Add files via upload
al8963 Dec 13, 2017
93d3971
Update links
DevRuto Dec 14, 2017
8f19b60
Fixed up colors
DevRuto Dec 14, 2017
080896b
Merge branch 'dev' of https://github.com/rutokz/NetworkGame into dev
DevRuto Dec 14, 2017
60535b6
Removed redundant code. Added STATE popup
DevRuto Dec 14, 2017
f482558
Updated javadoc scripts; Published generated JavaDocs
DevRuto Dec 14, 2017
2d06d4e
Update GameServer.java
Dec 15, 2017
7a1c340
Update MemoryGame.java
Dec 15, 2017
4c24a7b
Update Card.java
Dec 15, 2017
66c6452
Update GameServer.java
Dec 15, 2017
9d1c51d
Update GameServer.java
Dec 15, 2017
ab29607
Added server start message to GUI
DevRuto Dec 15, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Compiled class file
# Ignore java artifacts
*.class
*.jar

# Log file
*.log
Expand All @@ -20,3 +21,6 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Backup files
*.bak
215 changes: 215 additions & 0 deletions Client/Card.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
/*
* Card.java
*
* @author Kajal Nagrani, Winston Chang, Alex Kramer, Caleb Maynard, Aiden Lin
* @since 2017-12-08
* @version 1.0
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.ArrayList;
import java.util.TimerTask;

/**
* A component containing information
* and animations for a card
*/
public class Card extends JComponent implements MouseListener {
private ArrayList<ActionListener> actionListeners = new ArrayList<ActionListener>();
private int id;
private boolean matched = false;
private boolean flip = false;
private java.util.Timer timer;
private boolean textVisible = false;
private JLabel label;
private int x, y, width, height;
private boolean halfPoint = false;
private boolean running = false;
private ActionEvent ae = new ActionEvent(this,3,"string");
private Color downColor = Color.green;
private Color upColor = Color.blue;

/**
* Set up the card layout
* @param timer The timer for the flip animation to base on
*/
public Card(java.util.Timer timer) {
this.timer = timer;
label = new JLabel();
label.setHorizontalAlignment(JLabel.CENTER);
label.setVerticalAlignment(JLabel.CENTER);
setLayout(new BorderLayout());
add(label, BorderLayout.CENTER);
addMouseListener(this);
}

/**
* Set the color of the face up card
* @param c the face up color
*/
public void setUpColor(Color c){
upColor = c;
}

/**
* The identifier of the card
* @param id The identifier of the card
*/
public void setId(int id) {
this.id = id;
label.setText(id + "");
}

/**
* SGet the id of this card
*/
public int getId() {
return this.id;
}

/**
* Set the text of the card
* @param text the text of the card to set
*/
public void setText(String text) {
label.setText(id + "");
}

/**
* Set the determined status
* @param matched Determines if this card has been matched
*/
public void setMatched(boolean matched) {
this.matched = matched;
}

/**
* Returns true if this card has been matched
*/
public boolean getMatched() {
return this.matched;
}

/**
* Get the width thats drawable
*/
private int getDrawWidth() {
return getWidth() - 1;
}

/**
* Get the height thats drawable
*/
private int getDrawHeight() {
return getHeight() - 2;
}

/**
* Starts the flip animation
*/
public void flip(boolean flip) {
this.flip = flip;
width = getDrawWidth();
height = getDrawHeight();
x = 2;
y = 0;
halfPoint = false;
timer.schedule(new FlipTask(), 0, 2);
}

/**
* Draws the card
*/
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);

label.setVisible(flip);
//label.setVisible(true);
label.setForeground(flip?Color.BLACK:Color.GRAY);
// Draw background
g.setColor(label.isVisible() ? Color.CYAN : downColor);
g.fillRect(x, y, width, height);

// Set border color
if (flip) {
g.setColor(Color.black);
g.drawRect(x, y, width - 4, height);
} else {
g.setColor(Color.black);
g.drawRect(0, 0, getDrawWidth(), getDrawHeight());
}
}

/**
* Custom onclick implementation
*/
public void addActionListener(ActionListener listener) {
if (!actionListeners.contains(listener))
actionListeners.add(listener);
}

/**
* Perform onclick
*/
@Override
public void mouseClicked(MouseEvent e) {
for (ActionListener listener : actionListeners)
listener.actionPerformed(ae);
}

@Override
public void mousePressed(MouseEvent e) {

}

@Override
public void mouseReleased(MouseEvent e) {

}

@Override
public void mouseEntered(MouseEvent e) {

}

@Override
public void mouseExited(MouseEvent e) {

}

/**
* A task that performs the flip animation
*/
class FlipTask extends TimerTask {

/**
* Perform the flip animation
*/
@Override
public void run() {
if (running) return;
if (!halfPoint) {
x += 1;
width -= 2;
} else {
x -= 1;
width += 2;
}

if (width >= getWidth()) {
running = false;
repaint();
cancel();
}
if (width <= 0) {
halfPoint = true;
textVisible = !textVisible;
}

repaint();
}

}
}
Loading