rpg

package
v0.0.0-...-07010e4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MagicMissile = "Magic Missile"
	Drain        = "Drain"
	Shield       = "Shield"
	Poison       = "Poison"
	Recharge     = "Recharge"
)

Variables

View Source
var Effects = []Effect{
	{
		Name:  "Magic Missile",
		Cost:  53,
		Timer: 0,
		OnAttack: func(w *Wizard, c *Character) {
			c.HitPoints -= 4
		},
		OnDefend: func(w *Wizard, c *Character) {},
	},
	{
		Name:  "Drain",
		Cost:  73,
		Timer: 0,
		OnAttack: func(w *Wizard, c *Character) {
			c.HitPoints -= 2
			w.HitPoints += 2
		},
		OnDefend: func(w *Wizard, c *Character) {},
	},
	{
		Name:     "Shield",
		Cost:     113,
		Timer:    6,
		OnAttack: func(w *Wizard, c *Character) {},
		OnDefend: func(w *Wizard, c *Character) {
			w.Armor = 7
		},
	},
	{
		Name:  "Poison",
		Cost:  173,
		Timer: 6,
		OnAttack: func(w *Wizard, c *Character) {
			c.HitPoints -= 3
		},
		OnDefend: func(w *Wizard, c *Character) {
			c.HitPoints -= 3
		},
	},
	{
		Name:  "Recharge",
		Cost:  229,
		Timer: 5,
		OnAttack: func(w *Wizard, c *Character) {
			w.Mana += 101
		},
		OnDefend: func(w *Wizard, c *Character) {
			w.Mana += 101
		},
	},
}

Functions

This section is empty.

Types

type ArmorItems

type ArmorItems struct {
	Armor    *Item
	RingPair RingPair
}

func (ArmorItems) Cost

func (ais ArmorItems) Cost() int

func (ArmorItems) Items

func (ais ArmorItems) Items() []*Item

type Character

type Character struct {
	Name      string
	Damage    int
	Armor     int
	HitPoints int
}

func NewCharacter

func NewCharacter(name string, damage, armor, hitPoints int) *Character

func (*Character) Attack

func (c *Character) Attack(oc *Character)

func (Character) String

func (c Character) String() string

type Effect

type Effect struct {
	Name     string
	Cost     int
	Timer    int
	OnAttack func(w *Wizard, c *Character)
	OnDefend func(w *Wizard, c *Character)
}

func Cast

func Cast(spell string) (*Effect, error)

type Item

type Item struct {
	Name   string
	Cost   int
	Damage int
	Armor  int
}

func NewItem

func NewItem(name string, cost, damage, armor int) *Item

type RingPair

type RingPair struct {
	R1 *Item
	R2 *Item
}

func (RingPair) Cost

func (rp RingPair) Cost() int

func (RingPair) Items

func (rp RingPair) Items() []*Item

func (RingPair) NumRings

func (rp RingPair) NumRings() int

type Store

type Store struct {
	Weapons     map[string]*Item
	Armor       map[string]*Item
	DamageRings map[string]*Item
	ArmorRings  map[string]*Item
}

func NewStore

func NewStore() *Store

func (*Store) AddArmor

func (s *Store) AddArmor(i *Item)

func (*Store) AddArmorRing

func (s *Store) AddArmorRing(i *Item)

func (*Store) AddDamageRing

func (s *Store) AddDamageRing(i *Item)

func (*Store) AddWeapon

func (s *Store) AddWeapon(i *Item)

func (*Store) CheckCheapest

func (s *Store) CheckCheapest(dam int, arm int)

func (*Store) CheckExpenciest

func (s *Store) CheckExpenciest(dam int, arm int)

type Wizard

type Wizard struct {
	Armor         int
	Mana          int
	HitPoints     int
	ActiveEffects map[string]*Effect
}

func NewWizard

func NewWizard(mana int, hitPoints int) *Wizard

func (*Wizard) ApplyAttackEffects

func (w *Wizard) ApplyAttackEffects(c *Character)

func (*Wizard) ApplyDefendEffects

func (w *Wizard) ApplyDefendEffects(c *Character)

func (*Wizard) Attack

func (w *Wizard) Attack(spell string, c *Character)

func (*Wizard) AvailableSpells

func (w *Wizard) AvailableSpells() []string

func (*Wizard) CheapestAvailableSpell

func (w *Wizard) CheapestAvailableSpell() string

func (*Wizard) Defend

func (w *Wizard) Defend(c *Character)

func (*Wizard) DumpActiveEffects

func (w *Wizard) DumpActiveEffects() []string

func (*Wizard) IsActive

func (w *Wizard) IsActive(ef string) bool

func (*Wizard) IsAvailable

func (w *Wizard) IsAvailable(spell string) bool

func (*Wizard) NecessarySpell

func (w *Wizard) NecessarySpell(c *Character) string

Jump to

Keyboard shortcuts

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