repl.it
@LakshayCodez/

UltimateDice2.0

Java

No description

fork
loading
Files
  • Main.java
  • jdt.ls-java-project
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
import java.util.*;
class Main {
    public static void rollBot() {
    clearScreen();
    String c2a = " ";
    int rt1 = 0;
    int rt2 = 0;
    int rt3 = 0;
    while(!c2a.equals("")||rt1>0||rt2>0||rt3>0){
      clearScreen();
      if(rt2>0){
        System.out.println("You chose to play again!");
      }
      if(rt1>0){
        System.out.println("Incorrect Input: Type roll");
      }
      if(rt3>0){
        System.out.println("Incorrect Input: Type Y or N");
      }
      System.out.println("Welcome to RollBot");
      System.out.println("Press enter to begin");
      rt1 = 0;
      rt2 = 0;
      rt3 = 0;
      Scanner c2 = new Scanner(System.in);
      c2a = c2.nextLine();
      if(c2a.equals("")){
        clearScreen();
        System.out.println("Try to get a higher score than RollBot");
        System.out.println("Type roll to roll the dice to a number in between 1 and 10.");
        Scanner c3 = new Scanner(System.in);
        String c3a = c3.nextLine();
        if(c3a.equals("roll")){
          System.out.println("Your Turn!");
          waitTime(1);
          double c3b = (((Math.random())*10))+1;
          int c3ba = (int)c3b;
          System.out.println("___");
          System.out.println("|"+c3ba+"|");
          System.out.println("‾‾‾");
          waitTime(1);
          System.out.println("RollBot's Turn!");
          waitTime(1);
          double c3c = (((Math.random())*10))+1;
          int c3ca = (int)c3c;
          System.out.println("___");
          System.out.println("|"+c3ca+"|");
          System.out.println("‾‾‾");
          waitTime(1);
          if(c3ba>c3ca){
            System.out.println("You Win!");
          }else if(c3ba<c3ca){
            System.out.println("You Lose!");
          }else if(c3ba==c3ca){
            System.out.println("You Tied!");
          }
          System.out.println("Do you want to play again!![Y,N]");
          Scanner c4 = new Scanner(System.in);
          String c4a = c4.nextLine();
          if(c4a.equals("Y")){
            rt2 = 1;
          }else if(c4a.equals("N")){
            System.out.println("Ok, Bye!!");
            waitTime(2);
            System.out.println("Redirecting...");
            waitTime(1);
          }else{
            rt3 = 1;
          }
        }else{
          rt1 = 1;
        }
      }else{
        System.out.println("You have to press ENTER!");
      }
    }
  }
    public static void clearScreen() {  
    System.out.print("\033[H\033[2J");  
    System.out.flush();  
  }  
    public static void main(String[] args) {
    int beg = 0;
    while(beg==0){
      clearScreen();
      System.out.println("Welcome to Ultimate Dice 2.0!!");
      System.out.println("The future to rolling dice!");
      System.out.println("===============================");
      System.out.println("1. I just want to roll dice.");
      System.out.println("2. 1v1 against RollBot");
      System.out.println("3. Leave");
      Scanner c1 = new Scanner(System.in);
      int c1a = c1.nextInt();
      if(c1a==2){
        System.out.println("Redirecting...");
        waitTime(1);
        rollBot();
        beg=0;
      }else if(c1a==1){
        System.out.println("Redirecting...");
        waitTime(1);
        rollDice();
        beg=0;
      }else if(c1a==3){
        System.out.println("GOODBYE!!!");
        waitTime(2);
        leavMess();
        beg = 1;
      }else{
        System.out.println("Incorrect Input:"+c1a);
        waitTime(1);
        System.out.println("Redirecting...");
        waitTime(1);
      }
    }
  }
    public static void rollDice(){
      int rg1 = 0;
      int rg2 = 1;
      int rg3 = 1;
      while(rg1==0||rg2==0||rg3==0){
        clearScreen();
        if(rg2==0){
          System.out.println("Your maximum is less than your minimum!!");
        }
        if(rg3==0){
          System.out.println("Your roll goal is outside your maximum or minimum!!");
        }
        rg1 = 1;
        rg2 = 1;
        rg3 = 1;
        System.out.println("You just want to roll dice!");
        System.out.println("What is your maximum roll?");
        Scanner c5 = new Scanner(System.in);
        int max = c5.nextInt();
        System.out.println("What is your minimum roll?");
        Scanner c6 = new Scanner(System.in);
        int min = c6.nextInt();
        if(max>=min){
          System.out.println("What is your roll goal?");
          Scanner c7 = new Scanner(System.in);
          int rolgol = c7.nextInt();
          if(rolgol<=max && rolgol>=min){
            System.out.println("Do you want to do automatic or manual??[A or M]");
            Scanner c8 = new Scanner(System.in);
            String c8a = c8.nextLine();
            if(c8a.equals("A")){
              int stop = 0;
              int rollnum = 0;
              while(stop==0){
                rollnum++;
                System.out.println("Rolling...");
                waitTime(1);
                System.out.println("Roll #"+rollnum);
                double c8b = (((Math.random())*max))+min;
                int c8c = (int)c8b;
                System.out.println("___");
                System.out.println("|"+c8c+"|");
                System.out.println("‾‾‾");
                if(c8c==rolgol){
                  System.out.println("You win!!");
                  waitTime(3);
                  System.out.println("Redirecting...");
                  waitTime(1);
                  stop=1;
                }else{
                  System.out.println("Try again!!");
                  waitTime(1);
                }
              }
            }else if(c8a.equals("M")){
              int stop2 = 0;
              int rollnum1 = 0;
              int c9b = 1;
              int lea1 = 0;
              int ask = 0;
              clearScreen();
              while(stop2==0||c9b==0||lea1==0){
                if(c9b==0){
                  clearScreen();
                  System.out.println("Incorrect input: Press enter!!");
                }
                c9b = 1;
                String c9a = " ";
                rollnum1++;
                ask++;
                System.out.println("Press ENTER to roll!");
                Scanner c9 = new Scanner(System.in);
                c9a = c9.nextLine();
                if(c9a.equals("")){
                  System.out.println("Rolling...");
                  waitTime(1);
                  System.out.println("Roll #"+rollnum1);
                  double c9e = (((Math.random())*max))+min;
                  int c9c = (int)c9e;
                  System.out.println("___");
                  System.out.println("|"+c9c+"|");
                  System.out.println("‾‾‾");
                  if(c9c==rolgol){
                    System.out.println("You Win!!");
                    waitTime(3);
                    System.out.println("Redirecting...");
                    waitTime(1);
                    stop2=1;
                    lea1=1;
                  }else if(ask%5==0){
                    System.out.println("Do you want to leave?[Y or N]");
                    String c10a = " ";
                    Scanner c10 = new Scanner(System.in);
                    c10a = c10.nextLine();
                    if(c10a.equals("Y")){
                      System.out.println("Ok, bye!!");
                      waitTime(2);
                      System.out.println("Redirecting...");
                      waitTime(1);
                      stop2 = 1;
                      lea1 = 1;
                    }else if(c10a.equals("N")){
                      System.out.println("Ok, Try Again!");
                      waitTime(1);
                      clearScreen();
                    }else{
                      System.out.println("Incorrect Input: Continuing...");
                      waitTime(1);
                    }
                  }else{
                    System.out.println("Try Again!!");
                    waitTime(1);
                  }
                }else{
                  c9b = 0;
                }
              }
            }
          }else{
            rg3 = 0;
          }
        }else{
          rg2=0;
        }
      }
    }
      public static void waitTime(int n){
        try        
        {
          Thread.sleep(n*1000);
        } 
          catch(InterruptedException ex) 
        {
          Thread.currentThread().interrupt();
        }
    }
      public static void leavMess(){
        clearScreen();
        System.out.println("____________________________");
        waitTime(1);
        System.out.println("| U L T I M A T E   D I C E |");
        waitTime(1);
        System.out.println("___________________________________");
        waitTime(1);
        System.out.println("| Credits:                         |");
        waitTime(1);
        System.out.println("| LKansal - Me (Creator)           |");
        waitTime(1);
        System.out.println("| BMacDougall - Idea for RollBot   |");
        waitTime(1);
        System.out.println("| JVanalek - Idea for roll for fun |");
        waitTime(1);
        System.out.println("| JDike - Idea for dice game       |");
        waitTime(1);
        System.out.println("___________________________________");
        
    }
}
?