Beispiel #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;
      }
    }
  }
Beispiel #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);
   }
 }
Beispiel #3
0
  public static int play(int choice) throws IOException {
    int cl_id = EntityContainer.getClassId(choice);
    boolean in_play = true;
    GodEntity enemy;
    String[] rels = Saver.getRelations();
    GodEntity god;
    String ch;
    if (rels[cl_id].equals("God")) {
      god = (God) EntityContainer.getGod(choice);
    } else {
      god = (SupremeGod) EntityContainer.getGod(choice);
    }
    god.introduce();
    EntityContainer.current_god = god;
    EntityContainer.current_god_id = choice;
    Menu.next();
    while (in_play) {
      Menu.getGodOption(god);
      ch = Menu.inputConsole();
      if (ch.equals("1")) {
        System.out.println("--- Choose God to atack ---");
        Menu.printList(EntityContainer.getListNameOfGods(), EntityContainer.current_god_id);
        ch = Menu.inputConsole();
        if (rels[EntityContainer.getClassId(Integer.parseInt(ch))] == "God") {
          enemy = (God) EntityContainer.getGod(Integer.parseInt(ch));
        } else {
          enemy = (SupremeGod) EntityContainer.getGod(Integer.parseInt(ch));
        }
        god.atack(enemy);
        Menu.next();
      } else if (ch.equals("2")) {
        System.out.println("--- Choose Human ---");
        List<Human> humans = EntityContainer.getUnreligiousHumans();
        Menu.printHumanList(humans);
        ch = Menu.inputConsole();
        int h_index = Integer.parseInt(ch);
        if (h_index >= humans.size()) return 0;
        Human human = humans.get(h_index);
        human.setBehavior(new ReligiousHumanRank());
      } else if (ch.equals("4")) {
        System.out.println("--- Choose God to atack ---");
        Menu.printList(EntityContainer.getListNameOfGods(), EntityContainer.current_god_id);
        ch = Menu.inputConsole();
        if (rels[EntityContainer.getClassId(Integer.parseInt(ch))] == "God") {
          enemy = (God) EntityContainer.getGod(Integer.parseInt(ch));
        } else {
          enemy = (SupremeGod) EntityContainer.getGod(Integer.parseInt(ch));
        }
        god.atack(enemy);
        Menu.next();
      } else if (ch.equals("5") && god.getClassName().indexOf(".SupremeGod") != -1) {
        ((SupremeGod) god).heal();
        Menu.next();
      } else if (ch.equals("3")) {
        return 1;
      } else if (ch.equals("0")) return 0;
      humanStepsInit();
    }

    return 0;
  }