diff --git a/.env b/.env index d3911fe1..3703645a 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ NODE_ENV=development -API_URL=http://localhost:8080 \ No newline at end of file +API_URL=http://localhost:8080 +PORT=8090 diff --git a/.gitignore b/.gitignore index 8c25b36e..0341ff70 100644 --- a/.gitignore +++ b/.gitignore @@ -150,4 +150,8 @@ sketch # Build build -# End of https://www.toptal.com/developers/gitignore/api/react,node \ No newline at end of file +# End of https://www.toptal.com/developers/gitignore/api/react,node + +# runtime env + +runtime-env.js \ No newline at end of file diff --git a/README.md b/README.md index 18223e6d..f6c29aa1 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,45 @@ # Snakebot Reactclient + This is the webclient for the Cygni snakebot tournament written in React with TypeScript. This application communicates with a [snakebot game server](https://github.com/cygni/snakebot) using a websocket. +# + ## Users -If you are a user who **only** wants to code your own bot, then simply head to the [snakebot client respository](https://github.com/cygni/snakebot-client-js) and follow the instructions there. There will be a *docker-compose* file there to easily get your own server and webclient running as containers without the need to clone them from here. +If you are a user who **only** wants to code your own bot, then simply head to the [snakebot client respository](https://github.com/cygni/snakebot-client-js) and follow the instructions there. There will be a _docker-compose_ file there to easily get your own server and webclient running as containers without the need to clone them from here. + +# ## Maintainers ### Requirements -* Node.js >= 16.15.1 -* npm >= 8.11.0 + +- Node.js >= 16.15.1 +- npm >= 8.11.0 + +# ### To get the development server running locally + After cloning the repository, open a terminal inside the root folder and run the following commands: + ``` > npm install > npm start ``` + The server should now be running on http://localhost:8090. +# + ### **Updates and Docker** **IMPORTANT**: Commits on the **main** branch will launch an action that builds and **overrides** the docker image tagged as the latest on [DockerHub](https://hub.docker.com/repository/docker/cygni/snakebot-reactclient). Therefore it is important to **ONLY** push changes to **main** that works and have been tested, to ensure that latest image works for anyone who wants to use it. If a commit is deemed **stable** you can also add a **tag** to that commit to ensure it remains on [DockerHub](https://hub.docker.com/repository/docker/cygni/snakebot-reactclient) without getting overwritten. E.g creating a release with a tag will both push the newly build docker image with the tag latest **AND** the tag name given as long as it follows the standard **X.X.X** name. Because of what mentioned above, when adding a new feature or changing some behavior, make sure to work on a **different branch** first before pushing to **main**. + +### **Production** + +**IMPORTANT**: Commits to the main branch will also act as commits towards production. Rebuilding the images on DockerHub through commits from main will cause the production server to reboot with the updated version of the image. + +# diff --git a/package.json b/package.json index ec566e1e..80c2de27 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { - "name": "snakebot-webclient-2.0", - "version": "0.1.0", - "homepage": "https://dolvur.github.io/", + "name": "snakebot-reactclient", + "description": "A new webclient for Snakebot", + "version": "1.0.0", + "contributors": ["Daniel Karlsson, Sebastian Helin", "Olivia Harlin"], "private": true, "dependencies": { "@reduxjs/toolkit": "^1.8.2", diff --git a/public/favicon-old.ico b/public/favicon-old.ico new file mode 100644 index 00000000..a11777cc Binary files /dev/null and b/public/favicon-old.ico differ diff --git a/public/favicon.ico b/public/favicon.ico index a11777cc..02fc382a 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/public/index.html b/public/index.html index 271907fc..2d0f80e1 100644 --- a/public/index.html +++ b/public/index.html @@ -11,7 +11,7 @@
{snakes.playerRanks[0]}
-{snakes.playerPoints[0]}
-{snakes.playerRanks[1]}
-{snakes.playerPoints[1]}
-{snakes.playerRanks[2]}
-{snakes.playerPoints[2]}
-Player {index+1}: {player.name}
- )) - } ++ Connect to the tournament by following the instructions found in the + README-file +
++ {player.name} +
+ ))} +{snakes[snakeID].name}
+{snakes[snakeID].points} points
+- We at Cygni love programming. We also love a friendly competetion over - a couple of beers. What better way to combine these two things than a - battle in programming! -
-- Feel free to hack your own Snake Bot and train it in the Training room. - From time to time we hold tournaments where you will be able to face - other player's Snake Bots. -
-- The rules are configurable per game, upon every game start the clients - will be notified of the current game settings. - Here are the default rules: -
-No result found
); - } else { - return ( -+ Make sure the spelling is correct or try searching for something + else. +
++ Game Played: + {game.gameDate}{" "} + + View Game - -
You can find old games here by searching for the snake name.
@@ -66,12 +78,12 @@ import type { Game } from "../api"; /> -- Your mission is to write the best Snake Bot and survive within the - game world. We have prepared several language bindings for you to make it - really easy to get started. All the boring stuff concerning server-client - communication, message parsing and event handling is already implemented. -
-- The game progresses through Game Ticks. For each Game Tick participating - Snake Bots have to choose an action (and they have to do it fast, - response is expected within 250ms). Actions are defined by a direction to - move the Snake head in. A Snake head may move UP, DOWN, RIGHT or LEFT. -
-- On every Game Tick each Snake Bot receives the current Map. The map contains - the positions of all the objects in the map. -
-Below are listed the currently implemented (and up to date) language - bindings. Each project has a Readme file that explains how to get - going. -
- -
- Remember the old game of Snake? One of the first common
- implementations was available on the phone Nokia 3310.
- Snake Record - Nokia 3310
-
-
- This game is a bit different. To play you need to program your own - Snake Bot and you will be competing against other bots! - The concept is simple, your snake can move UP, DOWN, RIGHT - or LEFT and the winner is the last snake alive. Extra points are awarded - when eating stars or nibbling on other snake's tails. Look out for the - black holes though! -
-- {/* Getting started is really easy. - We have implementations in several popular programming languages. Clone - an example Snake bot and get going! */} -
-- Checkout the screencasts below: -
-- -
-+ Log in with username and password to access additional functions. +
++ Remember the old game of Snake? One of the first common implementations was available on the phone Nokia 3310. + Snake Record - Nokia 3310 +
++ This game is a bit different. To play you need to program your own Snake Bot and you will be competing against + other bots! The concept is simple, your snake can move UP, DOWN, RIGHT or LEFT and the winner is the last + snake alive. Extra points are awarded when eating stars or nibbling on other snake's tails. Look out for the + black holes though! +
+Checkout the screencasts below:
+ ++ We at Cygni love programming. We also love a friendly competetion over a couple of beers. What better way to + combine these two things than a battle in programming! +
++ Hack your own Snake Bot and train it in the Training room. From time to time we hold tournaments where you + will be able to face other player's Snake Bots. +
+ ++ The rules are configurable per game, upon every game start the clients will be notified of the current game + settings. Here are the default rules: +
++ Your mission is to write the best Snake Bot and survive within the game world. All the boring stuff concerning + server-client communication, message parsing and event handling is already implemented. +
+ ++ The game progresses through Game Ticks. For each Game Tick participating Snake Bots have to choose an action + (and they have to do it fast, response is expected within 250ms). Actions are defined by a direction to move + the Snake head in. A Snake head may move UP, DOWN, RIGHT or LEFT. +
++ On every Game Tick each Snake Bot receives the current Map. The map contains the positions of all the objects + in the map. +
+ ++ The client is written in JavaScript and the project can be cloned through the GitHub repository via the link + below. We recommend using VS Code for editing this project but feel free to use any editor you prefer. The + project has a Readme file that explains how to get going. +
+ Github Repository ++ Follow @cygniatcampus at Instagram to find out more about the Cygni activities at your Campus and to get + info about our next Snakebot event. +
+