Version: v0.0.0-...-e366e6a Latest Latest

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

Go to latest
Published: Oct 5, 2020 License: MIT Imports: 4 Imported by: 0




View Source
const (
	ArmorTypeCloth   ArmorType = "Cloth"
	ArmorTypeLeather           = "Leather"
	ArmorTypePlate             = "Plate"
View Source
const (
	CombatTypeMelee CombatType = "Melee"
	CombaTypeRanged            = "Ranged"
	CombatTypeMagic            = "Magic"


View Source
var CharacterTemplates = []CharacterTemplate{
		TemplateID: 1,
		Character: Character{
			Name:             "Mr. Warrior",
			Description:      "Create a new Warrior",
			Race:             RaceHuman,
			Class:            ClassWarrior,
			CurrentHitPoints: 25,
			MaxHitPoints:     25,
			XP:               0,
			Level:            1,

			Attributes: createBaseAttributes(11, 8, 5, 6, 20),

		TemplateID: 2,
		Character: Character{
			Name:             "Mrs. Longstride",
			Description:      "Create a new Ranger",
			Race:             RaceElve,
			Class:            ClassRanger,
			CurrentHitPoints: 20,
			MaxHitPoints:     20,
			XP:               0,
			Level:            1,

			Attributes: createBaseAttributes(7, 15, 5, 6, 17),
		TemplateID: 3,
		Character: Character{
			Name:             "Gumdalf the Bay",
			Description:      "Create a new Wizard",
			Race:             RaceDwarf,
			Class:            ClassWizard,
			CurrentHitPoints: 17,
			MaxHitPoints:     17,
			XP:               0,
			Level:            1,

			Attributes: createBaseAttributes(5, 5, 15, 12, 13),

CharacterTemplates TODO: move to DB or yml?


This section is empty.


type ArmorType

type ArmorType string

ArmorType type

type Attribute

type Attribute struct {
	Name  string `json:"name"`
	Short string `json:"short"`
	Value int32  `json:"value"`

Attribute data

func NewAttribute

func NewAttribute(name, short string, value int32) Attribute

NewAttribute ...

type Attributes

type Attributes []Attribute

Attributes ...

type Character

type Character struct {
	*entities.Entity   `bson:",inline"`
	traits.BelongsUser `bson:",inline"`
	traits.CurrentRoom `bson:",inline"`

	Name        string `json:"name"`
	Description string `json:"description"`
	Race        Race   `json:"race"`
	Class       Class  `json:"class"`

	CurrentHitPoints int32 `json:"currentHitPoints"`
	MaxHitPoints     int32 `json:"maxHitPoints"`

	XP    int32 `json:"xp"`
	Level int32 `json:"level"`

	Created    time.Time  `bson:"created" json:"created,omitempty"`
	Attributes Attributes `bson:"attributes" json:"attributes,omitempty"`

	// complex character fields
	Inventory     Inventory                      `bson:"inventory" json:"inventory"`
	EquippedItems map[items.ItemSlot]*items.Item `bson:"equippedItems" json:"equippedItems"`

	// track alltime stats in character object but dont expose as json by default
	AllTimeStats struct {
		PlayersKilled   int32 `bson:"playersKilled" json:"playersKilled"`
		GoldCollected   int32 `bson:"goldCollected" json:"goldCollected"`
		QuestsCompleted int32 `bson:"questsCompleted" json:"questsCompleted"`
	} `bson:"allTimeStats" json:"_"`

Character data

type CharacterTemplate

type CharacterTemplate struct {
	TemplateID int32 `json:"templateId"`

CharacterTemplate ...

type Class

type Class struct {
	ID          string     `json:"id"`
	Name        string     `json:"name"`
	Description string     `json:"description"`
	ArmorType   ArmorType  `json:"armorType"`
	CombatType  CombatType `json:"combatType"`
var (
	ClassWarrior Class = Class{
		ID:          "warrior",
		Name:        "Warrior",
		Description: "Strong plate wearing melee warrior",
		ArmorType:   ArmorTypePlate,
		CombatType:  CombatTypeMelee,
	ClassRanger Class = Class{
		ID:          "ranger",
		Name:        "Ranger",
		Description: "Quick Bow wielding ranged combatant",
		ArmorType:   ArmorTypeLeather,
		CombatType:  CombaTypeRanged,
	ClassWizard Class = Class{
		ID:          "wizard",
		Name:        "Wizard",
		Description: "Master of the elements wielder of magic spells",
		ArmorType:   ArmorTypeCloth,
		CombatType:  CombatTypeMagic,

TODO: Move this to Database or YML files

type CombatType

type CombatType string

type Inventory

type Inventory struct {
	Size  int32         `json:"size"`
	Items []*items.Item `json:"items"`

Inventory data

type Race

type Race struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Heritage    string `json:"heritage"`

Race type

var (
	RaceDwarf Race = Race{
		ID:          "dwarf",
		Name:        "Dwarf",
		Description: "Small, but dont underestimate them",
		Heritage:    "Deep below a Mountain",
	RaceHuman Race = Race{
		ID:          "human",
		Name:        "Human",
		Description: "The common race",
		Heritage:    "Big cities",
	RaceElve Race = Race{
		ID:          "elve",
		Name:        "Elve",
		Description: "Splendid forestwalkers, great sight during nights",
		Heritage:    "Near the forest",

TODO: Move this to DB or YML

Jump to

Keyboard shortcuts

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