Class ViewCLI

java.lang.Object
fr.formiko.views.ViewCLI
All Implemented Interfaces:
fr.formiko.usual.Progression, View

public class ViewCLI extends Object implements View
View Console Line Interface.
Author:
Hydrolien
  • Field Details

    • scannerAnswer

      private Scanner scannerAnswer
    • tToPrint

      private String[] tToPrint
    • cLIMap

      private CLIMap cLIMap
    • sep

      private static String sep
    • actionGameOn

      private boolean actionGameOn
  • Constructor Details

    • ViewCLI

      public ViewCLI()
  • Method Details

    • getActionGameOn

      public boolean getActionGameOn()
      Specified by:
      getActionGameOn in interface View
    • ini

      public boolean ini()
      Initialize all the thing that need to be Initialize before using view.
      Specified by:
      ini in interface View
      Returns:
      Return true if it work well. (Nothing goes wrong.)
    • close

      public boolean close()
      close all the thing that need to be close after using view.
      Specified by:
      close in interface View
      Returns:
      Return true if it work well. (Nothing goes wrong.)
    • paint

      public boolean paint()
      Refrech actual view.
      Specified by:
      paint in interface View
      Returns:
      Return true if it work well. (Nothing goes wrong.)
    • actionGame

      public boolean actionGame()
      Launch action game part.
      Specified by:
      actionGame in interface View
      Returns:
      Return true if it work well. (Nothing goes wrong.)
    • pauseActionGame

      public int pauseActionGame()
      Stop game and print the escape menu.
      This action can only be run if action game is on.
      Specified by:
      pauseActionGame in interface View
      Returns:
      Return true if it work well. (Nothing goes wrong.)
    • endActionGame

      public boolean endActionGame(boolean withButton, int nextLevel, String message, GJoueur gj, boolean canResumeGame)
      Stop game and print the end menu.
      This action can only be run if action game is on.
      Specified by:
      endActionGame in interface View
      Parameters:
      withButton - true if we need to add button "return to main menu" and "next level".
      nextLevel - the number of the next level to link to the button. -1 = no next level.
      message - message to print.
      gj - sorted player list to print.
      Returns:
      Return true if it work well. (Nothing goes wrong.)
    • setLookedCCase

      public boolean setLookedCCase(CCase cc)
      Change the value of the loked Case.
      We need to repaint the information about this Case.
      This action can only be run if action game is on.
      Specified by:
      setLookedCCase in interface View
      Returns:
      Return true if it work well. (Nothing goes wrong.)
    • getLookedCCase

      public CCase getLookedCCase()
      Return the value of the looked CCase.
      This action can only be run if action game is on and cLIMap have been created.
      Specified by:
      getLookedCCase in interface View
      Returns:
      lookedCCase.
    • getCCase

      public CCase getCCase()
      get a CCase from the payer.
      It read Strings like this: "b13", "2c"
      This action can only be run if action game is on.
      Specified by:
      getCCase in interface View
      Returns:
      Selected CCase or null if it fail.
    • getAntChoice

      public int getAntChoice(int[] t)
      Return the chosen value for ant action.
      This action can only be run if action game is on.
      Specified by:
      getAntChoice in interface View
      Returns:
      Return ant choice.
    • message

      public void message(String message, boolean doWeNeedToDoNextCmdNow)
      Print a message.
      If message.equals("") we may need to delete last message, but we don't need to print a new message.
      Specified by:
      message in interface View
      Parameters:
      message - the message to print
      doWeNeedToDoNextCmdNow - true if we need to do next commande now.
    • loadingMessage

      public void loadingMessage(String message, int percentageDone)
      Print a loading message.
      Specified by:
      loadingMessage in interface View
      Parameters:
      message - the message to print.
      percentageDone - the percentage of loading curently done.
    • popUpMessage

      public void popUpMessage(String message)
      Print a message in a new window.
      Specified by:
      popUpMessage in interface View
      Parameters:
      message - the message to print.
    • popUpQuestion

      public String popUpQuestion(String message)
      Print a question in a new window.
      Specified by:
      popUpQuestion in interface View
      Parameters:
      message - the message to print.
      Returns:
      the answer.
    • popUpQuestionYN

      public boolean popUpQuestionYN(String message, boolean important, fr.formiko.usual.CheckFunction cf)
      Print a question in a new window.
      Specified by:
      popUpQuestionYN in interface View
      Parameters:
      message - the message to print.
      important - some gui action will be done if true
      cf - CheckFunction to use to get text, default checked & launch function
      Returns:
      the answer.
    • setPlayingAnt

      public void setPlayingAnt(Fourmi f)
      set playing ant.
      This action can only be run if action game is on.
      Specified by:
      setPlayingAnt in interface View
    • move

      public void move(ObjetSurCarteAId o, CCase from, CCase to)
      move ObjetSurCarteAId.
      This action can only be run if action game is on.
      This action do noting on view cli.
      Specified by:
      move in interface View
      Parameters:
      o - object to move.
      from - CCase that o leave.
      to - CCase were o is going.
    • setDownloadingMessage

      public void setDownloadingMessage(String message)
      Update downloading message.
      Specified by:
      setDownloadingMessage in interface fr.formiko.usual.Progression
    • setMoveMode

      public void setMoveMode(boolean b)
      Default fontion to move.
      Specified by:
      setMoveMode in interface View
    • getAntFromFere

      private Fourmi getAntFromFere()
      Select an ant from playingAnt anthill.
    • printActionMenu

      private void printActionMenu()
      Print all action aviable in a menu.
    • printArray

      private void printArray()
      Print tToPrint.
    • printMap

      private void printMap()
      Print map of the actual Partie.
    • printFereInColor

      private void printFereInColor()
      Print anthill of the playing ant.
    • getAllyAntInColor

      private String getAllyAntInColor(Creature c)
      Return the color depending of the status of c for playingAnt.
      Parameters:
      c - The Creature to inspect to know if it is ally, enemy or neutral (or equals to playingAnt).
    • getActionMenu

      private int getActionMenu(int maxValue)
      Return an aviable action in a menu.
      stop stop the game. cheat alowed to write 1 cheat code.
    • getIntBetween

      private int getIntBetween(int minValue, int maxValue)
      Return an int between minValue & maxValue.
      stop stop the game. cheat alowed to write 1 cheat code.
    • getSaveName

      private String getSaveName()
      Ask a save name to the user.
      If nothing is choose, save will have defaultName.
      Save name will be file save for every os.
    • getCCaseFromString

      public CCase getCCaseFromString(String s)
      transforme a String to a CCase and return it.
      This action can only be run if action game is on.
      Parameters:
      s - String like this: "b13", "2c"
      Returns:
      Selected CCase or null if it fail.
    • makeUserChooseOnArray

      public String makeUserChooseOnArray(String[] array, String varName)
      Make user choose in a String array.
      Specified by:
      makeUserChooseOnArray in interface View
      Parameters:
      array - the array where to choose
      varName - the name of the variable tp choose