/*
 *  CPS108 Spring 1998
 *  Boggle: BoggleViewImpl.java
 *  Brian Fan & Geoff Berry
 */

package boggle;
import java.io.*;
import java.util.*;

public class BoggleViewImpl implements BoggleView
{
    private BoggleGUI myGUI;

    public BoggleViewImpl()
    {
	myGUI = new BoggleGUI("Brian");
	System.out.println("BoggleViewImpl constructed");
    }

    public void setup()
    {
	System.out.println("BoggleViewImpl: setup called");
    }

    public String getName()
    {
	return "Brian";
    }

    public void setOpponents(String[] players)
    {
	System.out.println("BoggleViewImpl: setOpponents called");
	for (int i=0; i<players.length; i++)
	{
	    System.out.println("  " + players[i]);
	}
    }

    public void startWaiting(int seconds)
    {
    }

    public void startCountdown(int seconds)
    {
    }

    public void initializeBoard(char[][] board)
    {
	myGUI.setBoard(board);
    }

    public void startGame(int seconds)
    {
	System.out.println("BoggleViewImpl: Game officially started");
    }

    public void endGame()
    {
	System.out.println("BoggleViewImpl: endGame called");
    }

    public String[] getGuesses()
    {
	String[] temp = myGUI.getGuesses();
	String[] temp2 = { "none" };
	if (temp != null)
	    { return temp; }
	else
	    { return temp2; }
    }

    public void showMessage(String message)
    {
	System.out.println("BoggleViewImpl: showMessage called");
	System.out.println("  " + message);
    }

    public void showResults(String[] winners,
			    String[] common, String[] missed)
    {
	System.out.println("BoggleViewImpl: showResults called");
	int i;
	System.out.println("  Winners:");
	for (i=0; i<winners.length; i++)
	{
	    System.out.println("    " + winners[i]);
	}
	System.out.println("  Common:");
	for (i=0; i<common.length; i++)
	{
	    System.out.println("    " + common[i]);
	}
	System.out.println("  Missed:");
	for (i=0; i<missed.length; i++)
	{
	    System.out.println("    " + missed[i]);
	}
    }

    public void tick(int count)
    {
	myGUI.tick();
    }
}
