diff --git a/script/index.js b/script/index.js
index 3d79391..480a868 100644
--- a/script/index.js
+++ b/script/index.js
@@ -21,6 +21,9 @@ const P0CHARA = 'crashr';
const P1NAME = 'Sam';
const P1CHARA = 'saml';
+let playerTurn = false; //declares a value used for tracking player turn.
+let logging; //declares a value used to toggle logging
+
//creates the players
let Player0;
let Player1;
@@ -32,20 +35,11 @@ let graphicsBox;
let barsBox;
let controlsBox;
let outputBox;
-
let sp;
let log;
-let oldtext;
-let playerTurn = false; //declares a value used for tracking player turn.
-let logging; //declares a value used to toggle logging
-let graphics; //declares a value used to toggle graphics
-let sound; //declares a value used to toggle sound
-
-
-//used to link the urls we get from the JSON
let jsfGithub;
let jsfDatabaseGithub;
-
+let oldtext;
//Creates a class called Fighter to generate fighters easily and using less code
class Fighter {
@@ -70,13 +64,13 @@ class Fighter {
oldtext = outputBox.innerHTML
if (logging) {
- log = '
' + oldtext
+ log = '
' + oldtext
} else {
log = "";
}
- let damage = (Math.round(Math.random() + 1) * this.atk) //Does the attack with a random chance to be double. this is done by getting random number between one and zero, converts it to just one or zero and adds one to it making it randomly one or two. then it takes the one or two times the damage to deal random double damage
- let reducedDamage = Math.round(damage / 6) //Creates reducedDamage which is used to deal less damage then normal for when they dodge
+ let damage = (Math.round(Math.random() + 1) * this.atk); //Does the attack with a random chance to be double. this is done by getting random number between one and zero, converts it to just one or zero and adds one to it making it randomly one or two. then it takes the one or two times the damage to deal random double damage
+ let reducedDamage = Math.round(damage / 6); //Creates reducedDamage which is used to deal less damage then normal for when they dodge
let dodge = Math.round(Math.random()) //Gets a random value to determine wether to dodge
if (dodge) {
@@ -95,21 +89,12 @@ class Fighter {
charge(target) {
console.log('Working Properly')
- let charged = false
- if (this.hp >= 50) {
- outputBox.innerHTML += '
' + this.name + ' is too healthy to charge!'
-} else{
- outputBox.innerHTML += '
' + this.name + ' has charged up! incrased by 10! Health has decrased by five!'
- this.hp = this.hp - 5
- this.atk = this.atk + 10
- charged = true
-}
-if (charged) {
- outputBox.innerHTML += this.name + ' has already charged!'
- this.hp = this.hp
- this.atk = this.atk
-}
+ let damage = this.atk * 2
+ this.hp = this.hp - 10
+ this.atk = damage
+ outputBox.innerHTML += this.name + ' has started to charge!'
}
+
//used for a single attack
single(target) {
this.attack(target);
@@ -120,22 +105,28 @@ if (charged) {
double(target) {
this.attack(target);
this.attack(target);
+ // Check to see if this player has enough SP to use the ability
+ if (this.sp >= 5) {
+ // Consume SP for using the ability
+ this.sp = this.sp - 5;
+ // Log action details to 'outputBox'
endTurn();
}
+}
special(target) {
this.charge(target);
endTurn();
}
- //used to recover
+ //used to recover
recover() {
console.log('Recovered!'); //Logs the recovery in console
//save old text
oldtext = outputBox.innerHTML
if (logging) {
- log = '
' + oldtext
+ log = '
' + oldtext
} else {
log = "";
}
@@ -173,13 +164,11 @@ function startup() {
controlsBox = document.getElementById('controlsBox');
outputBox = document.getElementById('outputBox');
- showMenu()
- link1()
- link2()
+ showMenu();
+ link1();
+ link2();
logging = false
- sound = 'off'
- graphics = 'classic'
}
function gameStart() {
@@ -266,9 +255,13 @@ function endTurn() {
hideControls(); //calls hideControls to end the game
updateBars(); //calls updateBars in order to update the bars
} else {
- showControls() //shows controls for next players turn
+ showControls(); //shows controls for next players turn
updateBars(); //calls updateBars in order to update the bars
}
+ if (Player0.sp < 10)
+ Player0.sp += !playerTurn
+ if (Player1.sp < 10)
+ Player1.sp += playerTurn
}
//creates function for hiding controls to end the game by showing a reset button to restart the game
@@ -295,45 +288,21 @@ function showCharacterSelect() {
controlsBox.innerHTML = '';
}
-
-function updateSettings() {
- outputBox.innerHTML = '