Start repo, claude & kimi still vibing tho

This commit is contained in:
ra
2026-02-14 17:04:21 -07:00
commit f5b8aeb39d
54 changed files with 9466 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
defmodule Odinsea.Database.Schema.Account do
@moduledoc """
Ecto schema for the accounts table.
Represents a user account in the game.
"""
use Ecto.Schema
import Ecto.Changeset
@primary_key {:id, :id, autogenerate: true}
@timestamps_opts [inserted_at: :createdat, updated_at: false]
schema "accounts" do
field :name, :string
field :password, :string
field :salt, :string
field :second_password, :string, source: :"2ndpassword"
field :salt2, :string
field :loggedin, :integer, default: 0
field :lastlogin, :naive_datetime
field :createdat, :naive_datetime
field :birthday, :date
field :banned, :integer, default: 0
field :banreason, :string
field :gm, :integer, default: 0
field :email, :string
field :macs, :string
field :tempban, :naive_datetime
field :greason, :integer
field :acash, :integer, default: 0, source: :ACash
field :mpoints, :integer, default: 0, source: :mPoints
field :gender, :integer, default: 0
field :session_ip, :string, source: :SessionIP
field :points, :integer, default: 0
field :vpoints, :integer, default: 0
field :totalvotes, :integer, default: 0
field :lastlogon, :naive_datetime
field :lastvoteip, :string
has_many :characters, Odinsea.Database.Schema.Character, foreign_key: :accountid
end
@doc """
Changeset for account registration.
"""
def registration_changeset(account, attrs) do
account
|> cast(attrs, [:name, :password, :salt, :birthday, :gender, :email])
|> validate_required([:name, :password, :salt])
|> validate_length(:name, min: 3, max: 13)
|> validate_format(:name, ~r/^[a-zA-Z0-9]+$/, message: "only letters and numbers allowed")
|> unique_constraint(:name)
end
@doc """
Changeset for login updates (last login time, IP, etc).
"""
def login_changeset(account, attrs) do
account
|> cast(attrs, [:loggedin, :lastlogin, :session_ip])
end
@doc """
Changeset for ban updates.
"""
def ban_changeset(account, attrs) do
account
|> cast(attrs, [:banned, :banreason, :tempban, :greason])
end
end