In-Game Currency (Coins)
In-Game Currency (Coins)
Overview
The Coins service represents the platform's internal currency system, providing mechanisms for managing virtual currencies (coins). It allows creating different types of coins, managing user balances, and tracking transactions.
Core Functionality
Coin Types
The system can have multiple coin types, each with the following characteristics:
- Code (unique coin identifier, e.g.,
silver,gold) - Name (display name of the coin)
- Position (display order in the interface)
One of the coins is considered primary and used by default if no specific coin type is specified.
Payment Account
For each user and each coin type, a payment account (CoinAccount) is created, containing information about balance and transaction history.
Includes:
- User identifier
- Coin type identifier
- Current balance
- Sum of incoming transactions (deposits)
- Sum of outgoing transactions (withdrawals)
- Deposit (reserved funds)
Coin Operations
Balance Top-up
Users can receive coins in various ways:
- Completing tasks and achievements
- Daily activity
- Participating in promotions and events
- Rewards from administrators
When topping up the balance, a transaction with a positive amount is created, which increases the user's total balance.
Coin Deduction
Coins can be deducted in the following cases:
- Purchasing goods and services
- Paying for premium features
When deducting, a transaction with a negative amount is created, which decreases the user's balance.
Transactions
Each coin operation (top-up, deduction, transfer) creates a corresponding transaction in the system. A transaction contains information about:
- User account
- Operation amount
- Time of execution
- Reason - cause or source of the operation
- Reason identifier - related entity of the reason
- Additional information (note)
Transactions are used for complete tracking of all coin operations, balance verification, and report generation.
Business Processes
Coin Crediting
Automatic crediting
- For regular user activity
- For achieving specific goals
- For completing tasks in the system
Manual crediting
- Administrators can credit coins to users
- Administrators can reward users for useful content
Coin Usage
Purchasing goods and services
- Users can spend coins on acquiring virtual goods
- Coins can be used to activate special features
Social mechanics
- User encouragement
- Rewards for participating in events
- Status purchases
Economic Balance
The system is designed considering the need to maintain economic balance:
- Control over the volume of coins in circulation
- Analysis of accumulation and usage statistics
- Timely adjustment of crediting and deduction mechanisms
Reports and Monitoring
Tools are available for analyzing and monitoring the coin system:
- General statistics for all coin types
- Transaction reports with filtering by type, time, and reason
- User balance analysis
- Monitoring of anomalous activity
Integration with Other Services
The coin service is integrated with other platform modules:
- Tasks and achievements service
- Virtual goods store
- Rating service
- Economic mechanics of gaming elements
Security and Protection
To ensure security and prevent abuse, the following are provided:
- Transactional execution of operations to prevent data loss
- Event model for operation logging
- Mutexes to prevent parallel balance changes
- Balance checks before executing operations
- Notifications about important coin operations
Monetization
The coin system plays a key role in platform monetization:
- Sale of premium coins for real money
PRO - Special offers and coin packages
- Subscriptions with daily coin crediting
PRO - Conversion between different coin types
