-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Labels
Description
Issue: Missing Documentation and Code Comments
Description:
The codebase lacks comprehensive documentation, making it difficult for developers to understand the system architecture, function purposes, and integration points. Many functions have no comments, and there's no overall system documentation explaining how the different components work together.
Problems Identified:
- Missing Function Documentation: Most functions lack proper documentation explaining their purpose, parameters, and return values
- No System Architecture Documentation: No explanation of how the different systems (Player, Gear, Session, Marketplace) interact
- Missing API Documentation: No documentation for external interfaces and how to interact with the contracts
- Incomplete Code Comments: Many complex functions lack inline comments explaining the logic
- No Deployment Documentation: Missing documentation for deployment process and configuration
Code Issues Found:
// In CoreActions - Line 78: Function has no documentation
fn spawn_items(ref self: ContractState, mut amount: u256) {
// No documentation explaining what this function does
// No parameter documentation
// No return value documentation
}
// In PlayerActions - Line 100: Complex function with minimal comments
fn deal_damage(
ref self: ContractState,
target: Array<u256>,
target_types: Array<felt252>,
with_items: Array<u256>,
session_id: felt252,
) {
// Complex damage calculation logic with minimal comments
// No explanation of damage formulas or calculations
}
// In GearActions - Line 75: Interface with no documentation
fn upgrade_gear(
ref self: ContractState,
item_id: u256,
session_id: felt252,
materials_erc1155_address: ContractAddress,
) {
// No documentation of upgrade process
// No explanation of material requirements
}
Specific Problems:
- No Function Signatures: Functions lack proper documentation of parameters and return values
- Missing Business Logic Documentation: Complex game mechanics are not explained
- No Integration Examples: No examples of how to use the different systems together
- Missing Error Documentation: No documentation of possible errors and their meanings
- No Performance Documentation: No documentation of gas costs or performance considerations
Impact:
- Medium Priority: Difficult for new developers to understand and contribute
- Hard to maintain and extend the codebase
- Difficult to debug issues without proper documentation
- Poor developer experience
- Potential for misunderstandings and bugs
Recommended Solutions:
-
Add Comprehensive Function Documentation:
/// Spawns new gear items into the game world /// /// This function creates new gear items and mints them to the warehouse. /// Only the admin can call this function. /// /// # Parameters /// * `amount` - Number of items to spawn (must be > 0 and <= 100) /// /// # Returns /// * Emits `GearSpawned` event with list of spawned item IDs /// /// # Errors /// * `Only admin can spawn items` - If caller is not admin /// * `Invalid amount` - If amount is 0 or too large /// /// # Example /// ```cairo /// spawn_items(10); // Spawns 10 random gear items /// ``` fn spawn_items(ref self: ContractState, mut amount: u256) { // Implementation... }
-
Create System Architecture Documentation:
# Citizen of Arcanis - System Architecture ## Overview Citizen of Arcanis is a Dojo-based RPG game with the following core systems: ## Core Systems ### Player System - Manages player state, health, experience, and faction - Handles damage dealing and receiving - Manages player inventory and equipment ### Gear System - Manages all game items (weapons, armor, vehicles, pets) - Handles equipment and unequipment - Manages gear upgrades and stats ### Session System - Manages player sessions for game actions - Handles session validation and renewal - Tracks session analytics and performance ### Marketplace System - Handles item trading and auctions - Manages escrow and fee collection - Provides market analytics
-
Add Inline Code Comments:
fn deal_damage( ref self: ContractState, target: Array<u256>, target_types: Array<felt252>, with_items: Array<u256>, session_id: felt252, ) { // Validate session before proceeding self.validate_session_for_action(session_id); let mut world = self.world_default(); let caller = get_caller_address(); // Get the player data let player: Player = world.read_model(caller); // Validate input arrays have same length assert(target.len() == target_types.len(), 'Target arrays length mismatch'); let mut target_index = 0; // Calculate faction bonuses for damage multiplier let faction_stats = self.get_faction_stats(player.faction); // Process each target loop { if target_index >= target.len() { break; } let target_id = *target.at(target_index); let target_type = *target_types.at(target_index); // Calculate base damage based on attack type let mut total_damage = 0; if with_items.len() == 0 { // Normal melee attack - use player's base damage total_damage = self.calculate_melee_damage(player.clone(), faction_stats); } else { // Weapon-based attack - calculate damage from equipped weapons total_damage = self.calculate_weapon_damage(player.clone(), with_items.span(), faction_stats); } // Apply the calculated damage to the target self.damage_target(target_id, target_type, total_damage); // Emit damage event for tracking let event = DamageDealt { attacker: caller, target: target_id, damage: total_damage, target_type, }; world.emit_event(@event); target_index += 1; }; }
-
Create API Documentation:
# Citizen of Arcanis - API Documentation ## Player System API ### create_player Creates a new player with the specified faction. **Parameters:** - `faction`: Player faction (CHAOS_MERCENARIES, SUPREME_LAW, REBEL_TECHNOMANCERS) - `session_id`: Valid session ID for the operation **Returns:** - Emits `PlayerInitialized` event **Errors:** - `INVALID_SESSION`: Session validation failed - `PLAYER_ALREADY_EXISTS`: Player already created
-
Add Deployment Documentation:
# Deployment Guide ## Prerequisites - Dojo CLI installed - Starknet account configured - Sufficient STRK for deployment ## Deployment Steps ### 1. Build the Project ```bash sozo build
2. Deploy to Testnet
sozo migrate apply --rpc-url https://starknet-sepolia.public.blastapi.io/rpc/v0_7
3. Start Torii Indexer
torii --world <WORLD_ADDRESS> --rpc-url https://starknet-sepolia.public.blastapi.io/rpc/v0_7
-
Add Error Documentation:
/// Error codes and their meanings pub mod Errors { /// Session validation failed pub const INVALID_SESSION: felt252 = 'INVALID_SESSION'; /// Player not found or not initialized pub const PLAYER_NOT_FOUND: felt252 = 'PLAYER_NOT_FOUND'; /// Insufficient permissions for the operation pub const INSUFFICIENT_PERMISSIONS: felt252 = 'INSUFFICIENT_PERMISSIONS'; /// Item not found or not available pub const ITEM_NOT_FOUND: felt252 = 'ITEM_NOT_FOUND'; /// Insufficient credits for the operation pub const INSUFFICIENT_CREDITS: felt252 = 'INSUFFICIENT_CREDITS'; }
Files Affected:
- All system files need documentation
src/README.md
- Needs comprehensive system documentation- Missing: API documentation, deployment guide, architecture documentation
- All function files need proper documentation headers