CHOA¶
Overview¶
CHOA is the game operations contract that handles player gameplay actions. It manages playing, chatting, and coordinates with SEI for player state.
- Inherits: DYSNOMIA V2
- License: Sharia
- Solidity: ^0.8.21
What This Means For Players¶
Plain English Summary: CHOA is the gameplay controller - it handles your playing and chatting actions. When you want to start playing or send a chat message in a venue, CHOA is the contract that processes those actions and calculates your rewards.
Real-World Analogy: Think of CHOA like the game's action handler in a multiplayer game. When you press buttons to perform actions (chat, join a venue), CHOA processes those inputs, updates the game state, and dishes out experience points (rewards) based on your activity.
How It Affects Your Gameplay:
- Start playing - Use Play() to register as an active player and get your YUE set up
- Chat and earn - Chatting through CHOA earns you MAI tokens as rewards
- Yuan power - Your "Yuan" score weighs your token holdings (wallet + LAU + YUE)
- First-time bonus - New players get an initial YUE token mint
State Variables¶
| Variable | Type | Visibility | Description |
|---|---|---|---|
| Type | string | public constant | "CHOA" |
| Sei | SEI | public | Reference to SEI player manager |
| _players | mapping(uint64 => YUEINTERFACE) | private | Soul → YUE mapping |
Read Functions¶
Yuan¶
- Access:public view
- Parameters:
- Currency (address): Token contract address to calculate power for
- Returns:
- Bae (uint256): Weighted balance = balanceOf(wallet) + (10 * balanceOf(LAU)) + (40 * balanceOf(YUE))
- Description: Calculates the player's weighted token holdings across wallet, LAU, and YUE.
- Computation Details:
- Direct wallet balance counts 1x
- LAU player token balance counts 10x
- YUE bank balance counts 40x
- Formula: Currency.balanceOf(tx.origin) + 10 * Currency.balanceOf(UserToken) + 40 * Currency.balanceOf(Yue)
- In Plain English: Calculate your total "power" for a token. Tokens in your YUE count 40x, in your LAU 10x, and in your wallet 1x. Higher Yuan means more influence in game calculations like XIA.Charge and ZI.Spin moduli.
Write Functions¶
Play¶
- Access:public
- Parameters:
- UserTokenAddress (address): Player's LAU token contract address
- Returns:
- Chi (YUEINTERFACE): Player's YUE bank contract
- UserToken (LAU): Player's LAU token contract
- Description: Registers a player in the game by entering through CHO and setting up their YUE bank.
- Logic Flow:
1. Enter through CHO authentication: Sei.Chan().Xie().Xia().Mai().Qi().Zuo().Cho().Enter(UserTokenAddress)
2. Get player state: (Chi, UserToken) = Sei.Chi()
3. Check if first-time player: if(address(_players[UserToken.Saat(1)]) == address(0x0))
4. If new, mint initial YUE: Sei.Chan().YueMintToOrigin(Chi)
5. Register in players mapping: _players[UserToken.Saat(1)] = Chi
6. Mint to capacity
- Side Effects: Authenticates via CHO; may mint initial YUE tokens; updates _players mapping; mints CHOA tokens
- In Plain English: Start playing the game! Present your LAU token to register as an active player. The system authenticates you through CHO, retrieves your YUE bank, and first-time players automatically get their initial YUE token minted.
Chat¶
- Access:public
- Parameters:
- Qing (address): QING venue address to chat in
- MSG (string): Message content to broadcast
- Returns:
- Charge (uint256): Reaction charge from YUE activity at venue
- Description: Sends a chat message in a venue and rewards the player with MAI tokens.
- Logic Flow:
1. Get player's YUE and LAU: (Yue, UserToken) = Sei.Chi()
2. Send chat message: _qing.Chat(UserToken, MSG)
3. React YUE with venue: Charge = Sei.Chan().ReactYue(Yue, Qing)
4. Calculate MAI reward: Mai = Sei.Chan().Xie().Xia().Mai().React(UserToken.Saat(1), _qing.Waat())
5. Cap reward: if(Mai > 1 * 10^18) Mai = 1 * 10^18
6. Transfer if balance available: if(balanceOf(this) >= Mai) _transfer(this, Yue, Mai)
- Computation Details:
- MAI reward comes from soeng chain MAI.React function
- Maximum reward per chat capped at 1 CHOA token (1 * 10^18 wei)
- Reward is transferred from CHOA contract to player's YUE
- Side Effects: Emits LogEvent on QING (chat message); triggers YUE reaction; may transfer CHOA tokens to player's YUE; triggers MAI soeng calculation
- In Plain English: Send a message in a venue AND earn rewards! Your chat builds activity points (Charge) and you receive MAI-calculated tokens deposited to your YUE bank, capped at 1 token per message. Chat more, earn more.
Contract Interactions¶
Depends On¶
- DYSNOMIA V2 - Base functionality
- SEI - Player management
- CHAN - YUE coordination
Depended On By¶
- ZI - Uses CHOA for player state
Special Mechanisms¶
Yuan Calculation¶
function Yuan(address Currency) public view returns (uint256 Bae) {
(YUEINTERFACE Yue, LAU UserToken) = Sei.Chi();
DYSNOMIA Bai = DYSNOMIA(Currency);
// Weighted sum: direct + 10x LAU + 40x YUE
return Bai.balanceOf(tx.origin)
+ (10 * Bai.balanceOf(address(UserToken)))
+ (40 * Bai.balanceOf(address(Yue)));
}
Play Registration¶
function Play(address UserTokenAddress) public returns (YUEINTERFACE Chi, LAU UserToken) {
// Enter via CHO
Sei.Chan().Xie().Xia().Mai().Qi().Zuo().Cho().Enter(UserTokenAddress);
// Get player state
(Chi, UserToken) = Sei.Chi();
// First time player gets YUE mint
if(address(_players[UserToken.Saat(1)]) == address(0x0))
Sei.Chan().YueMintToOrigin(Chi);
_players[UserToken.Saat(1)] = Chi;
}
Chat With Rewards¶
function Chat(address Qing, string memory MSG) public returns (uint256 Charge) {
(YUEINTERFACE Yue, LAU UserToken) = Sei.Chi();
QINGINTERFACE _qing = QINGINTERFACE(Qing);
// Send chat
_qing.Chat(UserToken, MSG);
// React for charge
Charge = Sei.Chan().ReactYue(Yue, Qing);
// Calculate MAI reward
uint256 Mai = Sei.Chan().Xie().Xia().Mai().React(UserToken.Saat(1), _qing.Waat());
// Cap and transfer
if(Mai > 1 * 10 ** decimals()) Mai = 1 * 10 ** decimals();
if(balanceOf(address(this)) >= Mai)
_transfer(address(this), address(Yue), Mai);
}
Contract Verification¶
| Property | Value |
|---|---|
| Keccak256 Hash | 0xe3a49cfe56d7054d4e949fa1c55bd639f366b4a6cc9fcb695ce88ada56ddcfc8 |
| Source URL | https://raw.githubusercontent.com/busytoby/atropa_pulsechain/main/solidity/dysnomia/domain/sky/02_choa.sol |
| Hash Generated | 2026-02-08T00:29:08Z |