Advertisement
Guest User

Untitled

a guest
May 27th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.44 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////
  2. @Override
  3.     public boolean processLine(String s) {
  4.         // Split the line into tokens
  5.         s = s.trim();
  6.         if (s.length() == 0) {
  7.             // Empty line, do nothing
  8.             return true;
  9.         }
  10.         String[] tokens = s.trim().split("\\s+");
  11.         // Convert the tokens to words. Build words. Exit if there
  12.         // was an error
  13.         List<Word> words = new ArrayList<Word>();
  14.         for (String t : tokens) {
  15.             Word w = findWord(t);
  16.             if (!game.noiseWords.get(0).getWords().contains(w)) {
  17.                 words.add(w);
  18.             }
  19.                
  20.         }
  21.         if(words.size() == 0)
  22.             game.specialMap.get("command.allnoise").println(game.messageOut, s);
  23.         // Check for the correct number of words.
  24.         if (words.size() > 2) {
  25.             game.specialMap.get("command.toolong").println(game.messageOut, s);
  26.            
  27.             return true;
  28.         }
  29.         // Find an action
  30.         Word word1 = words.get(0);
  31.         Word word2 = (words.size() > 1) ? words.get(1) : null;
  32.         Actions act = findAction(word1, word2);
  33.  
  34.         if (act == null) {
  35.             if (word1 != null && word2 == null)
  36.                 game.specialMap.get("command.unknown.one").println(
  37.                         game.messageOut, word1.getWord());
  38.             if (word1 != null && word2 != null)
  39.                 game.specialMap.get("command.unknown.two").println(
  40.                         game.messageOut, word1.getWord(), word2.getWord());
  41.  
  42.             return true;
  43.         }
  44.         return !doAction(act, game, word1, word2);
  45.     }
  46.  ////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement