Logo Search packages:      
Sourcecode: filler version File versions  Download package

void friendless::games::filler::FillerModel::randomFill ( boolean  remoteGame  )  [inline, package]

Parameters:
remoteGame True if this is a game against a remote player.

Definition at line 382 of file FillerModel.java.

References friendless::games::filler::remote::IsMessage::getMessageId().

Referenced by friendless::games::filler::FillerBoard::restart().

                                        {
        if (remoteGame && !RemoteConnection.getInstance().isServer()) {
            // This is the client side of a game against a remote player.
            // We will wait for the NewGame message which carries the
            // board layout.
            try {
                IsMessage msg =
                    RemoteConnection.getInstance().receiveMessage();
                if (msg.getMessageId() == IsMessageID.MSGID_GAME_NEW) {
                    setPieces(((NewGameMessage) msg).getPieces());
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        } else {
            // This is not a remote game or we are the server side of
            // a remote game.
            for (int i=0; i<pieces.length; i++) {
                pieces[i] = (valid(i)) ? rng.nextInt(FillerSettings.NUM_COLOURS) : -1;
            }
            if (remoteGame) {
                try {
                    NewGameMessage msg = new NewGameMessage(pieces);
                    RemoteConnection.getInstance().sendMessage(msg);
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }
        }
    }


Generated by  Doxygen 1.6.0   Back to index