Add complete ai.card Rust implementation
- Implement complete Rust API server with axum framework - Add database abstraction supporting PostgreSQL and SQLite - Implement comprehensive gacha system with probability calculations - Add JWT authentication with atproto DID integration - Create card master data system with rarities (Normal, Rare, SuperRare, Kira, Unique) - Implement draw history tracking and collection management - Add API endpoints for authentication, card drawing, and collection viewing - Include database migrations for both PostgreSQL and SQLite - Maintain full compatibility with Python API implementation - Add comprehensive documentation and development guide 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1
python/api/app/models/__init__.py
Normal file
1
python/api/app/models/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
# Models Package
|
57
python/api/app/models/card.py
Normal file
57
python/api/app/models/card.py
Normal file
@ -0,0 +1,57 @@
|
||||
"""Card data models"""
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class CardRarity(str, Enum):
|
||||
"""カードのレアリティ"""
|
||||
NORMAL = "normal"
|
||||
RARE = "rare"
|
||||
SUPER_RARE = "super_rare"
|
||||
KIRA = "kira" # キラカード(0.1%)
|
||||
UNIQUE = "unique" # uniqueカード(0.0001%)
|
||||
|
||||
|
||||
class CardBase(BaseModel):
|
||||
"""カードの基本情報"""
|
||||
id: int = Field(..., ge=0, le=15, description="カード種類ID (0-15)")
|
||||
cp: int = Field(..., ge=1, le=999, description="カードパワー")
|
||||
status: CardRarity = Field(default=CardRarity.NORMAL, description="レアリティ")
|
||||
skill: Optional[str] = Field(None, description="スキル情報")
|
||||
|
||||
|
||||
class Card(CardBase):
|
||||
"""所有カード情報"""
|
||||
owner_did: str = Field(..., description="所有者のatproto DID")
|
||||
obtained_at: datetime = Field(default_factory=datetime.utcnow, description="取得日時")
|
||||
is_unique: bool = Field(default=False, description="uniqueカードフラグ")
|
||||
unique_id: Optional[str] = Field(None, description="unique時のグローバルID")
|
||||
|
||||
class Config:
|
||||
json_encoders = {
|
||||
datetime: lambda v: v.isoformat()
|
||||
}
|
||||
|
||||
|
||||
class CardDraw(BaseModel):
|
||||
"""カード抽選リクエスト"""
|
||||
user_did: str = Field(..., description="ユーザーのDID")
|
||||
is_paid: bool = Field(default=False, description="課金ガチャかどうか")
|
||||
|
||||
|
||||
class CardDrawResult(BaseModel):
|
||||
"""カード抽選結果"""
|
||||
card: Card
|
||||
is_new: bool = Field(..., description="新規取得かどうか")
|
||||
animation_type: str = Field(..., description="演出タイプ")
|
||||
|
||||
|
||||
class UniqueCardRegistry(BaseModel):
|
||||
"""uniqueカードの登録情報"""
|
||||
card_id: int
|
||||
unique_id: str
|
||||
owner_did: str
|
||||
obtained_at: datetime
|
||||
verse_skill_id: Optional[str] = None
|
Reference in New Issue
Block a user