Skip to content

Commit

Permalink
Release 0.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarrough committed Dec 24, 2020
1 parent 7911800 commit 43db8d3
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 113 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v0.10.2](https://github.com/oskarrough/slaytheweb/compare/v0.10.1...v0.10.2)

- Add tutorial to main menu [`830a815`](https://github.com/oskarrough/slaytheweb/commit/830a8155e52cb858a320f8faa82e9e160ae9918e)
- Fix errors after upgrading immer v8 [`7911800`](https://github.com/oskarrough/slaytheweb/commit/79118002fe48133988ac4934f34e61e0dd58d6c9)

#### [v0.10.1](https://github.com/oskarrough/slaytheweb/compare/v0.10.0...v0.10.1)

> 24 December 2020
- Update dependencies [`cce6c4e`](https://github.com/oskarrough/slaytheweb/commit/cce6c4e6cb9e2dd0f036aa820f9e9ac9c6c49a5e)
- Nicer main menu [`7f626c3`](https://github.com/oskarrough/slaytheweb/commit/7f626c3c38101b0963985193c7a8a32be5414232)
- Display room type on the map [`77f36f8`](https://github.com/oskarrough/slaytheweb/commit/77f36f86c61ec1e1be3e76635ccd529851057fb8)
- Release 0.10.1 [`81c744d`](https://github.com/oskarrough/slaytheweb/commit/81c744d1de89f165659ab069f0b07f94c1af482e)

#### [v0.10.0](https://github.com/oskarrough/slaytheweb/compare/v0.9.5...v0.10.0)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slaytheweb",
"version": "0.10.1",
"version": "0.10.2",
"license": "AGPL-3.0-or-later",
"homepage": "https://slaytheweb.cards",
"bugs": "https://github.com/oskarrough/slaytheweb/issues",
Expand Down
152 changes: 76 additions & 76 deletions tests/dungeon.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
import test from 'ava'
import actions from '../public/game/actions'
import Dungeon, {CampfireRoom, MonsterRoom, Monster} from '../public/game/dungeon'
import {getCurrRoom, isCurrentRoomCompleted, isDungeonCompleted} from '../public/game/utils'

const a = actions

test('can create rooms with many monsters', (t) => {
const room = new MonsterRoom(new Monster(), new Monster())
t.is(room.monsters.length, 2)
})

test('can create a dungeon', (t) => {
const d = Dungeon({
rooms: [MonsterRoom(Monster()), CampfireRoom(), MonsterRoom(Monster())],
})
t.is(d.rooms.length, 3)
t.is(d.rooms[0].type, 'monster')
t.is(d.rooms[0].monsters.length, 1)
t.is(d.rooms[1].type, 'campfire')
t.is(d.rooms[2].type, 'monster')
})

test('can set a dungeon', (t) => {
const dungeon = Dungeon({rooms: [MonsterRoom(Monster())]})
let state = a.createNewGame()
state = a.setDungeon(state, dungeon)
t.deepEqual(state.dungeon, dungeon, 'setting dungeon works')
})

test('we know when a monster room is won', (t) => {
const room = new MonsterRoom(new Monster())
const state = {dungeon: {rooms: [room]}}
t.false(isCurrentRoomCompleted(state))
room.monsters[0].currentHealth = 0
t.true(isCurrentRoomCompleted(state))
})

test('we know when the entire dungeon has been cleared', (t) => {
const dungeon = Dungeon({
rooms: [MonsterRoom(Monster()), MonsterRoom(Monster())],
})
const state = {dungeon}
t.false(isDungeonCompleted(state))
state.dungeon.rooms[0].monsters[0].currentHealth = 0
t.false(isDungeonCompleted(state))
state.dungeon.rooms[1].monsters[0].currentHealth = 0
t.true(isDungeonCompleted(state))
})

test('we know when a monster room with many monsters is won', (t) => {
const room = new MonsterRoom(new Monster(), new Monster())
const state = {dungeon: {rooms: [room]}}
t.false(isCurrentRoomCompleted(state))
room.monsters[0].currentHealth = 0
t.false(isCurrentRoomCompleted(state))
room.monsters[1].currentHealth = 0
t.true(isCurrentRoomCompleted(state))
})

test.todo('we know when a campfire has been used')

test('we can navigate a dungeon', (t) => {
// Prepare a game with a dungeon.
let state = a.createNewGame()
const dungeon = Dungeon({
rooms: [CampfireRoom(), CampfireRoom(), CampfireRoom()],
})
state = a.setDungeon(state, dungeon)
// Go through the next rooms.
state = a.goToNextRoom(state)
t.is(getCurrRoom(state).id, dungeon.rooms[1].id)
state = a.goToNextRoom(state)
t.is(getCurrRoom(state).id, dungeon.rooms[2].id)
t.throws(() => a.goToNextRoom(state), null, 'can not go further than last room')
})
import test from 'ava'
import actions from '../public/game/actions'
import Dungeon, {CampfireRoom, MonsterRoom, Monster} from '../public/game/dungeon'
import {getCurrRoom, isCurrentRoomCompleted, isDungeonCompleted} from '../public/game/utils'

const a = actions

test('can create rooms with many monsters', (t) => {
const room = new MonsterRoom(new Monster(), new Monster())
t.is(room.monsters.length, 2)
})

test('can create a dungeon', (t) => {
const d = Dungeon({
rooms: [MonsterRoom(Monster()), CampfireRoom(), MonsterRoom(Monster())],
})
t.is(d.rooms.length, 3)
t.is(d.rooms[0].type, 'monster')
t.is(d.rooms[0].monsters.length, 1)
t.is(d.rooms[1].type, 'campfire')
t.is(d.rooms[2].type, 'monster')
})

test('can set a dungeon', (t) => {
const dungeon = Dungeon({rooms: [MonsterRoom(Monster())]})
let state = a.createNewGame()
state = a.setDungeon(state, dungeon)
t.deepEqual(state.dungeon, dungeon, 'setting dungeon works')
})

test('we know when a monster room is won', (t) => {
const room = new MonsterRoom(new Monster())
const state = {dungeon: {rooms: [room]}}
t.false(isCurrentRoomCompleted(state))
room.monsters[0].currentHealth = 0
t.true(isCurrentRoomCompleted(state))
})

test('we know when the entire dungeon has been cleared', (t) => {
const dungeon = Dungeon({
rooms: [MonsterRoom(Monster()), MonsterRoom(Monster())],
})
const state = {dungeon}
t.false(isDungeonCompleted(state))
state.dungeon.rooms[0].monsters[0].currentHealth = 0
t.false(isDungeonCompleted(state))
state.dungeon.rooms[1].monsters[0].currentHealth = 0
t.true(isDungeonCompleted(state))
})

test('we know when a monster room with many monsters is won', (t) => {
const room = new MonsterRoom(new Monster(), new Monster())
const state = {dungeon: {rooms: [room]}}
t.false(isCurrentRoomCompleted(state))
room.monsters[0].currentHealth = 0
t.false(isCurrentRoomCompleted(state))
room.monsters[1].currentHealth = 0
t.true(isCurrentRoomCompleted(state))
})

test.todo('we know when a campfire has been used')

test('we can navigate a dungeon', (t) => {
// Prepare a game with a dungeon.
let state = a.createNewGame()
const dungeon = Dungeon({
rooms: [CampfireRoom(), CampfireRoom(), CampfireRoom()],
})
state = a.setDungeon(state, dungeon)
// Go through the next rooms.
state = a.goToNextRoom(state)
t.is(getCurrRoom(state).id, dungeon.rooms[1].id)
state = a.goToNextRoom(state)
t.is(getCurrRoom(state).id, dungeon.rooms[2].id)
t.throws(() => a.goToNextRoom(state), null, 'can not go further than last room')
})
70 changes: 35 additions & 35 deletions tests/game.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import test from 'ava'
import createNewGame from '../public/game/index.js'
import {createCard} from '../public/game/cards'

// We don't want to test too much here,
// since tests/actions.js has most of it.

test('it all', (t) => {
const game = createNewGame()
t.is(game.state.player.currentHealth, 72)
// can add a card
const strike = createCard('Strike')
game.enqueue({type: 'addCardToHand', card: strike})
t.is(game.future.list.length, 1)
t.is(game.past.list.length, 0)
game.dequeue()
t.is(game.future.list.length, 0)
t.is(game.past.list.length, 1)
t.is(game.state.hand.length, 6)
t.is(game.state.hand[game.state.hand.length - 1].id, strike.id)
// we can undo
game.undo()
t.is(game.state.hand.length, 5)
// and draw cards again
game.enqueue({type: 'drawCards'})
game.dequeue()
t.is(game.state.hand.length, 10)
})

test('game also contains actions', (t) => {
const game = createNewGame()
game.state.hand = []
game.state = game.actions.drawCards(game.state)
t.is(game.state.hand.length, 5)
})
import test from 'ava'
import createNewGame from '../public/game/index.js'
import {createCard} from '../public/game/cards'

// We don't want to test too much here,
// since tests/actions.js has most of it.

test('it all', (t) => {
const game = createNewGame()
t.is(game.state.player.currentHealth, 72)
// can add a card
const strike = createCard('Strike')
game.enqueue({type: 'addCardToHand', card: strike})
t.is(game.future.list.length, 1)
t.is(game.past.list.length, 0)
game.dequeue()
t.is(game.future.list.length, 0)
t.is(game.past.list.length, 1)
t.is(game.state.hand.length, 6)
t.is(game.state.hand[game.state.hand.length - 1].id, strike.id)
// we can undo
game.undo()
t.is(game.state.hand.length, 5)
// and draw cards again
game.enqueue({type: 'drawCards'})
game.dequeue()
t.is(game.state.hand.length, 10)
})

test('game also contains actions', (t) => {
const game = createNewGame()
game.state.hand = []
game.state = game.actions.drawCards(game.state)
t.is(game.state.hand.length, 5)
})

0 comments on commit 43db8d3

Please sign in to comment.