예제 #1
0
  public static void coreInit() throws IOException, FileNotFoundException, ClassNotFoundException {
    getData();
    getRelation();
    boolean playing = false;
    int choice = -1;

    while (!playing && choice != 0) {
      // Load Menu
      choice = Menu.getChoiceFromLoadingMenu();

      switch (choice) {
        case 1:
          Saver.load(objs, relations);
          MLogger.info("Data were loaded");
          break;
        case 2:
          addGod();
          break;
        case 3:
          addHuman();
          break;
        case 4:
          Saver.removeData();
          break;
        case 5:
          playing();
          playing = true;
          break;
      }
    }
  }
예제 #2
0
 public static void playing() throws IOException {
   MLogger.info("Game is starting! Good Luck!");
   MLogger.info("Updating gods container - " + objs.size());
   // updating gods container
   EntityContainer.updateData(objs, relations);
   Menu.getGameMenu();
   int choice = Integer.parseInt(Menu.inputConsole());
   int switching = -1;
   if (choice == 1) {
     while (switching != 0) {
       Menu.printList(EntityContainer.getListNameOfGods(), -1);
       choice = Integer.parseInt(Menu.inputConsole());
       MLogger.info("Choosing god with id - " + choice);
       switching = play(choice);
     }
     Saver.save(objs, relations);
   } else {
     Saver.save(objs, relations);
   }
 }
예제 #3
0
  public static boolean addGod() throws IOException {
    List<Object> objects = getData();
    List<Integer> rels = getRelation();

    int type = Integer.parseInt(Menu.printAddingGodMenu("type"));
    if (type != 1 && type != 2) return false;
    String name = Menu.printAddingGodMenu("name");
    int age = Integer.parseInt(Menu.printAddingGodMenu("age"));
    String power_name = Menu.printAddingGodMenu("power");
    int power_points = Integer.parseInt(Menu.printAddingGodMenu("power_points"));
    Power power = new Power(power_name, power_points);
    if (type == 1) {
      objects.add(new God(name, age, power, 1));
      rels.add(0);
      MLogger.info("God " + name + " was created and added");
    } else {
      objects.add(new SupremeGod(name, age, power, 1));
      rels.add(1);
      MLogger.info("Supreme God " + name + " was created and added");
    }
    return true;
  }