Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////
- @Override
- public boolean processLine(String s) {
- // Split the line into tokens
- s = s.trim();
- if (s.length() == 0) {
- // Empty line, do nothing
- return true;
- }
- String[] tokens = s.trim().split("\\s+");
- // Convert the tokens to words. Build words. Exit if there
- // was an error
- List<Word> words = new ArrayList<Word>();
- for (String t : tokens) {
- Word w = findWord(t);
- if (!game.noiseWords.get(0).getWords().contains(w)) {
- words.add(w);
- }
- }
- if(words.size() == 0)
- game.specialMap.get("command.allnoise").println(game.messageOut, s);
- // Check for the correct number of words.
- if (words.size() > 2) {
- game.specialMap.get("command.toolong").println(game.messageOut, s);
- return true;
- }
- // Find an action
- Word word1 = words.get(0);
- Word word2 = (words.size() > 1) ? words.get(1) : null;
- Actions act = findAction(word1, word2);
- if (act == null) {
- if (word1 != null && word2 == null)
- game.specialMap.get("command.unknown.one").println(
- game.messageOut, word1.getWord());
- if (word1 != null && word2 != null)
- game.specialMap.get("command.unknown.two").println(
- game.messageOut, word1.getWord(), word2.getWord());
- return true;
- }
- return !doAction(act, game, word1, word2);
- }
- ////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement