Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: CI

on:
pull_request:
paths:
- 'functions/**'
branches:
- master
push:
paths:
- 'functions/**'
Expand Down Expand Up @@ -28,6 +33,7 @@ jobs:
npm run test

deploy:
if: github.event == 'push'
needs: test
runs-on: ubuntu-latest
steps:
Expand All @@ -48,4 +54,4 @@ jobs:
with:
args: deploy --only functions
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
27 changes: 15 additions & 12 deletions functions/src/util/shuffle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,23 @@ export function cut<T>(array: T[], cutVariance: number = 10): T[] {

export function fisherYatesModifiedShuffleCutFive<T>(array: T[]): T[] {
if (array.length <= 1) return array;

//loop five times
for (let i = 0; i < 5; i++) {
//run a Fisher-Yates Shuffle
for (let i = 0; i < array.length; i++) {
const randomChoiceIndex = getRandom(i, array.length - 1);
[array[i], array[randomChoiceIndex]] = [array[randomChoiceIndex], array[i]];
}
//cut the deck
const cv = Math.min(array.length, cutVariance);
const cutPos = Math.floor(Math.random() * cv) + ((array.length - cv) / 2);
const bottom = array.slice(0, cutPos);
const top = array.slice(cutPos);

}

//run a Fisher-Yates Shuffle
for (let i = 0; i < array.length; i++) {
const randomChoiceIndex = getRandom(i, array.length - 1);
[array[i], array[randomChoiceIndex]] = [array[randomChoiceIndex], array[i]];
}
//cut the deck
const cv = Math.min(array.length, 10);
const cutPos = Math.floor(Math.random() * cv) + ((array.length - cv) / 2);
const bottom = array.slice(0, cutPos);
const top = array.slice(cutPos);
array = top.concat(bottom);
}

//return the array
return array;
}