Skip to content

Commit

Permalink
maintenance release
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Hurst committed Jun 3, 2020
1 parent 986580a commit 97c8caf
Show file tree
Hide file tree
Showing 19 changed files with 107 additions and 79 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
🇺🇸 ©️1991 - 2020 [Robert Hurst](https://robert.hurst-ri.us)
> [developed](https://github.com/theflyingape/dankdomain) using TypeScript for the web client with terminal emulator; and to run the Node.js [app and service](https://play.DDgame.us) within the Google Cloud Platform (us-central1)
### **8-May-2020** `v2.5.2`
### **3-Jun-2020** `v2.6.0`

* dungeon map enhancements
* xterm.js v4.6 release
* xvt v1.2 release for scrollback enhancements

#### **8-May-2020** `v2.5.2`

* RI last day of its "Stay At Home" order
* refactor for animate.css v4
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dankdomain",
"version": "2.5.4",
"version": "2.6.0",
"description": "Dank Domain: the return of Hack & Slash",
"main": "telnet",
"publisher": "theflyingape",
Expand Down Expand Up @@ -46,6 +46,7 @@
"animate.css": "^4.1.0",
"better-sqlite3": "^7.0.1",
"chokidar": "^3.4.0",
"class-validator": "^0.12.2",
"express": "^4.17.1",
"fs-extra": "^9.0.0",
"got": "^11.2.0",
Expand All @@ -61,7 +62,7 @@
"xterm-addon-unicode11": "^0.2.0",
"xterm-addon-web-links": "^0.4.0",
"xterm-addon-webgl": "^0.7.0",
"xvt": "^1.1.6"
"xvt": "^1.2.1"
},
"devDependencies": {
"@types/better-sqlite3": "^5.4.0",
Expand Down
27 changes: 14 additions & 13 deletions src/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import $ = require('./common')
import xvt = require('xvt')
import { isArray, isBoolean, isDefined } from 'class-validator'
import { sprintf } from 'sprintf-js'

module Battle {
Expand Down Expand Up @@ -189,12 +190,12 @@ module Battle {
$.from = menu

let a: active[], b: active[]
if (xvt.validator.isArray(party))
if (isArray(party))
a = <active[]>party
else
a = new Array(<active>party)

if (xvt.validator.isArray(mob))
if (isArray(mob))
b = <active[]>mob
else
b = new Array(<active>mob)
Expand Down Expand Up @@ -804,15 +805,15 @@ module Battle {
let credit = new $.coins(loser.weapon.value)
credit.value = $.worth(credit.value, winner.cha)
let result = $.Weapon.swap(winner, loser, credit)
if (xvt.validator.isBoolean(result) && result)
if (isBoolean(result) && result)
xvt.outln(winner.who.He, $.what(winner, 'take'), loser.who.his, winner.user.weapon, '.')
else if ($.from == 'Monster' && result)
xvt.outln(winner.who.He, $.what(winner, 'get'), credit.carry(), ' for ', loser.who.his, loser.user.weapon, '.')

credit = new $.coins(loser.armor.value)
credit.value = $.worth(credit.value, winner.cha)
result = $.Armor.swap(winner, loser, credit)
if (xvt.validator.isBoolean(result) && result) {
if (isBoolean(result) && result) {
xvt.outln(winner.who.He, 'also ', $.what(winner, 'take'), loser.who.his, winner.user.armor, '.')
if (/_DM|_NEP|_OLD|_TAX/.test(loser.user.id)) $.sound('shield', 16)
}
Expand Down Expand Up @@ -1144,7 +1145,7 @@ module Battle {
}

// some sensible ground rules to avoid known muling exploits, aka White Knights passing gas
if (xvt.validator.isDefined(nme)) {
if (isDefined(nme)) {
if ([1, 2, 3, 4, 5, 6, 10].indexOf(spell.cast) >= 0) {
if (rpc === $.online)
xvt.outln('You cannot cast that spell during a battle!')
Expand Down Expand Up @@ -1222,30 +1223,30 @@ module Battle {
}

// Tigress prefers the Ranger (and Paladin) class, because it comes with a coupon and a better warranty
if (rpc.user.magic == 2 && !summon && $.dice(+xvt.validator.isDefined($.Access.name[rpc.user.access].sysop) + 5) == 1) {
if (rpc.user.magic == 2 && !summon && $.dice(+isDefined($.Access.name[rpc.user.access].sysop) + 5) == 1) {
rpc.altered = true
$.Magic.remove(rpc.user.spells, spell.cast)
if (!(rpc.user.id[0] == '_' || rpc.user.gender == 'I')) $.saveUser(rpc)
xvt.outln(p1.His, 'scroll burns as ', p1.he, $.what(rpc, 'cast'), 'the spell ... ', -44 * spell.cast)
}

if (xvt.validator.isDefined(nme)) {
if (isDefined(nme)) {
let mod = $.Ring.power([], nme.user.rings, 'resist', 'spell', name)
if (mod.power) {
if (!$.Ring.have(rpc.user.rings, $.Ring.theOne)) {
xvt.outln(xvt.faint, '>> ', xvt.normal, p1.His, xvt.bright, xvt.magenta, name, xvt.normal, ' spell '
, xvt.reset, 'attempt is ineffective against')
xvt.out(' ', p2.his, xvt.bright, xvt.cyan, mod.name, xvt.normal)
, -300, xvt.reset, 'attempt is ineffective against', -200)
xvt.out(' ', p2.his, xvt.bright, xvt.cyan, mod.name, xvt.normal, -100)
if ($.player.emulation == 'XT' && nme.user.sex !== 'I') xvt.out(' ', $.Ring.name[mod.name].emoji, ' 💍')
xvt.outln(nme.user.sex == 'I' ? ' power' : ' ring', xvt.reset, '!', xvt.faint, ' <<')
cb()
return
}
else {
xvt.out(xvt.magenta, xvt.faint, '>> ', xvt.normal, p1.His, xvt.bright, $.Ring.theOne, xvt.normal, ' ring '
, 'dispels ', p2.his, xvt.bright, xvt.cyan, mod.name, xvt.normal)
xvt.out(xvt.magenta, xvt.faint, '>> ', xvt.normal, p1.His, xvt.bright, $.Ring.theOne, xvt.normal, ' ring ', -300
, 'dispels ', p2.his, xvt.bright, xvt.cyan, mod.name, xvt.normal, -200)
if ($.player.emulation == 'XT') xvt.out(' ', $.Ring.name[mod.name].emoji, ' 💍')
xvt.outln(' ring', xvt.magenta, '!', xvt.faint, ' <<', -400)
xvt.outln(' ring', xvt.magenta, '!', xvt.faint, ' <<', -100)
}
}
}
Expand Down Expand Up @@ -1405,7 +1406,7 @@ module Battle {
break

case 8:
if (xvt.validator.isDefined(nme)) {
if (isDefined(nme)) {
$.sound('teleport')
xvt.out(xvt.bright, xvt.magenta)
if (backfire) {
Expand Down
35 changes: 22 additions & 13 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import fs = require('fs')
import xvt = require('xvt')
import Items = require('./items')
import { isDefined, isEmpty, isNotEmpty } from 'class-validator'
import { sprintf } from 'sprintf-js'
import { titleCase } from 'title-case'

Expand Down Expand Up @@ -231,7 +232,7 @@ module Common {

i = 22 - profile.user.handle.length
n = 11 + i / 2
xvt.out(xvt.clear)
clear()
xvt.out(xvt.blue, '+', xvt.faint, line.slice(0, n), xvt.normal, '=:))')
xvt.out(xvt.Blue, xvt.yellow, xvt.bright, ' ', profile.user.handle, ' ', xvt.reset)
n = 11 + i / 2 + i % 2
Expand Down Expand Up @@ -441,7 +442,7 @@ module Common {
xvt.out(sprintf('%-42s', profile.user.realestate + ' (' + profile.user.security + ')'))
xvt.outln(' ', xvt.reset, xvt.blue, xvt.faint, '|')

if (xvt.validator.isNotEmpty(profile.user.gang)) {
if (profile.user.gang) {
xvt.out(xvt.blue, xvt.faint, '|', xvt.Blue, xvt.cyan, xvt.bright)
xvt.out(' Party: ', xvt.white)
if (player.emulation == 'XT') xvt.out('\r\x1B[2C🏴\r\x1B[12C')
Expand Down Expand Up @@ -685,7 +686,7 @@ module Common {
one.hull = one.user.hull
Weapon.equip(one, one.user.weapon, true)
Armor.equip(one, one.user.armor, true)
if (!xvt.validator.isDefined(one.user.access))
if (!isDefined(one.user.access))
one.user.access = Object.keys(Access.name)[0]

if (keep) {
Expand Down Expand Up @@ -748,7 +749,7 @@ module Common {
let title = Object.keys(Access.name).indexOf(rpc.user.access)
do {
rpc.user.access = Object.keys(Access.name)[++title]
} while (!xvt.validator.isDefined(Access.name[rpc.user.access][rpc.user.gender]))
} while (!isDefined(Access.name[rpc.user.access][rpc.user.gender]))
xvt.outln(-500)
xvt.outln(xvt.yellow
, Access.name[king.access][king.sex], ' the ', king.access.toLowerCase()
Expand Down Expand Up @@ -1359,7 +1360,7 @@ module Common {
}

function ability(field?: string) {
if (xvt.validator.isNotEmpty(field)) {
if (isNotEmpty(field)) {
xvt.out('\n', xvt.yellow, 'You have ', xvt.bright, points.toString(), xvt.normal, ' points to distribute between 4 abilities: Strength, Intellect,\n')
xvt.outln('Dexterity, Charisma. Each ability must be between ', xvt.bright, '20', xvt.normal, ' and ', xvt.bright, '80', xvt.normal, ' points.')
xvt.app.form[field].enter = player.str.toString()
Expand Down Expand Up @@ -1479,7 +1480,7 @@ module Common {
user.tw = 0

// reset for new or non player
if (xvt.validator.isEmpty(user.id) || user.id[0] == '_') {
if (isEmpty(user.id) || user.id[0] == '_') {
if (isNaN(user.dob)) user.dob = now().date
if (isNaN(user.joined)) user.joined = now().date
user.lastdate = now().date
Expand All @@ -1492,7 +1493,7 @@ module Common {
user.expert = false
user.rows = process.stdout.rows || 24
user.remote = ''
user.novice = xvt.validator.isEmpty(user.id) && user.gender !== 'I'
user.novice = isEmpty(user.id) && user.gender !== 'I'
user.gang = ''
user.wins = 0
user.immortal = 0
Expand Down Expand Up @@ -1520,7 +1521,7 @@ module Common {
// if (!user.novice && !Access.name[player.access].sysop) user.email = ''
}

if (level == 1 || xvt.validator.isEmpty(user.id) || user.id[0] == '_') {
if (level == 1 || isEmpty(user.id) || user.id[0] == '_') {
// no extra free or augmented stuff
user.poisons = []
user.spells = []
Expand Down Expand Up @@ -1982,6 +1983,14 @@ module Common {
}
}

export function clear() {
const scroll = xvt.row - (xvt.col == 1 ? 1 : 0)
xvt.out(xvt.off)
xvt.plot(player.rows, 1)
xvt.outln('\n'.repeat(scroll))
xvt.out(xvt.clear)
}

export function death(by: string) {
reason = by
profile({ handle: `💀 ${reason} 💀`, png: `death${player.today}`, effect: 'fadeInDownBig' })
Expand All @@ -1991,7 +2000,7 @@ module Common {
export function display(title: string, back: number, fore: number, suppress: boolean, menu: choices, hint?: string): string {
menu['Q'] = {} // Q=Quit
if (!suppress) {
xvt.out(xvt.reset, xvt.clear)
clear()
if (!cat(title)) {
xvt.out(' ')
if (back)
Expand All @@ -2002,7 +2011,7 @@ module Common {
xvt.out(titlecase(title))
xvt.outln('\n')
for (let i in menu) {
if (xvt.validator.isNotEmpty(menu[i].description))
if (isNotEmpty(menu[i].description))
xvt.outln(xvt.faint, fore, '<', xvt.bright, xvt.white, i, xvt.faint, fore, '> ',
xvt.reset, menu[i].description)
}
Expand Down Expand Up @@ -2035,7 +2044,7 @@ module Common {
xvt.app.form = {
'term': {
cb: () => {
if (xvt.validator.isNotEmpty(xvt.entry) && xvt.entry.length == 2) xvt.app.emulation = <xvt.emulator>xvt.entry.toUpperCase()
if (isNotEmpty(xvt.entry) && xvt.entry.length == 2) xvt.app.emulation = <xvt.emulator>xvt.entry.toUpperCase()
player.emulation = xvt.app.emulation
xvt.outln('\n\n', xvt.reset, xvt.magenta, xvt.app.LGradient, xvt.reverse, 'BANNER', xvt.noreverse, xvt.app.RGradient)
xvt.outln(xvt.red, 'R', xvt.green, 'G', xvt.blue, 'B', xvt.reset, xvt.bright, ' bold ', xvt.normal, 'normal', xvt.blink, ' flash ', xvt.noblink, xvt.faint, 'dim')
Expand Down Expand Up @@ -2101,7 +2110,7 @@ module Common {
news(`\tonline player dropped by ${sysop.who} ${time(player.lasttime)} (${reason})\n`, true)
}
}
if (xvt.validator.isNotEmpty(player.id)) {
if (isNotEmpty(player.id)) {
if (access.roleplay) {
// did midnight or noon cross since last visit?
if (player.lastdate != now().date || (player.lasttime < 1200 && now().time >= 1200))
Expand Down Expand Up @@ -2433,7 +2442,7 @@ module Common {

let user: user = isActive(rpc) ? rpc.user : rpc

if (xvt.validator.isEmpty(user.id)) return
if (isEmpty(user.id)) return
if (insert || locked || user.id[0] == '_') {
let trace = `${users}/.${user.id}.json`
fs.writeFileSync(trace, JSON.stringify(user, null, 2))
Expand Down
3 changes: 2 additions & 1 deletion src/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import fs = require('fs')
import nodemailer = require('nodemailer')
import smtpTransport = require('nodemailer-smtp-transport')
import xvt = require('xvt')
import { isEmail } from 'class-validator'

module Email {

Expand All @@ -27,7 +28,7 @@ module Email {

function email() {
$.player.email = xvt.entry.toLowerCase()
if (!xvt.validator.isEmail($.player.email)) {
if (!isEmail($.player.email)) {
xvt.app.refocus()
return
}
Expand Down
3 changes: 2 additions & 1 deletion src/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
\*****************************************************************************/

import xvt = require('xvt')
import { isDefined } from 'class-validator'

module Items {

Expand Down Expand Up @@ -173,7 +174,7 @@ module Items {
let backfire: number

fail = rpc.int + Math.trunc(rpc.user.level / 10) - (this.spells[spell].cast < 17 ? this.spells[spell].cast : this.spells[spell].cast - 10)
if (xvt.validator.isDefined(nme) && [9, 11, 12, 14, 15, 16, 19, 20, 21, 22].indexOf(this.spells[spell].cast) >= 0) {
if (isDefined(nme) && [9, 11, 12, 14, 15, 16, 19, 20, 21, 22].indexOf(this.spells[spell].cast) >= 0) {
let m = rpc.int - nme.int
m = (m < -10) ? -10 : (m > 10) ? 10 : m
m += 2 * (skill - nme.user.magic)
Expand Down
5 changes: 3 additions & 2 deletions src/tty/arena.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import $ = require('../common')
import xvt = require('xvt')
import Battle = require('../battle')
import { isNotEmpty } from 'class-validator'
import { sprintf } from 'sprintf-js'

module Arena {
Expand Down Expand Up @@ -50,8 +51,8 @@ module Arena {
function choice() {
let suppress = false
let choice = xvt.entry.toUpperCase()
if (xvt.validator.isNotEmpty(arena[choice]))
if (xvt.validator.isNotEmpty(arena[choice].description)) {
if (isNotEmpty(arena[choice]))
if (isNotEmpty(arena[choice].description)) {
xvt.out(' - ', arena[choice].description)
suppress = $.player.expert
}
Expand Down
Loading

0 comments on commit 97c8caf

Please sign in to comment.