package com.covoex.qarvox.Application;

import com.covoex.qarvox.Logic.GameCharacter;
import com.covoex.qarvox.Logic.Person;

import java.util.ArrayList;
import java.util.Collections;

import static com.covoex.qarvox.Application.Input.s;
import static com.covoex.qarvox.Application.Input.worldInput;

/**
 * @author Myeongjun Kim
 */

public class BasicFunction {
    public static Person mainCharacter = new Person();

    public static void programStart() {
        System.out.println("----------------------------------------------------------------------------------");
        System.out.println("----------------------------------------------------------------------------------");
        System.out.println("Qarvox is a text-based java RPG Game created by Myeongjun Kim");
        System.out.println("----------------------------------------------------------------------------------");
        System.out.println("");
        System.out.print("Press [any key] and [Enter] to play the game" + ": ");

        if (String.valueOf(s.nextLine()).matches(".")) {
            System.out.println();
            System.out.print("Type in your character's name" + ": ");
            mainCharacter.setName(s.nextLine());
            System.out.println();
            System.out.print(
                    "Do you want to play the tutorial? Press [y] or [n] and [Enter]" + ": ");
            if (s.nextLine().equals("y")) {
                Tutorial.tutorial();
            } else if (s.nextLine().equals("n")) {
                System.out.print("What world do you want to go? World: ");
                worldInput(s.nextInt());
            }
        }
    }

    /**
     * @return randomstring
     */
    public static String getRandomString() {
        String baseString = "abcdjfghijklmnopqrstuvwxyz";
        String string = "";

        for (int i = 0; i < 5; i++) {
            int value = (int) (Math.random() * 100);
            while (value > 26) {
                value = (int) (Math.random() * 100);
                if (value <= 25) {
                    break;
                }
            }
            string += baseString.charAt(value);
        }
        return string;
    }

    public static void printHealthGauge(GameCharacter c) {
        String returnString = "";
        String addString = "";
        for (int i = 0; i < (c.getInitialHealth() - c.getHealth()); i++) {
            addString += " ";
        }
        for (int i = 0; i < c.getHealth(); i++) {
            returnString += '\u0254';
        }
        System.out.println("[" + returnString + addString + "]");
    }

    /**
     * get random int between [-1 - 1]
     */
    public static int randomInt() {
        ArrayList<Integer> arrayList = new ArrayList<>();
        arrayList.add(-1);
        arrayList.add(0);
        arrayList.add(1);
        Collections.shuffle(arrayList);
        return arrayList.get(0);
    }

    public static boolean fiftyFifty() {
        ArrayList<Integer> arrayList = new ArrayList<>();
        arrayList.add(0);
        arrayList.add(1);
        Collections.shuffle(arrayList);
        return arrayList.get(0).equals(0);
    }
}
@@ -292,16 +292,79 @@
 ldInput;
+%0Aimport static com.covoex.qarvox.Application.Tutorial.tutorial;
 %0A%0A/**%0A *
@@ -610,142 +610,8 @@
 ----
---------------------%22);%0A        System.out.println(%22----------------------------------------------------------------------------------
 %22);%0A
@@ -699,16 +699,17 @@
 gjun Kim
+.
 %22);%0A    
@@ -794,36 +794,16 @@
 --------
----
------------------
 %22);%0A    
@@ -825,18 +825,16 @@
 println(
-%22%22
 );%0A     
@@ -1270,32 +1270,33 @@
 nter%5D%22 + %22: %22);%0A
+%0A
             if (
@@ -1299,31 +1299,16 @@
 if (
-s.nextLine().equals(%22y%22
+yesOrNo(
 )) %7B
@@ -1324,25 +1324,16 @@
         
-Tutorial.
 tutorial
@@ -1359,39 +1359,47 @@
 lse 
-if (s.nextLine().equals(%22n%22)) %7B
+%7B%0A                System.out.println();
 %0A   
@@ -2039,32 +2039,32 @@
 lue);%0A        %7D%0A
-
         return s
@@ -2069,32 +2069,381 @@
  string;%0A    %7D%0A%0A
+    public static boolean yesOrNo() %7B%0A        String string = s.nextLine();%0A        if (string.contains(%22y%22)) %7B%0A            return true;%0A        %7D else if (string.contains(%22n%22)) %7B%0A            return false;%0A        %7D else %7B%0A            System.out.print(%22Press %5By%5D or %5Bn%5D and %5BEnter%5D: %22);%0A            yesOrNo();%0A        %7D%0A        return false;%0A    %7D%0A%0A
     public stati

Optimized the code