util

package
v0.0.0-...-c1fe771 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2016 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Mode stores the AAC mode
	Mode int

	// Monsters holds all server monsters
	Monsters = &ServerMonsters{
		m:  make(map[string]*Monster),
		rw: &sync.RWMutex{},
	}
	// Config contains the whole parsed config lua file
	Config = &ConfigLUA{
		make(map[string]interface{}),
		&sync.RWMutex{},
	}
	// Stages contains the server experience stages
	Stages = &ServerStages{
		&stageDefinition{},
		&sync.RWMutex{},
	}
	// Items contains the server items xml parsed
	Items = &ServerItems{
		make(map[int]ItemDefinition),
		&sync.RWMutex{},
	}
	// Houses contains the server houses.xml
	Houses = &ServerHouses{
		&HouseList{},
		&sync.RWMutex{},
	}
	// Towns contains the server town list
	Towns = &ServerTowns{
		[]otmap.Town{},
		&sync.RWMutex{},
	}
	// Spr contains the client spr file
	Spr = &SpriteFile{
		rw: &sync.RWMutex{},
	}
)

Functions

func CreateSignature

func CreateSignature(name string, gender, vocation, level int, lastlogin int64) ([]byte, error)

CreateSignature creates a player signature image

func Gender

func Gender(gender string) int

Gender gets the gender id from a given string

func GetGender

func GetGender(gender int) string

GetGender gets the gender string from a id

func GetHighscoreQuery

func GetHighscoreQuery(page int, highscoreType string, per int) (int, string, string)

GetHighscoreQuery returns a highscore query

func GetVocation

func GetVocation(voc int) string

GetVocation gets the vocation string from a id

func Outfit

func Outfit(path string, looktype, lookhead, lookbody, looklegs, lookfeet, lookaddons int) ([]byte, error)

Outfit renders a tibia outfit with the given looks

func ParseConfig

func ParseConfig(path string)

ParseConfig parses the config lua file

func ParseItems

func ParseItems(path string)

ParseItems loads items xml into memory

func ParseMap

func ParseMap(path string)

ParseMap loads and parses the given OTBM file

func ParseMonsters

func ParseMonsters(path string)

ParseMonsters parses monsters.xml

func ParseSpr

func ParseSpr(path string)

ParseSpr parses tibia.spr file

func ParseStages

func ParseStages(path string)

ParseStages loads server stages with the given path

func QueryToTable

func QueryToTable(r [][]interface{}, names []string) *lua.LTable

QueryToTable converts a slice of interfaces to a lua table

func SetMode

func SetMode(mode int)

SetMode sets the AAC run mode DEBUG(0) RELEASE(1)

func TableToMap

func TableToMap(r *lua.LTable) map[string]interface{}

TableToMap converts a lua table to a map

func UnixToString

func UnixToString(unix int64) string

UnixToString converts a int64 to a string date

func ValidFormat

func ValidFormat(format string) bool

ValidFormat checks if an image format is valid

func Validate

func Validate(f interface{}) []error

Validate validates de given struct with its tags

func Vocation

func Vocation(voc string) int

Vocation gets the vocation id from a given string

Types

type ConfigLUA

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

ConfigLUA holds the parsed config lua file

func (*ConfigLUA) Bool

func (c *ConfigLUA) Bool(key string) bool

Bool returns a config lua bool value

func (*ConfigLUA) Int

func (c *ConfigLUA) Int(key string) int

Int returns a config lua int value

func (*ConfigLUA) String

func (c *ConfigLUA) String(key string) string

String returns a config lua string value

type House

type House struct {
	ID     uint32 `xml:"houseid,attr"`
	Name   string `xml:"name,attr"`
	EntryX uint16 `xml:"entryx,attr"`
	EntryY uint16 `xml:"entryy,attr"`
	EntryZ uint16 `xml:"entryz,attr"`
	Size   int    `xml:"size,attr"`
	TownID uint32 `xml:"townid,attr"`
}

House holds all information about a game house

type HouseList

type HouseList struct {
	XMLName xml.Name `xml:"houses"`
	Houses  []*House `xml:"house"`
}

HouseList holds the house array

type ItemDefinition

type ItemDefinition struct {
	ID         int             `xml:"id,attr"`
	Name       string          `xml:"name,attr"`
	Attributes []itemAttribute `xml:"attribute"`
}

ItemDefinition represents a server item

func (*ItemDefinition) GetArmor

func (s *ItemDefinition) GetArmor() int

GetArmor returns an item armor value

func (*ItemDefinition) GetDescription

func (s *ItemDefinition) GetDescription() string

GetDescription returns an item description

func (*ItemDefinition) GetSlot

func (s *ItemDefinition) GetSlot() string

GetSlot returns an item slot type

func (*ItemDefinition) GetWeight

func (s *ItemDefinition) GetWeight() int

GetWeight returns an item weight

type Monster

type Monster struct {
	XMLName         xml.Name          `xml:"monster"`
	Name            string            `xml:"name,attr"`
	NameDescription string            `xml:"nameDescription,attr"`
	Race            string            `xml:"race,attr"`
	Experience      int               `xml:"experience,attr"`
	Speed           int               `xml:"speed,attr"`
	ManaCost        int               `xml:"manacost,attr"`
	Health          MonsterHealth     `xml:"health"`
	Look            MonsterLook       `xml:"look"`
	Voices          []MonsterSentence `xml:"voices>voice"`
	Loot            []MonsterItem     `xml:"loot>item"`
}

Monster is the main monster representation

type MonsterHealth

type MonsterHealth struct {
	Now int `xml:"now,attr"`
	Max int `xml:"max,attr"`
}

MonsterHealth struct for monster stats

type MonsterItem

type MonsterItem struct {
	ID       int `xml:"id,attr"`
	CountMax int `xml:"countmax,attr"`
	Chance   int `xml:"chance,attr"`
}

MonsterItem struct for monster loot

type MonsterLook

type MonsterLook struct {
	Type   int `xml:"type,attr"`
	Head   int `xml:"head,attr"`
	Body   int `xml:"body,attr"`
	Legs   int `xml:"legs,attr"`
	Feet   int `xml:"feet,attr"`
	Corpse int `xml:"corpse,attr"`
}

MonsterLook struct for monster looktype

type MonsterSentence

type MonsterSentence struct {
	Sentence string `xml:"sentence,attr"`
}

MonsterSentence struct for monster talks

type PaypalAmount

type PaypalAmount struct {
	Total    string `json:"total"`
	Currency string `json:"currency"`
}

PaypalAmount paypal payment amount

type PaypalAmountDetails

type PaypalAmountDetails struct {
	Subtotal float64 `json:"subtotal"`
}

PaypalAmountDetails detials of paypal payment amount

type PaypalLink struct {
	Href   string `json:"href"`
	Rel    string `json:"rel"`
	Method string `json:"method"`
}

PaypalLink links of created payment

type PaypalPayer

type PaypalPayer struct {
	PaymentMethod string `json:"payment_method"`
}

PaypalPayer payment method

type PaypalPayerInfo

type PaypalPayerInfo struct {
	Email       string `json:"email"`
	FirstName   string `json:"first_name"`
	LastName    string `json:"last_name"`
	PayerID     string `json:"payer_id"`
	CountryCode string `json:"country_code"`
}

PaypalPayerInfo holds information about the payer

type PaypalPayerInformation

type PaypalPayerInformation struct {
	PaymentMethod string          `json:"payment_method"`
	Status        string          `json:"status"`
	PayerInfo     PaypalPayerInfo `json:"payer_info"`
}

PaypalPayerInformation holds information about the payer

type PaypalPayment

type PaypalPayment struct {
	ID           string              `json:"id"`
	CreateTime   string              `json:"create_time"`
	UpdateTime   string              `json:"update_time"`
	State        string              `json:"state"`
	Intent       string              `json:"intent"`
	Payer        PaypalPayer         `json:"payer"`
	Transactions []PaypalTransaction `json:"transactions"`
	Links        []PaypalLink        `json:"links"`
}

PaypalPayment struct for a created payment

func CreatePaypalPayment

func CreatePaypalPayment(hostURL, baseURL, paypalToken, amount, description, currency string) (*PaypalPayment, error)

CreatePaypalPayment creates a paypal payment and returns the response

type PaypalPaymentCreation

type PaypalPaymentCreation struct {
	Intent       string              `json:"intent"`
	RedirectURL  PaypalRedirectURL   `json:"redirect_urls"`
	Payer        PaypalPayer         `json:"payer"`
	Transactions []PaypalTransaction `json:"transactions"`
}

PaypalPaymentCreation struct for creating paypal payments

type PaypalPaymentInformation

type PaypalPaymentInformation struct {
	ID           string
	Intent       string                 `json:"intent"`
	State        string                 `json:"state"`
	Payer        PaypalPayerInformation `json:"payer"`
	Transactions []PaypalTransaction    `json:"transactions"`
}

PaypalPaymentInformation contains information about an executed payment

func ProcessPaypalPayment

func ProcessPaypalPayment(baseURL, payerID, paymentID, paypalToken string) (*PaypalPaymentInformation, error)

ProcessPaypalPayment executes a paypal payment

func (*PaypalPaymentInformation) IsEmpty

func (p *PaypalPaymentInformation) IsEmpty() bool

IsEmpty checks if a payment is processed

type PaypalPaymentProcess

type PaypalPaymentProcess struct {
	PayerID string `json:"payer_id"`
}

PaypalPaymentProcess used to execute payments

type PaypalRedirectURL

type PaypalRedirectURL struct {
	ReturnURL string `json:"return_url"`
	CancelURL string `json:"cancel_url"`
}

PaypalRedirectURL redirect url payment

type PaypalToken

type PaypalToken struct {
	Scope     string `json:"scope"`
	Token     string `json:"access_token"`
	Type      string `json:"token_type"`
	ExpiresIn int64  `json:"expires_in"`
}

PaypalToken is the main oauth struct for paypal

func GetPaypalToken

func GetPaypalToken(baseURL, public, private string) (*PaypalToken, error)

GetPaypalToken returns a new paypal oauth token

type PaypalTransaction

type PaypalTransaction struct {
	Amount      PaypalAmount `json:"amount"`
	Description string       `json:"description"`
}

PaypalTransaction array of paypal payment transactions

type ServerHouses

type ServerHouses struct {
	List *HouseList
	// contains filtered or unexported fields
}

ServerHouses contains the whole house list of the server

func (*ServerHouses) GetHouse

func (s *ServerHouses) GetHouse(id uint32) *House

GetHouse gets a house by its ID

func (*ServerHouses) GetHouseByName

func (s *ServerHouses) GetHouseByName(name string) *House

GetHouseByName gets a house by its name

func (*ServerHouses) GetList

func (s *ServerHouses) GetList(id uint32) []*House

GetList returns the full list of houses by its town

type ServerItems

type ServerItems struct {
	Items map[int]ItemDefinition
	// contains filtered or unexported fields
}

ServerItems holds all server items

func (*ServerItems) Get

func (s *ServerItems) Get(id int) *ItemDefinition

Get gets an item by its ID

type ServerMonsters

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

ServerMonsters holds all server monsters

func (*ServerMonsters) Get

func (m *ServerMonsters) Get(name string) *Monster

Get returns a monster struct

type ServerStages

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

ServerStages holds all the server stages

func (*ServerStages) Get

func (s *ServerStages) Get(index int) StageDef

Get returns an stage by its index

func (*ServerStages) GetAll

func (s *ServerStages) GetAll() []StageDef

GetAll retrieves all stages

func (*ServerStages) IsEnabled

func (s *ServerStages) IsEnabled() bool

IsEnabled checks if stages are enabled on the server

type ServerTowns

type ServerTowns struct {
	List []otmap.Town
	// contains filtered or unexported fields
}

ServerTowns contains the whole town list of the server

func (*ServerTowns) Exists

func (s *ServerTowns) Exists(name string) bool

Exists checks if a town is valid

func (*ServerTowns) Get

func (s *ServerTowns) Get(name string) *otmap.Town

Get returns a town by its name

func (*ServerTowns) GetByID

func (s *ServerTowns) GetByID(id uint32) string

GetByID returns a town by its ID

func (*ServerTowns) GetList

func (s *ServerTowns) GetList() []otmap.Town

GetList returns the whole town list

func (*ServerTowns) GetRandom

func (s *ServerTowns) GetRandom() otmap.Town

GetRandom returns a random town

type SpriteFile

type SpriteFile struct {
	Signature uint32
	Amount    uint32
	// contains filtered or unexported fields
}

SpriteFile contains all the information about the .spr file

type StageDef

type StageDef struct {
	MinLevel   int `xml:"minlevel,attr"`
	MaxLevel   int `xml:"maxlevel,attr"`
	Multiplier int `xml:"multiplier,attr"`
}

StageDef represents an experience stage

Jump to

Keyboard shortcuts

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