Exemplo n.º 1
0
  private void saveCurrent() {
    PrintWriter writer = null;

    try {
      writer = new PrintWriter("config.txt", "UTF-8");
      writer.println("PhoneNumbers:");

      for (String s : Main.getEmails()) {
        writer.println(s);
      }

      writer.println("Items:");

      for (Item s : Main.getItems()) {
        writer.println(s.getName() + "," + s.getWebsite());
      }

      results.setText("Current settings have been saved sucessfully.");
    } catch (FileNotFoundException e1) {
      e1.printStackTrace();
    } catch (UnsupportedEncodingException e1) {
      e1.printStackTrace();
    }

    writer.close();
  }
Exemplo n.º 2
0
  public void checkInput() {
    // SwingUtilities.invokeLater(new Runnable() {
    // public void run() {
    String text = inputText.getText();
    if (!text.equals("")) {
      appendToPane(text + "\n\n", Color.blue);
      inputText.setText("");
      if (text.startsWith("use ")) {
        ArrayList<Item> inventory = player.getInventory();
        String key = text.substring(4);
        boolean found = false;
        for (Item i : inventory) {
          if (i.getName().equalsIgnoreCase(key)) {
            found = true;
            i.use();
            break;
          }
        }
        if (!found) {
          appendToPane("Item does not exist in your iventory.\n\n", Color.black);
        } else {

        }
      }
      if (text.startsWith("inventory")) {
        ArrayList<Item> inventory = player.getInventory();
        if (inventory.size() > 0) {
          for (Item i : inventory) {
            appendToPane(i.getName() + "\n", Color.darkGray);
          }
        } else appendToPane("Your iventory is empty.\n\n", Color.black);
        appendToPane("#", Color.blue);
      } else {
        userInput = text;
      }
    }
    // }
    // });
  }
 /**
  * Uses an item on a game object.
  *
  * @param item the item to use
  * @param target the game object to be used on by the item
  * @return <tt>true</tt> if the "Use" action had been used on both the inventory item and the game
  *     object; otherwise <tt>false</tt>
  */
 public static boolean useItem(Item item, GameObject target) {
   if (item != null && target != null) {
     for (int i = 0, r = Random.nextInt(5, 8); i < r; i++) {
       if (!isItemSelected()) {
         if (item.interact("Use")) {
           for (int j = 0; j < 10 && !isItemSelected(); j++) {
             Task.sleep(100, 200);
           }
         } else {
           return false;
         }
       }
       // just make sure in case something bad happened
       if (isItemSelected()) {
         final String itemName = item.getName();
         final ObjectDefinition targetDef = target.getDef();
         final Model targetModel = target.getModel();
         if (targetDef != null && itemName != null && targetModel != null) {
           final String targetName = targetDef.getName();
           Mouse.move(targetModel.getNextPoint());
           final String action =
               "Use "
                   + itemName.replace("<col=ff9040>", "")
                   + " -> "
                   + targetName.replace("<col=ff9040>", "");
           for (int j = 0, s = Random.nextInt(5, 8); j < s; j++) {
             if (Menu.contains(action) && Menu.click(action)) {
               return true;
             } else {
               Mouse.move(targetModel.getNextPoint());
             }
           }
         }
         // kay, since that failed, let's try just use
         if (target.interact("Use")) {
           return true;
         }
       }
     }
   }
   return false;
 }
Exemplo n.º 4
0
  private void displayInformation() {
    results.setText("-Cell Phones-\n");
    if (Main.getEmails().isEmpty()) {
      results.append("\nNo Numbers");
    } else {
      ArrayList<String> emails = Main.getEmails();
      int index = 0;

      for (String s : emails) {
        index++;
        results.append("\n(" + index + ")   " + s);
      }
    }

    results.append("\n\n-Current Items-");
    if (Main.getItems().isEmpty()) {
      results.append("\n\nNo Items");
    } else {
      ArrayList<Item> items = Main.getItems();
      int index = 0;

      for (Item i : items) {
        String s = i.getWebsite().substring(46, i.getWebsite().length());

        index++;

        for (int j = 0; j < s.length(); j++) {
          if (s.substring(j, j + 1).equals("&")) {
            s = s.substring(0, j);
          }
        }

        results.append("\n\n(" + index + ")\nName: \t" + i.getName() + "\nItem: \t" + s);
      }
      results.append("\n\n");
    }
  }