Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arcade Account Improvements #543

Merged
merged 24 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
79ffc89
Implement AA Migration Tools (#541)
starknetdev Jan 25, 2024
7183685
Arcade Account Fixes (#542)
starknetdev Jan 29, 2024
6c9ea55
add campaign leaderboard
starknetdev Jan 31, 2024
6fb9dc7
fix campaign leaderboard pages
starknetdev Jan 31, 2024
0a236d3
fix metadata from dropped items not being reused (#544)
loothero Feb 8, 2024
954f7a7
Dependency upgrades (#545)
ponderingdemocritus Feb 17, 2024
f57e125
Increase adventurer max level and select stats (#546)
ponderingdemocritus Feb 18, 2024
760fa5f
DevEx improvements (#547) (#548)
loothero Feb 18, 2024
924b978
changes from goerli to sepolia for testsnet (#549)
loothero Feb 19, 2024
1f1909d
fix scarb lint warnings (#553)
loothero Feb 24, 2024
703c0a1
only reset idle counter on beast defeat (#552)
loothero Feb 24, 2024
2a28283
lower starting price of game from 25 to 10 $lords (#556)
loothero Feb 24, 2024
c8f3c25
updates
ponderingdemocritus Feb 27, 2024
b50ece5
Revert "updates"
ponderingdemocritus Feb 27, 2024
43c0eb3
Revert "lower starting price of game from 25 to 10 $lords (#556)"
ponderingdemocritus Feb 27, 2024
8474dd9
reduce start delay blocks (#559)
loothero Mar 8, 2024
24ca86f
fixes item metadata duplication bug (#565)
loothero Mar 10, 2024
8141eb9
Sync v1.1 reward distribution schedule with v1.0 (#558)
loothero Mar 11, 2024
7d1cb4e
continue exploring after discovering health or gold (#567)
loothero Mar 11, 2024
78621f9
use 11 block delay on testnet
loothero Mar 11, 2024
fe02fe7
Revert "use 11 block delay on testnet"
loothero Mar 11, 2024
e65c9fa
use 11 block delay on testnet (#570)
loothero Mar 11, 2024
8586e15
update starknetjs to 6.4.3
starknetdev Mar 17, 2024
f7692da
- upgrade starknet-react
starknetdev Mar 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Use Debian Bookworm as a base image
FROM debian:bookworm-slim

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# Update the package list and install minimal utilities
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
git \
ca-certificates \
unzip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v 2.5.4
RUN curl https://get.starkli.sh | bash
RUN /root/.starkli/bin/starkliup
# Specify the command to run on container start
CMD ["bash"]
10 changes: 7 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"name": "Rust",
"image": "mcr.microsoft.com/devcontainers/rust:0-1-bullseye",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"starkware.cairo1"
"starkware.cairo1",
"github.copilot"
]
}
},
Expand All @@ -14,5 +17,6 @@
"CAIRO_COMPILER_DIR":"~/.cairo/target/release/",
"CAIRO_COMPILER_ARGS":"--add-pythonic-hints"
},
"postCreateCommand":"curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v 0.7.0 && curl https://pyenv.run | bash && echo 'export PATH=\"$HOME/.pyenv/bin:$PATH\"' >> ~/.bashrc && echo 'eval \"$(pyenv init -)\"' >> ~/.bashrc && echo 'eval \"$(pyenv virtualenv-init -)\"' >> ~/.bashrc && $HOME/.pyenv/bin/pyenv install 3.9.0 && $HOME/.pyenv/bin/pyenv virtualenv 3.9.0 cairo_venv && echo 'pyenv activate cairo_venv' >> ~/.bashrc && echo 'pip install cairo-lang 2> /dev/null' >> ~/.bashrc"
"postCreateCommand": "git config --global core.editor \"code --wait\" && bash scripts/starkli_setup.sh",
"postStartCommand": "cd contracts && scarb build && scarb test"
}
98 changes: 19 additions & 79 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,92 +4,32 @@ on:
push:
branches:
- main
pull_request:
pull_request:

env:
SCARB_VERSION: 0.7.0
SCARB_VERSION: 2.5.4

jobs:
build-contracts:
name: Build Adventurer
build:
name: Build Contracts
runs-on: ubuntu-latest
strategy:
matrix:
contract: [
adventurer,
game,
loot,
market,
obstacles,
combat,
game_entropy,
game_snapshot,
]
steps:
- uses: actions/checkout@v3

- name: Setup Scarb
run: |
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v ${{ env.SCARB_VERSION }}
run: curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v ${{ env.SCARB_VERSION }}

- name: Scarb build
run: |
cd contracts/adventurer && scarb build && scarb cairo-test

build-game:
name: Build Game
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Scarb
run: |
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v ${{ env.SCARB_VERSION }}

- name: Scarb build
run: |
cd contracts/game && scarb build && scarb cairo-test

build-loot:
name: Build Loot
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Scarb
run: |
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v ${{ env.SCARB_VERSION }}

- name: Scarb build
run: |
cd contracts/loot && scarb build && scarb cairo-test

build-market:
name: Build Market
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Scarb
run: |
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v ${{ env.SCARB_VERSION }}

- name: Scarb build
run: |
cd contracts/market && scarb build && scarb cairo-test

build-obstacles:
name: Build Obstacles
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Scarb
run: |
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v ${{ env.SCARB_VERSION }}

- name: Scarb build
run: |
cd contracts/obstacles && scarb build && scarb cairo-test

build-combat:
name: Build Combat
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Scarb
run: |
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v ${{ env.SCARB_VERSION }}

- name: Scarb build
run: |
cd contracts/combat && scarb build && scarb cairo-test
- name: Scarb build ${{ matrix.contract }}
run: cd contracts/${{ matrix.contract }} && scarb build && scarb cairo-test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ contracts/game_entropy/target/CACHEDIR.TAG
contracts/game_entropy/target/dev/game_entropy.sierra

scripts/stress_test.py
.env
115 changes: 29 additions & 86 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,127 +148,70 @@ Loot Survivor is an onchain game, designed to be immutable and permanently hoste

### Deploying

#### Set up env

Follow instructions here: `https://docs.starknet.io/documentation/getting_started/environment_setup/`


```
source ~/cairo_venv/bin/activate
```

```bash
export STARKNET_NETWORK=alpha-goerli
export STARKNET_WALLET=starkware.starknet.wallets.open_zeppelin.OpenZeppelinAccount
export CAIRO_COMPILER_DIR=~/.cairo/target/release/
export CAIRO_COMPILER_ARGS=--add-pythonic-hints

# you will have an account from the Starknet ENV setup
export ACCOUNT_NAME=INSERT_YOUR_ACCOUNT_NAME_HERE
export ADVENTURER_ID=INSERT_YOUR_ADVENTURER_ID_HERE
export STRENGTH=0
export DEXTERITY=1
export VITALITY=2
export INTELLIGENCE=4
export CHARISMA=5

export LORDS_ADDRESS=0x059dac5df32cbce17b081399e97d90be5fba726f97f00638f838613d088e5a47
export DAO_ADDRESS=0x020b96923a9e60f63a1829d440a03cf680768cadbc8fe737f71380258817d85b

# nav to dir
cd contracts/game

# build
scarb build

# declare
starknet declare --contract target/dev/game_Game.sierra.json --account $ACCOUNT_NAME

# deploy
# <classhash> will be in the output of the previous command
starknet deploy --class_hash 0x2958304935054101c0aeab16cf6507adda1c98b4d977af40d59c2ae75f05767 --max_fee 100000000000000000 --input $LORDS_ADDRESS $DAO_ADDRESS --account $ACCOUNT_NAME
```
#### Setup Starkli Account

```bash
# set contract address
export CONTRACT_ADDRESS=0x06ee32da9f22c736c4ef049719c0021380c302e5d449fbc8acf97489e16a9d05
bash scripts/starkli_setup.sh
```

#### Deploy Contract
```bash
starknet invoke --function mint --address $LORDS_ADDRESS --input 0x1feb9c05d31b70a1506decf52a809d57493bfcd5cc85d6a3e9fd54a12d64389 1000000000000000000000 0 --max_fee 10000000000000000 --account $ACCOUNT_NAME

starknet invoke --function approve --address $LORDS_ADDRESS --input $CONTRACT_ADDRESS 1000000000000000000000 0 --max_fee 10000000000000000 --account $ACCOUNT_NAME
bash scripts/deploy.sh.sh
```

### Game Actions
### Play

#### Start
#### Mint $lords and approve LS to spend
```bash
starknet invoke --function start --address $CONTRACT_ADDRESS --input 0x020b96923a9e60f63a1829d440a03cf680768cadbc8fe737f71380258817d85b 12 123 0 0 0 --max_fee 10000000000000000 --account $ACCOUNT_NAME
source "/workspaces/loot-survivor/.env"
starkli invoke $LORDS_ADDRESS mint 0x1feb9c05d31b70a1506decf52a809d57493bfcd5cc85d6a3e9fd54a12d64389 1000000000000000000000 0 --account $STARKNET_ACCOUNT --private-key $PRIVATE_KEY
starkli invoke $LORDS_ADDRESS approve $CONTRACT_ADDRESS 1000000000000000000000 0 --account $STARKNET_ACCOUNT --private-key $PRIVATE_KEY
```

#### Explore
#### Start New Game
```bash
starknet invoke --function explore --address $CONTRACT_ADDRESS --input $ADVENTURER_ID 0 --max_fee 10000000000000000 --account $ACCOUNT_NAME
starkli invoke $CONTRACT_ADDRESS new_game 0x020b96923a9e60f63a1829d440a03cf680768cadbc8fe737f71380258817d85b 12 123 0 0 0 --account $STARKNET_ACCOUNT --private-key $PRIVATE_KEY
```

#### Attack
#### Explore
```bash
starknet invoke --function attack --address $CONTRACT_ADDRESS --input $ADVENTURER_ID 0 --max_fee 10000000000000000 --account $ACCOUNT_NAME
starkli invoke $CONTRACT_ADDRESS explore $ADVENTURER_ID 0 --account $STARKNET_ACCOUNT --private-key $PRIVATE_KEY
```

#### Flee
#### Attack Starter Beast
```bash
starknet invoke --function flee --address $CONTRACT_ADDRESS --input $ADVENTURER_ID 0 --max_fee 10000000000000000 --account $ACCOUNT_NAME
starkli invoke $CONTRACT_ADDRESS attack $ADVENTURER_ID 0 --account $STARKNET_ACCOUNT --private-key $PRIVATE_KEY
```

#### Upgrade Stat (Charisma x 1)
#### Upgrade Adventurer
```bash
starknet invoke --function upgrade_stat --address $CONTRACT_ADDRESS --input $ADVENTURER_ID 0 $CHARISMA 1 --max_fee 10000000000000000 --account $ACCOUNT_NAME
starkli invoke $CONTRACT_ADDRESS upgrade $ADVENTURER_ID 0 $CHARISMA 1 --account $STARKNET_ACCOUNT --private-key $PRIVATE_KEY
```


### Checking On Your Adventurer
### View Adventurer Details

##### Get full adventurer state
##### Adventurer State
```bash
starknet call --function get_adventurer --address $CONTRACT_ADDRESS --input $ADVENTURER_ID 0 --account $ACCOUNT_NAME
starkli call --watch $CONTRACT_ADDRESS get_adventurer $ADVENTURER_ID 0 --account $STARKNET_ACCOUNT --private-key $PRIVATE_KEY
```

##### Get adventurer health
##### Get Adventurer Health
```bash
starknet call --function get_health --address $CONTRACT_ADDRESS --input $ADVENTURER_ID 0 --account $ACCOUNT_NAME
starkli call --watch $CONTRACT_ADDRESS get_health $ADVENTURER_ID 0 --account $STARKNET_ACCOUNT --private-key $PRIVATE_KEY
```

##### Get adventurer gold
##### Get Adventurer Gold
```bash
starknet call --function get_gold --address $CONTRACT_ADDRESS --input $ADVENTURER_ID 0 --account $ACCOUNT_NAME
starkli call --watch $CONTRACT_ADDRESS get_gold $ADVENTURER_ID 0 --account $STARKNET_ACCOUNT --private-key $PRIVATE_KEY
```

##### Get adventurer xp
##### Get Adventurer XP
```bash
starknet call --function get_xp --address $CONTRACT_ADDRESS --input $ADVENTURER_ID 0 --account $ACCOUNT_NAME
starkli call --watch $CONTRACT_ADDRESS get_xp $ADVENTURER_ID 0 --account $STARKNET_ACCOUNT --private-key $PRIVATE_KEY
```

##### Get upgradable stat points
##### Get number of stat upgrades available
```bash
starknet call --function get_stat_upgrades_available --address $CONTRACT_ADDRESS --input $ADVENTURER_ID 0 --account $ACCOUNT_NAME
```

##### Get base charisma stat (doesn't include boost from items)
```bash
starknet call --function get_base_charisma --address $CONTRACT_ADDRESS --input $ADVENTURER_ID 0 --account $ACCOUNT_NAME
```

##### Get charisma stat including item boosts
```bash
starknet call --function get_charisma --address $CONTRACT_ADDRESS --input $ADVENTURER_ID 0 --account $ACCOUNT_NAME
```


# Starkli Deploy


starkli declare /contracts/game/target/dev/game_Game.sierra.json --account ./account --keystore ./keys --max-fee 0.01

starkli deploy 0x00cccbd15bf27792e7635bd89da237de68b13d29ec01b5cae1da786b276be8a4 $LORDS_ADDRESS $DAO_ADDRESS 0x06fe9215a0f193431f30043e612d921b62331946529ebf5f258949a4b34aa799 --account ./account --keystore ./keys
starkli call --watch $CONTRACT_ADDRESS get_stat_upgrades_available $ADVENTURER_ID 0 --account $STARKNET_ACCOUNT --private-key $PRIVATE_KEY
```
Loading
Loading