node

package
v0.0.0-...-d530cd0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

the node package provides an implemenation of a darwin node

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	// Id is a unique identifier for the node
	Id uuid.UUID `json:"id" yaml:"id"`
	// Name of the node
	Name string `json:"name" yaml:"name"`
	// Description of the node
	Description string `json:"description" yaml:"description"`
	// Title you unlock when you achieve a node
	Title string `json:"title" yaml:"title"`
	// Levels points needed to define each level of the node
	// all levels start at 0
	Levels []int `json:"levels" yaml:"levels"`
	// Unit this a type of the this is useful when displaying info
	// to a user eg.{Current Level: 100 <unit>}
	Unit string `json:"unit" yaml:"unit"`
	// Parents of the node
	Parents     []uuid.UUID `json:"parents"	yaml:"parents"`
	ParentNodes []*Node     `json:"-" yaml:"-"`
	// points are the current points the user has achieved
	Points int `json:"points" yaml:"points"`
	// LastAchieved is the unix timestamp of the last time a level was achieved
	LastAchieved int64 `json:"last_achieved" yaml:"last_achieved"`
	// Starred is a boolean value that represents if the node is starred
	Starred bool `json:"starred" yaml:"starred"`
}

func New

func New(name string, parents []uuid.UUID) *Node

NewNode creates a new node with sane defaults

func (*Node) AddPoints

func (n *Node) AddPoints(points int)

AddPoints adds points to the node and updates the last achieved time

func (*Node) Level

func (n *Node) Level() int

Level returns the current level of the node

func (*Node) NextLevel

func (n *Node) NextLevel() int

NextLevel returns the nextLevel the node could achieve or the max level if the node is already at the max level

func (*Node) Progress

func (n *Node) Progress() float32

Progress returns the a value between 0 and 1 representing the the amount of points achieved towards the next level

Jump to

Keyboard shortcuts

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