-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharchlegends.java
More file actions
362 lines (336 loc) · 7.5 KB
/
archlegends.java
File metadata and controls
362 lines (336 loc) · 7.5 KB
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
// Karishma Sinha 2018339
import java.util.*;
import java.io.*;
import java.lang.*;
public class archlegends
{
public class GFG
{
// A user define class to represent a graph.
// A graph is an array of adjacency lists.
// Size of array will be V (number of vertices
// in graph)
static class Graph
{
int V=11;
LinkedList<Integer> adjListArray[];
// constructor
Graph(int V)
{
this.V = V;
// define the size of array as
// number of vertices
adjListArray = new LinkedList[V];
// Create a new list for each vertex
// such that adjacent nodes can be stored
for(int i = 0; i < V ; i++){
adjListArray[i] = new LinkedList<>();
}
}
}
// Adds an edge to an undirected graph
static void addEdge(Graph graph, int src, int dest)
{
// Add an edge from src to dest.
graph.adjListArray[src].add(dest);
// Since graph is undirected, add an edge from dest
// to src also
graph.adjListArray[dest].add(src);
}
// A utility function to print the adjacency list
// representation of graph
static void printGraph(Graph graph)
{
for(int v = 0; v < graph.V; v++)
{
System.out.println("Adjacency list of vertex "+ v);
System.out.print("head");
for(Integer pCrawl: graph.adjListArray[v]){
System.out.print(" -> "+pCrawl);
}
System.out.println("\n");
}
}
// Driver program to test above functions
// public static void main(String args[])
// {
// // create the graph given in above figure
// int V = 5;
// Graph graph = new Graph(V);
// addEdge(graph, 0, 1);
// addEdge(graph, 0, 4);
// addEdge(graph, 1, 2);
// addEdge(graph, 1, 3);
// addEdge(graph, 1, 4);
// addEdge(graph, 2, 3);
// addEdge(graph, 3, 4);
// // print the adjacency list representation of
// // the above graph
// printGraph(graph);
// }
}
public void creategraph()
{
}
abstract class hero
{
protected String username;
protected int level=1;
protected int xp=0;
protected double hp=100;
protected int moves=0;
protected double aa;
protected double da;
public boolean isSpPowOn()
{
}
public void attack(moster m);
public void defense();
public void spPower();
public void levelUp()
{
if(xp==20)
{
level=2;
hp=150;
this.aa+=1;
this.da+=1;
}
else if(xp==40)
{
level=3;
hp=200;
this.aa+=1;
this.da+=1;
}
else if(xp==60)
{
level=4;
hp=250;
this.aa+=1;
this.da+=1;
}
}
}
class warrior extends hero
{
public warrior(String name)
{
this.username=name;
this.aa=10;
this.da=3;
}
@Override
public void attack(monster m)
{
m.hp-=aa;
}
@Override
public void defense()
{
this.hp+=da;
}
@Override
public void spPower()
{
m.hp-=(aa+5);
this.hp+=(da+5);
}
}
class mage extends hero
{
public mage(String name)
{
this.username=name;
this.aa=5;
this.da=5;
}
@Override
public void attack(monster m)
{
m.hp-=this.aa;
}
@Override
public void defense()
{
this.hp+=this.da;
}
@Override
public void spPower()
{
m.hp-=m.hp*0.05;
}
}
class thief extends hero
{
public thief(String name)
{
this.username=name;
this.aa=6;
this.da=4;
}
@Override
public void attack(monster m)
{
m.hp-=this.aa;
}
@Override
public void defense()
{
this.hp+=this.da;
}
@Override
public void spPower()
{
this.hp+=m.hp*0.3;
m.hp-=m.hp*0.3;
}
}
class healer extends hero
{
public healer(String name)
{
this.username=name;
this.aa=4;
this.da=8;
}
@Override
public void attack(monster m)
{
m.hp-=this.aa;
}
@Override
public void defense()
{
this.hp+=this.da;
}
@Override
public void spPower()
{
this.hp+=this.hp*0.05;
}
}
abstract class monster
{
//protected double;
protected double mhp;
protected int levelm;
protected int positionNode;
public void attackm(hero h)
{
Random rand = new Random();
double x=rand.nextGaussian(this.mhp*0.26);
h.hp-=x*this.mhp;
}
}
class goblin extends monster
{
public goblin()
{
this.level=1;
this.mhp=100;
}
}
class zombie extends monster
{
public zombie()
{
this.level=2;
this.mhp=100;
}
}
class fiend extends monster
{
public fiend()
{
this.level=3;
this.mhp=200;
}
}
class lionfang extends monster
{
public lionfang()
{
this.level=4;
this.mhp=250;
}
public void attackm(hero h)
{
Random rand = new Random();
int x=rand.nextInt(10);
if(x==0)
{
h.hp/=2;
}
}
}
public static void main(String[] args)
{
String usern;
Scanner input=new Scanner(System.in);
ArrayList<String> Players=new ArrayList<>();
do
{
System.out.println("Welcome to ArchLegends");
System.out.println("Choose your option");
System.out.println("1. New User");
System.out.println("2. Existing User");
System.out.println("3. Exit");
int ans=input.nextInt();
switch(ans)
{
case 1:
System.out.println("Enter Username");
usern=input.next();
Players.add(usern);
System.out.println("Choose a Hero");
System.out.println("1. Warrior");
System.out.println("2. Thief");
System.out.println("3. Mage");
System.out.println("4. Healer");
int heron=input.nextInt();
if(heron==1)
{
warrior h=new warrior(usern);
System.out.println("User Creation done. Username: "+ usern+". Hero type: "+"Warrior"+". Log in to play the game. Exiting");
}
else if(heron==2)
{
thief h=new thief(usern);
System.out.println("User Creation done. Username: "+ usern+". Hero type: "+"Thief"+". Log in to play the game. Exiting");
}
else if(heron==3)
{
mage h=new mage(usern);
System.out.println("User Creation done. Username: "+ usern+". Hero type: "+"Mage"+". Log in to play the game. Exiting");
}
else if(heron==4)
{
healer h=new healer(usern);
System.out.println("User Creation done. Username: "+ usern+". Hero type: "+"Healer"+". Log in to play the game. Exiting");
}
//System.out.println("User Creation done. Username: "+ usern+". Hero type: "++". Log in to play the game. Exiting");
break;
case 2:
System.out.println("Enter Username");
usern=input.next();
for(int i=0;i<Players.size();i++)
{
if(Players.get(i).equals(usern))
{
System.out.println("User Found... logging in");
System.out.println("Welcome "+M.get(i));
System.out.println("You are at the starting location. Choose path:");
creategraph();
}
}
break;
case 3: break;
case 4: break;
case 5: break;
default: System.out.println("Enter valid option");
break;
}
}
}
}