From cc3c7f52bbde6e5149c222d09f2db47664470cd6 Mon Sep 17 00:00:00 2001 From: Matt Kohls Date: Sat, 30 Nov 2019 23:43:38 -0500 Subject: Some prep work for server side of things --- README.md | 3 ++- public/js/rogue.js | 2 ++ rogue-server.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a9f61f3..0c5de4f 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,5 @@ GPL3 #### Artwork -[minirogue-all.png](https://forums.tigsource.com/index.php?topic=14166.0) by Arachne, [CC-BY-SA](https://creativecommons.org/licenses/by-sa/4.0/) \ No newline at end of file +Original sprites based on +[scroll-o-sprites.png](https://imgur.com/a/uHx4k) by Quale, [CC-BY-SA](https://creativecommons.org/licenses/by-sa/3.0/) diff --git a/public/js/rogue.js b/public/js/rogue.js index 1580593..a5a640a 100644 --- a/public/js/rogue.js +++ b/public/js/rogue.js @@ -42,6 +42,7 @@ var wall = [ var stairsdown = new Sprite(12, 26, 16, 16); var starisup = new Sprite(13, 26, 16, 16); +var tomb = new Sprite(2, 27, 16, 16); var water = new Sprite(8, 34, 16, 16); @@ -59,6 +60,7 @@ var book = new Sprite(10, 49, 16, 16); var mace = new Sprite(13, 3, 1); var dagger = new Sprite(2, 45, 16, 16); var sword = new Sprite(3, 45, 16, 16); +var staff = new Sprite(2, 49, 16, 16); var axe = new Sprite(4, 45, 16, 16); var club = new Sprite(7, 45, 16, 16); var hammer = new Sprite(8, 45, 16, 16); 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'); -- cgit v1.2.3