Package nfc.sample.tictactoe.protocol

Examples of nfc.sample.tictactoe.protocol.ProtocolMessageMasterBid


    public void initNewGameMessaging() {
        try {
            // send bid message over SNEP
            proto = new GameProtocol(this);
            my_bid = new ProtocolMessageMasterBid();
            proto.sendMasterBid(my_bid);
            proto.listenForMessages();
        } catch(NFCException e) {
            Utilities.log("XXXX StartGameScreen:" + e.getClass().getName() + ":" + e.getMessage());
            Utilities.popupMessage("Error: separate devices and try again!");
View Full Code Here


        }
    }

    public void gameMessage(ProtocolMessage message) {
        if(message instanceof ProtocolMessageMasterBid) {
            ProtocolMessageMasterBid other_bid = (ProtocolMessageMasterBid) message;
            int device_status = 0;
            boolean initialised = false;
            if(my_bid.getBid() > other_bid.getBid()) {
                Utilities.log("XXXX won the bid: player 1");
                device_status = Constants.PLAYER_1;
                initialised = true;
            } else {
                if(my_bid.getBid() < other_bid.getBid()) {
                    Utilities.log("XXXX lost the bid: player 2");
                    device_status = Constants.PLAYER_2;
                    initialised = true;
                } else {
                    Utilities.popupMessage("It didn't work, try again!");
View Full Code Here

            game_state.setOther_bid_received(other_bid);
            // if we've received this message then one way or another it must be game over (maybe the other device has won)
            game_state.setGame_over(true);

            if(!game_state.isBid_sent()) {
                my_bid = new ProtocolMessageMasterBid();
                try {
                    proto.sendMasterBid(my_bid);
                    ok = true;
                } catch(NFCException e1) {
                    ok = false;
View Full Code Here

        }
        for(int i = 0; i < 3; i++) {
            tiles[win_line[i]].setImage(win_line_bmp);
        }
        game_state.setGame_over(true);
        my_bid = new ProtocolMessageMasterBid();
        try {
            proto.sendMasterBid(my_bid);
            proto.listenForMessages();
        } catch(NFCException e) {
            Utilities.log("XXXX " + e.getClass().getName() + ":" + e.getMessage());
View Full Code Here

            } else {
                tiles[i].setImage(stale_mate_nought_bmp);
            }
        }
        game_state.setGame_over(true);
        my_bid = new ProtocolMessageMasterBid();
        try {
            proto.sendMasterBid(my_bid);
            proto.listenForMessages();
        } catch(NFCException e) {
            Utilities.log("XXXX " + e.getClass().getName() + ":" + e.getMessage());
View Full Code Here

TOP

Related Classes of nfc.sample.tictactoe.protocol.ProtocolMessageMasterBid

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.