# proofofplay/piratenation-contracts architecture

> Architecture diagram of the GitHub repository proofofplay/piratenation-contracts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/proofofplay/piratenation-contracts
- Repository: https://github.com/proofofplay/piratenation-contracts

## Overview

##### Main Components Organization

a) Core Game Systems Layer
- 'core' components at the center
- Related game mechanics (combat, energy, dungeons)
- Checkpoint and cooldown systems

b) Asset Layer
- Token-related contracts (NFTs, gold token)
- Equipment and loot systems

c) Game Features Layer
- Gameplay features (achievements, islands, levels)
- Gacha and shop systems

d) Infrastructure Layer
- VRF (Verifiable Random Function) components
- Multichain support systems
- Randomizer contracts

##### Component Relationships

- How game mechanics interact with core components
- Token interactions with game systems

- Achievement system to relevant game actions
- VRF interactions with randomized game elements

##### Specific Component Details

a) Token System
- GameNFT
- ShipNFT
- StarterPirateNFT
- AchievementNFT
- GoldToken
- GameItems

b) Game Mechanics
- Combat system
- Energy system
- Dungeon mechanics
- Island exploration
- Trading system

##### Technical Integration Points

Highlight:
- Interface contracts
- Library connections
- Component interactions
- Mock contract relationships

##### Infrastructure support systems

Remember to:
- Keep core game mechanics centrally located
- Clear paths for user interactions
- Points of external integration
- Cross-chain boundaries
- Mock contract relationships for testing

This blockchain game architecture requires special attention to:
- Token flow and management
- Random number generation security
- Cross-chain interactions
- Game state management
- Economic balance mechanisms

## Diagram (Mermaid)

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#2b2b2b',
    'primaryTextColor': '#fff',
    'primaryBorderColor': '#7C0000',
    'lineColor': '#F8B229',
    'secondaryColor': '#006100',
    'tertiaryColor': '#0000ff'
  }
}}%%

flowchart TB
    classDef core fill:#0000ff,color:white
    classDef asset fill:#006100,color:white
    classDef feature fill:#F8B229,color:black
    classDef infra fill:#666666,color:white
    classDef additional fill:#7C0000,color:white

    subgraph CoreSystems["Core Game Systems"]
        Core["Core Components"]
        Combat["Combat System"]
        Energy["Energy System"]
        Dungeon["Dungeon System"]
        Checkpoint["Checkpoint System"]
        Cooldown["Cooldown System"]
    end

    subgraph AssetLayer["Asset Management"]
        GameNFT["Game NFT"]
        ShipNFT["Ship NFT"]
        StarterNFT["Starter Pirate NFT"]
        AchievementNFT["Achievement NFT"]
        GoldToken["Gold Token"]
        GameItems["Game Items"]
    end

    subgraph GameFeatures["Game Features"]
        Achievements["Achievements"]
        Islands["Islands"]
        Levels["Level System"]
        Gacha["Gacha System"]
        Shop["Shop System"]
        Trading["Trading System"]
        Equipment["Equipment System"]
        Loot["Loot System"]
    end

    subgraph Infrastructure["Infrastructure Layer"]
        VRF["VRF System"]
        Multichain["Multichain Support"]
        Randomizer["Randomizer"]
    end

    subgraph Additional["Additional Components"]
        Captain["Captain System"]
        Scene["Scene Management"]
        Subscription["Subscription System"]
        GameGlobals["Game Globals"]
        Interfaces["Interface Definitions"]
        Libraries["Library Components"]
    end

    Core --> Combat
    Core --> Energy
    Core --> Dungeon
    Core --> Checkpoint
    Core --> Cooldown

    Core -.-> AssetLayer
    Core -.-> GameFeatures
    
    VRF --> Gacha
    VRF --> Loot
    Randomizer --> Combat
    
    GameNFT --> Trading
    ShipNFT --> Islands
    StarterNFT --> GameGlobals
    GoldToken --> Shop
    
    Equipment --> Combat
    Loot --> Equipment
    
    Multichain --> Core
    
    Captain --> Core
    Scene --> Islands
    GameGlobals --> Core
    Libraries --> Core
    Interfaces --> Core

    %% Click events for component mapping
    click Core "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/core"
    click Combat "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/combat"
    click Energy "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/energy"
    click Dungeon "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/dungeons"
    click Checkpoint "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/checkpoint"
    click Cooldown "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/cooldown"
    
    click GameNFT "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/tokens/gamenft"
    click ShipNFT "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/tokens/shipnft"
    click StarterNFT "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/tokens/starterpiratenft"
    click AchievementNFT "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/tokens/achievementnft"
    click GoldToken "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/tokens/goldtoken"
    click GameItems "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/tokens/gameitems"
    
    click Achievements "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/achievements"
    click Islands "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/islands"
    click Levels "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/level"
    click Gacha "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/gacha"
    click Shop "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/shop"
    click Trading "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/trade"
    click Equipment "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/equipment"
    click Loot "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/loot"
    
    click VRF "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/vrf"
    click Multichain "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/multichain"
    click Randomizer "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/randomizer"
    
    click Captain "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/captain"
    click Scene "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/scene"
    click Subscription "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/subscription"
    click GameGlobals "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/gameglobals"
    click Interfaces "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/interfaces"
    click Libraries "https://github.com/proofofplay/piratenation-contracts/tree/main/contracts/libraries"

    %% Styling
    class Core,Combat,Energy,Dungeon,Checkpoint,Cooldown core
    class GameNFT,ShipNFT,StarterNFT,AchievementNFT,GoldToken,GameItems asset
    class Achievements,Islands,Levels,Gacha,Shop,Trading,Equipment,Loot feature
    class VRF,Multichain,Randomizer infra
    class Captain,Scene,Subscription,GameGlobals,Interfaces,Libraries additional
```
