Skip to content

underware-gg/pistols

Repository files navigation

Pistols at Dawn

Formerly known as Pistols at 10 Blocks

A fully on-chain game, made with love, by Underware, with Dojo, for Realms, on Starknet.

Started as a joke with Calc at Autonomous Worlds Istanbul 2023. Winner of the Dojo Game Jam #3

Follow us on @Pistols_gg and the #duels channel in the Realms Discord

                                          ~~^             ^J~                                                           
                                         ~5G5!           75~                                                            
                                       .~PBG~        ^75P7                                                              
                                      ^?5BY~~^     YP5J~                                                                
                                    ^!J5GGPJ7      ?P^,                                                                 
                           ... ^!?Y5P7GB&&@&5J???7?YPY5YYJ?~7!!~~~~!!~^7~~~~~~!~~~~~^^~^^^^^^^^^^~^^[!]vvvvv!::)      
                      .. ^~~JPB###&#B?^PB#55Y?7YG5?J7?BG5YJ?7777!!!7777?777?7?????JJJJYJJYJJJJYYYYJY[!]~~~~~!::)      
                  .. ~7JPBBBB5?~?YJ~??~YGP7!???YGPJ5BGPBGPP555P5YYG###GGGPPGPPPPPPPPPPGGPGGPGGBB#B##[!]^^^^^!::)      
               . ^75B##BG55J~::~Y7~!75BG5~^::^~~!!7?J?J55BPPPB#BPG&&&#########BB#BBBBBBBBBGPGBBBBBBB[!]               
              ^7P##BGGGP5YY^:.:^~?J??YPGJ?7???YYY555GGBBGBBB#&&#B#/~~~~~~~~^^^^^^^^^^^^^^^~~~~^^^^^^^^^^^^^^)         
          .:!5###GPP5J?777JY55PGB########&##########BGP55YJ?7/~^^^                                                      
         ^JB##GP5Y?77J5GBB#####BP5GBJ!!!77JJ!~^^^^^^        /                                                           
       ~YB#GP55YY5GB##BPY7!~~?Y   ^!      7~                                                                            
     .^Y##BG5555B&&#P?^:      :?~  ^^.   ^!!                                                                             
    ?B#BGP5P##&@&Y^            ^~~~~~!                                                                               
   P#BBG5YP###&B~..   -__ /\\             ,        ,,                     ,        -_____                       
  B#PBG5J5B&#&#!.       ||  \\  '        ||        ||               _    ||          ' | -,    _   ;            
 J#5PGGY?YBB#@B^.      /||__|| \\  _-_, =||=  /'\\ ||  _-_,        < \, =||=        /| |  |`  < \, \\/\/\ \\/\\ 
 YGGGGPJ?JGBB@#7.      \||__|| || ||_.   ||  || || || ||_.         /-||  ||         || |==||  /-|| || | | || || 
 JP5?~^...^?JG&#^       ||  |, ||  ~ ||  ||  || || ||  ~ ||       (( ||  ||        ~|| |  |, (( || || | | || || 
 ~PY!::. .:7?YBB^     _-||-_/  \\ ,-_-   \\, \\,/  \\ ,-_-         \/\\  \\,        ~-____,   \/\\ \\/\\/ \\ \\ 
  ~55J!~:^7?5PY^        ||                                                         (                                                                                                                               
    ~?YYYJ?7!^              A game of honour, chance and betrayal. Defend thine honour, scound! By Underware.gg
       ^^^                                                                                                                       

Overview

Thou art an offence to all that is decent, dog. I challenge you... to a duel!

Pistols at Dawn is an onchain game, in which you face off against another Lord in a pistol duel to defend your honour.

A righteous smoulder in your eye and your smoothbore, flintlock pistol held lightly at your side, cocked and ready, you stand in the misty morning field. Holding back the gorge rising in your throat, you shake that mongrel's hand and turn, taking your first step. Your feet crunch in the crisp morning grass, one step, two steps, three. You hear the snap of a cloak, the gasp of your second, and a sharp, booming crack, then your left arm explodes into pain. That traitorous scum shot early! Gritting your teeth against the pain, and without turning around, you keep stepping foward. Four, Five, Six, Seven, Eight, Nine... Ten. You turn around, slowly, a dark menace in your shoulder, and raise your pistol. The cur stands there, a defiant sneer upon his face, and throws his still smoking pistol to the ground. You take a deep breath, and whisper "May you find honour in death, you wretch!"

Blood sprays in a beautiful arc from his head, and he drops like a felled log. Silence, interrupted only by the spattering of blood from your arm, into the morning grass.

Team

Other Contributors

  • @voltrevo — Engineering, Hidden information mechanism

Contents

  • /client: Main game web client (typescript, Vite)
  • /dojo: Dojo contracts (cairo)
  • /sdk: Pistols at Dawm SDK (typescript)
  • /dreams: Daydreams AI agents (typescript)
  • /gamejam: Original Dojo Game Jam #3 contents
  • /assets: Assorted test assets
  • /verifier: Contracts verifier

Assets

Development notes

Environment Setup

Dojo Book

Install Rust + Cargo + others

# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# open new terminal
rustup override set stable
rustup update

# Install Scarb v2.10.1
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh -s -- -v 2.10.1

# Install starkli
# https://github.com/xJonathanLEI/starkli
curl https://get.starkli.sh | sh
starkliup

# Install pnpm
curl -fsSL https://get.pnpm.io/install.sh | sh -

# other stuff you will need
pnpm install -g turbo
brew install llvm@19
brew install jq
brew install protobuf
cargo install toml-cli

Install the Cairo 1.0 extension for Visual Studio Code / Cursor

Install Dojo

Dojo Book

Currenty using Dojo version v1.5.0

curl -L https://install.dojoengine.org | bash
# open new terminal to update PATH
dojoup -v v1.5.0

# test dojo
cd dojo
sozo build
sozo test

# install packages
cd ../client
pnpm install

Launch Dojo

Terminal 1: Katana (local node)

cd dojo
katana --disable-fee --chain-id KATANA_LOCAL --invoke-max-steps 10000000 --allowed-origins "*"

# or preferably...
cd dojo
./run_katana

Terminal 2: Torii (indexer)

Uncomment the world_address parameter in dojo/Scarb.toml then:

cd dojo
torii --allowed-origins "*" --index-pending --world 0xbee2bb53422762f6c51fb478a8a5da41a64ad678860d02800e0dbdac23dc36

# or preferably...
cd dojo
./run_torii dev

Terminal 3: Sozo commands / migration

Migrating to localhost:

# build world and systems
cd dojo
sozo clean
sozo build

# migrate to local Katana
./migrate dev

# migrate other profiles...
# ./migrate <PROFILE_NAME>
./migrate slot

For Starknet chains, create env files for SN_SEPOLIA (.env.sepolia) and/or SN_MAIN (.env.mainnet)

export STARKNET_RPC_URL=https://sepolia.your-favorite-rpc-provider.com/xxx/
export DOJO_ACCOUNT_ADDRESS=0x1234
export DOJO_PRIVATE_KEY=0x1234

then migrate...

# enable env
source .env.sepolia

# migrate to local Katana
./migrate sepolia

# clear env if you want to work on another profile
source .env.clear

Terminal 4: Client

Install dependencies

cd client
pnpm i

Configure default NetworkId in your .env file:

# enable debug options
VITE_DEBUG=1

# Main network
VITE_NETWORK_ID=KATANA_LOCAL
#VITE_NETWORK_ID=STAGING
#VITE_NETWORK_ID=SEPOLIA
#VITE_NETWORK_ID=MAINNET

# Academy chain (tutorials)
VITE_ACADEMY_NETWORK_ID=ACADEMY

# optional/alternative service urls
# VITE_CLIENT_URL=https://play.pistols.gg
# VITE_ASSETS_SERVER_URL=https://assets.underware.gg

# optional/alternative dojo urls
# VITE_SLOT_NAME=pistols-mainnet-2
# VITE_RPC_URL=https://api.cartridge.gg/x/starknet/mainnet
# VITE_TORII_URL=https://api.cartridge.gg/x/pistols-mainnet-2/torii
# VITE_TORII_GRAPHQL_URL=https://api.cartridge.gg/x/pistols-mainnet-2/torii/graphql
# VITE_TORII_SQL_URL=https://api.cartridge.gg/x/pistols-mainnet-2/torii/sql

# Socials config
VITE_DISCORD_CLIENT_ID=<OAUTH2_CLIENT_ID>
VITE_DISCORD_REDIRECT_URL=https://assets.underware.gg/api/oauth/discord

Start the client

# http server
# http://localhost:5173
cd pistols
turbo dev

# https server (required for Catridge Controller)
# https://localhost:5173
cd pistols
turbo devs

Open http://localhost:5173 or https://localhost:5173