Overview
Items are the rewards players can win from opening cases. Each item has a value, image, and probability that determines how often it drops. Items are created and managed directly within the case creation flow.Item Structure
Database Schema
/home/daytona/workspace/source/types/supabase.ts:73-101
Item Properties Explained
Name
- Purpose: Display name shown to players
- Format: Free text (e.g., “AK-47 | Redline”, “Dragon Knife”)
- Best Practice: Include item type and variant for clarity
Value
- Purpose: Item worth, affects rarity perception
- Type: Decimal number (e.g., 1.50, 99.99)
- Usage: Used for:
- Display purposes
- Calculating expected case value
- Determining “win” vs “loss” for players
Image URL
- Purpose: Visual representation of the item
- Requirements:
- Must be a valid, publicly accessible URL
- Should load quickly (optimized images)
- Recommended format: PNG with transparency
Probability
- Purpose: Determines drop rate
- Range: 0-100 (percentage)
- Constraint: All items in a case must sum to exactly 100%
- Example:
- Common item: 45%
- Rare item: 5%
- Legendary: 1%
Adding Items to Cases
During Case Creation
Items are added when creating a new case via the create case form:/home/daytona/workspace/source/components/admin/create-case-form.tsx:57-60
Adding Additional Items
Click “Agregar Ítem” button to add more items (up to 15 total):/home/daytona/workspace/source/components/admin/create-case-form.tsx:64-67
Item Limits
Minimum Items
- Minimum: 2 items per case
- Reason: Ensures variety and meaningful choice
/home/daytona/workspace/source/components/admin/create-case-form.tsx:25-26
Maximum Items
- Maximum: 15 items per case
- Reason: UI/UX constraints and performance
/home/daytona/workspace/source/components/admin/create-case-form.tsx:26
Probability Management
Validation Rules
The system enforces strict probability validation:/home/daytona/workspace/source/components/admin/create-case-form.tsx:27-30
Real-Time Probability Tracking
The form displays live probability totals:- Green: Total = 100% (valid)
- Red: Total ≠ 100% (invalid)
/home/daytona/workspace/source/components/admin/create-case-form.tsx:69-71
Rarity Tiers
While not enforced by the database schema, following rarity conventions improves player experience:Suggested Rarity Structure
Common (Gray)
- Probability: 40-60%
- Value: 0.50 - 2.00
- Purpose: Most frequent drops, base value
Uncommon (Light Blue)
- Probability: 20-35%
- Value: 2.00 - 5.00
- Purpose: Regular decent drops
Rare (Blue)
- Probability: 10-20%
- Value: 5.00 - 15.00
- Purpose: Notable wins
Epic (Purple)
- Probability: 5-10%
- Value: 15.00 - 50.00
- Purpose: Exciting wins
Legendary (Gold/Red)
- Probability: 1-5%
- Value: 50.00+
- Purpose: Jackpot items
Example Distribution
Drop Rate Configuration
How Drop Rates Work
When a player opens a case:- A random number 0-100 is generated
- Items are checked in order of probability
- The item whose cumulative range includes the random number is selected
Setting Fair Drop Rates
-
Calculate Expected Value:
-
House Edge Consideration:
- If price > expected value: Favors the house
- If price < expected value: Favors the player
- Sweet spot: 85-95% RTP (Return to Player)
-
Example:
Item Management in Database
Database Structure
/home/daytona/workspace/source/supabase/migrations/0000_create_cases_system.sql:14-23
Cascading Deletes
When a case is deleted, all associated items are automatically removed:Row Level Security (RLS)
Read Access
Anyone can view case items:Write Access
Only admins can modify items:/home/daytona/workspace/source/supabase/migrations/0000_create_cases_system.sql:53-62
Bulk Item Creation
When creating a case, all items are inserted in a single operation:/home/daytona/workspace/source/app/actions/create-case.ts:109-119
Rollback on Failure
If item creation fails, the case is deleted to maintain consistency:/home/daytona/workspace/source/app/actions/create-case.ts:121-125
Best Practices
Image Management
- Consistent Dimensions: Use square images (512x512 or 1024x1024)
- Format: PNG with transparency for best quality
- Optimization: Compress images (aim for less than 100KB per image)
- CDN: Host on a CDN for fast loading
- Naming: Use descriptive filenames (e.g.,
awp-dragon-lore.png)
Probability Design
- Start with high-value items: Set legendary item probabilities first (1-5%)
- Work backwards: Distribute remaining probability to lower tiers
- Use decimals: 2.5%, 7.3% for fine-tuning
- Verify sum: Always ensure total = 100.00%
Value Assignment
- Market research: Check similar items in other games/platforms
- Relative pricing: Higher rarity = higher value
- Psychological pricing: Use .99 endings (4.99, 9.99)
- Avoid zero value: Minimum value of 0.50 keeps all items meaningful
Item Naming
- Be descriptive: “AK-47 | Redline” > “Red Gun”
- Consistent format: [Weapon] | [Skin Name]
- Avoid special characters: Stick to alphanumeric and basic symbols
- Length: Keep under 30 characters for UI compatibility
Common Issues
Probability Doesn’t Sum to 100%
Symptom: Red indicator, submit disabled Solution:Item Value Too Low
Symptom: Expected value makes case unprofitable Solutions:- Increase high-value item probabilities
- Add more medium-value items
- Increase case price
Image Not Loading
Symptoms: Broken image icons in case display Checks:- URL is publicly accessible
- URL uses HTTPS
- Image file exists at URL
- No CORS restrictions
- Image format is supported (PNG, JPG, WebP)
Updating Items
Current Limitation
The current implementation creates items during case creation. To update items after creation, you would need to:-
Query existing items:
-
Update specific item:
- Ensure probabilities still sum to 100%
Future Enhancement
Consider adding an “Edit Case” page that allows:- Updating item properties
- Adding/removing items from existing cases
- Rebalancing probabilities with live preview
Example: Complete Item Configuration
Next Steps
- Creating Cases - Full guide to case creation flow
- Monitoring - Track item drops and player activity
- Admin Overview - Understand admin permissions
