combat

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 (
	ActionAttack  = "Attack"
	ActionItem    = "Item"
	ActionMagic   = "Magic"
	ActionSpecial = "Special"
	ActionFlee    = "Flee"
)

Variables

View Source
var ActorLabels = ActorLabel{
	EquipSlotLabels: []string{
		`Weapon `,
		`Armor `,
		`Accessory 1 `,
		`Accessory 2 `,
	},
	EquipSlotId: []string{
		"Weapon",
		"Armor",
		"Accessory1",
		"Accessory2",
	},
	EquipSlotTypes: map[world.ItemType]string{
		world.Weapon:    "Weapon",
		world.Armor:     "Armor",
		world.Accessory: "Accessory",
	},

	ActorStats: []string{
		"Strength",
		"Speed",
		"Intelligence",
	},
	ItemStats: []string{
		"Attack",
		"Defense",
		"Magic",
		"Resist",
	},
	ActorStatLabels: []string{
		`Strength `,
		`Speed `,
		`Intelligence `,
	},
	ItemStatLabels: []string{
		`Attack `,
		`Defense `,
		`Magic `,
		`Resist `,
	},
	ActionLabels: ActionLabels{
		Attack: "Attack",
		Item:   "Item",
	},
}
View Source
var DragonDef = ActorDef{
	Id:       "dragon",
	IsPlayer: false,
	Stats: world.BaseStats{
		HpNow:    200,
		HpMax:    200,
		MpNow:    0,
		MpMax:    0,
		Strength: 35, Speed: 8, Intelligence: 20,
		Counter: 0.1,
	},
	Name:     "Green Dragon",
	Portrait: "../resources/avatar_hero.png",
	Actions:  []string{ActionAttack},
	Drop: Drop{
		XP:     350,
		Gold:   [2]int{250, 300},
		Always: nil,
		Chance: []DropChanceItem{
			{Oddment: 1, ItemId: -1},
			{Oddment: 3, ItemId: 10},
		},
	},
	StealItem: 11,
}
View Source
var EnemyDefinitions = map[string]ActorDef{
	"goblin": GoblinDef,
	"dragon": DragonDef,
	"ogre":   OgreDef,
}
View Source
var GoblinDef = ActorDef{
	Id:       "goblin",
	IsPlayer: false,
	Stats: world.BaseStats{
		HpNow:    90,
		HpMax:    90,
		MpNow:    0,
		MpMax:    0,
		Strength: 15, Speed: 8, Intelligence: 2,
	},
	Name:     "Goblin",
	Portrait: "../resources/avatar_hero.png",
	Actions:  []string{ActionAttack},
	Drop: Drop{
		XP:     150,
		Gold:   [2]int{5, 15},
		Always: nil,
		Chance: []DropChanceItem{
			{Oddment: 1, ItemId: -1},
			{Oddment: 3, ItemId: 11},
		},
	},
	StealItem: 14,
}
View Source
var HeroDef = ActorDef{
	Id:       "hero",
	IsPlayer: true,
	Stats: world.BaseStats{
		HpNow:    40,
		HpMax:    40,
		MpNow:    8,
		MpMax:    8,
		Level:    0,
		Strength: 10, Speed: 12, Intelligence: 10,
		Counter: 0,
	},
	StatGrowth: map[string]func() int{
		"HpMax":        dice.Create("2d25+25"),
		"MpMax":        dice.Create("1d5+2"),
		"Strength":     world.StatsGrowth.Fast,
		"Speed":        world.StatsGrowth.Fast,
		"Intelligence": world.StatsGrowth.Med,
	},
	ActionGrowth: map[int]map[string][]string{
		5: {
			ActionSpecial: []string{world.SpecialSlash},
		},
	},
	Name:             "Chandragupta",
	Portrait:         "../resources/avatar_hero.png",
	Actions:          []string{ActionAttack, ActionItem, ActionFlee},
	Special:          []string{world.SpecialSlash},
	ActiveEquipSlots: []int{0, 1, 2, 3},
}
View Source
var MageDef = ActorDef{
	Id:       "mage",
	IsPlayer: true,
	Stats: world.BaseStats{
		HpNow:    30,
		HpMax:    30,
		MpNow:    10,
		MpMax:    10,
		Level:    0,
		Strength: 8, Speed: 11, Intelligence: 20,
	},
	StatGrowth: map[string]func() int{
		"HpMax":        dice.Create("2d25+18"),
		"MpMax":        dice.Create("1d5+2"),
		"Strength":     world.StatsGrowth.Med,
		"Speed":        world.StatsGrowth.Med,
		"Intelligence": world.StatsGrowth.Fast,
	},
	ActionGrowth: map[int]map[string][]string{
		1: {
			ActionMagic: []string{world.SpellBolt},
		},
		2: {
			ActionMagic: []string{world.SpellFire, world.SpellIce},
		},
		4: {
			ActionMagic: []string{world.SpellBurn},
		},
	},
	Name:             "Mrignayani",
	Portrait:         "../resources/avatar_mage.png",
	Actions:          []string{ActionAttack, ActionItem, ActionFlee},
	Magic:            []string{world.SpellFire, world.SpellBurn, world.SpellBolt},
	ActiveEquipSlots: []int{0, 1, 2, 3},
}
View Source
var OgreDef = ActorDef{
	Id:       "ogre",
	IsPlayer: false,
	Stats: world.BaseStats{
		HpNow:    150,
		HpMax:    150,
		MpNow:    0,
		MpMax:    0,
		Strength: 20, Speed: 8, Intelligence: 2,
		Counter: 0,
	},
	Name:     "Ogre",
	Portrait: "../resources/avatar_hero.png",
	Actions:  []string{ActionAttack},
	Drop: Drop{
		XP:     250,
		Gold:   [2]int{100, 200},
		Always: nil,
		Chance: []DropChanceItem{
			{Oddment: 1, ItemId: -1},
			{Oddment: 3, ItemId: 10},
		},
	},
	StealItem: 12,
}
View Source
var PartyMembersDefinitions = map[string]ActorDef{
	"hero":  HeroDef,
	"mage":  MageDef,
	"thief": ThiefDef,
}
View Source
var ThiefDef = ActorDef{
	Id:       "thief",
	IsPlayer: true,
	Stats: world.BaseStats{
		HpNow:    35,
		HpMax:    35,
		MpNow:    7,
		MpMax:    7,
		Level:    0,
		Strength: 10, Speed: 13, Intelligence: 10,
	},
	StatGrowth: map[string]func() int{
		"HpMax":        dice.Create("2d25+20"),
		"MpMax":        dice.Create("1d10+5"),
		"Strength":     world.StatsGrowth.Med,
		"Speed":        world.StatsGrowth.Med,
		"Intelligence": world.StatsGrowth.Med,
	},
	ActionGrowth: map[int]map[string][]string{
		2: {
			world.SpecialSteal: []string{ActionSpecial},
		},
	},
	Name:             "Shashank",
	Portrait:         "../resources/avatar_thief.png",
	Actions:          []string{ActionAttack, ActionItem, ActionFlee},
	Special:          []string{world.SpecialSteal},
	ActiveEquipSlots: []int{0, 1, 2, 3},
}

Functions

func NextLevel

func NextLevel(level int) float64

exponent represents the increase of difficulty between levels Disgea Level formula to the first 99 levels.

Types

type ActionLabels

type ActionLabels struct {
	Attack, Item string
}

type Actor

type Actor struct {
	Id, Name   string
	Stats      world.Stats
	StatGrowth map[string]func() int

	PortraitTexture  pixel.Picture
	Portrait         *pixel.Sprite
	Level            int
	XP, NextLevelXP  float64
	Actions          []string
	Magic            []string
	Special          []string
	StealItem        int //Item ID only for Enemy actors
	ActiveEquipSlots []int
	Equipped         map[string]int //int is ItemsDB Id

	Drop ActorDropItem
	// contains filtered or unexported fields
}

Actor is any creature or character that participates in combat and therefore requires stats, equipment, etc

func ActorCreate

func ActorCreate(def ActorDef, randName ...interface{}) Actor

ActorCreate

func (*Actor) AddAction

func (a *Actor) AddAction(actionId string, specials []string)

func (*Actor) AddXP

func (a *Actor) AddXP(xp float64) bool

func (*Actor) ApplyLevel

func (a *Actor) ApplyLevel(levelUp LevelUp)

func (Actor) CanUse

func (a Actor) CanUse(item world.Item) bool

func (Actor) CreateLevelUp

func (a Actor) CreateLevelUp() LevelUp

func (Actor) CreateStatLabelList

func (a Actor) CreateStatLabelList() (statsLabels []string)

func (Actor) CreateStatNameList

func (a Actor) CreateStatNameList() (statsIDs []string)

func (*Actor) Equip

func (a *Actor) Equip(equipSlotId string, item world.Item)

func (Actor) GetEquipSlotIdByItemType

func (a Actor) GetEquipSlotIdByItemType(itemT world.ItemType) string

GetEquipSlotIdByItemType takes in Item Type INT return Type string e.g. Weapon

func (Actor) GetItemTypeBySlotPos

func (a Actor) GetItemTypeBySlotPos(slot int) world.ItemType

func (Actor) IsKOed

func (a Actor) IsKOed() bool

has Knocked Out?

func (*Actor) IsPlayer

func (a *Actor) IsPlayer() bool

IsPlayer tell's if Actor is player controlled e.g. Hero, Mage, ..

func (*Actor) KO

func (a *Actor) KO()

Knock Out

func (Actor) PredictStats

func (a Actor) PredictStats(equipSlotId string, item world.Item) map[string]float64

PredictStats compare Equipped Item Stats with given Item returns -> BaseStats after comparison

func (Actor) ReadyToLevelUp

func (a Actor) ReadyToLevelUp() bool

func (*Actor) RenderEquipment

func (a *Actor) RenderEquipment(args ...interface{})

func (*Actor) UnEquip

func (a *Actor) UnEquip(equipSlotId string)

func (*Actor) UnlockMenuAction

func (a *Actor) UnlockMenuAction(actionId string)

type ActorDef

type ActorDef struct {
	Id               string //must match entityDef
	Stats            world.BaseStats
	StatGrowth       map[string]func() int
	Level            int
	ActionGrowth     map[int]map[string][]string //Level -> {Action : [special, special]}
	Portrait         string
	Name             string
	Actions          []string
	Magic            []string
	Special          []string
	StealItem        int //Item ID only for Enemy actors
	ActiveEquipSlots []int
	IsPlayer         bool
	Equipment
	Drop
}

type ActorDropItem

type ActorDropItem struct {
	XP     float64
	Gold   float64
	Always []int //ActionItem ids that are guaranteed to drop
	Chance *OddmentTable
}

type ActorLabel

type ActorLabel struct {
	EquipSlotLabels []string
	EquipSlotId     []string
	ActorStats      []string
	ItemStats       []string
	ActorStatLabels []string
	ItemStatLabels  []string
	ActionLabels    ActionLabels
	EquipSlotTypes  map[world.ItemType]string
}

type ActorSummary

type ActorSummary struct {
	X, Y, Width  float64
	Actor        Actor
	HPBar, MPBar gui.ProgressBarIMD
	XPBar        gui.ProgressBar
	ShowXP       bool
	AvatarTextPadding,
	LabelRightPadding,
	LabelValuePadding,
	VerticalPadding,
	TextPaddingY float64
}

func ActorSummaryCreate

func ActorSummaryCreate(actor Actor, showXP bool) ActorSummary

func (ActorSummary) GetCursorPosition

func (s ActorSummary) GetCursorPosition() pixel.Vec

func (*ActorSummary) HideXP

func (s *ActorSummary) HideXP()

func (*ActorSummary) Render

func (s *ActorSummary) Render(renderer pixel.Target)

func (*ActorSummary) SetPosition

func (s *ActorSummary) SetPosition(x, y float64)

SetPosition

type ActorXPSummary

type ActorXPSummary struct {
	Actor                     *Actor
	X, Y                      float64
	Avatar                    *pixel.Sprite
	AvatarWidth, AvatarHeight float64
	Layout                    gui.Layout
	LayoutId                  string
	XPBar                     gui.ProgressBarIMD
	PopUpList                 []*gui.XPPopUp
	PopUpDisplayTime          float64
}

func ActorXPSummaryCreate

func ActorXPSummaryCreate(actor *Actor, layout gui.Layout, layoutId string) *ActorXPSummary

func (*ActorXPSummary) AddPopUp

func (a *ActorXPSummary) AddPopUp(text, hexColor string)

func (*ActorXPSummary) CancelPopUp

func (a *ActorXPSummary) CancelPopUp()

func (ActorXPSummary) PopUpCount

func (a ActorXPSummary) PopUpCount() int

func (*ActorXPSummary) Render

func (a *ActorXPSummary) Render(renderer pixel.Target)

func (*ActorXPSummary) SetPosition

func (a *ActorXPSummary) SetPosition(x, y float64)

func (*ActorXPSummary) Update

func (a *ActorXPSummary) Update(dt float64)

type Drop

type Drop struct {
	XP     float64
	Gold   [2]int //range min, max
	Always []int  //item ids that are guaranteed to drop
	Chance []DropChanceItem
}

type DropChanceItem

type DropChanceItem struct {
	Oddment float64
	ItemId  int //item ID
}

type Equipment

type Equipment struct {
	Weapon,
	Armor,
	Access1,
	Access2 int //ItemsDB.Id
}

Must match to ItemsDB ID

type LevelUp

type LevelUp struct {
	XP        float64
	Level     int
	BaseStats map[string]float64
	Actions   map[string][]string
}

type OddmentTable

type OddmentTable struct {
	Items   []DropChanceItem
	Oddment float64
}

func OddmentTableCreate

func OddmentTableCreate(items []DropChanceItem) *OddmentTable

func (OddmentTable) CalcOddment

func (o OddmentTable) CalcOddment() (total float64)

func (OddmentTable) Pick

func (o OddmentTable) Pick() world.ItemIndex

type Party

type Party struct {
	Members map[string]*Actor
	World   *WorldExtended
}

func PartyCreate

func PartyCreate(w *WorldExtended) *Party

func (*Party) Add

func (p *Party) Add(member Actor)

func (*Party) Remove

func (p *Party) Remove(member Actor)

func (Party) ToArray

func (p Party) ToArray() []*Actor

type WorldExtended

type WorldExtended struct {
	world.World
	Party *Party
}

func WorldExtendedCreate

func WorldExtendedCreate() *WorldExtended

Jump to

Keyboard shortcuts

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