Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #110

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e53f004
level one work
Fezz-xiii Dec 30, 2020
cb59f8b
changes and tweaks to stageOne & framework for stageOneTwo
Fezz-xiii Jan 1, 2021
e1d1312
more tweaks to dmg | fixed reference errors
Fezz-xiii Jan 3, 2021
821a78e
changes to enDmg
Fezz-xiii Jan 4, 2021
a01de7b
general update
Fezz-xiii Jan 6, 2021
27a97b5
implemented objects in place of arrays as function arguments
Fezz-xiii Jan 6, 2021
86dcbe2
more changes to implement objects
Fezz-xiii Jan 6, 2021
dab1c0c
refactoring
Fezz-xiii Jan 25, 2021
642a139
minor tweaks and bug fixes, loop is running kinda
Fezz-xiii Jan 25, 2021
4bb85d5
heroStats obj now to host character stats
Fezz-xiii Mar 21, 2021
7ec55dd
constitutionRoll replaces addHealth and minusHealth
Fezz-xiii Mar 21, 2021
e6ca280
savepoint
Fezz-xiii Mar 21, 2021
e8b2f35
dmg() runs as expected
Fezz-xiii Apr 2, 2021
cd29ba1
tweaks to dmg
Fezz-xiii Apr 4, 2021
c215c9a
fix dmg, endmg, dodge, working on constitution roll
Fezz-xiii Apr 5, 2021
d18bdbb
testing
Fezz-xiii Apr 16, 2021
78a47c6
combine hero and ememy stats into a singular workable object
Fezz-xiii Jun 15, 2021
a5e1da3
refactor fight function pt 1
Fezz-xiii Jun 15, 2021
5343019
housekeeping
Fezz-xiii Jun 25, 2021
d1174c1
updated readme.md
Rvndyr Jun 25, 2021
350bc26
Merge pull request #1 from Rvndyr/master
jonnicwolf Jun 25, 2021
30926fe
updated readme with instructions on how to install and run
Rvndyr Jun 25, 2021
57a02a7
fixed the 'project setup' in readme
Rvndyr Jun 25, 2021
2e2d783
Merge pull request #2 from Rvndyr/master
jonnicwolf Jun 25, 2021
a4b9bb5
dmg is now attack
Fezz-xiii Jun 26, 2021
bef96ea
bug fixes on dmg.js
Fezz-xiii Jun 26, 2021
5b82471
enDmg refactor
Fezz-xiii Jun 27, 2021
4e8031c
comment out some lines im working on
Fezz-xiii Jun 27, 2021
0fa2ea1
Merge branch 'master' of github.com:jonnicwolf/FSW-Text-Based-Adventure
Fezz-xiii Jun 27, 2021
ee783ee
dmg.js working as expected
Fezz-xiii Jun 27, 2021
6a88680
enemyDmg.js working as expected
Fezz-xiii Jun 27, 2021
7d76525
change ln18+ options[i] to options[index]
Fezz-xiii Jun 28, 2021
0f9ee51
fight.js attack option runs
Fezz-xiii Jun 28, 2021
49c8ead
display cleanup
Fezz-xiii Jun 28, 2021
3fdbed6
housekeeping
Fezz-xiii Jun 28, 2021
fb598fa
reassign character health value ln28 & ln37 @fight.js
Fezz-xiii Jun 29, 2021
fce910c
dmg div constant 150 -> 50 to curb excessive high damage rolls
Fezz-xiii Jul 3, 2021
8c449a3
testing display algo for dialogue + housekeeping
Fezz-xiii Jul 20, 2021
bd88044
start-dialogue @test.js works
Fezz-xiii Aug 19, 2021
235cd80
pickYes/No fixed
Fezz-xiii Aug 19, 2021
de97ac1
minor bug fixes
Fezz-xiii Aug 19, 2021
4bc61ff
delay quest start until showDialogue runs
Fezz-xiii Aug 19, 2021
337006f
place all dialogues in arrays to organise them
Fezz-xiii Aug 19, 2021
73f048e
work on stageOne dialogue && more
Fezz-xiii Aug 26, 2021
11ac98c
levelOne dialogues cleanup
Fezz-xiii Aug 26, 2021
19599d0
aggregate corefunctions for easier imports
Fezz-xiii Aug 27, 2021
e3c0963
dodge refactored
jonnicwolf Oct 7, 2021
ab76865
start working
jonnicwolf Oct 8, 2021
01e1c6a
ln 16 -> switch statement
jonnicwolf Oct 8, 2021
5628e60
connect nameInput to levelone dialogue
jonnicwolf Oct 10, 2021
0da757c
bug fix: hero was undefined
jonnicwolf Oct 10, 2021
19366ef
start working, timing issues fixed
jonnicwolf Oct 11, 2021
e596a1a
file and readme cleanup
jonnicwolf Dec 8, 2021
23b855a
testing on start
jonnicwolf Dec 8, 2021
fca45bb
package.json updates
jonnicwolf Dec 8, 2021
c13dba8
start module now runs
jonnicwolf Dec 8, 2021
ee0bd43
nameInput moved to corefunctions library
jonnicwolf Dec 8, 2021
ba1e47f
typo levelOne lb 17
jonnicwolf Dec 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
15 changes: 15 additions & 0 deletions CoreFunctions/Dodge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const dodge = (risk) => {
const dice = dice(6,1);
if (dice > 3){
console.log(`+ Successful dodge!+`);
return true;
}
else if (dice === 3){
console.log(`+ You tripped during your dodge and took ${risk} damage! +`);
return hero.health - risk;
}
else {
return false;
};
};

7 changes: 7 additions & 0 deletions CoreFunctions/constitutionRoll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const constitutionRoll = () => {

}

export {
constitutionRoll
};
184 changes: 184 additions & 0 deletions CoreFunctions/coreFunctions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
const {
keyInYN,
question} = require("readline-sync");

let nameInput = question("Enter your name: ");

console.log(`Hello ${nameInput}! Welcome to DragonRend.`);

//all random events are based of this rng 'dice'
const dice = (nat, min) => {
return Math.floor(Math.random() * nat + min);
};

//Damage calculator
const dmg = (herostat, enemy) => {
const d6Roll = dice(6, 1);
const critRoll = dice(3, 1);

let atk, level;
[atk, level] = [herostat.attack, herostat.level];
const enemyDef = enemy.defense;

const damage = Math.ceil(
(((2 * level + 10) / 50) * (atk / enemyDef) + 2) * d6Roll
);

const critical = Math.ceil(
(((2 * level + 10) / 50) * (atk / enemyDef) + 2) * critRoll
);

if (d6Roll !== 1 && d6Roll !== 6) {
// console.log('+--------------------------------------------------------------------------------------+')
console.log("Normal hit.");
return damage;
}
else if (d6Roll === 6) {
let critDmg = damage + critical;
console.log("Critical hit!");
return critDmg;
}
else if (d6Roll === 1) {
console.log(`Your attack missed!`);
return 0;
}
};

//Enemy damage calculator
const enemyDmg = (herostat, enemy) => {
const d6 = dice(6, 1);
const d2 = dice(2, 1);
const heroDef = herostat.defense;

let enemyAtk, enemyLvl;
[enemyAtk, enemyLvl] = [enemy.attack, enemy.level];
// console.log(enemyAtk, enemyLvl)
let damage = Math.ceil(
(((2 * enemyLvl + 10) / 50) * (enemyAtk / heroDef) + 2) * d6
);
// console.log(damage)
return d2 === 2 ? damage : 0;
};

//
const fight = (herostat, enemy, risk, experience) => {
const victoryRes = [
` ||=====\ //=====+= ====== ||=====\\ `,
` || - | || //\\\ || - | `,
` || | | ||---| // \\\ || | | `,
` || 1 | || //====\\\ || 1 | `,
` ||=====// ||======\\ === ====||======// `
]
const deathRes = [
`== == ======== || || | `,
`|| ___ || || || | || | `,
`|| | || || || | || | `,
`|| 1 || || || |||| | `,
` |==|+|==// ======*= || ||| O `,
]
while (herostat.health > 0 || enemy.health > 0) {
const options = ["Attack", "Dodge", "Special Attack", "Run"];
let index = keyInSelect(options, `What's your move?`);

switch (options[index]){
case 0:
const damage = dmg(herostat, enemy);
enemy.health = enemy.health - damage;
console.log(
`Hero did ${damage} damage to the enemy \n
${herostat.health}❤️ \n${enemy.health}🖤`
);
if (hero.health < 1) {
showDialogue(deathRes)
start();
} else if (enemy.health < 1) {
showDialogue(victoryRes)
};
break;
case 1:
//lets move dodge to a global variable in fight()'s scope
let dodge = dodge(risk);
break;
case 2:
//Special atk
hero.level > 3
? true
: console.log(`Do you even lift? Your level is too low, scrub`)
break;
case 3:
const coin = dice(2,1);
coin === 2
? `Two heads are indeed better than one but a true hero never runs, the Heads beyond the skies have`
: hero.health - 1
break;
default:
quitGame();
}
const enDamage = enemyDmg(herostat, enemy);
hero.health = hero.health - enDamage;

console.log(
`Enemy did ${enDamage} damage to our hero \nHP❤️ ${hero.health} \nHP🖤 ${enemy.health}`
);
if (hero.health < 1) {
showDialogue(deathRes)
start();
} else if (enemy.health < 1) {
showDialogue(victoryRes);
}
}
};

const quitGame = () => {
let restart = keyInYN(
"To the well-organised mind, death is but the next great adventure. Restart?"
);
console.log("Til next time " + nameInput);
if (restart === true) {
start();
} else if (restart === false) {
console.log("Til next time " + nameInput);
process.exit();
}
};

const showDialogue = (dialogue) => {
let i = 0;
const len = dialogue.length;

const timer = setInterval(() => {
console.log(dialogue[i]);
i++;
i === len
? clearInterval(timer)
: null
}, 250);
};

const health = (passingValue, reward, risk) => {
let roll = dice(6, 1);
switch (roll){
case roll >= passingValue:
console.log(`Hero gains ${reward}💛`);
hero.health += reward;
break;
case roll < passingValue:
console.log(`+--------------------------------------------------------------------------------------+`)
console.log(` Hero takes ${risk}🖤`);
hero.health =- risk;
break;
default:
console.log(`Whoa something went really wrong here`);
};
};



module.exports = {
dice,
dmg,
fight,
enemyDmg,
showDialogue,
quitGame
}
12 changes: 12 additions & 0 deletions CoreFunctions/dice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// nat -> highest value of the di
//min -> lowest possible roll of the di

const dice = (nat, min) => {
return Math.floor(Math.random() * nat + min);
};
const dice = (nat, min) => {
return Math.floor(math.random)
};

export {dice};

36 changes: 36 additions & 0 deletions CoreFunctions/dmg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const dice = require('./dice.js')
// const statsAPI = require('./characterStats-API.js')

const dmg = (herostat, enemy) => {
const d6Roll = dice(6, 1)
const critRoll = dice(3, 1)

let atk, level;
[atk, level] = [herostat.attack,herostat.level]
const enemyDef = enemy.defense

let damage = Math.ceil(((
(2 * level + 10) / 50) * (atk / enemyDef) + 2) * d6Roll)

let critical = Math.ceil(((
(2 * level + 10) / 50) * (atk / enemyDef) + 2) * critRoll)


if (d6Roll !== 1 && d6Roll !== 6) {
// console.log('+--------------------------------------------------------------------------------------+')
console.log('Normal hit.')
return damage

} else if (d6Roll === 6) {
let critDmg = damage + critical
console.log('Critical hit!')
return critDmg

} else if (d6Roll === 1) {
console.log(`Your attack missed!`)
return 0
}
}
export = dmg;


30 changes: 30 additions & 0 deletions CoreFunctions/enemyDmg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const dice = require(`./dice.js`)
// const statsAPI = require('./characterStats-API.js')

const enemyDmg = (herostat, enemy) => {
//dice dependencies
const d6 = dice(6, 1)
const d2 = dice(2, 1)

//character dependencies
const heroDef = herostat.defense

let enemyAtk, enemyLvl;
[enemyAtk, enemyLvl] = [enemy.attack, enemy.level]
// console.log(enemyAtk, enemyLvl)
let damage = Math.ceil(((
(2 * enemyLvl + 10) / 50) * (enemyAtk / heroDef) + 2) * d6)
// console.log(damage)
return d2 === 2
? damage
: 0
};

export = enemyDmg







84 changes: 84 additions & 0 deletions CoreFunctions/fight.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//import dice,
const dice = require("./dice.js");
const dmg = require("./dmg.js");
const enemyDmg = require("./enemyDmg.js");
const quitGame = require("./quitGame.js");

const { keyInSelect } = require("readline-sync");
const { hero, troll } = require("./characterStats-API.js");

const fight = (herostat, enemy, risk, experience) => {
while (herostat.health > 0 || enemy.health > 0) {
const options = ["Attack", "Dodge", "Special Attack", "Run"];
let index = keyInSelect(options, `What's your move?`);

if (options[index] === options[0]) {
const damage = dmg(herostat, enemy);
enemy.health = enemy.health - damage;
console.log(
`Hero did ${damage} damage to the enemy \n${herostat.health}❤️ \n${enemy.health}🖤`
);
if (hero.health < 1) {
console.log(` ||=====\ ======== //=====+= ||=====\\ `);
console.log(` || - | || || || - | `);
console.log(` || | | || ||---| || | | `);
console.log(` || 1 | || || || 1 | `);
console.log(` ||=====// ======*= ||======\\ ||======// `);
start();
} else if (enemy.health < 1) {
console.log(" == == ======== || || | ");
console.log(" || ___ || || || | || | ");
console.log(" || | || || || | || | ");
console.log(" || 1 || || || |||| | ");
console.log(" |==|+|==// ======*= || || O ");
}
}
else if (options[index] === options[1]) {
let dodge = dodge(risk);
return dodge;
}
else if (options[index] === options[2]) {
if (herostat.level > 3) {
return true;
} else {
console.log(`Do you even lift? Your level is too low, scrub.`);
}
} else if (options[index] === options[3]) {
const d2 = dice(2, 1);
if (d2 === 1) {
console.log(`How could 1 tail beat 2 heads? `);
fight(herostat, enemy, risk, next);
}
else {
console.log(
`2 heads are indeed better than one. However, a hero never runs, the Heads beyond the skies have judged you and condemn thee to die`
);
quitGame();
}
}
const enDamage = enemyDmg(herostat, enemy);
hero.health = hero.health - enDamage;

console.log(
`Enemy did ${enDamage} damage to our hero \nHP❤️ ${hero.health} \nHP🖤 ${enemy.health}`
);
if (hero.health < 1) {
console.log(` ||======\ ======== //=====+= ||======\ `);
console.log(` || - | || || || - | `);
console.log(` || | | || ||---| || | | `);
console.log(` || 1 | || || || 1 | `);
console.log(` ||======// ======*= ||======\\ ||======// `);
start();
} else if (enemy.health < 1) {
console.log(" == == ======== || || | ");
console.log(" || ___ || || || | || | ");
console.log(" || | || || || | || | ");
console.log(" || 1 || || || |||| | ");
console.log(" |==|+|==// ======*= || || O ");
}
}
};

module.export = {
fight
}
Loading