Package com.svanloon.game.wizard.network

Examples of com.svanloon.game.wizard.network.MessageParam


    return msg;
  }

  private Message handleScore(ScoreEvent e) {
    Message msg = new Message(MessageType.SCORE_EVENT);
    msg.addMsgParam(new MessageParam(MessageParamConstants.SCORE, String.valueOf(e.getScoreChangeAmount())));
    handlePlayerEvent(e, msg);
    return msg;
  }
View Full Code Here


    return msg;
  }

  private void handlePlayerEvent(PlayerEvent e, Message msg) {
    //msg.addMsgParam(new MessageParam(MessageParamConstants.PLAYER_NAME, e.getPlayerName()));
    msg.addMsgParam(new MessageParam(MessageParamConstants.PLAYER_ID, String.valueOf(e.getPlayerId())));
  }
View Full Code Here

      int max = findParameterAsInt(MessageParamConstants.MAX, mps);
      int bidNotAllowed = findParameterAsInt(MessageParamConstants.BID_NOT_ALLOWED, mps);
      int bid = player.bid(card, min, max, bidNotAllowed);

      responseMessageType = MessageType.BID;
      responseMps.add(new MessageParam(MessageParamConstants.BID, String.valueOf(bid)));
     
    //} else if (cc.equals(CommandConstants.GET_HAND)) {
   
    } else if (cc.equals(MessageType.GIVE_CARD)) {
      Card card = getCard(mps);
      player.giveCard(card);
      responseMessageType = MessageType.OK;
    } else if (cc.equals(MessageType.PICK_TRUMP)) {
      Suit suit = player.pickTrump();
      responseMessageType = MessageType.OK;
      responseMps.add(new MessageParam(MessageParamConstants.SUIT, suit.getShortName()));
    } else if (cc.equals(MessageType.PLAY_CARD)) {
      Card card = player.playCard();
      responseMessageType = MessageType.OK;
      responseMps.add(new MessageParam(MessageParamConstants.SUIT, card.getSuit().getShortName()));
      responseMps.add(new MessageParam(MessageParamConstants.VALUE, card.getValue().getShortNm()));
    } else if (cc.equals(MessageType.PLAY_CARD_IS_NOT_VALID)) {
      Card card = getCard(mps);
      player.playCardIsNotValid(card);
      responseMessageType = MessageType.OK;
    } else if (cc.equals(MessageType.PLAY_CARD_IS_VALID)) {
View Full Code Here

  public int bid(Card trump, int min, int max, int notAllowedToBid) {
    try {
      Message message = new Message(MessageType.BID);
      ms.addCard(message, trump);
      message.addMsgParam(new MessageParam(MessageParamConstants.MIN, String.valueOf(min)));
      message.addMsgParam(new MessageParam(MessageParamConstants.MAX, String.valueOf(max)));
      message.addMsgParam(new MessageParam(MessageParamConstants.BID_NOT_ALLOWED, String.valueOf(notAllowedToBid)));
      return ms.getInt(message);
    } catch (IOException e) {
      e.printStackTrace();
    }
    return 0;
View Full Code Here

    return np;
  }

  private Message createGetNameMessage(int id, int eventPort, int commandPort, int messengerPort, GameOptions pGo) {
    Message msg = new Message(MessageType.GET_NAME);
    msg.addMsgParam(new MessageParam(MessageParamConstants.PLAYER_ID, String.valueOf(id)));
    msg.addMsgParam(new MessageParam(MessageParamConstants.COMMAND_PORT, String.valueOf(commandPort)));
    msg.addMsgParam(new MessageParam(MessageParamConstants.EVENT_PORT, String.valueOf(eventPort)));
    msg.addMsgParam(new MessageParam(MessageParamConstants.MESSENGER_PORT, String.valueOf(messengerPort)));
    msg.addMsgParam(new MessageParam(MessageParamConstants.NUMBER_OF_PLAYERS, String.valueOf(pGo.getTotalNumberOfPlayers())));
    return msg;
  }
View Full Code Here

    Message message;
    try {
      mr2 = new MessageReceiver(ip, initialConnectionPort);
      message = mr2.receive();
      Message response = new Message(MessageType.GET_NAME);
      response.addMsgParam(new MessageParam(MessageParamConstants.PLAYER_NAME, name));
      mr2.sendMessage(response);
      mr2.close();
    } catch (UnknownHostException e2) {
      e2.printStackTrace();
      return;
View Full Code Here

TOP

Related Classes of com.svanloon.game.wizard.network.MessageParam

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.