character

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidClassGender = &ErrCharacter{
	Code:    4,
	Message: "invalid class gender data",
}

ErrInvalidClassGender happens if the client tries to bypass client side verification

View Source
var ErrInvalidName = &ErrCharacter{
	Code:    3,
	Message: "invalid name",
}

ErrInvalidName happens if the client tries to bypass client side verification

View Source
var ErrInvalidSlot = &ErrCharacter{
	Code:    0,
	Message: "invalid slot",
}

ErrInvalidSlot happens if the client tries to bypass client side verification

View Source
var ErrNameTaken = &ErrCharacter{
	Code:    1,
	Message: "name taken",
}

ErrNameTaken name is reserved or in use

View Source
var ErrNoSlot = &ErrCharacter{
	Code:    2,
	Message: "no slot available",
}

ErrNoSlot happens if the client tries to bypass client side verification

Functions

func CreateTables

func CreateTables(db *pg.DB) error

CreateTables if not yet created

func Delete

func Delete(db *pg.DB, userID uint64, req structs.NcAvatarEraseReq) error

Delete character for User with userID soft deletion is performed

func DeleteTables

func DeleteTables(db *pg.DB) error

DeleteTables if they exist

func New

New creates character for the User with userID and returns data the client can understand

func Validate

func Validate(db *pg.DB, userID uint64, req structs.NcAvatarCreateReq) error

Validate checks data sent by the client is valid

Types

type Appearance

type Appearance struct {
	ID          uint64
	CharacterID uint64 //
	Character   *Character
	Class       uint8     `pg:",notnull"`
	Gender      uint8     `pg:",notnull,use_zero"`
	HairType    uint8     `pg:",notnull,use_zero"`
	HairColor   uint8     `pg:",notnull,use_zero"`
	FaceType    uint8     `pg:",notnull,use_zero"`
	DeletedAt   time.Time `pg:",soft_delete"`
	// contains filtered or unexported fields
}

Appearance model for the database layer

func (*Appearance) NcRepresentation added in v0.0.2

func (ca *Appearance) NcRepresentation() structs.ProtoAvatarShapeInfo

NcRepresentation returns a struct that can be serialized into bytes and can be sent to the client

type Attributes

type Attributes struct {
	ID           uint64
	CharacterID  uint64
	Character    *Character
	Level        uint16    `pg:",notnull"`
	Experience   uint64    `pg:",notnull,use_zero"`
	Fame         uint64    `pg:",notnull,use_zero"`
	Hp           uint32    `pg:",notnull"`
	Sp           uint32    `pg:",notnull"`
	Intelligence uint32    `pg:",notnull"`
	Strength     uint32    `pg:",notnull"`
	Dexterity    uint32    `pg:",notnull"`
	Endurance    uint32    `pg:",notnull"`
	Spirit       uint32    `pg:",notnull"`
	Money        uint64    `pg:",notnull,use_zero"`
	KillPoints   uint32    `pg:",notnull,use_zero"`
	HpStones     uint16    `pg:",notnull"`
	SpStones     uint16    `pg:",notnull"`
	DeletedAt    time.Time `pg:",soft_delete"`
	// contains filtered or unexported fields
}

Attributes model for the database layer

type Character

type Character struct {
	ID            uint64
	UserID        uint64 `pg:",notnull"`
	Name          string `pg:",notnull,unique"`
	Appearance    *Appearance
	Attributes    *Attributes
	Location      *Location
	Inventory     *Inventory
	EquippedItems *EquippedItems
	AdminLevel    uint8     `pg:",notnull,use_zero"`
	Slot          uint8     `pg:",notnull,use_zero"`
	IsDeleted     bool      `pg:",use_zero"`
	DeletedAt     time.Time `pg:",soft_delete"`
	// contains filtered or unexported fields
}

Character model for the database layer

func (*Character) NcRepresentation added in v0.0.2

func (c *Character) NcRepresentation() structs.AvatarInformation

NcRepresentation returns a struct that can be serialized into bytes and can be sent to the client

type EquippedItems

type EquippedItems struct {
	ID               uint64
	CharacterID      uint64 //
	Character        *Character
	Head             uint16
	Face             uint16
	Body             uint16
	Pants            uint16
	Boots            uint16
	LeftHand         uint16
	RightHand        uint16
	LeftMiniPet      uint16
	RightMiniPet     uint16
	ApparelHead      uint16
	ApparelFace      uint16
	ApparelEye       uint16
	ApparelBody      uint16
	ApparelPants     uint16
	ApparelBoots     uint16
	ApparelLeftHand  uint16
	ApparelRightHand uint16
	ApparelBack      uint16
	ApparelTail      uint16
	ApparelAura      uint16
	ApparelShield    uint16
	DeletedAt        time.Time `pg:",soft_delete"`
	// contains filtered or unexported fields
}

EquippedItems model for the database layer

func (*EquippedItems) NcRepresentation added in v0.0.2

func (cei *EquippedItems) NcRepresentation() structs.ProtoEquipment

NcRepresentation returns a struct that can be serialized into bytes and can be sent to the client

type ErrCharacter

type ErrCharacter struct {
	Code    int
	Message string
}

ErrCharacter is used to handle known errors

func (*ErrCharacter) Error

func (ec *ErrCharacter) Error() string

type Inventory

type Inventory struct {
	ID          uint64
	CharacterID uint64 //
	Character   *Character
	ShnID       uint16    `pg:",notnull"`
	Slot        uint16    `pg:",notnull,use_zero"`
	IsStack     bool      `pg:",notnull,use_zero"`
	IsStored    bool      `pg:",notnull,use_zero"`
	FromMonarch bool      `pg:",notnull,use_zero"`
	FromStore   bool      `pg:",notnull,use_zero"`
	DeletedAt   time.Time `pg:",soft_delete"`
	// contains filtered or unexported fields
}

Inventory model for the database layer

type Location

type Location struct {
	ID          uint64
	CharacterID uint64 //
	Character   *Character
	MapName     string    `pg:",notnull"`
	X           uint32    `pg:",notnull"`
	Y           uint32    `pg:",notnull"`
	D           uint32    `pg:",notnull"`
	IsKQ        bool      `pg:",notnull,use_zero"`
	DeletedAt   time.Time `pg:",soft_delete"`
	// contains filtered or unexported fields
}

Location model for the database layer

Jump to

Keyboard shortcuts

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