Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f1284cd2d |
1 changed files with 44 additions and 0 deletions
|
|
@ -0,0 +1,44 @@
|
||||||
|
import { userInput } from "./functions";
|
||||||
|
import { inventoryMenuM } from "./inventory";
|
||||||
|
import { health, playerLevel } from "./variables";
|
||||||
|
|
||||||
|
export function combatScreen(encounter){
|
||||||
|
console.log("You encounter a " + encounter.name);
|
||||||
|
console.log("-----------------------------------");
|
||||||
|
console.log("1). Fight");
|
||||||
|
console.log("2). Items");
|
||||||
|
console.log("3). Flee");
|
||||||
|
var combatInput = userInput("Enter: ");
|
||||||
|
switch(combatInput){
|
||||||
|
case "1":
|
||||||
|
fightAttempt(encounter);
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
inventoryMenuM();
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
fleeAttempt();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fightAttempt(encounter){
|
||||||
|
|
||||||
|
if(encounter.minLevel > playerLevel){
|
||||||
|
var encounterLevel = encounter.minLevel;
|
||||||
|
} else if(encounter.maxLevel < playerLevel){
|
||||||
|
var encounterLevel = encounter.maxLevel;
|
||||||
|
} else {
|
||||||
|
var encounterLevel = playerLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
var enemyHealth = Math.floor(encounter.baseHealth * (1.05 ** encounterLevel));
|
||||||
|
console.log("Your health: " + health);
|
||||||
|
console.log("Enemy health: " + enemyHealth);
|
||||||
|
console.log("------------------------------");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function fleeAttempt(encounter){
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue