aboutsummaryrefslogtreecommitdiffstats
path: root/rogue-server.js
diff options
context:
space:
mode:
Diffstat (limited to 'rogue-server.js')
-rw-r--r--rogue-server.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/rogue-server.js b/rogue-server.js
index a8d553a..e91306a 100644
--- a/rogue-server.js
+++ b/rogue-server.js
@@ -6,6 +6,53 @@
* GPL3
*/
+function getBonus(value) {
+ if(value % 2 == 1) {
+ --value;
+ }
+ return (value - 10) / 2;
+}
+
+class Item {
+ constructor(bonus, type) {
+ this.bonus = bonus;
+ this.type = type;
+ }
+
+ get name() {
+ var name = type + " ";
+ if(bonus > 0) {
+ name = name + "+" + bonus;
+ } else if(bonus < 0) {
+ name = name + "-" + bonus;
+ }
+ return name;
+ }
+
+ get bonus() {
+ return bonus;
+ }
+
+ get type() {
+ return type;
+ }
+}
+
+class Mob {
+ constuctor(strength, dexterity, constitution, intelligence, wisdom, level, location) {
+ this.strength = strength;
+ this.dexterity = dexterity;
+ this.constitution = constitution;
+ this.intelligence = intelligence;
+ this.wisdom = wisdom;
+ this.level = level;
+ this.xp = 0;
+ this.hp = level * getBonus(constitution) + Math.floor(Math.random() * 6) * level;
+ this.ac = dexterity + 10;
+ this.invintory = {};
+ }
+}
+
const http = require('http');
const WebSocket = require('ws');
const uuid = require('uuid/v4');