player

package
v0.0.0-...-e988257 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AIBehavior

type AIBehavior interface {
	// return a list of decisions to make for the current turn
	Update(*Player, []*Player, AIServices, int) []AIDecision

	// called after all decisions have been processed for an AI player
	PostUpdate(*Player, []*Player)

	// reset any state that needs to be reset at the start of a new turn
	NewTurn(*Player)

	// called when a new unit is produced in the city
	ProducedUnit(*citylib.City, *Player)

	// true to raze, false to occupy
	ConfirmRazeTown(*citylib.City) bool
}

type AIBuildOutpostDecision

type AIBuildOutpostDecision struct {
	Stack *UnitStack
}

type AICastSpellDecision

type AICastSpellDecision struct {
	Spell spellbook.Spell
}

type AICreateUnitDecision

type AICreateUnitDecision struct {
	Unit  units.Unit
	X     int
	Y     int
	Plane data.Plane
}

type AIDecision

type AIDecision interface {
}

type AIMoveStackDecision

type AIMoveStackDecision struct {
	Stack            *UnitStack
	Location         image.Point
	Invalid          func()
	ConfirmEncounter func(*maplib.ExtraEncounter) bool
}

type AIProduceDecision

type AIProduceDecision struct {
	City     *citylib.City
	Building buildinglib.Building
	Unit     units.Unit
}

type AIResearchSpellDecision

type AIResearchSpellDecision struct {
	Spell spellbook.Spell
}

choose a new spell to research

type AIServices

type AIServices interface {
	FindPath(oldX int, oldY int, newX int, newY int, player *Player, stack *UnitStack, fog data.FogMap) pathfinding.Path
	FindSettlableLocations(x int, y int, plane data.Plane, fog data.FogMap) []image.Point
	IsSettlableLocation(x int, y int, plane data.Plane) bool
}

type ActiveMap

type ActiveMap map[units.StackUnit]bool

type CityEnchantment

type CityEnchantment struct {
	City        *citylib.City
	Enchantment citylib.Enchantment
}

type CityEnchantmentsProvider

type CityEnchantmentsProvider interface {
	GetCityEnchantmentsByBanner(banner data.BannerType) []CityEnchantment
}

type Player

type Player struct {
	// matrix the same size as the map containg information if the tile is explored,
	// unexplored or in the range of sight
	ArcanusFog data.FogMap
	MyrrorFog  data.FogMap

	TaxRate fraction.Fraction

	Gold int
	Mana int

	Human    bool
	Defeated bool

	// Fame (without just cause and/or heroes)
	Fame int

	// used to seed the random number generator for generating the order of how magic books are drawn
	BookOrderSeed1 uint64
	BookOrderSeed2 uint64

	// if true, the game will only do strategic (non-graphics/non-realtime) based combat if both sides are strategic
	StrategicCombat bool
	// godmode that lets the player interact with enemy cities/units
	Admin bool

	// true if the wizard is currently banished
	Banished bool

	// known spells
	KnownSpells spellbook.Spells

	// the full set of spells that can be known by the wizard
	ResearchPoolSpells spellbook.Spells

	// spells that can be researched
	ResearchCandidateSpells spellbook.Spells

	GlobalEnchantments *set.Set[data.Enchantment]

	PowerDistribution PowerDistribution

	AIBehavior AIBehavior

	// relations with other players (treaties, etc)
	PlayerRelations map[*Player]*Relationship

	// possible heros that can be employed. some heroes might be dead
	HeroPool map[herolib.HeroType]*herolib.Hero

	// currently employed heroes
	Heroes [6]*herolib.Hero

	VaultEquipment [4]*artifact.Artifact

	// total power points put into the casting skill
	CastingSkillPower int
	// how much casting skill remains in this turn
	RemainingCastingSkill int

	ResearchingSpell spellbook.Spell
	ResearchProgress int

	// current spell being cast
	CastingSpell spellbook.Spell
	// how much mana has been put towards the current spell. When this value equals
	// the spell's casting cost, the spell is cast
	CastingSpellProgress int

	// the artifact currently being created by a spell cast of Create Artifact or Enchant Item
	CreateArtifact *artifact.Artifact

	Wizard setup.WizardCustom

	// FIXME: probably remove Units and just use Stacks to track the units
	Units []units.StackUnit

	Stacks []*UnitStack
	Cities []*citylib.City

	// counter for the next created unit owned by this player
	UnitId        uint64
	SelectedStack *UnitStack
}

func MakePlayer

func MakePlayer(wizard setup.WizardCustom, human bool, mapWidth int, mapHeight int, heroNames map[herolib.HeroType]string) *Player

func (*Player) AddCity

func (player *Player) AddCity(city *citylib.City) *citylib.City

func (*Player) AddHero

func (player *Player) AddHero(hero *herolib.Hero) bool

returns true if the hero was actually added to the player

func (*Player) AddStack

func (player *Player) AddStack(stack *UnitStack) *UnitStack

func (*Player) AddUnit

func (player *Player) AddUnit(unit units.StackUnit) units.StackUnit

func (*Player) AliveHeroes

func (player *Player) AliveHeroes() []*herolib.Hero

func (*Player) AllianceWithPlayer

func (player *Player) AllianceWithPlayer(other *Player)

func (*Player) AwarePlayer

func (player *Player) AwarePlayer(other *Player)

this player should now be aware of the other player

func (*Player) CastingSkillPerTurn

func (player *Player) CastingSkillPerTurn(power int) int

func (*Player) ComputeCastingSkill

func (player *Player) ComputeCastingSkill() int

func (*Player) ComputePlunderedGold

func (player *Player) ComputePlunderedGold(city *citylib.City) int

how much gold is stored in this city relative to the player's overall wealth

func (*Player) ExploreFogSquare

func (player *Player) ExploreFogSquare(x int, y int, squares int, plane data.Plane)

Doesn't provide direct visibility, whilst making the tiles explored.

func (*Player) FindAllStacks

func (player *Player) FindAllStacks(x int, y int, plane data.Plane) []*UnitStack

multiple stacks can be on the same tile

func (*Player) FindCity

func (player *Player) FindCity(x int, y int, plane data.Plane) *citylib.City

func (*Player) FindFortressCity

func (player *Player) FindFortressCity() *citylib.City

return the city that contains the summoning circle

func (*Player) FindStack

func (player *Player) FindStack(x int, y int, plane data.Plane) *UnitStack

func (*Player) FindStackByUnit

func (player *Player) FindStackByUnit(unit units.StackUnit) *UnitStack

func (*Player) FindSummoningCity

func (player *Player) FindSummoningCity() *citylib.City

return the city that contains the summoning circle

func (*Player) FoodPerTurn

func (player *Player) FoodPerTurn() int

func (*Player) GetBanner

func (player *Player) GetBanner() data.BannerType

func (*Player) GetFame

func (player *Player) GetFame() int

func (*Player) GetFog

func (player *Player) GetFog(plane data.Plane) data.FogMap

func (*Player) GetGlobalEnchantments

func (player *Player) GetGlobalEnchantments() *set.Set[data.Enchantment]

func (*Player) GetKnownPlayers

func (player *Player) GetKnownPlayers() []*Player

func (*Player) GetRulingRace

func (player *Player) GetRulingRace() data.Race

func (*Player) GetTaxRate

func (player *Player) GetTaxRate() fraction.Fraction

func (*Player) GetUnits

func (player *Player) GetUnits(x int, y int, plane data.Plane) []units.StackUnit

func (*Player) GoldPerTurn

func (player *Player) GoldPerTurn() int

func (*Player) HasDeathBooks

func (player *Player) HasDeathBooks() bool

func (*Player) HasDivinePower

func (player *Player) HasDivinePower() bool

func (*Player) HasInfernalPower

func (player *Player) HasInfernalPower() bool

func (*Player) HasLifeBooks

func (player *Player) HasLifeBooks() bool

func (*Player) IsAI

func (player *Player) IsAI() bool

func (*Player) IsHuman

func (player *Player) IsHuman() bool

func (*Player) IsTileExplored

func (player *Player) IsTileExplored(x int, y int, plane data.Plane) bool

func (*Player) IsVisible

func (player *Player) IsVisible(x int, y int, plane data.Plane) bool

func (*Player) LearnSpell

func (player *Player) LearnSpell(spell spellbook.Spell)

func (*Player) LiftFog

func (player *Player) LiftFog(x int, y int, radius int, plane data.Plane)

make anything within the given radius viewable by the player

func (*Player) LiftFogAll

func (player *Player) LiftFogAll(plane data.Plane)

func (*Player) LiftFogSquare

func (player *Player) LiftFogSquare(x int, y int, squares int, plane data.Plane)

func (*Player) MakeExperienceInfo

func (player *Player) MakeExperienceInfo() units.ExperienceInfo

func (*Player) ManaPerTurn

func (player *Player) ManaPerTurn(power int, cityEnchantmentsProvider CityEnchantmentsProvider) int

func (*Player) MergeStacks

func (player *Player) MergeStacks(stack1 *UnitStack, stack2 *UnitStack) *UnitStack

func (*Player) OwnsCity

func (player *Player) OwnsCity(city *citylib.City) bool

func (*Player) OwnsStack

func (player *Player) OwnsStack(stack *UnitStack) bool

func (*Player) PactWithPlayer

func (player *Player) PactWithPlayer(other *Player)

func (*Player) RemoveCity

func (player *Player) RemoveCity(city *citylib.City)

func (*Player) RemoveUnit

func (player *Player) RemoveUnit(unit units.StackUnit)

func (*Player) SetSelectedStack

func (player *Player) SetSelectedStack(stack *UnitStack)

func (*Player) SpellResearchPerTurn

func (player *Player) SpellResearchPerTurn(power int) float64

func (*Player) SplitActiveStack

func (player *Player) SplitActiveStack(stack *UnitStack) *UnitStack

func (*Player) TotalBooks

func (player *Player) TotalBooks() int

func (*Player) TotalEnchantmentUpkeep

func (player *Player) TotalEnchantmentUpkeep(cityEnchantmentsProvider CityEnchantmentsProvider) int

func (*Player) TotalUnitUpkeepFood

func (player *Player) TotalUnitUpkeepFood() int

func (*Player) TotalUnitUpkeepGold

func (player *Player) TotalUnitUpkeepGold() int

func (*Player) TotalUnitUpkeepMana

func (player *Player) TotalUnitUpkeepMana() int

func (*Player) UpdateFogVisibility

func (player *Player) UpdateFogVisibility()

func (*Player) UpdateResearchCandidates

func (player *Player) UpdateResearchCandidates()

fill up the research candidate spells so that there are at most 8. * choose spells from the research pool that are not already known, but preferring * lower rarity spells first.

func (*Player) UpdateTaxRate

func (player *Player) UpdateTaxRate(rate fraction.Fraction)

func (*Player) WarWithPlayer

func (player *Player) WarWithPlayer(other *Player)

func (*Player) WrapX

func (player *Player) WrapX(x int) int

type PowerDistribution

type PowerDistribution struct {
	Mana     float64
	Research float64
	Skill    float64
}

in the magic screen, power is distributed across the 3 categories

type Relationship

type Relationship struct {
	Treaty data.TreatyType
}

type UnitStack

type UnitStack struct {
	CurrentPath pathfinding.Path
	// contains filtered or unexported fields
}

func MakeUnitStack

func MakeUnitStack() *UnitStack

func MakeUnitStackFromUnits

func MakeUnitStackFromUnits(units []units.StackUnit) *UnitStack

func (*UnitStack) ActiveUnits

func (stack *UnitStack) ActiveUnits() []units.StackUnit

func (*UnitStack) ActiveUnitsDoesntHaveAbility

func (stack *UnitStack) ActiveUnitsDoesntHaveAbility(ability data.AbilityType) bool

returns true if none of the active units in the stack have the given ability if a single unit has the ability then return false

func (*UnitStack) ActiveUnitsHasAbility

func (stack *UnitStack) ActiveUnitsHasAbility(ability data.AbilityType) bool

returns true if any of the active units in the stack have the given ability

func (*UnitStack) ActiveUnitsHasEnchantment

func (stack *UnitStack) ActiveUnitsHasEnchantment(ability data.UnitEnchantment) bool

func (*UnitStack) AddUnit

func (stack *UnitStack) AddUnit(unit units.StackUnit)

func (*UnitStack) AllActive

func (stack *UnitStack) AllActive() bool

func (*UnitStack) AllFlyers

func (stack *UnitStack) AllFlyers() bool

func (*UnitStack) AllLandWalkers

func (stack *UnitStack) AllLandWalkers() bool

true if every active unit can only walk on land

func (*UnitStack) AllSwimmers

func (stack *UnitStack) AllSwimmers() bool

func (*UnitStack) AnyOutOfMoves

func (stack *UnitStack) AnyOutOfMoves() bool

func (*UnitStack) ContainsUnit

func (stack *UnitStack) ContainsUnit(unit units.StackUnit) bool

func (*UnitStack) EnableMovers

func (stack *UnitStack) EnableMovers()

func (*UnitStack) ExhaustMoves

func (stack *UnitStack) ExhaustMoves()

func (*UnitStack) GetBanner

func (stack *UnitStack) GetBanner() data.BannerType

func (*UnitStack) GetRemainingMoves

func (stack *UnitStack) GetRemainingMoves() fraction.Fraction

func (*UnitStack) GetSightRange

func (stack *UnitStack) GetSightRange() int

func (*UnitStack) HasHero

func (stack *UnitStack) HasHero() bool

func (*UnitStack) HasMoves

func (stack *UnitStack) HasMoves() bool

true if any unit in the stack has moves left

func (*UnitStack) HasPathfinding

func (stack *UnitStack) HasPathfinding() bool

func (*UnitStack) HasSailingUnits

func (stack *UnitStack) HasSailingUnits(onlyActive bool) bool

pass in true to only check active units

func (*UnitStack) InactiveUnits

func (stack *UnitStack) InactiveUnits() []units.StackUnit

func (*UnitStack) IsActive

func (stack *UnitStack) IsActive(unit units.StackUnit) bool

func (*UnitStack) IsEmpty

func (stack *UnitStack) IsEmpty() bool

func (*UnitStack) Leader

func (stack *UnitStack) Leader() units.StackUnit

func (*UnitStack) Move

func (stack *UnitStack) Move(dx int, dy int, cost fraction.Fraction, normalize units.NormalizeCoordinateFunc)

func (*UnitStack) NaturalHeal

func (stack *UnitStack) NaturalHeal(rate float64)

func (*UnitStack) OffsetX

func (stack *UnitStack) OffsetX() float64

func (*UnitStack) OffsetY

func (stack *UnitStack) OffsetY() float64

func (*UnitStack) OutOfMoves

func (stack *UnitStack) OutOfMoves() bool

true if no unit has any moves left

func (*UnitStack) Plane

func (stack *UnitStack) Plane() data.Plane

func (*UnitStack) RemoveUnit

func (stack *UnitStack) RemoveUnit(unit units.StackUnit)

func (*UnitStack) RemoveUnits

func (stack *UnitStack) RemoveUnits(units []units.StackUnit)

func (*UnitStack) ResetMoves

func (stack *UnitStack) ResetMoves()

func (*UnitStack) SetOffset

func (stack *UnitStack) SetOffset(x float64, y float64)

func (*UnitStack) SetPlane

func (stack *UnitStack) SetPlane(plane data.Plane)

func (*UnitStack) SetX

func (stack *UnitStack) SetX(x int)

func (*UnitStack) SetY

func (stack *UnitStack) SetY(y int)

func (*UnitStack) SplitActiveUnits

func (stack *UnitStack) SplitActiveUnits() *UnitStack

return a new stack that only contains the active units this might return the same stack if all units are active

func (*UnitStack) ToggleActive

func (stack *UnitStack) ToggleActive(unit units.StackUnit)

func (*UnitStack) Units

func (stack *UnitStack) Units() []units.StackUnit

func (*UnitStack) X

func (stack *UnitStack) X() int

func (*UnitStack) Y

func (stack *UnitStack) Y() int

Jump to

Keyboard shortcuts

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