-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: init migration to vite * feat: init migration to vite * chore: update lockfile * fix: make server work * fix: make build work for browser * chore: update ci
- Loading branch information
Showing
30 changed files
with
1,766 additions
and
10,530 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM node:16-alpine | ||
FROM node:18-alpine | ||
WORKDIR /usr/src/app | ||
|
||
COPY .yarn .yarn/ | ||
|
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 |
---|---|---|
@@ -1,43 +1,54 @@ | ||
c4 | ||
== | ||
# c4 | ||
|
||
![Test](https://github.com/kenrick95/c4/workflows/Test/badge.svg) | ||
![Test](https://github.com/kenrick95/c4/workflows/Test/badge.svg) ![Deploy](https://github.com/kenrick95/c4/workflows/Deploy/badge.svg) | ||
|
||
**c4**, stands for **Connect Four**, is a browser game written in TypeScript and utilizes HTML's `canvas`. Player is playing against an AI that uses Minimax algorithm and alpha-beta pruning. The evaluation function is hard-coded, and hence the AI may not be moving using the most optimal move. | ||
|
||
## Play | ||
* [kenrick95.github.io/c4](https://kenrick95.github.io/c4/) | ||
|
||
- [kenrick95.github.io/c4](https://kenrick95.github.io/c4/) | ||
|
||
## Gameplay | ||
|
||
### Objective | ||
*Connect four* of your game pieces vertically, horizontally, or diagonally before the other player do so. | ||
|
||
_Connect four_ of your game pieces vertically, horizontally, or diagonally before the other player do so. | ||
|
||
### How to move? | ||
|
||
At each turn, player will drop a game piece in one of the seven columns by clicking on the chosen column. | ||
|
||
### More info | ||
|
||
Read [Wikipedia page on Connect Four](https://en.wikipedia.org/wiki/Connect_Four) | ||
|
||
## Browser compatibility | ||
- Should be good in latest Firefox, Edge, Chrome, Opera, Safari, and IE. | ||
|
||
Should be good in latest Firefox, Edge, Chrome, and Safari. | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! I'm happy to accept any kind of contributions, pull requests, or bug reports. | ||
|
||
### Developing | ||
|
||
1. Fork and clone this repository | ||
2. Install dependencies | ||
``` | ||
yarn install | ||
``` | ||
|
||
``` | ||
yarn install | ||
``` | ||
|
||
3. Start local development server | ||
``` | ||
yarn start | ||
``` | ||
|
||
``` | ||
yarn start | ||
``` | ||
|
||
4. Make your changes at either `browser/`, `core/`, or `server/` | ||
5. Test it out at http://localhost:1234/ | ||
5. Test it out at http://localhost:5173/ | ||
6. After you are happy with your changes, please submit your Pull Request! | ||
|
||
## License | ||
|
||
This work is licensed under MIT License. |
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
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
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,13 @@ | ||
/** | ||
* @see https://esdiscuss.org/topic/promises-async-functions-and-requestanimationframe-together | ||
*/ | ||
export function animationFrame(): Promise<Function> { | ||
let resolve: Function | null = null | ||
const promise: Promise<Function> = new Promise( | ||
(r: Function): Function => (resolve = r) | ||
) | ||
|
||
if (resolve) window.requestAnimationFrame(resolve) | ||
|
||
return promise | ||
} |
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,35 @@ | ||
export function showMessage(message: string = ''): void { | ||
const messageDOM: Element | null = document.querySelector('.message') | ||
|
||
if (!messageDOM) return console.error('Message DOM is null!') | ||
|
||
messageDOM.classList.remove('hidden') | ||
|
||
const messageContentDOM: Element | null = document.querySelector( | ||
'.message-body-content' | ||
) | ||
|
||
if (!messageContentDOM) | ||
return console.error('Message body content DOM is null!') | ||
|
||
messageContentDOM.innerHTML = message | ||
|
||
const messageDismissDOM: Element | null = document.querySelector( | ||
'.message-body-dismiss' | ||
) | ||
|
||
if (!messageDismissDOM) | ||
return console.error('Message body dismiss DOM is null!') | ||
|
||
const dismissHandler = (): void => { | ||
messageDOM.classList.add('invisible') | ||
messageDOM.addEventListener('transitionend', (): void => { | ||
messageDOM.classList.add('hidden') | ||
messageDOM.classList.remove('invisible') | ||
}) | ||
|
||
messageDismissDOM.removeEventListener('click', dismissHandler) | ||
} | ||
|
||
messageDismissDOM.addEventListener('click', dismissHandler) | ||
} |
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,8 @@ | ||
import { defineConfig } from 'vite' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
resolve: { | ||
conditions: ['__source', 'import', 'module', 'browser', 'default'], | ||
}, | ||
}) |
This file was deleted.
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
Oops, something went wrong.