%   TTTStartGamePBCB.m
%   Description: 
%       This script will setup the TicTacToe figure ready for play if the
%   TicTacToe figure has never been started before. 
%       Otherwise, it will reset the game board and visuals.
%
%   Variables:
%       StartNewGame, boolean, keeps track of whether or not a new game
%           must be started because a current game is running
%       GameOver, boolean, keeps track of whether the current game is over
%          or not
%       MainGame, 3x3 matrix, board with values for X's and O's in
%           appropriate positions
%       DifficultyCBPushed, boolean, confirmation for whether or not to 
%           run a computer move
%       DifficultyLevel, integer, keeps track of current difficulty
%       CurrentTurn, char, keeps track of which mark is current (X or O)
%       CurrentPlayer, string, keeps track of who's turn it is
%
%   Team DATT "All DATT and dim sum."
%   11/17/05

if StartNewGame == true %First time Tic-Tac-Toe is running
    open('TicTacToe.fig')
    
    %Create Virtual Game Board and Game Conditions
    MainGame=[0,0,0;0,0,0;0,0,0];
    GameOver = false;
    StartNewGame = false;
    DifficultyCBPushed = false;
    
    %Set standard: Human goes first as X's
    CurrentTurn='X';
    CurrentPlayer='Human';

    %Set Standard Difficulty to Easy
    DifficultyLevel = 1; %Easy
    set(findobj('tag','DifficultyPB'),'string','Easy')

    close('TTTStartUp')
else

    %Reset virtual main board and display's main board
    for x = 1:9
        MainGame(x)=0;
        set(findobj('tag',strcat('Pos',num2str(x))),'string',' ')
    end

    %X's always go first
    CurrentTurn='X';
    GameOver = false;
    
    if get(findobj('tag','WhoGoesFirstCheckBox'),'value')==1
        CurrentPlayer = 'Compu';
        if DifficultyCBPushed == false %Does not run first computer move
                                       %if a Difficulty is not chosen
            TTTClickSquarePBCB
        end
    else
        CurrentPlayer = 'Human';
    end
end