dd.hurricane
Class Main

java.lang.Object
  extended bydd.ui.GameSupport
      extended bydd.hurricane.Main
All Implemented Interfaces:
DLUGUI, GUIEvents, UI
Direct Known Subclasses:
Observer, StartlessMain

public class Main
extends GameSupport
implements DLUGUI, GUIEvents

The Disaster Land-Use Game prototype main class. This class is the main class for DLUG, the Disaster Land-Use game. Run this class to start an instance of DLUG.

In the model/view/controller paradigm, Main is the controller. It implements the DLUGUI interface, so it can receive messages from the game server. It presents a swing user interface by creating view objects, such as the Map (MapView) and list of proposals.

If a game is already running and the automatic network broadcast mechanism can locate the game, running this as the main class will connect to that existing game. If no game is found, a server will be started on this machine, and the game will connect to this (local) server. Subsequent clients will connect to the server.

Author:
Eric Scharff

Field Summary
protected  javax.swing.JButton amendButton
           
protected  BriefingPanel briefingPanel
           
protected  javax.swing.Box buttons
           
protected  ChatPanel chatPanel
           
protected  ChooseGame chooseGame
           
protected  java.awt.CardLayout controlManager
           
protected  javax.swing.JTabbedPane controlPanel
           
protected  ProposalView currentProposalView
           
protected  GameRoot gameRoot
           
protected  boolean gameRunning
           
static java.awt.Color hazardYellow
           
protected  HelpPanel helpPanel
           
protected static java.util.HashMap imageCache
           
protected  InfoPanel infoPanel
           
static java.lang.String[] luColorNames
           
static java.awt.Color[] luColors
           
static java.lang.String[] luNames
           
protected  javax.swing.JPanel main
           
protected  javax.swing.JFrame mainWindow
           
protected  MapView mapView
           
static java.lang.String[] metrics
           
protected  int myNumber
           
protected  TurnClient netClient
           
protected  javax.swing.Box notifyBox
           
protected  boolean notifying
           
protected  javax.swing.JButton opinionCancelButton
           
protected  javax.swing.JButton opinionMaybeButton
           
protected  javax.swing.JButton opinionNoButton
           
protected  javax.swing.JButton opinionYesButton
           
protected  javax.swing.JLabel pauseMessage
           
protected  javax.swing.JFrame pauseWindow
           
protected  Proposal pendingAmendment
           
protected  ProposalList proposalList
           
protected  javax.swing.JScrollPane proposalListPane
           
protected  java.util.HashMap propViz
           
protected  int requestedRole
           
protected  javax.swing.JButton retractButton
           
static java.lang.String[] roleNames
           
protected  Proposal selectedProposal
           
 java.util.HashSet showViz
           
protected static boolean singlePlayerMode
           
protected static javax.swing.JFrame splash
           
protected  java.lang.String state
           
protected  StatusBar statusBar
           
protected  javax.swing.JPanel swap
           
static boolean useServiceDiscovery
           
protected  VotePanel votePanel
           
protected  javax.swing.JLabel waitMessage
           
 
Constructor Summary
Main()
           
 
Method Summary
 java.lang.String askUserName()
           
 void availableGames(java.lang.String[] gameList)
           
 void beginNegotiationPhase()
           
 void beginSetupPhase()
           
 void beginVotePhase()
           
 void briefingEnded()
           
protected static void cacheDlugImages()
           
 void callForVote(java.lang.String proposalID)
           
 void castVote(Proposal p, int vote)
           
 void createNewGame(java.lang.String name)
           
 void disableUI()
           
 void doAmendButton()
           
 void doEditButton()
           
 void doneNotify(Player p)
           
 void doRetractButton()
           
 void editingComplete(Proposal p)
           
 void enableUI()
           
 void endVote()
           
 void errorMessage(java.lang.String message)
           
 void gameEnded()
           
 void gameMessage(java.lang.String message)
           
 java.awt.Color getColor(int turnNumber)
           
 java.awt.Color getColor(Player p)
           
 java.awt.Color getColor(Proposal p)
           
static java.awt.Color getColor(java.lang.String landuse)
           
 java.lang.String getColorName(int turnNumber)
           
 Player getCurrentPlayer()
           
 MapView getMapView()
           
 Player getPlayer(int turnNumber)
           
 java.util.HashMap getPropViz()
           
 GameRoot getRoot()
           
 void gotUserMessage(java.awt.Color color)
           
 void indicateOpinion(java.lang.String val)
           
 void joinedGame()
           
 void joinGame(java.lang.String name, int requestedPlayer)
           
 void lostServer()
           
static void main(java.lang.String[] args)
           
 void makeUI()
           
 void notifyUser(java.lang.String message)
           
 void pauseUI(java.lang.String message)
           
 void plistRefreshed()
           
 void prepareForVotingOn(Proposal proposal)
           
 void proposalDoubleClicked(Proposal p)
           
 void refreshGameList()
           
 void rejoinGame(java.lang.String name, int requestedPlayer)
           
 void setButtonStates()
           
 void setHelpContent(java.lang.String location)
           
 void setNetClient(TurnClient client)
           
 void setNumber(java.lang.String turnNumber)
           
 void setRoot(GameRoot root)
           
 void setSelectedProposal(Proposal proposal)
           
static void splash()
           
 void startBriefing(Briefing b)
           
 void startVote()
           
 void startVotingTimer()
           
 void unpauseUI()
           
 void votingTimerExpired()
           
 
Methods inherited from class dd.ui.GameSupport
cacheImages, centerWindow, createImageIcon, emptyImageIcon, getImage, sizeCols
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

imageCache

protected static java.util.HashMap imageCache

useServiceDiscovery

public static final boolean useServiceDiscovery
See Also:
Constant Field Values

myNumber

protected int myNumber

requestedRole

protected int requestedRole

netClient

protected TurnClient netClient

gameRoot

protected GameRoot gameRoot

propViz

protected java.util.HashMap propViz

showViz

public java.util.HashSet showViz

chooseGame

protected ChooseGame chooseGame

mainWindow

protected javax.swing.JFrame mainWindow

pauseWindow

protected javax.swing.JFrame pauseWindow

briefingPanel

protected BriefingPanel briefingPanel

controlPanel

protected javax.swing.JTabbedPane controlPanel

main

protected javax.swing.JPanel main

swap

protected javax.swing.JPanel swap

notifyBox

protected javax.swing.Box notifyBox

pauseMessage

protected javax.swing.JLabel pauseMessage

controlManager

protected java.awt.CardLayout controlManager

notifying

protected boolean notifying

state

protected java.lang.String state

helpPanel

protected HelpPanel helpPanel

mapView

protected MapView mapView

proposalList

protected ProposalList proposalList

proposalListPane

protected javax.swing.JScrollPane proposalListPane

currentProposalView

protected ProposalView currentProposalView

statusBar

protected StatusBar statusBar

pendingAmendment

protected Proposal pendingAmendment

waitMessage

protected javax.swing.JLabel waitMessage

chatPanel

protected ChatPanel chatPanel

infoPanel

protected InfoPanel infoPanel

buttons

protected javax.swing.Box buttons

opinionYesButton

protected javax.swing.JButton opinionYesButton

opinionNoButton

protected javax.swing.JButton opinionNoButton

opinionMaybeButton

protected javax.swing.JButton opinionMaybeButton

opinionCancelButton

protected javax.swing.JButton opinionCancelButton

amendButton

protected javax.swing.JButton amendButton

retractButton

protected javax.swing.JButton retractButton

votePanel

protected VotePanel votePanel

gameRunning

protected boolean gameRunning

selectedProposal

protected Proposal selectedProposal

singlePlayerMode

protected static final boolean singlePlayerMode
See Also:
Constant Field Values

splash

protected static javax.swing.JFrame splash

luNames

public static final java.lang.String[] luNames

metrics

public static final java.lang.String[] metrics

roleNames

public static final java.lang.String[] roleNames

luColors

public static final java.awt.Color[] luColors

luColorNames

public static final java.lang.String[] luColorNames

hazardYellow

public static final java.awt.Color hazardYellow
Constructor Detail

Main

public Main()
Method Detail

cacheDlugImages

protected static void cacheDlugImages()

doAmendButton

public void doAmendButton()

doRetractButton

public void doRetractButton()

callForVote

public void callForVote(java.lang.String proposalID)
Specified by:
callForVote in interface GUIEvents

doEditButton

public void doEditButton()

askUserName

public java.lang.String askUserName()

makeUI

public void makeUI()

enableUI

public void enableUI()
Specified by:
enableUI in interface UI

disableUI

public void disableUI()
Specified by:
disableUI in interface UI

startBriefing

public void startBriefing(Briefing b)
Specified by:
startBriefing in interface DLUGUI

briefingEnded

public void briefingEnded()
Specified by:
briefingEnded in interface GUIEvents

pauseUI

public void pauseUI(java.lang.String message)
Specified by:
pauseUI in interface UI

unpauseUI

public void unpauseUI()
Specified by:
unpauseUI in interface UI

lostServer

public void lostServer()
Specified by:
lostServer in interface UI

getColor

public java.awt.Color getColor(Proposal p)
Specified by:
getColor in interface GUIEvents

getColor

public java.awt.Color getColor(Player p)
Specified by:
getColor in interface GUIEvents

getColor

public java.awt.Color getColor(int turnNumber)
Specified by:
getColor in interface GUIEvents

getColorName

public java.lang.String getColorName(int turnNumber)

getColor

public static java.awt.Color getColor(java.lang.String landuse)

getMapView

public MapView getMapView()
Specified by:
getMapView in interface GUIEvents

setSelectedProposal

public void setSelectedProposal(Proposal proposal)
Specified by:
setSelectedProposal in interface GUIEvents

setHelpContent

public void setHelpContent(java.lang.String location)
Specified by:
setHelpContent in interface GUIEvents

proposalDoubleClicked

public void proposalDoubleClicked(Proposal p)
Specified by:
proposalDoubleClicked in interface GUIEvents

plistRefreshed

public void plistRefreshed()
Specified by:
plistRefreshed in interface GUIEvents

editingComplete

public void editingComplete(Proposal p)
Specified by:
editingComplete in interface GUIEvents

getCurrentPlayer

public Player getCurrentPlayer()
Specified by:
getCurrentPlayer in interface GUIEvents

getPlayer

public Player getPlayer(int turnNumber)
Specified by:
getPlayer in interface GUIEvents

getRoot

public GameRoot getRoot()
Specified by:
getRoot in interface GUIEvents

gotUserMessage

public void gotUserMessage(java.awt.Color color)
Specified by:
gotUserMessage in interface GUIEvents

setNetClient

public void setNetClient(TurnClient client)

setNumber

public void setNumber(java.lang.String turnNumber)
Specified by:
setNumber in interface DLUGUI

availableGames

public void availableGames(java.lang.String[] gameList)
Specified by:
availableGames in interface DLUGUI

refreshGameList

public void refreshGameList()
Specified by:
refreshGameList in interface GUIEvents

rejoinGame

public void rejoinGame(java.lang.String name,
                       int requestedPlayer)
Specified by:
rejoinGame in interface GUIEvents

joinGame

public void joinGame(java.lang.String name,
                     int requestedPlayer)
Specified by:
joinGame in interface GUIEvents

createNewGame

public void createNewGame(java.lang.String name)
Specified by:
createNewGame in interface GUIEvents

joinedGame

public void joinedGame()
Specified by:
joinedGame in interface DLUGUI

beginSetupPhase

public void beginSetupPhase()
Specified by:
beginSetupPhase in interface DLUGUI

setRoot

public void setRoot(GameRoot root)
Specified by:
setRoot in interface DLUGUI

beginNegotiationPhase

public void beginNegotiationPhase()
Specified by:
beginNegotiationPhase in interface DLUGUI

indicateOpinion

public void indicateOpinion(java.lang.String val)

doneNotify

public void doneNotify(Player p)
Specified by:
doneNotify in interface DLUGUI

beginVotePhase

public void beginVotePhase()
Specified by:
beginVotePhase in interface GUIEvents

prepareForVotingOn

public void prepareForVotingOn(Proposal proposal)
Specified by:
prepareForVotingOn in interface DLUGUI

startVote

public void startVote()
Specified by:
startVote in interface DLUGUI

startVotingTimer

public void startVotingTimer()
Specified by:
startVotingTimer in interface DLUGUI

votingTimerExpired

public void votingTimerExpired()
Specified by:
votingTimerExpired in interface GUIEvents

castVote

public void castVote(Proposal p,
                     int vote)
Specified by:
castVote in interface GUIEvents

gameMessage

public void gameMessage(java.lang.String message)
Specified by:
gameMessage in interface DLUGUI

errorMessage

public void errorMessage(java.lang.String message)
Specified by:
errorMessage in interface DLUGUI

notifyUser

public void notifyUser(java.lang.String message)
Specified by:
notifyUser in interface DLUGUI

endVote

public void endVote()
Specified by:
endVote in interface DLUGUI

gameEnded

public void gameEnded()
Specified by:
gameEnded in interface DLUGUI

getPropViz

public java.util.HashMap getPropViz()
Specified by:
getPropViz in interface GUIEvents

setButtonStates

public void setButtonStates()

splash

public static void splash()

main

public static void main(java.lang.String[] args)