Skip to content
Permalink
c928038ac8
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
171 lines (117 sloc) 3.14 KB
package controller;
import view.*;
import java.util.ArrayList;
import model.*;
public class Cashflow
{
private GameBoard _board;
public Player[] players;
//private CardStack[] _cards;
public GameboardWindow gameboard;
public static int numPlayers;
private JFrame frame;
private JWindow sidewindow;
private GameboardWindow window;
public static void go(String [] playerNames)
{
for(int i = 0; i<playerNames.length; i++)
{
System.out.println(playerNames[i]);
}
// Joe
// Initialize game board
// Initialize GUI
// Initialize players (pick professions)
/*
* Start game:
* calls play function that has a
* while loop that repeats until either a player wins or
* someone elects to quit
*/
}
public void play()
{
while(!isWinner())
{
// TODO Play method
// Get player whose turn it is
// Display their financial statement
// Check down sized (check if player's down size counter is 0)
// Check charity (Check if charity counter is 0)
// Roll dice
// Move player (Have to wrap tiles to next tile after last tile is the beginning)
// Call tile's getLandedOn method
// Update current/all players' financials
// Increment player array (Also needs to wrap like tiles array)
}
}
public boolean isWinner()
{
boolean isWinner = false;
for(Player p : players)
{
if(p.hasWon())
{
return true;
}
}
return isWinner;
}
private static void testGamePlay()
{
Player p1 = new Player();
Player p2 = new Player();
GameBoard g = new GameBoard(p1, p2);
System.out.println(p1.getLocation());
g.movePlayer(p1, 5);
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);
}
public static void testCards()
{
BigDealStack ms = new BigDealStack();
int initialSize = ms.getSize();
for(int i=0; i<initialSize; i++)
{
int num = i+1;
System.out.println(num + ": " + ms.get(i).getTitle()); //Always going to need this cast when getting description unfortunately
}
Card c1 = ms.pop();
Card c2 = ms.pop();
System.out.println("Just popped: " + c1.getTitle());
System.out.println("Just popped: " + c2.getTitle());
for(int i=0; i<initialSize; i++)
{
int num = i+1;
System.out.println(num + ": " + (ms.get(i).getTitle())); //Always going to need this cast when getting description unfortunately
}
}
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
}
}