From 79e21a11562ca522f8088ab203d7519201019d1e Mon Sep 17 00:00:00 2001 From: Nathan Du Date: Sat, 2 Oct 2021 15:04:19 +0800 Subject: [PATCH] allow viewing current attributes during trajectory[sic] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 补上了查看当前属性的功能。 命令行端的功能现在应该和 web 端差不多了。 ||为什么要给查看当前属性的功能取 getLastRecord 这样奇怪的名字|| --- repl/app.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/repl/app.js b/repl/app.js index 37d3a37..db3ef61 100644 --- a/repl/app.js +++ b/repl/app.js @@ -134,7 +134,7 @@ class App { case '/alloc': case '/allocate': case '/attrib': - case '/attribute': return this.alloc(...command); + case '/attribute': return this.attrib(...command); case 'rd': case 'random': @@ -516,6 +516,31 @@ class App { return total - CHR - INT - STR - MNY; } + attrib(tag, value) { + switch (this.#step) { + case this.Steps.PROPERTY: + return this.alloc(tag, value); + + case this.Steps.TRAJECTORY: + return this.viewProperty(); + + default: + return undefined; + } + } + + viewProperty() { + let property = this.#life.getLastRecord(); + return `当前属性 + +属性(TAG) 当前值 +颜值(CHR) ${property.CHR} +智力(INT) ${property.INT} +体质(STR) ${property.STR} +家境(MNY) ${property.MNY} +快乐(SPR) ${property.SPR}` + } + alloc(tag, value) { const warn = str => `${this.prop()}\n${this.style('warn', str)}` if(!value) return warn('⚠ 分配的数值没有给定');