-
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
15 changed files
with
113 additions
and
30 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
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
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,26 @@ | ||
import type { TestContext } from "../types/test-context.js"; | ||
import { getGame } from "../utils/get-game.js"; | ||
import { Phase } from "../types/phase.js"; | ||
import { goToNextPhase } from "./go-to-next-phase.js"; | ||
|
||
export async function goToNextPlanningPhase( | ||
testContext: TestContext, | ||
playerIndex = 0, | ||
) { | ||
const frontContext = testContext.frontContexts[playerIndex]; | ||
|
||
if (!frontContext) { | ||
throw new Error(`Player ${playerIndex} not found !`); | ||
} | ||
|
||
if (!frontContext.playsig) { | ||
throw new Error(`Player ${playerIndex} has not initiated the game !`); | ||
} | ||
|
||
let game = await getGame(testContext); | ||
|
||
do { | ||
await goToNextPhase(testContext); | ||
game = await getGame(testContext); | ||
} while (game?.phase !== Phase.Planning); | ||
} |
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
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,11 @@ | ||
import { asPlayerLevelUp } from "../automations/as-player-level-up.js"; | ||
import { goToNextPlanningPhase } from "../automations/go-to-next-planning-phase.js"; | ||
import type { TestContext } from "../types/test-context.js"; | ||
import { withOneBoughtHero } from "./with-one-bought-hero.js"; | ||
|
||
export async function withOneBoughtHeroAndLevelTwo(): Promise<TestContext> { | ||
const testContext = await withOneBoughtHero(); | ||
await goToNextPlanningPhase(testContext); | ||
await asPlayerLevelUp(testContext); | ||
return testContext; | ||
} |
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
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
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,21 @@ | ||
import type { Game } from "../types/game.js"; | ||
import type { PublicKey } from "../types/public-key.js"; | ||
import { getHeroCost } from "./get-hero-cost.js"; | ||
import { getLevelUpCost } from "./get-level-up-cost.js"; | ||
|
||
export function isBotOutOfMoves(game: Game, publicKey: PublicKey): boolean { | ||
const money = game.playerMoney[publicKey]; | ||
const levelUpCost = getLevelUpCost(game, publicKey); | ||
const cantLevelUp = money < levelUpCost; | ||
const shop = game.playerShops[publicKey] || []; | ||
const minShopEntryPrice = Math.min(...shop.map(getHeroCost)); | ||
const bench = game.playerBenches[publicKey] || {}; | ||
const benchSize = Object.values(bench).filter(Boolean).length; | ||
const benchHasFreeSlots = benchSize < 6; | ||
const cantShopBuy = money < minShopEntryPrice || !benchHasFreeSlots; | ||
const board = game.playerHeroes[publicKey] || []; | ||
const level = game.playerLevel[publicKey] || 1; | ||
const boardHasFreeSlots = board.length < level; | ||
const cantTransposeToBoard = !benchSize || !boardHasFreeSlots; | ||
return cantLevelUp && cantShopBuy && cantTransposeToBoard; | ||
} |
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
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