retro

package module
v0.0.0-...-a4b1f48 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: MPL-2.0 Imports: 11 Imported by: 6

README

retro

retro is a core library for Dofus Retro. It declares data types and provides constants and functions to work with the game. It also declares the Storer interface implemented in package retropg.

Requirements

Installation

go get -u -v github.com/kralamoure/retro

Documentation

Overview

Package retro is a core library for Dofus Retro. It declares data types and provides constants and functions to work with the game. It also declares the Storer interface implemented in package retropg (https://github.com/kralamoure/retropg).

Index

Constants

This section is empty.

Variables

View Source
var CharacterHonorFloors = []int{500, 1500, 3000, 5000, 7500, 10000, 12500, 15000, 17500, 18000}
View Source
var CharacterXPFloors = []int{}/* 199 elements not displayed */
View Source
var ErrAlreadyExists = errors.New("already exists")
View Source
var ErrCharacterNameAndGameServerIdAlreadyExist = errors.New("character name and game server ID already exist")
View Source
var ErrGameServerHostAndPortAlreadyExist = errors.New("game server host and port already exist")
View Source
var ErrNotFound = errors.New("not found")
View Source
var ErrTicketAccountIdAlreadyExists = errors.New("ticket account ID already exist")
View Source
var MountCertificateIdByMountTemplateId = map[int]int{
	3:  7808,
	9:  7810,
	10: 7811,
	11: 7812,
	12: 7813,
	15: 7814,
	16: 7815,
	17: 7816,
	18: 7817,
	19: 7818,
	20: 7819,
	21: 7820,
	22: 7821,
	23: 7822,
	33: 7823,
	34: 7824,
	35: 7825,
	36: 7826,
	37: 7827,
	38: 7828,
	39: 7829,
	40: 7830,
	41: 7831,
	42: 7832,
	43: 7833,
	44: 7834,
	45: 7835,
	46: 7836,
	47: 7837,
	48: 7838,
	49: 7839,
	50: 7840,
	51: 7841,
	52: 7842,
	53: 7843,
	54: 7844,
	55: 7845,
	56: 7846,
	57: 7847,
	58: 7848,
	59: 7849,
	60: 7850,
	61: 7851,
	62: 7852,
	63: 7853,
	64: 7854,
	65: 7855,
	66: 7856,
	67: 7857,
	68: 7858,
	69: 7859,
	70: 7860,
	71: 7861,
	72: 7862,
	73: 7863,
	75: 7865,
	76: 7866,
	77: 7867,
	78: 7868,
	79: 7869,
	80: 7870,
	82: 7871,
	83: 7872,
	84: 7873,
	85: 7874,
	86: 7875,
	87: 7876,
	88: 9582,
}
View Source
var MountTemplateIdByMountCertificateId = map[int]int{
	7808: 3,
	7810: 9,
	7811: 10,
	7812: 11,
	7813: 12,
	7814: 15,
	7815: 16,
	7816: 17,
	7817: 18,
	7818: 19,
	7819: 20,
	7820: 21,
	7821: 22,
	7822: 23,
	7823: 33,
	7824: 34,
	7825: 35,
	7826: 36,
	7827: 37,
	7828: 38,
	7829: 39,
	7830: 40,
	7831: 41,
	7832: 42,
	7833: 43,
	7834: 44,
	7835: 45,
	7836: 46,
	7837: 47,
	7838: 48,
	7839: 49,
	7840: 50,
	7841: 51,
	7842: 52,
	7843: 53,
	7844: 54,
	7845: 55,
	7846: 56,
	7847: 57,
	7848: 58,
	7849: 59,
	7850: 60,
	7851: 61,
	7852: 62,
	7853: 63,
	7854: 64,
	7855: 65,
	7856: 66,
	7857: 67,
	7858: 68,
	7859: 69,
	7860: 70,
	7861: 71,
	7862: 72,
	7863: 73,
	7865: 75,
	7866: 76,
	7867: 77,
	7868: 78,
	7869: 79,
	7870: 80,
	7871: 82,
	7872: 83,
	7873: 84,
	7874: 85,
	7875: 86,
	7876: 87,
	9582: 88,
}
View Source
var MountXPFloors = []int{600, 1_750, 2_750, 4_000, 5_500, 7_250, 9_250, 11_500, 14_000, 16_750, 19_750, 23_000, 26_500,
	30_250, 34_250, 38_500, 43_000, 47_750, 52_750, 58_000, 63_500, 69_250, 75_250, 81_500, 88_000, 94_750, 101_750,
	109_000, 116_500, 124_250, 132_250, 140_500, 149_000, 157_750, 166_750, 176_000, 185_500, 195_250, 205_250, 215_500,
	226_000, 236_750, 247_750, 259_000, 270_500, 282_250, 294_250, 306_500, 319_000, 331_750, 344_750, 358_000, 371_500,
	385_250, 399_250, 413_500, 427_000, 441_750, 456_750, 473_000, 488_500, 504_250, 520_250, 536_500, 553_000, 569_750,
	586_750, 604_000, 621_500, 639_250, 657_250, 675_500, 694_000, 712_750, 731_750, 751_000, 770_000, 790_250, 810_250,
	830_500, 851_000, 871_750, 892_750, 914_000, 935_500, 957_250, 979_250, 1_001_500, 1_025_000, 1_046_750, 1_069_750,
	1_093_000, 1_116_500, 1_140_250, 1_164_250, 1_188_500, 1_213_000, 1_237_750, 1_262_750,
}

Functions

func DecodeItemEffect

func DecodeItemEffect(s string) (effect retrotyp.Effect, err error)

func DecodeItemEffects

func DecodeItemEffects(sli []string) (effects []retrotyp.Effect, err error)

func EffectDiceParam

func EffectDiceParam(effect retrotyp.Effect) string

func EncodeItemEffect

func EncodeItemEffect(effect retrotyp.Effect) string

func EncodeItemEffects

func EncodeItemEffects(effects []retrotyp.Effect) []string

Types

type Character

type Character struct {
	Id               int
	AccountId        string
	GameServerId     int
	Name             retrotyp.CharacterName
	Sex              retrotyp.Sex
	ClassId          retrotyp.ClassId
	Color1           retrotyp.Color
	Color2           retrotyp.Color
	Color3           retrotyp.Color
	Alignment        retrotyp.Alignment
	AlignmentEnabled bool
	XP               int
	Kamas            int
	BonusPoints      int
	BonusPointsSpell int
	Honor            int
	Disgrace         int
	Stats            CharacterStats // TODO: validation (non-negative)
	GameMapId        int
	Cell             int
	Direction        int // TODO: maybe a custom type
	Spells           []CharacterSpell
	MountId          int
	Mounting         bool
}

func (Character) Grade

func (c Character) Grade() retrotyp.AlignmentGrade

func (Character) Level

func (c Character) Level() int

func (Character) Validate

func (c Character) Validate() error

func (Character) XPHigh

func (c Character) XPHigh() int

func (Character) XPLow

func (c Character) XPLow() int

type CharacterItem

type CharacterItem struct {
	Item
	Position    retrotyp.CharacterItemPosition
	CharacterId int
}

type CharacterSpell

type CharacterSpell struct {
	Id       int
	Level    int
	Position int
}

type CharacterStats

type CharacterStats struct {
	Vitality     int
	Wisdom       int
	Strength     int
	Intelligence int
	Chance       int
	Agility      int
}

type Class

type Class struct {
	Id               retrotyp.ClassId
	Name             string
	Label            string
	ShortDescription string
	Description      string
	Spells           []int
	BoostCosts       ClassBoostCosts
}

type ClassBoostCost

type ClassBoostCost struct {
	Quantity int
	Cost     int
	Bonus    int
}

type ClassBoostCosts

type ClassBoostCosts struct {
	Vitality     []ClassBoostCost
	Wisdom       []ClassBoostCost
	Strength     []ClassBoostCost
	Intelligence []ClassBoostCost
	Chance       []ClassBoostCost
	Agility      []ClassBoostCost
}

type EffectTemplate

type EffectTemplate struct {
	Id               int
	Description      string
	Dice             bool
	Operator         retrotyp.EffectOperator
	CharacteristicId retrotyp.CharacteristicId
	Element          retrotyp.EffectElement
}

type GameMap

type GameMap struct {
	Id            int
	Name          string
	Width         int
	Height        int
	Background    int
	Ambiance      int
	Music         int
	Outdoor       bool
	Capabilities  int
	Data          string
	EncryptedData string
	Key           string
}

func (GameMap) Cells

func (m GameMap) Cells() ([]retroutil.Cell, error)

type GameMapPath

type GameMapPath struct {
	CellId int
	Dir    int
}

type GameServer

type GameServer struct {
	Id         int
	Host       string
	Port       string
	State      retrotyp.GameServerState
	Completion int
}

func (GameServer) Validate

func (a GameServer) Validate() error

type Item

type Item struct {
	Id         int
	TemplateId int
	Quantity   int
	Effects    []retrotyp.Effect
}

func (Item) DisplayEffects

func (item Item) DisplayEffects() []retrotyp.Effect

type ItemSet

type ItemSet struct {
	Id    int
	Name  string
	Bonus [][]retrotyp.Effect
}

func (ItemSet) Validate

func (s ItemSet) Validate() error

TODO: maybe should validate by iterating through bonus

type ItemTemplate

type ItemTemplate struct {
	Id            int
	Name          string
	Description   string
	Type          retrotyp.ItemType
	Enhanceable   bool
	TwoHands      bool
	Ethereal      bool
	Hidden        bool
	ItemSetId     int
	CanUse        bool
	CanTarget     bool
	Level         int
	GFX           int
	Price         int
	Weight        int
	Cursed        bool
	Conditions    string // TODO
	Effects       []retrotyp.Effect
	WeaponEffects WeaponEffects
}

func (ItemTemplate) Validate

func (t ItemTemplate) Validate() error

TODO: maybe should validate by iterating through effects

type Market

type Market struct {
	Id            string
	GameServerId  int
	Quantity1     int
	Quantity2     int
	Quantity3     int
	Types         []retrotyp.ItemType
	Fee           float32
	MaxLevel      int
	MaxPerAccount int
	MaxHours      int
}

type MarketItem

type MarketItem struct {
	Item
	Price    int
	MarketId string
}

type Mount

type Mount struct {
	Id          int
	TemplateId  int
	CharacterId int
	Name        string
	Sex         retrotyp.Sex
	XP          int
	Capacities  []retrotyp.MountCapacityId
	Validity    time.Time
}

func (Mount) Level

func (c Mount) Level() int

func (Mount) XPHigh

func (c Mount) XPHigh() int

func (Mount) XPLow

func (c Mount) XPLow() int

type MountTemplate

type MountTemplate struct {
	Id         int
	Name       string
	GFXId      int
	Color1     retrotyp.Color
	Color2     retrotyp.Color
	Color3     retrotyp.Color
	MaxEffects []retrotyp.Effect
}

func (MountTemplate) Effects

func (t MountTemplate) Effects(level int) []retrotyp.Effect

type NPC

type NPC struct {
	Id            string
	GameServerId  int
	MapId         int
	CellId        int
	Direction     int
	TemplateId    int
	Sex           retrotyp.Sex
	GFX           int
	ScaleX        int
	ScaleY        int
	Color1        retrotyp.Color
	Color2        retrotyp.Color
	Color3        retrotyp.Color
	Accessories   string // TODO
	ExtraClip     int    // -1 for no extra clip.
	CustomArtwork int
	DialogId      int
	MarketId      string
}

type NPCDialog

type NPCDialog struct {
	Id        int
	Text      string
	Responses []int
}

type NPCResponse

type NPCResponse struct {
	Id         int
	Text       string
	Action     retrotyp.NPCResponseAction
	Arguments  []string
	Conditions []string // TODO
}

type NPCTemplate

type NPCTemplate struct {
	Id      int
	Name    string
	Actions []retrotyp.NPCAction
}

type Spell

type Spell struct {
	Id          int
	Name        string
	Description string
	Levels      []retrotyp.SpellLevel
}

type Storer

type Storer interface {
	GameMaps(ctx context.Context) (map[int]GameMap, error)
	EffectTemplates(ctx context.Context) (map[int]EffectTemplate, error)
	ItemSets(ctx context.Context) (map[int]ItemSet, error)
	ItemTemplates(ctx context.Context) (map[int]ItemTemplate, error)
	NPCTemplates(ctx context.Context) (map[int]NPCTemplate, error)
	NPCDialogs(ctx context.Context) (map[int]NPCDialog, error)
	NPCResponses(ctx context.Context) (map[int]NPCResponse, error)
	Classes(ctx context.Context) (map[retrotyp.ClassId]Class, error)
	Spells(ctx context.Context) (map[int]Spell, error)
	MountTemplates(ctx context.Context) (map[int]MountTemplate, error)

	Triggers(ctx context.Context) (map[string]Trigger, error)
	TriggerByGameMapIdAndCellId(ctx context.Context, gameMapId, cellId int) (Trigger, error)

	CreateGameServer(ctx context.Context, gameServer GameServer) error
	GameServers(ctx context.Context) (map[int]GameServer, error)
	GameServer(ctx context.Context, id int) (GameServer, error)
	SetGameServerState(ctx context.Context, id int, state retrotyp.GameServerState) error

	CreateTicket(ctx context.Context, ticket Ticket) (string, error)
	DeleteTickets(ctx context.Context, before time.Time) (int, error)
	UseTicket(ctx context.Context, id string) (Ticket, error)
	Tickets(ctx context.Context) (map[string]Ticket, error)
	Ticket(ctx context.Context, id string) (Ticket, error)

	CreateCharacter(ctx context.Context, character Character) (int, error)
	UpdateCharacter(ctx context.Context, character Character) error
	DeleteCharacter(ctx context.Context, id int) error
	AllCharacters(ctx context.Context) (map[int]Character, error)
	AllCharactersByAccountId(ctx context.Context, accountId string) (map[int]Character, error)
	Characters(ctx context.Context, gameServerId int) (map[int]Character, error)
	CharactersByAccountId(ctx context.Context, gameServerId int, accountId string) (map[int]Character, error)
	CharactersByGameMapId(ctx context.Context, gameServerId int, gameMapId int) (map[int]Character, error)
	Character(ctx context.Context, id int) (Character, error)

	Markets(ctx context.Context, gameServerId int) (map[string]Market, error)

	CreateCharacterItem(ctx context.Context, item CharacterItem) (int, error)
	UpdateCharacterItem(ctx context.Context, item CharacterItem) error
	DeleteCharacterItem(ctx context.Context, id int) error
	CharacterItemsByCharacterId(ctx context.Context, characterId int) (map[int]CharacterItem, error)
	CharacterItem(ctx context.Context, id int) (CharacterItem, error)

	CreateMarketItem(ctx context.Context, item MarketItem) (int, error)
	DeleteMarketItem(ctx context.Context, id int) error
	MarketItems(ctx context.Context, gameServerId int) (map[int]MarketItem, error)
	MarketItemsByMarketId(ctx context.Context, marketId string) (map[int]MarketItem, error)
	MarketItem(ctx context.Context, id int) (MarketItem, error)

	NPCs(ctx context.Context, gameServerId int) (map[string]NPC, error)

	CreateMount(ctx context.Context, mount Mount) (int, error)
	UpdateMount(ctx context.Context, mount Mount) error
	DeleteMount(ctx context.Context, id int) error
	Mount(ctx context.Context, id int) (Mount, error)
	Mounts(ctx context.Context) (map[int]Mount, error)
	MountsByCharacterId(ctx context.Context, characterId int) (map[int]Mount, error)
}

type Ticket

type Ticket struct {
	Id           string
	AccountId    string
	GameServerId int
	Created      time.Time
}

type Trigger

type Trigger struct {
	Id              string
	GameMapId       int
	CellId          int
	TargetGameMapId int
	TargetCellId    int
}

type WeaponEffects

type WeaponEffects struct {
	CriticalHitBonus int
	APCost           int
	RangeMin         int
	RangeMax         int
	CriticalHit      int
	CriticalFailure  int
	LineOnly         bool
	LineOfSight      bool
}

Directories

Path Synopsis
Package d1typ is a library of data types for Dofus 1.
Package d1typ is a library of data types for Dofus 1.

Jump to

Keyboard shortcuts

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