feat(hunt): Add bingo board to hunts
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
const possibleCombos = [
|
||||
// horizontal
|
||||
[0, 1, 2],
|
||||
[3, 4, 5],
|
||||
[6, 7, 8],
|
||||
// vertical
|
||||
[0, 3, 6],
|
||||
[1, 4, 7],
|
||||
[2, 5, 8],
|
||||
// diagonal
|
||||
[0, 4, 8],
|
||||
[2, 4, 6]
|
||||
];
|
||||
|
||||
export function bingoDone(fields: boolean[]) {
|
||||
// TODO: Support different sizes
|
||||
if (fields.length < 9) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return possibleCombos.some((combo) => combo.every((ci) => fields[ci]));
|
||||
}
|
||||
export function findBingo(fields: boolean[]) {
|
||||
// TODO: Support different sizes
|
||||
if (fields.length < 9) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return possibleCombos.filter((combo) => combo.every((ci) => !!fields[ci]))
|
||||
.length;
|
||||
}
|
||||
Reference in New Issue
Block a user