-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CI
- Loading branch information
Showing
9 changed files
with
135 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Pre-deploy | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [10.x, 12.x, 14.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm ci | ||
- run: npm run build --if-present | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.eslintcache | ||
|
||
# testing | ||
/coverage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Changelog | ||
|
||
This project is following [Semantic Versioning](https://semver.org/) | ||
|
||
## [1.4.1](https://github.com/j-m/word-guess/releases/tag/1.4.1) - Fix 'show seed' (December 16, 2020) | ||
|
||
- Fix 'show seed' seed | ||
- Added tests | ||
- Added GitHub action | ||
|
||
## [1.4.0](https://github.com/j-m/word-guess/releases/tag/1.4.0) - Start Menu Info (November 16, 2020) | ||
|
||
- Show seed button | ||
- Project version | ||
- GitHub link | ||
|
||
## [1.3.0](https://github.com/j-m/word-guess/releases/tag/1.3.0) - Continue Playing (November 16, 2020) | ||
|
||
- Added continue playing button if game lost | ||
- Added guess counter if playing in `overtime` | ||
- Created Heroku deployment | ||
|
||
## [1.2.0](https://github.com/j-m/word-guess/releases/tag/1.2.0) - Large Seed Fix (November 16, 2020) | ||
|
||
- Swapped to `bigint` to allow for arbitrarily long seeds (any words/sentences longer than 10 characters) | ||
- Better lose animation | ||
|
||
## [1.1.0](https://github.com/j-m/word-guess/releases/tag/1.1.0) - Spaces Fix (November 15, 2020) | ||
|
||
- Fixed seeds representing multi-word games | ||
- Fixed lives | ||
- Breaking change but only bumped minor because project was private | ||
|
||
## [1.0.0](https://github.com/j-m/word-guess/releases/tag/1.0.0) - Seeding (November 15, 2020) | ||
|
||
- Added seed calculation | ||
- Allow seed input in start menu | ||
- Detect if input is a numeric (seed), alpha + space (sentence) , or alphanumeric (invalid) | ||
- Lives separated into its own component | ||
|
||
## 0.1.0 - Proof of Concept | ||
|
||
- Added start menu | ||
- Added Sentence components | ||
- Added Alphabet components | ||
- Added lives | ||
- Added celebration/losing animations | ||
- Added replay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {sentenceToSeed, seedToSentence} from './seed' | ||
describe('Seed', () => { | ||
test('with 1 word', () => { | ||
const input = "TEST" | ||
const seed = sentenceToSeed(input) | ||
const output = seedToSentence(seed) | ||
expect(output).toBe(input) | ||
}) | ||
|
||
test('works with multiple words', () => { | ||
const input = "THIS IS A TEST" | ||
const seed = sentenceToSeed(input) | ||
const output = seedToSentence(seed) | ||
expect(output).toBe(input) | ||
}) | ||
|
||
test('works with a long sentence', () => { | ||
const input = "THIS IS A MUCH LONGER TEST THAN THE OTHERS BUT PROBABLY STILL IS NOT AS LONG AS A GOOD TEST SHOULD BE BUT HEY HO" | ||
const seed = sentenceToSeed(input) | ||
const output = seedToSentence(seed) | ||
expect(output).toBe(input) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const BASE: bigint = 27n | ||
|
||
export function sentenceToSeed(input: string): bigint { | ||
let seed: bigint = 0n | ||
Object.values(input.split("")).forEach(letter => { | ||
if (letter !== " ") { | ||
seed += BigInt(letter.charCodeAt(0)) - 65n + 1n | ||
} | ||
seed *= BASE | ||
}) | ||
return seed | ||
} | ||
|
||
export function seedToSentence(seed: bigint): string { | ||
let sentence: string = "" | ||
while (seed > BASE) { | ||
seed /= BASE | ||
const letter: bigint = seed % BASE | ||
if (letter === 0n) { | ||
sentence += ' ' | ||
} else { | ||
sentence += String.fromCharCode(Number(letter + 65n - 1n)) | ||
} | ||
} | ||
return sentence.split("").reverse().join("") | ||
} |