Skip to content

Commit 13e2541

Browse files
committed
EditorConfig + eslint fixes
1 parent 2cf47bf commit 13e2541

File tree

9 files changed

+36
-25
lines changed

9 files changed

+36
-25
lines changed

.editorconfig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
root = true
22

3-
# Unix-style newlines with a newline ending every file
43
[*]
54
charset = utf-8
65
end_of_line = lf
76
insert_final_newline = true
87

9-
[*.js,*.json]
8+
[*.js]
9+
indent_style = space
10+
indent_size = 2
11+
trim_trailing_whitespace = true
12+
13+
[*.json]
1014
indent_style = space
1115
indent_size = 2
1216
trim_trailing_whitespace = true

.eslintrc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ rules:
77
- error
88
- 2
99
- SwitchCase: 1
10+
no-multiple-empty-lines:
11+
- error
12+
- max: 2
13+
maxEOF: 1
1014
linebreak-style:
1115
- error
1216
- unix

lib/advent350/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
/**
44
* This file is a reimplementation of the game written at:
5-
*
5+
*
66
* https://github.com/Quuxplusone/Advent/blob/master/POHL0350/
7-
*
7+
*
88
* Basically, it's the 350-point version of the Colossal Cave Adventure as
99
* written by Jerry Pohl in 1984. (And of course based on the game created by
1010
* Will Crowther, and then extended by Don Woods.) It's mostly faithful to the
@@ -31,11 +31,11 @@ const STRINGS = _.assign({},
3131

3232
const MAXOBJ = 100; // max # of objects in cave
3333
// const MAXWC = 301; // max # of adventure words
34-
const MAXLOC = 145; // max # of cave locations
34+
const MAXLOC = 145; // max # of cave locations
3535
// const WORDSIZE = 20; // max # of chars in commands
3636
// const MAXMSG = 201; // max # of action messages
3737

38-
// const MAXTRAV = 16+1; // max # of travel directions from loc
38+
// const MAXTRAV = 16+1; // max # of travel directions from loc
3939
const DWARFMAX = 7; // max # of nasty dwarves
4040
const MAXDIE = 3; // max # of deaths before close
4141
const MAXTRS = 79; // max # of treasures in cave
@@ -518,7 +518,7 @@ GameState.prototype._handleDwarves = function () {
518518

519519
GameState.prototype._handleMovement = function () {
520520
if (this.loc === this.newloc) { return; }
521-
521+
522522
this.turns ++;
523523
this.loc = this.newloc;
524524

@@ -544,7 +544,7 @@ GameState.prototype._handleDescription = function () {
544544
var desc;
545545

546546
if (gu.toting(this, DEF.obj.BEAR)) { this._rspeak(141); }
547-
547+
548548
const is_dark = gu.dark(this);
549549
if (is_dark) {
550550
this._rspeak(16);
@@ -564,7 +564,7 @@ GameState.prototype._handleDescription = function () {
564564

565565
// We can see:
566566
this.visited[this.loc] ++;
567-
567+
568568
for (var i=1; i<MAXOBJ; i++) {
569569
if (gu.at(this, i)) {
570570
if (i === DEF.obj.STEPS && gu.toting(this, DEF.obj.NUGGET)) {
@@ -582,7 +582,7 @@ GameState.prototype._handleDescription = function () {
582582
var is_steps = i === DEF.obj.STEPS;
583583
var steps_here = this.loc === this.fixed[DEF.obj.STEPS];
584584
var state = (is_steps && steps_here) ? 1 : this.prop[i];
585-
585+
586586
this._pspeak(i, state);
587587
}
588588
}
@@ -649,11 +649,11 @@ GameState.prototype._parseEnglish = function (msg) {
649649
if (w1.type === 3 && w2.type === 3 && w1.val === 51 && w2.val === 51) {
650650
console.log("-- outwords()");
651651
return 0;
652-
652+
653653
} else if (w1.type === 3) {
654654
this._rspeak(w1.val);
655655
return 0;
656-
656+
657657
} else if (w2.type === 3) {
658658
this._rspeak(w2.val);
659659
return 0;
@@ -688,7 +688,7 @@ GameState.prototype._parseEnglish = function (msg) {
688688
this._msg(fail_msg);
689689
return 0;
690690
}
691-
691+
692692
} else {
693693
this._bug(36);
694694
return 0;

lib/advent350/methods/movement.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
const DEF = require('../vars/defs.json');
44
const gu = require('../gameUtils');
55

6+
const MAXOBJ = 100; // max # of objects in cave
7+
68
exports._doMove = function () {
79
switch (this.motion) {
810
case DEF.verb.NULLX:
@@ -77,7 +79,7 @@ exports._doTravel = function () {
7779
var travels = gu.travels(this.loc);
7880
for(var i=0; i<travels.length && !mvflag; i++) {
7981
cur = travels[i];
80-
82+
8183
var div = Math.floor(cur.tcond / 100);
8284
var robj = cur.tcond % 100;
8385

@@ -100,6 +102,7 @@ exports._doTravel = function () {
100102
if (gu.toting(this, robj) || gu.at(this, robj)) {
101103
mvflag ++;
102104
}
105+
break;
103106
case 3:
104107
case 4:
105108
case 5:
@@ -139,7 +142,7 @@ exports._badMove = function () {
139142
exports._specialMove = function (rdest) {
140143
switch(rdest - 300) {
141144
case 1:
142-
var hold = this.holding
145+
var hold = this.holding;
143146
if (!hold || (hold === 1 && gu.toting(this, DEF.obj.EMERALD))) {
144147
this.newloc = 199 - this.loc;
145148
} else {

lib/advent350/methods/verbs.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,13 @@ exports._verbTake = function () {
287287
}
288288

289289
gu.carry(this, obj);
290-
290+
291291
// Also liquids:
292292
var i = gu.liq(this);
293293
if (obj === DEF.obj.BOTTLE && i != 0) {
294294
this.place[i] = -1;
295295
}
296-
296+
297297
this._rspeak(54);
298298
};
299299

@@ -560,7 +560,7 @@ exports._intransitiveDrink = function () {
560560
exports._verbDrink = function () {
561561
if (this.object !== DEF.obj.WATER) {
562562
this._rspeak(110);
563-
563+
564564
} else if (gu.liq(this) !== DEF.obj.WATER || !gu.here(this, DEF.obj.BOTTLE)) {
565565
this._actionSpeak();
566566

@@ -605,7 +605,7 @@ exports._verbDrop = function () {
605605
this._pspeak(DEF.obj.BATTERIES, 0);
606606
return;
607607
}
608-
608+
609609
// Bird / Dragon:
610610
const is_bird = this.object === DEF.obj.BIRD;
611611
const at_dragon = gu.at(this, DEF.obj.DRAGON);
@@ -744,10 +744,10 @@ exports._verbSay = function () {
744744
exports._verbOn = function () {
745745
if (!gu.here(this, DEF.obj.LAMP)) {
746746
this._actionSpeak();
747-
747+
748748
} else if (this.limit < 0) {
749749
this._rspeak(184);
750-
750+
751751
} else {
752752
this.prop[DEF.obj.LAMP] = 1;
753753
this._rspeak(39);

lib/advent350/vars/actionMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@
3434
13,
3535
13
3636
]
37-
}
37+
}

lib/advent350/vars/defs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@
100100
"HINTM": 128,
101101
"HINT": 240
102102
}
103-
}
103+
}

lib/advent350/vars/travel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,4 +1033,4 @@
10331033
"80001000"
10341034
]
10351035
]
1036-
}
1036+
}

lib/advent350/vars/vocab.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,4 +1205,4 @@
12051205
"code": 55
12061206
}
12071207
]
1208-
}
1208+
}

0 commit comments

Comments
 (0)