Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of
  • Loading branch information
afortuna2016 committed Apr 25, 2017
2 parents ac8faef + deaa729 commit d273363
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 60 deletions.
Binary file modified bin/controller/Cashflow.class
Binary file not shown.
Binary file modified bin/model/CharityTile.class
Binary file not shown.
Binary file modified bin/model/DealTile.class
Binary file not shown.
Binary file modified bin/view/CharityWindow$1.class
Binary file not shown.
Binary file modified bin/view/CharityWindow$2.class
Binary file not shown.
Binary file modified bin/view/CharityWindow$3.class
Binary file not shown.
Binary file modified bin/view/CharityWindow.class
Binary file not shown.
64 changes: 27 additions & 37 deletions src/controller/Cashflow.java
Expand Up @@ -40,7 +40,6 @@ public class Cashflow
// Initialize game board
_board = new GameBoard(_players);


// Initialize GUI


Expand Down Expand Up @@ -96,22 +95,15 @@ public class Cashflow
players.add(p2);
GameBoard g = new GameBoard(players);
System.out.println(p1.getLocation());
g.movePlayer(p1, 5);
g.movePlayer(p1, 4);
System.out.println(p1.getLocation());


FSWindow FSWindow = new FSWindow();
FSWindow.prepareGUI(p1);
FSWindow.showButtonDemo();


// Delay to check how the financial statement updates
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


FSWindow.prepareGUI(p2);

Expand Down Expand Up @@ -146,33 +138,31 @@ public class Cashflow
}


//
// public void setUpScreen()
// {
// frame = new JFrame("Cashflow");
// frame.setLayout(new FlowLayout());
// window = new GameboardWindow(_board);
//
// sidewindow = new JWindow();
// sidewindow.setLayout(new GridLayout(5, 5));
//
// frame.add(window);
//
//
// frame.pack();
//
// frame.setVisible(true);
// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// }
// public static void main(String[] args) {
// new Cashflow(4);
//
// }
// public Cashflow(int numPlayers)
// {
// //this.setUpScreen(); // just did this to test the screen
//
// }

public void setUpScreen()
{
frame = new JFrame("Cashflow");
frame.setLayout(new FlowLayout());
window = new GameboardWindow(_board);

sidewindow = new JWindow();
sidewindow.setLayout(new GridLayout(5, 5));

frame.add(window);


frame.pack();

frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}


public Cashflow(int numPlayers)
{
//this.setUpScreen(); // just did this to test the screen

}


}
Expand Down
20 changes: 20 additions & 0 deletions src/model/CharityTile.java
@@ -1,5 +1,7 @@
package model;

import view.CharityWindow;

public class CharityTile extends Tile
{

Expand All @@ -15,6 +17,24 @@ public class CharityTile extends Tile
FinancialStatement f = p.getFinancialStatement();
// call view method
// TODO
CharityWindow charityWindow = new CharityWindow();
charityWindow.showButtonDemo();


while(!charityWindow.hasAnswered)
{
try {
Thread.sleep(200);
} catch(InterruptedException e) {

}
}
System.out.println(charityWindow.doesDonate);

// Pick card from big/small deal stack:
Card c;
if(charityWindow.doesDonate)


if (p.donateCharity())
{
Expand Down
21 changes: 17 additions & 4 deletions src/model/DealTile.java
Expand Up @@ -20,19 +20,30 @@ public class DealTile extends Tile
public void getLandedOn(Player p)
{
// TODO
// For now, using a scanner to interact with user until GUI is ready:
// Ask user to decide big/small deal:
CharityWindow charityWindow = new CharityWindow();
charityWindow.showButtonDemo();


while(!charityWindow.hasAnswered)
{
try {
Thread.sleep(200);
} catch(InterruptedException e) {

}
}
System.out.println(charityWindow.doesDonate);


// Pick card from big/small deal stack:
Card c;
if(input.equals("1"))
if(charityWindow.doesDonate)
{
c = _smallDealStack.pickCard();
}
else
{
c = _smallDealStack.pickCard();
c = _bigDealStack.pickCard();
}

// If stock, update price, then ask user if they want to buy and ask everyone if they want to sell:
Expand All @@ -41,6 +52,8 @@ public class DealTile extends Tile
// If property, ask user if they want to do it (and check if they can afford the down payment):
// If yes, call ButIncomeProperty method:
// Else, do nothing:
System.out.println(charityWindow.hasAnswered);
charityWindow = null;
}

public void buyIncomeProperty(Player p, DealCard d)
Expand Down
91 changes: 73 additions & 18 deletions src/view/CharityWindow.java
Expand Up @@ -9,13 +9,16 @@ public class CharityWindow {
private JLabel headerLabel;
private JLabel statusLabel;
private JPanel controlPanel;
public boolean doesDonate;
public boolean hasAnswered = false;

public CharityWindow(){
prepareGUI();
}
public static void main(String[] args){
CharityWindow CharityWindow = new CharityWindow();
CharityWindow.showButtonDemo();
boolean b = CharityWindow.showButtonDemo();
System.out.println(b);
}
private void prepareGUI(){
mainFrame = new JFrame("Charity");
Expand Down Expand Up @@ -46,7 +49,7 @@ public class CharityWindow {
mainFrame.setVisible(true);
}

private void showButtonDemo(){
public boolean showButtonDemo(){
headerLabel.setText("Charity!");
statusLabel.setText("Charity description");

Expand All @@ -57,29 +60,81 @@ public class CharityWindow {
JButton DontDonate = new JButton("Don't Donate");
DontDonate.setHorizontalTextPosition(SwingConstants.LEFT);

Donate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//update cashbalance for player
try {
Thread.sleep(1);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.exit(0);
}

Donate.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
hasAnswered = true;
doesDonate = true;
mainFrame.dispose();
}

@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub

}
});

DontDonate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//put message that they are greedy. after 10 seconds, close window
System.exit(0);
}
DontDonate.addMouseListener(new MouseListener() {

@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
hasAnswered = true;
doesDonate = false;
mainFrame.dispose();
}

@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub

}
});
controlPanel.add(Donate);

controlPanel.add(DontDonate);

mainFrame.setVisible(true);

return doesDonate;
}
}
2 changes: 1 addition & 1 deletion src/view/GameboardWindow.java
Expand Up @@ -43,7 +43,7 @@ public class GameboardWindow extends JPanel {
setMaximumSize(size);
setSize(size);
setLayout(null);

setUpTiles();

Positioners = new ArrayList<Positioner>();
Expand Down

0 comments on commit d273363

Please sign in to comment.