Skip to content

Backend for Overdrive. Written in Cairo running on Dojo Engine.

License

Notifications You must be signed in to change notification settings

FerneLabs/Overdrive-onchain

Repository files navigation

Run Katana

./run katana

Build and migrate

./run build

Run Torii

./run torii

Go to GraphQL playground:

http://localhost:8080/graphql

GraphQL Queries:

Subscribe to all entity updates
subscription {
  entityUpdated {
    id
    keys
    models {
      __typename
      ... on overdrive_PlayerAccount {
        username
        games_played
        games_won
      }
      ... on overdrive_PlayerState {
        is_bot
        score
        shield
        energy
        playing
      }
      ... on overdrive_PlayerCiphers {
        is_bot
        hack_cipher_1 {
          cipher_type
          cipher_value
        }
        hack_cipher_2 {
          cipher_type
          cipher_value
        }
        hack_cipher_3 {
          cipher_type
          cipher_value
        }
      }
      ... on overdrive_GameState {
        player_1
        player_2
        status
        winner_address
        result {
          _0
          _1
        }
        start_time
        end_time
      }
    }
  }
}
Query Player Accounts
query {
  overdrivePlayerAccountModels {
    edges {
      node {
        player_address
        username
        games_played
        games_won
      }
    }
  }
}
Query Player States
query {
  overdrivePlayerStateModels (order: {field: IS_BOT, direction: ASC}) {
    edges {
      node {
        player_address
        is_bot
        game_id
        score
        shield
        playing
      }
    }
  }
}
Query Player Ciphers
query {
  entities {
    edges {
      node {
        models {
          __typename
          ... on overdrive_PlayerCiphers {
            hack_ciphers {
              cipher_type
              cipher_value
            }
            deck_ciphers {
              cipher_type
              cipher_value
            }
          }
        }
      }
    }
  }
}
Query Game States
query {
  overdriveGameStateModels {
    edges {
      node {
        id
        status
        player_1
        player_2
        winner_address
        mode
        result {
          _0
          _1
        }
        start_time
        end_time
      }
    }
  }
}

Interact with world

See all methods

./run help

Build

./run build

Create account

./run create USERNAME

Create new game GAME_MODE = 0 (SP) || 1 (MP)

./run init GAME_MODE

Request ciphers for caller address. IS_BOT = 0 || 1. For empty deck send int:0,IS_BOT

./run request DECK_ARRAY,IS_BOT
  # Example usage:
  ./run request int:2,int:1,3,5,int:1,3,1,0
  # Where: 
      # int:2 -> Length of module array
        # int:1 -> Length of Type array
        # 3 -> Type indexes, in this case, single energy cipher
        # 5 -> cipher_value
        ###
        # int:1 -> Length of Type array
        # 3 -> Type indexes, in this case, single energy cipher
        # 1 -> cipher_value
      # 0 -> is_bot = false

Runs module with cipher values sent. For empty deck send int:0,IS_BOT

./run module MODULE_ARRAY,DECK_ARRAY,IS_BOT
  # Example usage:
  ./run module int:2,int:2,0,0,15,int:2,0,0,20,int:3,int:1,2,5,int:1,3,2,int:1,3,1,0

  # Where: 
    # int:2 -> Length of module array
      # int:2 -> Length of Type array
      # 0,0 -> Type indexes, in this case, pure ADV cipher
      # 15 -> cipher_value
      ###
      # int:3 -> Length of Type array
      # 0,0 -> Type indexes, in this case, pure ADV cipher
      # 20 -> cipher_value
    # int:3 -> Length of deck array
      # int:1 -> Length of Type array
      # 2 -> Type indexes, in this case, single shield cipher 
      # 5 -> cipher_value
      ###
      # int:1 -> Length of Type array
      # 3 -> Type indexes, in this case, single energy cipher 
      # 2 -> cipher_value
      ##
      # int:1 -> Length of Type array
      # 3 -> Type indexes, in this case, single energy cipher 
      # 1 -> cipher_value
    # 0 -> is_bot = false

About

Backend for Overdrive. Written in Cairo running on Dojo Engine.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published