db

package
v0.0.0-...-cafca90 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QUERY_PLAYERS = `` /* 631-byte string literal not displayed */

)

Variables

View Source
var (
	ErrLoginInvalidID       = errors.New("invalid Login ID")
	ErrLoginInvalidPassword = errors.New("invalid ID && Password combo")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	AccountID    int    `db:"accountid"`
	Login        string `db:"login"`
	Password     string `db:"password"`
	Selected     int    `db:"selected"`
	AccountLevel int    `db:"accountlevel"`
	Created      int    `db:"created"`
	LastLogin    int    `db:"lastlogin"`
	BannedUntil  int    `db:"banneduntil"`
	BannedSince  int    `db:"bannedsince"`
	BanReason    string `db:"banreason"`
}

type DBHandler

type DBHandler struct {
	// contains filtered or unexported fields
}

func OpenFromConnectionString

func OpenFromConnectionString(driverName, connectionString string) (*DBHandler, error)

func OpenPostgresDB

func OpenPostgresDB(dbAddr string) (*DBHandler, error)

func (*DBHandler) Close

func (db *DBHandler) Close() error

func (*DBHandler) DeletePlayer

func (db *DBHandler) DeletePlayer(PlayerID, AccountID int) (int, error)

returns the deleted Slot number

func (*DBHandler) Exec

func (db *DBHandler) Exec(query string, args ...any) (sql.Result, error)

func (*DBHandler) FinishPlayer

func (db *DBHandler) FinishPlayer(character *protocol.SP_CL2LS_REQ_CHAR_CREATE, AccountId int) error

TODO: should this operate on the raw packet? should we do validation here or prior?

func (*DBHandler) FinishTutorial

func (db *DBHandler) FinishTutorial(PlayerID, AccountID int) error

func (*DBHandler) GetPlayer

func (db *DBHandler) GetPlayer(PlayerID int) (*Player, error)

func (*DBHandler) GetPlayerInventorySlots

func (db *DBHandler) GetPlayerInventorySlots(PlayerID int, start int, end int) ([]protocol.SItemBase, error)

start && end are both inclusive

func (*DBHandler) GetPlayers

func (db *DBHandler) GetPlayers(AccountID int) ([]Player, error)

func (*DBHandler) NewAccount

func (db *DBHandler) NewAccount(Login, Password string) (*Account, error)

func (*DBHandler) NewPlayer

func (db *DBHandler) NewPlayer(AccountID int, FirstName, LastName string, slot int) (int, error)

returns PlayerID, error

func (*DBHandler) Query

func (db *DBHandler) Query(query string, args ...any) (*sql.Rows, error)

func (*DBHandler) SetPlayerInventorySlots

func (db *DBHandler) SetPlayerInventorySlots(PlayerID int, start int, items []protocol.SItemBase) error

start is inclusive

func (*DBHandler) Setup

func (db *DBHandler) Setup() error

func (*DBHandler) Transaction

func (db *DBHandler) Transaction(transaction func(*sql.Tx) error) (err error)

calls transaction, if transaction returns a non-nil error the transaction is rolled back. otherwise the transaction is committed

func (*DBHandler) TryLogin

func (db *DBHandler) TryLogin(Login, Password string) (*Account, error)

type Inventory

type Inventory struct {
	PlayerID  int `db:"playerid"`
	Slot      int `db:"slot"`
	ID        int `db:"id"`
	Type      int `db:"type"`
	Opt       int `db:"opt"`
	TimeLimit int `db:"timelimit"`
}

type Player

type Player struct {
	PlayerID           int
	AccountID          int
	AccountLevel       int
	Slot               int
	PCStyle            protocol.SPCStyle
	PCStyle2           protocol.SPCStyle2
	EquippedNanos      [3]int
	Nanos              [config.NANO_COUNT]protocol.SNano
	Equip              [config.AEQUIP_COUNT]protocol.SItemBase
	Inven              [config.AINVEN_COUNT]protocol.SItemBase
	Bank               [config.ABANK_COUNT]protocol.SItemBase
	SkywayLocationFlag []byte
	FirstUseFlag       []byte
	Quests             []byte
	HP                 int
	Level              int
	Taros              int
	FusionMatter       int
	Mentor             int
	X, Y, Z            int
	Angle              int
	BatteryN           int
	BatteryW           int
	WarpLocationFlag   int
	ActiveNanoSlotNum  int
	Fatigue            int
	CurrentMissionID   int
	IPCState           int8
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL