object

package
v0.0.0-...-5198b88 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CategoryList []Category

	HuntingKnife = Object{
		Name:     "Hunting knife",
		Category: "Weapon",
		Weight:   200,
		Stats: []ObjectStat{
			{
				Name:     "physicalDamage",
				Modifier: 2,
			},
		},
		CanvasPath: "static/knife.png",
	}

	BluntSword = Object{
		Name:     "Blunt sword",
		Category: "Weapon",
		Weight:   1500,
		Stats: []ObjectStat{
			{
				Name:     "physicalDamage",
				Modifier: 4,
			},
		},
		CanvasPath: "static/sword.png",
	}

	BareHands = Object{
		Name:     "Bare Hands",
		Category: "Weapon",
		Weight:   0,
	}
)

Functions

func CategoryExists

func CategoryExists(categoryName string) bool

CategoryExists checks if the given category exists in the CommonCategories slice.

func GenerateCategories

func GenerateCategories(names, descriptions []string)

GenerateCategories creates all the categories based on the provided names and descriptions.

func InitializeCategories

func InitializeCategories()

InitializeCategories initializes the categories with their names and descriptions.

Types

type Category

type Category struct {
	Name        string // Category name.
	Description string // Description of the category.
}

Category represents a common object category.

type Object

type Object struct {
	Name        string        // Object name.
	Category    string        // Object category.
	Weight      int           // Object weight in grams
	InInventory bool          // Is Object in inventory
	Equipped    bool          // Is Object equipped
	Coord       coord.Coord   // Object position
	Stats       []ObjectStat  // Object stats (e.g., strength, health, etc.).
	CanvasImage *canvas.Image // Object image
	CanvasPath  string        // Image path for Object
}

Object represents an object with its properties.

func CreateObject

func CreateObject(obj Object, coord coord.Coord) (Object, error)

CreateObject creates a copy of the given object and returns it. It also validates the category before creating the object.

func (*Object) Copy

func (subject *Object) Copy() *Object

func (*Object) DrawObject

func (subject *Object) DrawObject(mapContainer *fyne.Container)

DrawObject displays an object's image on the mapContainer.

func (*Object) MoveObject

func (subject *Object) MoveObject(futurePosX, futurePosY int)

MoveObject moves object's coordinates and updates image position on map.

func (*Object) RefreshObject

func (subject *Object) RefreshObject()

RefreshObject allows to refresh Object Image in case it was removed (save/load).

type ObjectStat

type ObjectStat struct {
	Name     string // Stat name, e.g., "Strength", "Health", etc.
	Modifier int    // Modifier value for the stat.
}

ObjectStat represents a specific stat of an object.

func (*ObjectStat) Copy

func (os *ObjectStat) Copy() ObjectStat

Jump to

Keyboard shortcuts

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