Documentation
¶
Index ¶
- Constants
- func CleanDB()
- func CloseDB()
- func CreateTables() error
- func DB() *pg.DB
- func DeleteCharacter(userID uint64, slot int) error
- func DeleteItem(itemID int) error
- func DeleteTables() error
- func InitDB(cp database.ConnectionParams)
- func UpdateCharacter(c *Character) error
- func UpdateLocation(c *Character) error
- func ValidateCharacter(userID uint64, req *structs.NcAvatarCreateReq) error
- type Appearance
- type Attributes
- type Character
- func GetCharacter(characterID uint64) (Character, error)
- func GetCharacterByName(name string) (Character, error)
- func GetCharacterBySlot(slot byte, userID uint64) (Character, error)
- func NewCharacter(userID uint64, req *structs.NcAvatarCreateReq, initialItems bool) (*Character, error)
- func NewDummyCharacter(class string, initialItems bool, name string) *Character
- func UserCharacters(id uint64) ([]*Character, error)
- type ClientOptions
- type EquippedItems
- type InventoryType
- type Item
- type ItemAttributes
- type ItemParams
- type Location
Constants ¶
View Source
const ( UnknownInventory InventoryType = 0 BufferInventory InventoryType = 100 EquippedInventory InventoryType = 8 BagInventory InventoryType = 9 DepositInventory InventoryType = 6 RewardInventory InventoryType = 2 MiniHouseInventory InventoryType = 12 BufferInventoryMin = 0 BufferInventoryMax = 1024 BagInventoryMin = 0 BagInventoryMax = 191 DepositInventoryMin = 0 DepositInventoryMax = 144 DepositInventoryPageLimit = 36 RewardInventoryMin = 0 RewardInventoryMax = 4096 EquippedInventoryMin = 1 EquippedInventoryMax = 29 MiniHouseInventoryMin = 0 MiniHouseInventoryMax = 23 )
Variables ¶
This section is empty.
Functions ¶
func DeleteCharacter ¶
DeleteCharacter todo: switch to method
func DeleteItem ¶
func DeleteTables ¶
func DeleteTables() error
DeleteTables if they exist TODO: https://github.com/go-pg/migrations#example
func InitDB ¶
func InitDB(cp database.ConnectionParams)
func UpdateCharacter ¶
func ValidateCharacter ¶
func ValidateCharacter(userID uint64, req *structs.NcAvatarCreateReq) error
ValidateCharacter 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"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt time.Time `pg:",soft_delete"`
// contains filtered or unexported fields
}
Appearance model for the database layer
type Attributes ¶
type Attributes struct {
ID uint64
CharacterID uint64
Character *Character
Level uint8 `pg:",notnull"`
Experience uint64 `pg:",notnull,use_zero"`
Fame uint32 `pg:",notnull,use_zero"`
Hp uint32 `pg:",notnull"`
Sp uint32 `pg:",notnull"`
Intelligence uint8 `pg:",notnull,use_zero"`
Strength uint8 `pg:",notnull,use_zero"`
Dexterity uint8 `pg:",notnull,use_zero"`
Endurance uint8 `pg:",notnull,use_zero"`
Spirit uint8 `pg:",notnull,use_zero"`
Money uint64 `pg:",notnull,use_zero"`
KillPoints uint32 `pg:",notnull,use_zero"`
HpStones uint16 `pg:",notnull"`
SpStones uint16 `pg:",notnull"`
CreatedAt time.Time
UpdatedAt time.Time
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 `pg:"rel:belongs-to"`
Attributes *Attributes `pg:"rel:belongs-to"`
Location *Location `pg:"rel:belongs-to"`
Options *ClientOptions `pg:"rel:belongs-to"`
Items []*Item `pg:"rel:has-many"`
EquippedItems *EquippedItems `pg:"rel:belongs-to"`
AdminLevel uint8 `pg:",notnull,use_zero"`
Slot uint8 `pg:",notnull,use_zero"`
IsDeleted bool `pg:",use_zero"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt time.Time `pg:",soft_delete"`
// contains filtered or unexported fields
}
Character model for the database layer
func GetCharacter ¶
func GetCharacterByName ¶
func NewCharacter ¶
func NewCharacter(userID uint64, req *structs.NcAvatarCreateReq, initialItems bool) (*Character, error)
NewCharacter creates character for the User with userID and returns data the client can understand
func NewDummyCharacter ¶
NewDummyCharacter to be used only for testing purposes where a character is needed
func UserCharacters ¶
type ClientOptions ¶
type ClientOptions struct {
ID uint64
CharacterID uint64 //
Character *Character
GameOptions []byte `pg:",notnull"`
Keymap []byte `pg:",notnull"`
Shortcuts []byte `pg:",notnull"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt time.Time `pg:",soft_delete"`
// contains filtered or unexported fields
}
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
type InventoryType ¶
type InventoryType int
type Item ¶
type Item struct {
ID uint64
InventoryType int `pg:",notnull,unique:item"`
// box 2 = reward inventory
// box 3 = mini house furniture
// box 8 = equipped items / 1-29
// box 9 = inventory, storage // 9216 - 9377 (24 slots per page)
// box 12 = mini houses // 12288 equipped minihouse, 12299-12322 available slots
// box 13 = mini house accessories
// box 14 = mini house tile all inventory
// box 15 = premium actions inventory(dances)
// box 16 = mini house mini game inventory
Slot int `pg:",use_zero,notnull,unique:item"`
CharacterID uint64 `pg:",notnull,unique:item" `
Character *Character `pg:"rel:belongs-to"`
ShnID uint16 `pg:",notnull"`
ShnInxName string `pg:",notnull"`
Stackable bool `pg:",notnull,use_zero"`
Amount int
Attributes *ItemAttributes `pg:"rel:belongs-to"`
CreatedAt time.Time
UpdatedAt time.Time
// contains filtered or unexported fields
}
func GetCharacterItems ¶
func GetCharacterItems(characterID int, inventoryType InventoryType) ([]*Item, error)
type ItemAttributes ¶
type ItemAttributes struct {
ID uint64 `pg:",unique:item"`
ItemID uint64 `pg:",use_zero,notnull,unique:item"`
StrengthBase int `pg:",use_zero"`
StrengthExtra int `pg:",use_zero"`
DexterityBase int `pg:",use_zero"`
DexterityExtra int `pg:",use_zero"`
IntelligenceBase int `pg:",use_zero"`
IntelligenceExtra int `pg:",use_zero"`
EnduranceBase int `pg:",use_zero"`
EnduranceExtra int `pg:",use_zero"`
SpiritBase int `pg:",use_zero"`
SpiritExtra int `pg:",use_zero"`
PAttackBase int `pg:",use_zero"`
PAttackExtra int `pg:",use_zero"`
MAttackBase int `pg:",use_zero"`
MAttackExtra int `pg:",use_zero"`
MDefenseBase int `pg:",use_zero"`
MDefenseExtra int `pg:",use_zero"`
PDefenseBase int `pg:",use_zero"`
PDefenseExtra int `pg:",use_zero"`
AimBase int `pg:",use_zero"`
AimExtra int `pg:",use_zero"`
EvasionBase int `pg:",use_zero"`
EvasionExtra int `pg:",use_zero"`
MaxHPBase int `pg:",use_zero"`
MaxHPExtra int `pg:",use_zero"`
CreatedAt time.Time
UpdatedAt time.Time
// contains filtered or unexported fields
}
type ItemParams ¶
type ItemParams struct {
CharacterID uint64
ShnID uint16
Stackable bool
Amount int
Attributes *ItemAttributes
}
type Location ¶
type Location struct {
ID uint64
CharacterID uint64 //
Character *Character
MapID uint32 `pg:",notnull"`
MapName string `pg:",notnull"`
X int `pg:",notnull"`
Y int `pg:",notnull"`
D int `pg:",notnull,use_zero"`
IsKQ bool `pg:",notnull,use_zero"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt time.Time `pg:",soft_delete"`
// contains filtered or unexported fields
}
Location model for the database layer
Click to show internal directories.
Click to hide internal directories.