forked from bsquires/LairOfShadows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AI.java
149 lines (131 loc) · 2.81 KB
/
AI.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
import java.util.Random;
public class AI {
//reference to the player character
//playing the game
Player user;
private int randomizer;
public AI(Player player1)
{
this.user = player1;
}
public void createEvent(){
int rdm=randomize(0, 7);
switch(rdm){
case 0:
System.out.println("Random Encounter!");
break;
case 1:
System.out.println("Enemy Encounter!");
Player bot = createEnemy(user);
Combat fight = new Combat(user, bot);
//Combat method must instantiate an enemy to fight with
//via create enemy
//fighting loops until someone runs out of life
fight.fighting();
break;
case 2:
System.out.println("Random Item Is Found!");
break;
default:
System.out.println("Catostraphic Disaster!!!!!!!");
break;
}
}
//Create an enemy combatant
public Player createEnemy(Player player1){
int e = randomize(0, 4);
//Generate a random multiple between 25% and 100%
int botStatsMultiplier = randomize(25, 75)/100;
//The bot stats will be used as the initial stats for our bots
//created by the following switch statement.
int botHealth = botStatsMultiplier*player1.getHealth();
int botDefense = botStatsMultiplier*player1.getDefense();
int botAttackForce = botStatsMultiplier*player1.getAttackForce();
switch(e){
case 0:
//create a boss enemy
break;
case 1:
//create a warrior enemy
//Special Attribute Focus will be a product 1/2 the bots health
Warrior bot = new Warrior(botHealth, botAttackForce, botDefense, (int) (botHealth*.5));
return bot;
break;
case 2:
//create a rouge enemy
break;
case 3:
while(eN<n){
//create a mage enemy
}
break;
case 4:
//create a sub-boss
break;
default:
//create a random or cannon fodder enemy
break;
}
}
//Generate a number between lower bound lb
//and upperbound ub
public int randomize(int lb, int ub)
{
Random random = new Random();
int result = -1;
//loop until you receive a result
//that falls within the specified bounds
while(result<lb)
{
result = random.nextInt(ub+1);
}
return result;
}
/*
public int randomize(int lb, int i){
int rdm=0;
Random random= new Random();
switch(i){
case 4:
rdm=random.nextInt(i);
while(rdm<lb){
rdm=random.nextInt(i);
}
break;
case 6:
rdm=random.nextInt(i);
while(rdm<lb){
rdm=random.nextInt(i);
}
break;
case 8:
rdm=random.nextInt(i);
while(rdm<lb){
rdm=random.nextInt(i);
}
break;
case 10:
rdm=random.nextInt(i);
while(rdm<lb){
rdm=random.nextInt(i);
}
break;
case 12:
rdm=random.nextInt(i);
while(rdm<lb){
rdm=random.nextInt(i);
}
break;
case 20:
rdm=random.nextInt(i);
while(rdm<lb){
rdm=random.nextInt(i);
}
break;
default:
break;
}
return rdm;
}
*/
}