Package clueless.events

Examples of clueless.events.TextStatusEvent


        makeSuggestion.setEnabled(true);
        endTurn.setEnabled(true);
      }

      //Print some diagnostics
      this.controller.fireTextStatusEvent(new TextStatusEvent(this, "Received hand."));
      jfrm.repaint();
      //Display the hand
      //Card[] cards = ((Card[])((Vector<Card>)gameInit.getHand()).toArray());
      //this.hand.displayHand(cards);
View Full Code Here


          if(firstPlayer == null){
            // Miss Scarlet is not in play so just choose someone to go first.
            firstPlayer = game.getPlayers().get(0);
          }
          currentPlayer = firstPlayer;
          this.fireTextStatusEvent(new TextStatusEvent(this, "Player "+ firstPlayer.getCharacter().toString() + " will go first. "));
         
          // Game on - start first turn.
          HallwayName hallwy = BoardView.getDefaultHall(currentPlayer.getCharacter());
          Hallway currHallwy = null;
          for(Location space : game.getSpaces()){
            if(space.getLocationType() == LocationType.HALLWAY_TYPE){
              if(((Hallway)space).getHallwayName() == hallwy){
                currHallwy = (Hallway)space;
              }
            }
          }
          server.send(currentPlayer, new AvailableMoveMessage(game.getValidMoves(currHallwy), currentPlayer.getCharacter()));
        }
      }
    }else if(event.getMessage() instanceof EndTurnMessage){
      if(isServer){
        //Move to the next player when we receive this message
        this.getNextPlayer();
        //TODO: Send available move message?  This still needs to be tested
        for(Location location : game.getSpaces()){
          Player player = location.getPlayer();
          if(player != null){
            if(player.getUUID().equals(currentPlayer.getUUID())){
              server.send(currentPlayer, new AvailableMoveMessage(game.getValidMoves(location), currentPlayer.getCharacter()));
              fireTextStatusEvent(new TextStatusEvent(this, "It is now " + currentPlayer.getCharacter() + "'s turn."))
            }
          }
        }
      }
      return;
View Full Code Here

    else //otherwise, fired by AccusationView and it contains an actual theory
    {
      //if host, pass message to clients indicating the suggestion being made, and whether it was correct
      if(isServer)
      {
        this.fireTextStatusEvent(new TextStatusEvent(this, theory.getTheoryText()));
        //check if theory is correct
        boolean isTheoryCorrect = testTheory(theory);
        if(isTheoryCorrect){
          this.fireTextStatusEvent(new TextStatusEvent(this, "Case Solved!"));
          //System.out.println("Case Solved!");
          // Do something like end game?
          server.sendAll(new EndGameMessage(currentPlayer));
        }
        else
        {
          this.fireTextStatusEvent(new TextStatusEvent(this, "Theory was incorrect."));
        }
         
        //AccusationMessage accusationMsg = new AccusationMessage(theory);
        //this.server.sendAll(accusationMsg);
        //this.getNextPlayer();
View Full Code Here

      msg.setPlayer(client.getPlayer());
      client.send(msg);
    }
    else //otherwise, fired by SuggestionView and it contains an actual theory
    {
      this.fireTextStatusEvent(new TextStatusEvent(this, theory.getTheoryText()));
      if(isServer)
      {
        //Inject player as theorist if null
        if(theory.getTheorist() == null)
          theory = new Theory(Theory.Type.SUGGESTION, theory.getWeapon(), theory.getCharacter(), theory.getLocation(), this.currentPlayer); //this.client.getPlayer());
       

        //TODO:  Shouldn't this only check the immediately next player, unless they have none of the cards in question?
       
        for(Player player : this.game.getPlayers())
        {
          if(!player.equals(currentPlayer))
          {
            Vector<Card> hand = player.getHand();
            LinkedList<Card> invalidCards = new LinkedList<Card>();
            for(Card card : hand){
              switch(card.getCardType()){
              case WEAPON_CARD:
                if(theory.getWeapon().getWeaponType().equals(((WeaponCard)card).getWeaponType())){
                  invalidCards.add(card);
                }
                break;
              case CHARACTER_CARD:
                if(theory.getCharacter().getCharacterName().equals(((CharacterCard)card).getCharacterName())){
                  invalidCards.add(card);
                }
                break;
              case LOCATION_CARD:
                if(theory.getLocation().getRoomName().equals(((LocationCard)card).getLocationName())){
                  invalidCards.add(card);
                }
                break;
              }
             
            }
            if(invalidCards != null){
              if(invalidCards.size()==1) {
                // This player has one of the suggestion cards, notify the suggester AND let everyone else know at least one card in the suggestion is wrong.
                server.send(theory.getTheorist(), new SuggestionDisprovedCardMessage(player, invalidCards.get(0)));
                server.sendAll(new SuggestionDisprovedMessage(player, theory));
                return;
              } else if(invalidCards.size()>1) {
                // This player has more than one card - we need them to decide which one to show the suggester.
                this.fireSuggestionDisprovedNeedFeedBackEvent(new SuggestionDisprovedNeedFeedBackEvent(this, theory, invalidCards));
                server.sendAll(new SuggestionDisprovedMessage(player, theory));
                server.send(player, new SuggestionDisprovedNeedFeedBackMessage(theory, invalidCards));
                return; //If we hit 1 result, it moves to the next player's turn. Not all cards in the suggestion get proved.
              }
              fireTextStatusEvent(new TextStatusEvent(this, "Theory disproven."));
            }
          }
        }
      }
      else
View Full Code Here

      //Game already instantiated and cards already dealt so we can assign players that
      event.getClient().setPlayer(this.game.getPlayers().get(server.getNumClients()-1));
      if(game.getNumberOfPlayers()==server.getNumClients())
      {
        this.fireTextStatusEvent(new TextStatusEvent(this, "Last player joined."));
        //Once number of clients connect = number of players in the game,
        //send game init message which includes hands
        for(Player player : this.game.getPlayers())
        {
          server.send(player, new GameInitializationMessage(player.getHand(), (player.getUUID().equals(this.getCurrentPlayer()))));
          //server.getClientThread(player)
          //server.send(player, new SendClientPlayerMessage(player));
          //System.out.println("playerSent: " + player.getCharacter());
        }
      }
      else
      {
        //TODO: update clients on how many more players we're waiting on
        String gameStatusText = "There are currently " + server.getNumClients() + " players connected.  Waiting for " + (this.game.getNumberOfPlayers()-server.getNumClients()) + " more players to join.";
        this.fireTextStatusEvent(new TextStatusEvent(this, gameStatusText));
      }
    }


View Full Code Here

  public void handleEndTurnEvent(EndTurnEvent event) {
    /**Send message to server indicating players turn is over */
    if(isServer)
    {
      //server.send(currentPlayer, new EndTurnMessage());
      this.fireTextStatusEvent(new TextStatusEvent(this, currentPlayer.getCharacter() + "'s turn is over."));
    }
    client.send(new EndTurnMessage());
   
  }
View Full Code Here

TOP

Related Classes of clueless.events.TextStatusEvent

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.