90 lines
No EOL
2.2 KiB
TypeScript
90 lines
No EOL
2.2 KiB
TypeScript
interface SpecialCardMeta {
|
||
type: "single-use" | "permanent"
|
||
description: string
|
||
weight: number
|
||
minPlayers: number
|
||
isAllowedInFirstRound: boolean
|
||
}
|
||
|
||
export type SpecialCardId =
|
||
| "return-last-opponent" | "return-last-own" | "increase-target-by-2" | "decrease-target-by-2" | "next-round-covert" | "double-draw" | "force-hit"
|
||
| "end-game"
|
||
|
||
export const specialCardsMeta: Record<SpecialCardId, SpecialCardMeta> = {
|
||
"return-last-opponent": {
|
||
type: "single-use",
|
||
description: "Return the last card your opponent drew to the stack.",
|
||
weight: 5,
|
||
minPlayers: 0,
|
||
isAllowedInFirstRound: false
|
||
},
|
||
"return-last-own": {
|
||
type: "single-use",
|
||
description: "Return the last card you drew to the stack.",
|
||
weight: 4,
|
||
minPlayers: 0,
|
||
isAllowedInFirstRound: false
|
||
},
|
||
"increase-target-by-2": {
|
||
type: "permanent",
|
||
description: "Increases the target card value by two.",
|
||
weight: 1,
|
||
minPlayers: 0,
|
||
isAllowedInFirstRound: true
|
||
},
|
||
"decrease-target-by-2": {
|
||
type: "permanent",
|
||
description: "Decreases the target card value by two.",
|
||
weight: 1,
|
||
minPlayers: 0,
|
||
isAllowedInFirstRound: true
|
||
},
|
||
"next-round-covert": {
|
||
type: "permanent",
|
||
description: "The next card you’ll draw will be covert.",
|
||
weight: 2,
|
||
minPlayers: 0,
|
||
isAllowedInFirstRound: true
|
||
},
|
||
"double-draw": {
|
||
type: "permanent",
|
||
description: "You will draw two number cards at once.",
|
||
weight: 5,
|
||
minPlayers: 0,
|
||
isAllowedInFirstRound: true
|
||
},
|
||
"force-hit": {
|
||
type: "permanent",
|
||
description: "Your opponent is not allowed to stay",
|
||
weight: 3,
|
||
minPlayers: 0,
|
||
isAllowedInFirstRound: true
|
||
},
|
||
"end-game": {
|
||
type: "permanent",
|
||
description: "The game ends after everyone had another turn.",
|
||
weight: 1000,
|
||
minPlayers: 3,
|
||
isAllowedInFirstRound: true
|
||
}
|
||
}
|
||
|
||
export const specialCardIds = Object.keys(specialCardsMeta) as SpecialCardId[]
|
||
|
||
export function createWeightedSpecialCardIdList(ids: SpecialCardId[]) {
|
||
const list: SpecialCardId[] = []
|
||
|
||
for (const id of ids) {
|
||
const meta = specialCardsMeta[id]
|
||
|
||
for (let i = 0; i < meta.weight; i++) {
|
||
list.push(id)
|
||
}
|
||
}
|
||
|
||
return list
|
||
}
|
||
|
||
export function getActiveSpecialCardIds(playerCount: number) {
|
||
return specialCardIds.filter(id => playerCount >= specialCardsMeta[id].minPlayers)
|
||
} |