♠️
RACE Protocol
NFT PresaleDiscord
  • ❤️Official Docs & Links
  • ⏳Progress Overview
  • RACE Protocol
    • 🏗️System Architecture
      • Components
      • On-chain Accounts
      • Synchronization
      • Randomization
      • Payment
    • 🎲Game Development
      • Game Handler
      • Effect
      • Event Handling
      • Race API
        • Arweave Integration
      • Race JS SDK
        • Installation and Setup
        • Key Components
          • AppClient
          • SubClient
          • Events
          • Game Context
          • Decryption Cache
        • Advanced Features
          • Getting Revealed Knowledge
          • Exiting and Detaching
          • Submitting Messages
          • Sub-game Interaction
        • Best Practices
        • API Reference
        • Troubleshooting
    • 🧪Testing
      • Race Test Kit
      • Unit Testing
      • Integration Testing
      • Additional Considerations
    • 🧱Modules & Features
      • Encryption Methods
      • Command-line Tools
      • Configuration Options
      • Blockchain Transport Implementations
    • 📃Smart Contract
      • Solana Program
    • 🔦Examples and Use Cases
      • Draw Card Game
      • Raffle Game
      • Other Examples
  • RACE Games
    • ♠️RACE Poker app
      • 🎮Start playing in minutes
        • 💰Cash and sit-n-go
        • 🏆Tournaments
      • 🎨Workshop
        • 🏆Create cash games
        • 🏨Create tourneys
      • 💡Concept introduction
      • 🏗️System architecture
      • 👾Game Flow
      • 🎲Cards shuffling
      • ☎️Communication
      • 🔐Key sharing/decryption
      • 💱Cash flow structure
    • ⚡Solfast
      • 🎲Game modes
  • RACE RESEARCH
    • 👾No-Code Development
      • Brainstorming
      • Implementation Approach
      • Project Status
    • 0️⃣Zero-Knowledge Proofs
      • Brainstorming
      • Integration steps
        • Verifiable Randomness Generation
        • Private Game State Updates
        • Verifiable Settlements
        • Private Player Actions
      • Project Status
    • 🛡️Security Audit Report
      • Executive summary
        • Introduction to Race Protocol
        • Audit Methodology
      • Findings
        • Smart Contract Security
        • WebAssembly Security
        • Client-side Security (Race SDK)
        • Server-side Security
        • Randomization and Encryption
        • On-chain Account Management
        • Synchronization Mechanisms
        • Payment Handling
      • Recommendations
      • Conclusion
  • RACE DAO
    • 😎About
    • 🫂Community
    • 🖼️NFT Collection [!]
Powered by GitBook
On this page
  1. RACE Protocol
  2. Game Development

Effect

The Effectobject plays a crucial role in Race Protocol by acting as a bridge between the game handler (WASM) and the runtime environment (Transactor or client). It serves two primary purposes:

  • Providing Context Information: The Effect object provides the game handler with relevant context information about the game and its environment. This information includes:

    • Event Timestamp: The timestamp of the event being handled, ensuring consistent timing across all nodes.

    • Number of Players and Servers: The total number of players and servers involved in the game, including those with pending status. This information can be used to determine if there are enough participants to start the game or trigger specific game logic.

    • Revealed Hidden Knowledge: This includes any previously hidden information that has been revealed to all participants, such as the outcome of randomization processes or player decisions.

  • Enabling Runtime Interaction: The Effect object allows the game handler to trigger actions and interact with the runtime environment. This includes:

    • Initializing Randomness: The game handler can use the Effect object to request the creation of randomness with specific characteristics (e.g., shuffled list, lottery). The Transactor and validator servers then handle the actual randomization process and share the necessary secrets with the game handler through the Effect object.

    • Assigning and Revealing Secrets: The game handler can use the Effect object to assign secrets to specific players, allowing them to decrypt and access hidden information relevant to their gameplay. It can also reveal secrets publicly to make information visible to all participants.

    • Triggering Settlements: When the game concludes, the game handler can use the Effect object to specify how assets should be distributed among players. This triggers the Transactor to create and submit a settlement transaction to the blockchain.

    • Managing Timeouts: The game handler can use the Effect object to set timeouts for player actions or general waiting periods. This helps ensure that the game progresses smoothly and prevents stalling.

    • Launching Sub-games: In games that require nested game structures, the game handler can use the Effect object to launch sub-games with specific configurations and initial states.

    • Emitting Bridge Events: The game handler can use the Effect object to send custom events to sub-games or other connected components, enabling communication and coordination between different parts of the game.

By utilizing the Effect object, the game handler can access essential context information and trigger actions within the runtime environment without directly interacting with the blockchain or other components. This promotes modularity, simplifies testing, and ensures that the game logic remains pure and deterministic.

The next section will discuss event handling in detail and explain how the game handler processes different types of events to drive the game forward.

PreviousGame HandlerNextEvent Handling

Last updated 1 year ago

🎲