|
| 1 | +/* eslint-env mocha */ |
| 2 | +const expect = require('chai').expect |
| 3 | +const { |
| 4 | + Cave |
| 5 | +} = require('./recipes') |
| 6 | + |
| 7 | +describe('--- Day 15: Beverage Bandits ---', () => { |
| 8 | + describe('Part 1:', () => { |
| 9 | + describe('new Cave()', () => { |
| 10 | + it('initializes a cave with elves and goblins', () => { |
| 11 | + const test = ` |
| 12 | + ####### |
| 13 | + #.G.E.# |
| 14 | + #E.G.E# |
| 15 | + #.G.E.# |
| 16 | + ####### |
| 17 | + ` |
| 18 | + const cave = new Cave(test) |
| 19 | + expect(cave.rounds).to.equal(0) |
| 20 | + expect(cave.outcome).to.equal(null) |
| 21 | + expect(cave.filter((unit) => unit.type === 'elves').length).to.equal(4) |
| 22 | + expect(cave.filter((unit) => unit.type === 'goblins').length).to.equal(3) |
| 23 | + expect(cave.filter((unit) => unit.type === 'elves')[0].location).to.deep.equal([5, 1]) |
| 24 | + expect(cave.filter((unit) => unit.type === 'goblins')[3].location).to.deep.equal([2, 3]) |
| 25 | + expect(cave.map[4][4]).to.equal('#') |
| 26 | + expect(cave.map[3][4]).to.equal('.') |
| 27 | + }) |
| 28 | + describe('advance()', () => { |
| 29 | + it('advances the cave combat cycle', () => { |
| 30 | + |
| 31 | + }) |
| 32 | + }) |
| 33 | + describe('findPath(origin, target)', () => { |
| 34 | + it('determines a path from the origin to the target', () => { |
| 35 | + |
| 36 | + }) |
| 37 | + it('returns null when the path is blocked by cave', () => { |
| 38 | + |
| 39 | + }) |
| 40 | + it('returns null when the path is blocked by other units', () => { |
| 41 | + |
| 42 | + }) |
| 43 | + }) |
| 44 | + describe('display()', () => { |
| 45 | + it('renders the current cave state', () => { |
| 46 | + |
| 47 | + }) |
| 48 | + }) |
| 49 | + }) |
| 50 | + describe('new Unit()', () => { |
| 51 | + it('initializes an elf or a goblin', () => { |
| 52 | + const expected = { hp: 200, ap: 3, location: [3, 4] } |
| 53 | + }) |
| 54 | + describe('attack()', () => { |
| 55 | + it('attacks the closest oponent', () => { |
| 56 | + |
| 57 | + }) |
| 58 | + }) |
| 59 | + describe('findClosestOponent()', () => { |
| 60 | + it('finds the unit\'s closest oponent', () => { |
| 61 | + |
| 62 | + }) |
| 63 | + }) |
| 64 | + describe('move()', () => { |
| 65 | + it('moves the unit towards the closest oponent', () => { |
| 66 | + const test = ` |
| 67 | + ####### |
| 68 | + #.E...# |
| 69 | + #.....# |
| 70 | + #...G.# |
| 71 | + #######` |
| 72 | + const expected = [3, 1] |
| 73 | + const cave = new Cave(test) |
| 74 | + cave.units[0].move() |
| 75 | + const actual = cave.units[0].location |
| 76 | + expect(actual).to.deep.equal(expected) |
| 77 | + }) |
| 78 | + }) |
| 79 | + }) |
| 80 | + }) |
| 81 | +}) |
0 commit comments