world

package
v0.0.0-...-54c8723 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Any               = "Any"
	MostHurtParty     = "MostHurtParty"    //lowest HP that is below their max HP value.
	MostDrainedParty  = "MostDrainedParty" //lowest MP
	MostHurtEnemy     = "MostHurtEnemy"
	DeadParty         = "DeadParty"
	RandomAlivePlayer = "RandomAlivePlayer"
	WeakestEnemy      = "WeakestEnemy"
	SideEnemy         = "SideEnemy"
	SelectAll         = "SelectAll"
)

below should match to Key of Co

View Source
const (
	SpecialSlash = "Slash"
	SpecialSteal = "Steal"
)
View Source
const (
	SpellFire = "Fire"
	SpellBurn = "Burn"
	SpellIce  = "Ice"
	SpellBolt = "Bolt"
)

Variables

View Source
var ItemsDB = make(map[int]Item)
View Source
var SpecialsDB = map[string]SpecialItem{
	SpecialSlash: {
		Name:       "Slash",
		MpCost:     15,
		Action:     ElementSlash,
		TimePoints: 10,
		Target: ItemTarget{
			Selector:    SideEnemy,
			SwitchSides: false,
			Type:        CombatTargetTypeSIDE,
		},
	},

	SpecialSteal: {
		Name:       "Steal",
		MpCost:     0,
		Action:     ElementSteal,
		TimePoints: 10,
		Target: ItemTarget{
			Selector:    WeakestEnemy,
			SwitchSides: false,
			Type:        CombatTargetTypeONE,
		},
	},
}
View Source
var SpellsDB = map[string]SpecialItem{
	SpellFire: {
		Name:          "Fire",
		Action:        ElementSpell,
		Element:       SpellFire,
		MpCost:        8,
		CastTime:      0.7,
		BaseDamage:    [2]float64{3, 5},
		BaseHitChance: 1,
		TimePoints:    10,
		Target: ItemTarget{
			Selector:    WeakestEnemy,
			SwitchSides: true,
			Type:        CombatTargetTypeONE,
		},
	},
	SpellBurn: {
		Name:          "Burn",
		Action:        ElementSpell,
		Element:       SpellFire,
		MpCost:        16,
		CastTime:      0.9,
		BaseDamage:    [2]float64{3, 6},
		BaseHitChance: 1,
		TimePoints:    20,
		Target: ItemTarget{
			Selector:    SideEnemy,
			SwitchSides: true,
			Type:        CombatTargetTypeSIDE,
		},
	},

	SpellIce: {
		Name:          "Ice",
		Action:        ElementSpell,
		Element:       SpellIce,
		MpCost:        8,
		CastTime:      1,
		BaseDamage:    [2]float64{7, 17},
		BaseHitChance: 1,
		TimePoints:    10,
		Target: ItemTarget{
			Selector:    WeakestEnemy,
			SwitchSides: true,
			Type:        CombatTargetTypeONE,
		},
	},

	SpellBolt: {
		Name:          "Electric bolt",
		Action:        ElementSpell,
		Element:       SpellBolt,
		MpCost:        8,
		CastTime:      0.5,
		BaseDamage:    [2]float64{4, 14},
		BaseHitChance: 1,
		TimePoints:    10,
		Target: ItemTarget{
			Selector:    WeakestEnemy,
			SwitchSides: true,
			Type:        CombatTargetTypeONE,
		},
	},
}

spell cast time 1 is base, 2 is twice as long etc

View Source
var StatsGrowth = StatsGrowthT{
	Fast: dice.Create("3d2"),
	Med:  dice.Create("1d3"),
	Slow: dice.Create("1d2"),
}

Functions

This section is empty.

Types

type Action

type Action int
const (
	Revive Action = iota
	HpRestore
	MpRestore
	ElementSpell
	ElementSlash
	ElementSteal
)

type BaseStats

type BaseStats struct {
	HpNow, HpMax                   float64
	MpNow, MpMax                   float64
	Strength, Speed, Intelligence  float64 //ActorStats
	Attack, Defense, Magic, Resist float64 //ItemStats
	Counter, Fire, Burn, Ice, Bolt float64 //Magic
	Level                          float64
}

type CombatTargetType

type CombatTargetType int
const (
	CombatTargetTypeONE CombatTargetType = iota
	CombatTargetTypeSIDE
	CombatTargetTypeALL
)

type IconDefs

type IconDefs struct {
	Usable,
	Accessory,
	Weapon,
	Sword,
	Dagger,
	Stave,
	Armor,
	Plate,
	Leather,
	Robe,
	UpArrow,
	DownArrow int
}

type Icons

type Icons struct {
	Texture  pixel.Picture
	UVs      []pixel.Rect
	Sprites  []*pixel.Sprite
	IconDefs IconDefs
}
var IconsDB Icons

func IconsCreate

func IconsCreate() Icons

func (Icons) Get

func (i Icons) Get(d int) *pixel.Sprite

Get accepts Item.Icon int e.g. 3

type Item

type Item struct {
	Id                int
	ItemType          ItemType
	Name, Description string
	Special           bool
	Stats             Mod
	Restrictions      []string //e.g. {"hero","mage",}
	Use               UseAction
	Icon              int
	Oddment           float64 //chances of finding
}

• Key Item - a special item, usually required to progress past a certain part of the game. • Weapon - an item that can be equipped and has properties related to inflicting damage.

type ItemIndex

type ItemIndex struct {
	Id, Count int
}

type ItemTarget

type ItemTarget struct {
	Selector    string
	SwitchSides bool
	Type        CombatTargetType
}

type ItemType

type ItemType int
const (
	Empty ItemType = iota
	Usable
	Accessory
	Weapon
	Sword
	Dagger
	Stave
	Armor
	Plate
	Leather
	Robe
	UpArrow
	DownArrow
)

type Mod

type Mod struct {
	Add  BaseStats
	Mult BaseStats
}

type Modifier

type Modifier struct {
	Name     string
	UniqueId int
	Mod      Mod
}

type SpecialItem

type SpecialItem struct {
	Name    string
	Action  Action
	Element string
	MpCost,
	CastTime,
	BaseHitChance,
	TimePoints float64
	BaseDamage [2]float64 // multiplied by level
	Target     ItemTarget
	Counter    bool
}

SpecialItem Damage = Spell Power * 4 + (Level * Magic Power * Spell Power / 32)

type Stats

type Stats struct {
	Base      map[string]float64
	Modifiers map[int]Mod
}

func StatsCreate

func StatsCreate(stats BaseStats) Stats

func (*Stats) AddModifier

func (s *Stats) AddModifier(uniqueId int, modifier Mod)

AddModifier

magic_sword := Modifier{
		UniqueId: 1,
		Mod: Mod{
			Add:  BaseStats{
				Strength: 5,
				Speed: 5,
			},
		},
	}

func (Stats) Get

func (s Stats) Get(id string) float64

Get id = BaseStats.KEY e.g. Get("Strength")

func (Stats) GetBaseStat

func (s Stats) GetBaseStat(id string) float64

func (*Stats) RemoveModifier

func (s *Stats) RemoveModifier(uniqueId int)

func (*Stats) Set

func (s *Stats) Set(baseStatId string, val float64)

Set e.g. Set("HpNow", 50) In combat, the HpNow and MpNow stats often change

type StatsGrowthT

type StatsGrowthT struct {
	Fast func() int
	Med  func() int
	Slow func() int
}

type UseAction

type UseAction struct {
	Action  Action
	Restore float64
	Target  ItemTarget
	Hint    string
}

type World

type World struct {
	Time, Gold      float64
	Items, KeyItems []ItemIndex
	//Party check world_extended.go
	Icons Icons
}

func Create

func Create() *World

func (*World) AddItem

func (w *World) AddItem(itemId, count int)

func (*World) AddKeyItem

func (w *World) AddKeyItem(itemId int)

func (World) DrawItem

func (w World) DrawItem(a ...interface{})

func (*World) FilterItems

func (w *World) FilterItems(predicate ItemType) []ItemIndex

func (*World) Get

func (w *World) Get(idx ItemIndex) Item

func (World) GetItemsAsStrings

func (w World) GetItemsAsStrings() []string

func (World) GetKeyItemsAsStrings

func (w World) GetKeyItemsAsStrings() []string

func (World) GoldAsString

func (w World) GoldAsString() string

func (*World) HasKey

func (w *World) HasKey(id int) bool

func (*World) RemoveItem

func (w *World) RemoveItem(itemId, count int)

func (*World) RemoveKeyItem

func (w *World) RemoveKeyItem(itemId int)

func (World) TimeAsString

func (w World) TimeAsString() string

func (*World) Update

func (w *World) Update(dt float64)

Jump to

Keyboard shortcuts

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