@slugbugblue/trax 0.9.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +9 -10
- package/docs/point.md +7 -0
- package/package.json +6 -3
- package/src/cli.js +2 -2
- package/src/cmds/import-export.js +2 -2
- package/src/point.js +12 -0
- package/src/version.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @slugbugblue/trax
|
|
2
2
|
|
|
3
|
+
## 0.10.1 - 0.10.2 - 2022-06-12
|
|
4
|
+
|
|
5
|
+
- Added an entry point for the `Point` class at `@slugbugblue/trax/point`
|
|
6
|
+
|
|
7
|
+
## 0.10.0 - 2022-06-12
|
|
8
|
+
|
|
9
|
+
- Added `point.in(topLoft, bottomRight)` to see if a point is inside a
|
|
10
|
+
rectangular bounded area
|
|
11
|
+
- Minor coding style changes due to updated `xo` rules
|
|
12
|
+
|
|
3
13
|
## 0.9.0 - 2022-04-24
|
|
4
14
|
|
|
5
15
|
- Added tab-completion and completion preview code to the interactive CLI
|
package/README.md
CHANGED
|
@@ -117,11 +117,9 @@ puzzle.play('@2\\')
|
|
|
117
117
|
|
|
118
118
|
For specifics, see the [engine.js documentation][engine-docs].
|
|
119
119
|
|
|
120
|
-
##
|
|
120
|
+
## Related Projects
|
|
121
121
|
|
|
122
|
-
- Game position analysis
|
|
123
|
-
- Bot
|
|
124
|
-
- Puzzles
|
|
122
|
+
- [TraxBot][traxbot]: Game position analysis and puzzlebot
|
|
125
123
|
|
|
126
124
|
## Support
|
|
127
125
|
|
|
@@ -142,11 +140,11 @@ Thanks to his widow Colleen Foley-Smith for extending that courtesy to allow me
|
|
|
142
140
|
to include Trax on [slugbugblue.com][sbb] as well.
|
|
143
141
|
|
|
144
142
|
I would also like to extend a huge heartfelt appreciation to the magnanimous
|
|
145
|
-
[Donald G. Bailey][dgb], who, through his excellent
|
|
146
|
-
the basics (and more!) of Trax. I found him
|
|
147
|
-
on the mechanics of the game, as well as
|
|
148
|
-
complexities. His undeserved kindness and
|
|
149
|
-
questions can never be repaid.
|
|
143
|
+
[Donald G. Bailey][dgb], who, through his excellent book [Trax Strategy for
|
|
144
|
+
Beginners][traxbook], taught me the basics (and more!) of Trax. I found him
|
|
145
|
+
always ready to share his insights on the mechanics of the game, as well as
|
|
146
|
+
various approaches to encoding its complexities. His undeserved kindness and
|
|
147
|
+
infinite patience in indulging my many questions can never be repaid.
|
|
150
148
|
|
|
151
149
|
## License
|
|
152
150
|
|
|
@@ -165,7 +163,7 @@ specific language governing permissions and limitations under the License.
|
|
|
165
163
|
|
|
166
164
|
## Trax rules copyright
|
|
167
165
|
|
|
168
|
-
In the United States, game mechanics are not eligible for
|
|
166
|
+
In the United States, game mechanics are not eligible for copyright protection;
|
|
169
167
|
however, the specific wording of game rules does fall under copyright law.
|
|
170
168
|
|
|
171
169
|
The official rules for Trax are found at http://traxgame.com/about_rules.php.
|
|
@@ -181,6 +179,7 @@ David Smith and heirs, and are not to be used without permission.
|
|
|
181
179
|
[repo]: https://gitlab.com/slugbugblue/trax
|
|
182
180
|
[sbb]: https://slugbugblue.com/
|
|
183
181
|
[traxbook]: http://traxgame.com/shop_book.php
|
|
182
|
+
[traxbot]: https://gitlab.com/slugbugblue/traxbot
|
|
184
183
|
[traxgame]: http://traxgame.com/
|
|
185
184
|
[xdg]:
|
|
186
185
|
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
package/docs/point.md
CHANGED
|
@@ -85,6 +85,13 @@ Returns the distance between two points. This will never be a negative number.
|
|
|
85
85
|
Returns `true` if the given point or point-like object is at the same location
|
|
86
86
|
as the existing point.
|
|
87
87
|
|
|
88
|
+
##### `in(topLeft, bottomRight)`
|
|
89
|
+
|
|
90
|
+
Pass in two points (or point-like objects) to define a rectangular bounding box.
|
|
91
|
+
|
|
92
|
+
Returns `true` if the calling point is located inside the box or along any of
|
|
93
|
+
its edges (ie, both bounding points are considered "inside").
|
|
94
|
+
|
|
88
95
|
#### Plays well with others
|
|
89
96
|
|
|
90
97
|
The Point class also includes functionality to provide useful default results
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slugbugblue/trax",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Trax game engine and friends",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"trax",
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
"bugs": "https://gitlab.com/slugbugblue/trax/issues",
|
|
12
12
|
"license": "Apache-2.0",
|
|
13
13
|
"author": "Chad Transtrum <chad@transtrum.net>",
|
|
14
|
-
"exports":
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./src/engine.js",
|
|
16
|
+
"./point.js": "./src/point.js"
|
|
17
|
+
},
|
|
15
18
|
"repository": "gitlab:slugbugblue/trax",
|
|
16
19
|
"bin": {
|
|
17
20
|
"trax": "./src/cli.js"
|
|
@@ -31,7 +34,7 @@
|
|
|
31
34
|
"c8": "^7.11.0",
|
|
32
35
|
"genversion": "^3.0.2",
|
|
33
36
|
"prettier": "^2.6.1",
|
|
34
|
-
"xo": "
|
|
37
|
+
"xo": "0.*"
|
|
35
38
|
},
|
|
36
39
|
"type": "module",
|
|
37
40
|
"engines": {
|
package/src/cli.js
CHANGED
|
@@ -485,7 +485,7 @@ const expand = (completions, match) => {
|
|
|
485
485
|
}
|
|
486
486
|
|
|
487
487
|
const completer = (line) => {
|
|
488
|
-
const words = line.split(/\s+/).filter(
|
|
488
|
+
const words = line.split(/\s+/).filter(Boolean)
|
|
489
489
|
|
|
490
490
|
let match = words.slice(-1)[0] || ''
|
|
491
491
|
const previous = new Set(words.slice(1, -1).map((s) => s.toLowerCase()))
|
|
@@ -541,7 +541,7 @@ const completer = (line) => {
|
|
|
541
541
|
}
|
|
542
542
|
|
|
543
543
|
const evaluate = async (command) => {
|
|
544
|
-
const [CMD, ...words] = command.split(/\s+/).filter(
|
|
544
|
+
const [CMD, ...words] = command.split(/\s+/).filter(Boolean)
|
|
545
545
|
const cmdLower = CMD.toLowerCase()
|
|
546
546
|
CLI.CMD = cmdLower
|
|
547
547
|
const cmd = abbreviations[cmdLower]
|
|
@@ -162,7 +162,7 @@ importCmd.fn = async (CLI, filename) => {
|
|
|
162
162
|
if (lower.includes('loop')) game = 'traxloop'
|
|
163
163
|
if (lower.includes('8x8')) game = 'trax8'
|
|
164
164
|
} else if (players.length === 0 && lower.includes(' vs ')) {
|
|
165
|
-
players = ln.split(' ').filter(
|
|
165
|
+
players = ln.split(' ').filter(Boolean)
|
|
166
166
|
} else {
|
|
167
167
|
moves.push(...ln.split(' '))
|
|
168
168
|
}
|
|
@@ -170,7 +170,7 @@ importCmd.fn = async (CLI, filename) => {
|
|
|
170
170
|
|
|
171
171
|
if (game) {
|
|
172
172
|
CLI.do('new', game, ...players)
|
|
173
|
-
CLI.do('play', ...moves.filter(
|
|
173
|
+
CLI.do('play', ...moves.filter(Boolean))
|
|
174
174
|
} else {
|
|
175
175
|
CLI.error(filename + ' does not appear to be formatted correctly.')
|
|
176
176
|
}
|
package/src/point.js
CHANGED
|
@@ -23,6 +23,8 @@ export const Point = class {
|
|
|
23
23
|
#x = 0
|
|
24
24
|
#y = 0
|
|
25
25
|
|
|
26
|
+
static dirs = ['up', 'down', 'left', 'right']
|
|
27
|
+
|
|
26
28
|
constructor(x, y) {
|
|
27
29
|
if (is(x, 'obj') && is(x.x, 'num') && is(x.y, 'num')) {
|
|
28
30
|
// You can call this with new Point(point) or new Point({x,y})
|
|
@@ -76,6 +78,7 @@ export const Point = class {
|
|
|
76
78
|
dir(direction) {
|
|
77
79
|
const error = 'direction must be one of: up, down, left, right, u, d, l, r'
|
|
78
80
|
if (!is(direction, 'str')) throw new SyntaxError(error)
|
|
81
|
+
direction = direction.toLowerCase()
|
|
79
82
|
if (direction[0] === 'u') return this.up
|
|
80
83
|
if (direction[0] === 'd') return this.down
|
|
81
84
|
if (direction[0] === 'l') return this.left
|
|
@@ -99,6 +102,15 @@ export const Point = class {
|
|
|
99
102
|
return this.#x === that.x && this.#y === that.y
|
|
100
103
|
}
|
|
101
104
|
|
|
105
|
+
in(topLeft, bottomRight) {
|
|
106
|
+
return (
|
|
107
|
+
this.x >= topLeft.x &&
|
|
108
|
+
this.x <= bottomRight.x &&
|
|
109
|
+
this.y >= topLeft.y &&
|
|
110
|
+
this.y <= bottomRight.y
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
102
114
|
// Play nicely with the rest of the world
|
|
103
115
|
|
|
104
116
|
toString() {
|
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '0.
|
|
2
|
+
export const version = '0.10.2'
|