Skip to content

Commit

Permalink
🪑 Portray bench
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdodo committed Nov 28, 2024
1 parent 976ed18 commit 93c1f01
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions core/utils/portray-bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Hero } from "../types/hero";
import type { Piece } from "../types/piece";
import { Animation } from "../types/animation";

export function portrayBench(
bench: Record<number, Hero>,
): Record<number, Piece> {
return Object.fromEntries(
Object.entries(bench).map(([index, hero]) => [
Number.parseInt(index, 10),
{
hero,
animation: Animation.Idle,
transposed: false,
animationStartAt: Date.now(),
right: false,
},
]),
);
}
3 changes: 2 additions & 1 deletion core/utils/portray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getLevelUpCost } from "./get-level-up-cost";
import { observePortrayedConfrontation } from "./observe-portrayed-confrontation";
import type { PublicKey } from "../types/public-key";
import type { Piece } from "../types/piece";
import { portrayBench } from "./portray-bench";

export function portray(publicKey: PublicKey): OperatorFunction<Game, Display> {
return (source: Observable<Game>) =>
Expand All @@ -32,7 +33,7 @@ export function portray(publicKey: PublicKey): OperatorFunction<Game, Display> {
isMe: p === publicKey,
})),
shop: game.playerShops[publicKey] || [],
bench: {},
bench: portrayBench(game.playerBenches[publicKey] || {}),
phase: game.phase,
money: game.playerMoney[publicKey] || 0,
levelUpCost: getLevelUpCost(game, publicKey),
Expand Down

0 comments on commit 93c1f01

Please sign in to comment.