Server for a 1v1 turned based game. This server is configured to make players take turns at the same time. The server can be modified to have a more traditional turned based game where each player take actual turns.
The client need to long poll the contract to get updates, such as knowing that the other player has in fact made their turn.
This server is written in the "singelton style".
We say that an AssemblyScript contract is written in the "singleton style" when the index.ts
file (the contract entry point) has a single exported class (the name of the class doesn't matter) that is decorated with @nearBindgen
.
In this case, all methods on the class become public contract methods unless marked private
. Also, all instance variables are stored as a serialized instance of the class under a special storage key named STATE
. AssemblyScript uses JSON for storage serialization (as opposed to Rust contracts which use a custom binary serialization format called borsh).
INSTALL NEAR CLI
first like this: npm i -g near-cli
- clone this repo to a local folder
- run
npm install
- run
./scripts/1.dev-deploy.sh
- run
./scripts/2.use-contract.sh
- run
./scripts/2.use-contract.sh
(yes, run it to see changes) - run
./scripts/3.cleanup.sh