Add spin session functionality and update game mechanics
- 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.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
|
||||
from sqlalchemy import DateTime, ForeignKey, Numeric, String, BigInteger, func
|
||||
from sqlalchemy import DateTime, ForeignKey, Numeric, String, BigInteger, Text, Integer, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.core.database import Base
|
||||
@@ -25,6 +25,9 @@ class User(Base):
|
||||
)
|
||||
|
||||
deposits: Mapped[list["Deposit"]] = relationship(back_populates="user", cascade="all, delete-orphan")
|
||||
spin_sessions: Mapped[list["SpinSession"]] = relationship(
|
||||
back_populates="user", cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
|
||||
class Deposit(Base):
|
||||
@@ -36,3 +39,18 @@ class Deposit(Base):
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now(), nullable=False)
|
||||
|
||||
user: Mapped[User] = relationship(back_populates="deposits")
|
||||
|
||||
|
||||
class SpinSession(Base):
|
||||
__tablename__ = "spin_sessions"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"), index=True, nullable=False)
|
||||
slug: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
|
||||
bet: Mapped[Decimal] = mapped_column(Numeric(18, 2), nullable=False)
|
||||
spin_count: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
total_win: Mapped[Decimal] = mapped_column(Numeric(18, 2), nullable=False)
|
||||
payload_json: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now(), nullable=False)
|
||||
|
||||
user: Mapped[User] = relationship(back_populates="spin_sessions")
|
||||
|
||||
Reference in New Issue
Block a user