-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmageFight.html
281 lines (257 loc) · 7.59 KB
/
mageFight.html
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
<!doctype html>
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="assets/style.css">
</head>
<body id="body">
<div class ="bg">
<!-- <img src='https://i.pinimg.com/originals/e5/0d/62/e50d624d3cbf1a9276a4fbbeac4dab18.jpg' \height=100% width=100% alt='failed'>
--> <div class ="container">
<div class ="row background">
<div class="row enemy">
<div class="col-lg-4 col-4-sm-4 col-md" id="enemy">
<div class="progress">
<div class="progress-bar progress-bar-success enemyBar" id="enemyBar" role="progressbar" aria-valuenow="100"
aria-valuemin="0" aria-valuemax="100" style="width:100%">
<span class="sr-only">70% Complete</span>
</div>
</div>
<img id ="animationBox" img src="">
<img src ="https://derpicdn.net/img/2012/11/20/158197/full.png" id="enemyPhoto" alt="witch" height=100% width=100%>
</div>
<div class="col-md-4 col-lg-4 col-sm-4" id="menu">
<p id= console>
Click a rune to attack.<br>
Press enter to end your turn after attacking.<br>
You may use the fire rune twice, and click "combine runes" for a special attack.<br>
game is in alpha, other rune combination currently not supported.
</p>
<button type="button" id="turnButton" class="btn">End Turn</button>
</div>
</div>
</div>
<div class ="row player" id="playerui">
<div id="playerAnimationLand">
<img id="playerAnimationBox" src="" alt="">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 skills" id="skills1">
<button type="button" class="btn-warning skillButton" value="air"><span class="glyphicon glyphicon-flash"></span></button><br>
<button type="button" class="btn-danger skillButton" value="fire"><span class="glyphicon glyphicon-fire"></span></button>
</div>
<div class = "col-lg-4 col-md-4 col-sm-4" id="player">
<div class="row" id="overbar">
Combine Runes
</div>
<div class="progress">
<div class="progress-bar progress-bar-success" id="playerBar" role="progressbar" aria-valuenow="100"
aria-valuemin="0" aria-valuemax="100" style="width:100%">
<span class="sr-only">70% Complete</span>
</div>
</div>
<img id="wizardPlayer" src='assets/images/Wizard-PNG-Image.png'>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 skills" id="skills2">
<button type="button" class="btn-primary skillButton" value="water"><span class="glyphicon glyphicon-tint"></span></button><br>
<button type="button" class="btn-success skillButton" value="earth"><span class="glyphicon glyphicon-leaf"></span></button>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).mousemove(function(event){
if (document.activeElement != document.body) document.activeElement.blur();
});
function SketchChar(name, gender, age, attack, hp, alignment, speed, maxhp, defence) {
this.name = name;
this.gender = gender;
this.age = age;
this.attack = attack;
this.hp = hp;
this.alignment = alignment;
this.speed = speed;
this.maxhp = maxhp;
this.defence = defence;
this.printStats = function() {
// console.log('name: '+this.name+' gender: '+this.gender+' age: '+this.age+' strength ' )
console.log(this)
}
}
var wizard = new SketchChar('wizard', 'male', 22, 0, 20, 'good', 2, 20,0);
var enemy = new SketchChar('enemy', 'female', 1000, 2, 20, 'evil',0,20,0 );
wizard.printStats();
var water = {
damage:1,
heal:1,
active:0,
}
var earth = {
damage:1,
bulk:1,
active:0,
}
var air = {
damage:0,
overTime:0,
overTimeDamage:1,
active:0,
}
var fire = {
damage:2,
active:0,
}
var inferno = {
damage:4
}
var turn = "playerTurn"
var damage;
function inferno() {
playerAttack(inferno.damage);
animate(assets/images/inferno.jpg);
$("#overbar").empty()
$("#overbar").append("combine runes")
fire.active=0;
}
function enemyAttack(z) {
damage =0;
damage = enemy.attack + z - wizard.defence;
wizard.hp = wizard.hp- damage;
if (bulked) {
wizard.defence = wizard.defence - earth.bulk;
bulked=false;
}
turn = "playerTurn"
console.log(wizard.hp+"wizard hp");
console.log(enemy.hp);
}
function playerAttack(z) {
damage =0;
damage = wizard.attack +z -enemy.defence;
enemy.hp = enemy.hp- damage;
turn = "enemyTurn"
console.log(wizard.hp+"wizard hp");
console.log(enemy.hp);
}
var newprogress;
function enemyBarCheck(z) {
if (enemy.hp < 1){
$('#console').text("you win!");
wait =1;
}
newprogress=0;
newprogress = (z.hp/z.maxhp)*100;
console.log(newprogress)
$('#enemyBar').width(newprogress + "%").attr('aria-valuenow', newprogress);
}
function playerBarCheck() {
if(wizard.hp < 1){
$('#console').text('you lose :(');
wait =1;
}
newprogress =0;
newprogress = (wizard.hp/wizard.maxhp)*100;
$('#playerBar').width(newprogress + "%").attr('aria-valuenow', newprogress);
}
function animate(z) {
wait=1
$("#animationBox").attr("src", z);
$('#animationBox').css('visibility', 'visible');
$('#animationBox').show()
$("#animationBox").animate({top: '100px'}, 'slow', function () { $(this).removeAttr('style'); });
setTimeout(function() {
$('#animationBox').hide();
$("#animationBox").attr("src", "");
wait=0;
}, 500);
}
function playerAnimate(z) {
wait=1
$("#playerAnimationBox").attr("src", z);
$('#playerAnimationBox').css('visibility', 'visible');
$('#playerAnimationBox').show()
$("#PlayerAnimationBox").animate({bottom: '100px'}, 'slow', function () { $(this).removeAttr('style'); });
setTimeout(function() {
$('#playerAnimationBox').hide();
$("#playerAnimationBox").attr("src", "");
wait=0;
}, 500);
}
function glyphWipe() {
$('#overbar').text('combine runes')
}
var skillz
var bulked
var wait = 1
$('#overbar').on('click', function(){
if (turn == "playerTurn"){
if (fire.active > 1) {
playerAttack(inferno.damage);
animate("assets/images/inferno.jpg");
$("#overbar").innerhtml=('combine runes');
fire.active=0;
glyphWipe();
$('.bg').css("background-image", "url(assets/images/hell.jpg");
turn = "enemyTurn"
enemyBarCheck(enemy);
}
}
})
$('.skillButton').on('click', function() {
skillz =(this.value);
if (turn == "playerTurn"){
switch (skillz) {
case "water":
if (wizard.hp < wizard.maxhp) {
wizard.hp = wizard.hp + water.heal;
}
playerAttack(water.damage);
playerAnimate("assets/images/heal.png")
animate("assets/images/water.png")
break;
case "fire":
playerAttack(fire.damage);
animate("assets/images/fire.png")
fire.active = fire.active+1
$('#overbar').append('<span class="glyphicon glyphicon-fire"></span>')
break;
case "earth":
wizard.defence = wizard.defence + earth.bulk;
playerAttack(earth.damage);
animate("assets/images/earth.png")
bulked=true;
break;
case "air":
playerAttack(air.damage);
animate("assets/images/air.png");
air.overTime = wizard.speed;
break
}
enemyBarCheck(enemy);
playerBarCheck();
}
});
$('body, .skillButton, html').keyup(function(e){
if(e.keyCode == 13) {
if (turn == "enemyTurn") {
if (wait == 0){
if (air.overTime > 0) {
enemy.hp = enemy.hp - air.overTimeDamage;
air.overTime--;
animate("assets/images/air.png");
}
enemyAttack(0);
enemyBarCheck(enemy);
playerBarCheck();
}
}
}
});
</script>
</body>