/* Copyright Jim Brain and Brain Innovations, 2005. This file is part of QLinkServer. QLinkServer is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. QLinkServer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with QLinkServer; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @author Jim Brain Created on Jul 23, 2005 */ package org.jbrain.qlink.state; import java.io.*; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask; import org.apache.log4j.Logger; import org.jbrain.qlink.*; import org.jbrain.qlink.chat.*; import org.jbrain.qlink.cmd.action.*; import org.jbrain.qlink.user.QHandle; public class PlayGame extends AbstractPhaseState { private static Logger _log=Logger.getLogger(PlayGame.class); private static Timer _timer=new Timer(); /** * * @uml.property name="_intState" * @uml.associationEnd multiplicity="(0 1)" */ private QState _intState; private boolean _bSystemPickOrder; private String _sType; private String _sName; /** * * @uml.property name="_room" * @uml.associationEnd multiplicity="(0 1)" */ private QRoom _room; /** * * @uml.property name="_game" * @uml.associationEnd multiplicity="(0 1)" */ private Game _game; private boolean _bInvited; private int _iGameID; /** * * @uml.property name="_alInvitees" * @uml.associationEnd elementType="org.jbrain.qlink.cmd.action.GamePlayer" multiplicity= * "(0 -1)" */ private ArrayList _alInvitees = new ArrayList(); private TimerTask _timerTask; private boolean _bRequestRestart=false; private static final int PHASE_INVITE = 1; private static final int PHASE_ACCEPT_INVITE = 2; private static final int PHASE_PLAYING = 3; private static final int PHASE_REQUEST_LOAD = 4; protected static final int PHASE_LOADING = 5; protected static final int PHASE_READY_TO_START = 6; protected static final int PHASE_REQUEST_RESTART = 7; private class InviteTimeoutTask extends TimerTask { public void run() { SeatInfo info; SeatInfo[] seats; if(!_game.canContinue()) { // too much time has elapsed... _log.debug("Timeout occurred"); List l=_game.getAbstainList(); // did some folks not respond? if(l.size()>0) { // we have players not yet hooked to the game. seats=_game.getPlayers(); for(int i=0,size=seats.length;i