pixel-battle/models/main.py

54 строки
972 B
Python

from pydantic import BaseModel, Field, IPvAnyNetwork
from datetime import datetime as DateTime, date as Date
area_width = 64
area_height = 32
pixel_size = 24
headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': '*',
'Access-Control-Allow-Headers': '*',
}
class User(BaseModel):
id: int
ip_address: IPvAnyNetwork
created: Date
progress: int
colors: list[int]
class Pixel(BaseModel):
x: int = Field(
...,
ge=0,
le=area_width - 1,
)
y: int = Field(
...,
ge=0,
le=area_height - 1,
)
color: int = Field(
...,
ge=0x000000,
le=0xFFFFFF,
)
last_update: DateTime
class Area(BaseModel):
width: int = area_width
height: int = area_height
pixel_size: int = pixel_size
pixels: list[Pixel]
class RequestsFrequency(BaseModel):
per_second: int
per_minute: int
per_hour: int
per_day: int