Class IslandFieldPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class IslandFieldPanel extends JPanel
Class necessary to print all the islands on GUI and perform all player's action that involve an island or islandGroup
See Also:
  • Field Details

    • model

      private final Model model
      Contains game's information
    • guiSocketListener

      private final GUISocketListener guiSocketListener
      Contains GuiReader's information necessary to record user's requests during his turn
    • entrancePositionToMove

      private OptionalValue<Integer> entrancePositionToMove
      Optional Integer containing student's index inside player's PlayerBoard's entrance (necessary when sending MoveStudentAction to Server)
    • selectedCharacterCard

      private OptionalValue<Integer> selectedCharacterCard
      Optional Integer containing card's index inside game (0 to 2), it can be empty if no characterCard has been played
    • pawnFromCharacterCard

      private OptionalValue<PawnColour> pawnFromCharacterCard
      Pawn from character card that player wants to move inside an island
    • actionType

      private ActionType actionType
      Status of islandField
  • Constructor Details

  • Method Details

    • setActionType

      public void setActionType(ActionType actionType, OptionalValue<Integer> toRemove)
      Method used for setting IslandFieldPanel's actionType from external panels
      Parameters:
      actionType - actionType that IslandFieldPanel will assume
      toRemove - PlayerBoard's entrance's index containing the student to move (Optional.empty if action type is not MOVESTUDENT)
    • getDimBoost

      private int getDimBoost(int IslandsNumbers)
      Support method used to increase islands' dimensions when the amount of IslandGroups decreases
      Parameters:
      IslandsNumbers - number of IslandGroups to show
      Returns:
      boost to add to original icons' dimensions
    • getMotherNatureSteps

      private int getMotherNatureSteps(ArrayList<IslandGroup> islandGroups, IslandGroup destinationIsland)
      Support method used to calculate difference between clicked islandGroup by user and actual motherNature's islandGroup
      Parameters:
      islandGroups - list of islandGroups present in game
      destinationIsland - IslandGroup that has been clicked by player
      Returns:
      number of steps that motherNature should perform to reach wished IslandGroup
    • iconToImage

      private Image iconToImage(Icon icon)
      Support method to extract Image from icon
      Parameters:
      icon - icon to convert
      Returns:
      image represented by icon
    • setCharacterCardAction

      public void setCharacterCardAction(ActionType actionType, OptionalValue<Integer> card, OptionalValue<PawnColour> toMove)
      Basing on CharacterCard that has been activated, this method setup IslandFieldPanel for send the right PlayerActionRequest to Server
      Parameters:
      actionType - ActionType that IslandFieldPanel is going to switch to
      card - card's index inside game
      toMove - possible pawn to move