[Discontinued] Ember was a fully on-chain Dungeon Keeper inspired strategy game built by lattice.xyz. Building Ember taught us a lot about designing large on-chain applications; and lead to us building MUD; an Ethereum application framework for large on-chain apps.
- Clone the repository
- Run
yarn
to install everything - Run
yarn start
to start a local node and run a local client connected to it
- Navigate to the
/eth
sub-directory - Run
yarn deploy
. You should now see the deploy script CLI - Choose options and answer the CLI prompts. You should be able to choose
- The network on which to deploy Ember (one of presets, see here for some examples of networks)
- Whether to re-deploy contracts
- Whether to re-deploy client
- Which key to use for Netlify site deployment (if deploying client)
- Once all the prompts are answered, the deploy script will kick off and deploy either the contracts or the client or both. Once completed without errors, there should be a message printed to stdout with a confirmation and the diamond address / client URL deployed
Note: the configuration for the deploy CLI is stored in the ~/.lattice/config.json
file. Remove or edit this file to re-set the deploy config cache, which will require you to answer some of the prompts in the deploying process again.
This is a sketch of things that you can do in Ember
- Mine dungeon tiles
- Claim dungeon tiles
- Claim regions
- Build upgrades, e.g. resource generators, lairs
- Find and harvest resources
- Use resources to summon creatures
- Move creatures from/to specific tiles and regions. Use the meta-move feature to strategically plan attacks and defenses
- Build walls to protect dungeon, break walls to attack players
- Fight battles. Attack a player by moving creatures into their regions
- Claim rival dungeons after victory in battle
For both local gameplay and a deployment on any of the specified chains, you will need a wallet to connect to the game and sign a message authorizing a burner wallet. If utilizing a network with a valid faucet (such as a Lattice Testnet), you don't need any funds prior to gameplay and any funds you require will be dripped to you.
A deployment is identified by two things that the client needs to be aware of
- The
chainId
(to know which network Ember has been deployed to) - The
diamondAddress
(to know where the deployed Ember world is)
So, when joining an Ember game, you should expect the URL to look something like https://ember.lattice.xyz?chainId=<CHAIN_ID>&diamondAddress=<DEPLOYED_DIAMOND_ADDRESS>
As of repository archival time, there are two stable and deployable branches
master
-- Ember "classic"ludens/4x
-- Ember "4x" beta version with modified mechanics, additional upgrades, and extra content
Note that if you change branches, make sure to run yarn
to install everything and re-build before trying to deploy to a chain with yarn deploy
- Use a chrome profile because you will need to create a new metamask account every time you restart your hardhat node (MM caches stuff and gets confused when the nonce drops back to 0)
- You need to add hardhat as a network because the dev bootloader won't do it for you
- network name:
hardhat
- rpc:
http://localhost:8545
- chain id:
31337
- currency:
ETH
- network name:
/client
/src/Backend
: client-side code for interacting with contracts (main file: GameManager.ts)/src/Frontend
: code for React UI like panels, toolbar, etc. (main file: Play.tsx)/src/Renderer
: code for things rendered by Phaser, like the map, creatures, etc. (main file: mainScene.ts)
/eth
: Contains contract-side code, like game logic and data store
If you are interested in
-
How actions on client are translated to on-chain state changes, check out GameManager.ts, for instance the
harvestTiles()
function or theclaimTiles()
function -
How creature movement works, check out GameManager.ts and look for
moveCreatures()
andmetaMoveCreatures()
functions. To get an in-depth look into various creature movement logic, check out CreatureTool.ts. ThebreakDownMetaMove()
function is a good place to start there -
Roughly how burner wallet impersonation works, check out the
checkImpersonationStatus()
function in Network.ts -
The order in which the client is booted up and what happens at boot-up, check out AppManager.ts
-
How some of the UI is implemented, decent places to start looking can be the PlayerCard.tsx and Toolbar.tsx
-
What the deploy CLI looks like, checkout the deploy.ts
GPL-3.0 (see LICENSE)