-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
32 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
import { test, expect } from "vitest"; | ||
import { withTwoPlayerGameStarted } from "../fixtures/with-two-player-game-started"; | ||
import { asPlayerReroll } from "../automations/as-player-reroll"; | ||
import { getDisplay } from "../utils/get-display"; | ||
import { getGame } from "../utils/get-game"; | ||
import { getGameShop } from "../utils/get-game-shop"; | ||
|
||
test("Reroll should swap the shop items with random hero from pool", async () => { | ||
const testContext = await withTwoPlayerGameStarted(); | ||
const display = await getDisplay(testContext); | ||
const game = await getGame(testContext); | ||
const publicKey = testContext.frontContexts[0].publicKey || "Error"; | ||
const shop = getGameShop(game, publicKey); | ||
const playsig = testContext.frontContexts[0].playsig || "Error"; | ||
const pool = await testContext.backContext.dataMapper.readPool(playsig); | ||
await asPlayerReroll(testContext); | ||
const displayAfter = await getDisplay(testContext); | ||
const gameAfter = await getGame(testContext); | ||
const shopAfter = getGameShop(gameAfter, publicKey); | ||
const poolAfter = await testContext.backContext.dataMapper.readPool(playsig); | ||
expect(displayAfter.shop).not.toEqual(display.shop); | ||
expect(shopAfter).not.toEqual(shop); | ||
expect(poolAfter?.heroes).not.toEqual(pool?.heroes); | ||
expect(pool?.heroes).toBeTruthy(); | ||
const merged = [...displayAfter.shop, ...(poolAfter?.heroes || [])].sort(); | ||
const mergedAfter = [...display.shop, ...(pool?.heroes || [])].sort(); | ||
const merged = [...shopAfter, ...(poolAfter?.heroes || [])].sort(); | ||
const mergedAfter = [...shop, ...(pool?.heroes || [])].sort(); | ||
expect(merged).toEqual(mergedAfter); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { Game } from "../types/game"; | ||
import type { Appellation } from "../types/appellation"; | ||
import type { PublicKey } from "../types/public-key"; | ||
|
||
export function getGameShop(game: Game, publicKey: PublicKey): Appellation[] { | ||
const shop = game.playerShops[publicKey]; | ||
|
||
if (!shop) { | ||
throw new Error("Shop not found !"); | ||
} | ||
|
||
return shop; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters