From 5ecae77c12d7134cf3cc3a563b049236b0eb104c Mon Sep 17 00:00:00 2001 From: Chris Thibault Date: Tue, 16 Mar 2021 10:35:25 -0400 Subject: [PATCH 1/3] Update shuffle.ts fixed the cut and syntax errors, added white-space, added indentation --- functions/src/util/shuffle.ts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/functions/src/util/shuffle.ts b/functions/src/util/shuffle.ts index 7a9415f..b91d53e 100644 --- a/functions/src/util/shuffle.ts +++ b/functions/src/util/shuffle.ts @@ -26,20 +26,23 @@ export function cut(array: T[], cutVariance: number = 10): T[] { export function fisherYatesModifiedShuffleCutFive(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; } From d6e46aa8a09d30609242254ca6eb7bf00e406fb7 Mon Sep 17 00:00:00 2001 From: Drew Heavner Date: Tue, 16 Mar 2021 10:38:15 -0400 Subject: [PATCH 2/3] Update ci.yml --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3883851..09d0c4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,11 @@ name: CI on: + pull_request: + paths: + - 'functions/**' + branches: + - master push: paths: - 'functions/**' @@ -48,4 +53,4 @@ jobs: with: args: deploy --only functions env: - FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} \ No newline at end of file + FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} From 9a2cd69649c1e578102697b888d525de49d20c6d Mon Sep 17 00:00:00 2001 From: Drew Heavner Date: Tue, 16 Mar 2021 10:41:38 -0400 Subject: [PATCH 3/3] Update ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09d0c4f..7dc1c80 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,7 @@ jobs: npm run test deploy: + if: github.event == 'push' needs: test runs-on: ubuntu-latest steps: