- Introduced a new `spin_sessions` table to track user spin activities. - Updated the API to include a new endpoint for spinning games, allowing users to place bets and specify spin counts. - Enhanced game information structure and added validation for bets and spin counts. - Implemented the `Forest Fortune` slot game mechanics, including payline evaluation and scatter functionality. - Updated dependencies in `pyproject.toml` for development and added `httpx` for HTTP requests. - Added unit tests for the new slot mechanics and API endpoints to ensure functionality and reliability.
102 lines
2.1 KiB
Python
102 lines
2.1 KiB
Python
from datetime import datetime
|
|
from decimal import Decimal
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class DevLoginRequest(BaseModel):
|
|
telegram_id: int = Field(default=100001, ge=1)
|
|
username: str | None = "dev_user"
|
|
first_name: str | None = "Traveler"
|
|
|
|
|
|
class TelegramAuthRequest(BaseModel):
|
|
init_data: str
|
|
|
|
|
|
class TokenResponse(BaseModel):
|
|
access_token: str
|
|
token_type: str = "bearer"
|
|
|
|
|
|
class UserResponse(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
telegram_id: int | None
|
|
username: str | None
|
|
first_name: str | None
|
|
balance: Decimal
|
|
agreement_accepted: bool
|
|
agreement_accepted_at: datetime | None
|
|
created_at: datetime
|
|
|
|
|
|
class DepositRequest(BaseModel):
|
|
amount: Decimal = Field(..., description="Allowed stub amounts: 100, 500, 1000")
|
|
|
|
|
|
class DepositResponse(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
amount: Decimal
|
|
created_at: datetime
|
|
|
|
|
|
class WalletResponse(BaseModel):
|
|
balance: Decimal
|
|
deposits: list[DepositResponse]
|
|
|
|
|
|
class GameInfo(BaseModel):
|
|
slug: str
|
|
title: str
|
|
description: str
|
|
status: str = "coming_soon"
|
|
min_bet: Decimal = Decimal("1.00")
|
|
max_bet: Decimal = Decimal("1000.00")
|
|
min_spin_count: int = 1
|
|
max_spin_count: int = 1000
|
|
|
|
|
|
# Backwards-compatible alias
|
|
GameStub = GameInfo
|
|
|
|
|
|
class SpinRequest(BaseModel):
|
|
bet: Decimal = Field(..., gt=0)
|
|
spin_count: int = Field(..., ge=1, le=1000)
|
|
|
|
|
|
class PaylineWinResponse(BaseModel):
|
|
line_index: int
|
|
symbol: str
|
|
count: int
|
|
amount: Decimal
|
|
path: list[int]
|
|
|
|
|
|
class SpinOutcomeResponse(BaseModel):
|
|
index: int
|
|
grid: list[list[str]]
|
|
line_wins: list[PaylineWinResponse]
|
|
scatter_count: int
|
|
scatter_win: Decimal
|
|
total_win: Decimal
|
|
level: int
|
|
multiplier: int
|
|
meta_triggered: bool
|
|
|
|
|
|
class SessionSpinResponse(BaseModel):
|
|
slug: str
|
|
bet: Decimal
|
|
spin_count: int
|
|
total_bet: Decimal
|
|
total_win: Decimal
|
|
max_level: int
|
|
trigger_count: int
|
|
balance: Decimal
|
|
spins: list[SpinOutcomeResponse]
|