maplib

package
v0.0.0-...-4e89139 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

Functions

func GeneratePlaneTowerPositions

func GeneratePlaneTowerPositions(landSize int, count int) []image.Point

func MakeMagicNode

func MakeMagicNode(kind MagicNode, magicSetting data.MagicSetting, difficulty data.DifficultySetting, plane data.Plane) (*ExtraMagicNode, *ExtraEncounter)

Types

type CityProvider

type CityProvider interface {
	ContainsCity(x int, y int, plane data.Plane) bool
}

type Direction

type Direction int
const (
	DirectionNorth Direction = iota
	DirectionNorthEast
	DirectionEast
	DirectionSouthEast
	DirectionSouth
	DirectionSouthWest
	DirectionWest
	DirectionNorthWest
)

type EncounterType

type EncounterType int
const (
	// lair, plane tower, ancient temple, fallen temple, ruins, abandoned keep, dungeon
	EncounterTypeLair EncounterType = iota
	EncounterTypeCave
	EncounterTypePlaneTower
	EncounterTypeAncientTemple
	EncounterTypeFallenTemple
	EncounterTypeRuins
	EncounterTypeAbandonedKeep
	EncounterTypeDungeon
	EncounterTypeChaosNode
	EncounterTypeNatureNode
	EncounterTypeSorceryNode
)

func (EncounterType) Name

func (encounterType EncounterType) Name() string

func (EncounterType) ShortName

func (encounterType EncounterType) ShortName() string

type ExtraBonus

type ExtraBonus struct {
	Bonus data.BonusType
}

wild game, gold ore, mithril, etc

func (*ExtraBonus) DrawLayer1

func (bonus *ExtraBonus) DrawLayer1(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

func (*ExtraBonus) DrawLayer2

func (bonus *ExtraBonus) DrawLayer2(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

type ExtraCorruption

type ExtraCorruption struct {
}

func (*ExtraCorruption) DrawLayer1

func (node *ExtraCorruption) DrawLayer1(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

func (*ExtraCorruption) DrawLayer2

func (node *ExtraCorruption) DrawLayer2(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

type ExtraEncounter

type ExtraEncounter struct {
	Type       EncounterType
	Units      []units.Unit
	Budget     int // used for treasure
	ExploredBy *set.Set[Wizard]
}

lair, plane tower, etc and also the initial enemies on nodes

func (*ExtraEncounter) DrawLayer1

func (extra *ExtraEncounter) DrawLayer1(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

func (*ExtraEncounter) DrawLayer2

func (extra *ExtraEncounter) DrawLayer2(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

type ExtraKind

type ExtraKind int
const (
	ExtraKindRoad ExtraKind = iota
	ExtraKindBonus
	ExtraKindMagicNode
	ExtraKindEncounter
	ExtraKindOpenTower
	ExtraKindVolcano
	ExtraKindCorruption
)

type ExtraMagicNode

type ExtraMagicNode struct {
	Kind MagicNode

	// list of points that are affected by the node
	Zone []image.Point

	// if this node is melded, then this player receives the power
	MeldingWizard Wizard
	// true if melded by a guardian spirit, otherwise false if melded by a magic spirit
	GuardianSpiritMeld bool

	Warped bool
	// the wizard that cast warp node (so it can be dispelled)
	WarpedOwner Wizard
}

func (*ExtraMagicNode) DrawLayer1

func (node *ExtraMagicNode) DrawLayer1(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

func (*ExtraMagicNode) DrawLayer2

func (node *ExtraMagicNode) DrawLayer2(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

func (*ExtraMagicNode) GetPower

func (node *ExtraMagicNode) GetPower(magicBonus float64) float64

func (*ExtraMagicNode) Meld

func (node *ExtraMagicNode) Meld(meldingWizard Wizard, spirit units.Unit) bool

type ExtraOpenTower

type ExtraOpenTower struct {
}

func (*ExtraOpenTower) DrawLayer1

func (extra *ExtraOpenTower) DrawLayer1(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

func (*ExtraOpenTower) DrawLayer2

func (extra *ExtraOpenTower) DrawLayer2(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

type ExtraRoad

type ExtraRoad struct {
	Map *Map
	// either cast Enchant Road, or build the road in Myrror
	Enchanted bool
	X         int
	Y         int
}

func (*ExtraRoad) DrawLayer1

func (road *ExtraRoad) DrawLayer1(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

func (*ExtraRoad) DrawLayer2

func (road *ExtraRoad) DrawLayer2(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

type ExtraTile

type ExtraTile interface {
	DrawLayer1(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)
	DrawLayer2(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)
}

type ExtraVolcano

type ExtraVolcano struct {
	CastingWizard Wizard
}

func (*ExtraVolcano) DrawLayer1

func (node *ExtraVolcano) DrawLayer1(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

func (*ExtraVolcano) DrawLayer2

func (node *ExtraVolcano) DrawLayer2(screen *ebiten.Image, imageCache *util.ImageCache, options *ebiten.DrawImageOptions, counter uint64, tileWidth int, tileHeight int)

type FullTile

type FullTile struct {
	Extras map[ExtraKind]ExtraTile
	Tile   terrain.Tile
	X      int
	Y      int
}

func (*FullTile) Corrupted

func (tile *FullTile) Corrupted() bool

func (*FullTile) FoodBonus

func (tile *FullTile) FoodBonus() fraction.Fraction

func (*FullTile) GetBonus

func (tile *FullTile) GetBonus() data.BonusType

func (*FullTile) GoldBonus

func (tile *FullTile) GoldBonus(mapObject *Map) int

percent bonus increase, 3 = 3%

func (*FullTile) HasEncounter

func (tile *FullTile) HasEncounter() bool

func (*FullTile) IsRiverMouth

func (tile *FullTile) IsRiverMouth(mapObject *Map) bool

func (*FullTile) IsTouchingShore

func (tile *FullTile) IsTouchingShore(mapObject *Map) bool

func (*FullTile) Name

func (tile *FullTile) Name(mapObject *Map) string

func (*FullTile) ProductionBonus

func (tile *FullTile) ProductionBonus(hasGaiasBlessing bool) int

percent bonus increase, 3 = 3%

func (*FullTile) Valid

func (tile *FullTile) Valid() bool

type MagicNode

type MagicNode int
const (
	MagicNodeNature MagicNode = iota
	MagicNodeSorcery
	MagicNodeChaos

	MagicNodeNone
)

func (MagicNode) Name

func (magicNode MagicNode) Name() string

type Map

type Map struct {
	Map *terrain.Map

	Plane data.Plane

	CityProvider CityProvider

	// contains information about map squares that contain extra features on top
	// such as a road, enchantment, encounter place (plane tower, lair, etc)
	ExtraMap map[image.Point]map[ExtraKind]ExtraTile

	Data *terrain.TerrainData

	TileCache map[int]*ebiten.Image
	// contains filtered or unexported fields
}

func MakeMap

func MakeMap(terrainData *terrain.TerrainData, landSize int, magicSetting data.MagicSetting, difficulty data.DifficultySetting, plane data.Plane, cityProvider CityProvider, planeTowers []image.Point) *Map

func (*Map) ContainsRoad

func (mapObject *Map) ContainsRoad(x int, y int) bool

func (*Map) CreateEncounter

func (mapObject *Map) CreateEncounter(x int, y int, encounterType EncounterType, difficulty data.DifficultySetting, weakStrength bool, plane data.Plane) bool

func (*Map) CreateEncounterRandom

func (mapObject *Map) CreateEncounterRandom(x int, y int, difficulty data.DifficultySetting, plane data.Plane) bool

func (*Map) CreateNode

func (mapObject *Map) CreateNode(x int, y int, node MagicNode, plane data.Plane, magicSetting data.MagicSetting, difficulty data.DifficultySetting) *ExtraMagicNode

for testing purposes

func (*Map) DrawLayer1

func (mapObject *Map) DrawLayer1(camera cameralib.Camera, animationCounter uint64, imageCache *util.ImageCache, screen *ebiten.Image, geom ebiten.GeoM)

draw base map tiles, in general stuff that should go under cities/units

func (*Map) DrawLayer2

func (mapObject *Map) DrawLayer2(camera cameralib.Camera, animationCounter uint64, imageCache *util.ImageCache, screen *ebiten.Image, geom ebiten.GeoM)

give the extra nodes a chance to draw on top of cities/units, but still under the fog

func (*Map) DrawMinimap

func (mapObject *Map) DrawMinimap(screen *ebiten.Image, cities []MiniMapCity, centerX int, centerY int, zoom float64, fog data.FogMap, counter uint64, crosshairs bool)

func (*Map) GetBonusTile

func (mapObject *Map) GetBonusTile(x int, y int) data.BonusType

func (*Map) GetCastedVolcanoes

func (mapObject *Map) GetCastedVolcanoes(caster Wizard) []*ExtraVolcano

func (*Map) GetCatchmentArea

func (mapObject *Map) GetCatchmentArea(x int, y int) map[image.Point]FullTile

Returns city catchment area (5x5 square minus the corners)

func (*Map) GetContinentTiles

func (mapObject *Map) GetContinentTiles(x int, y int) []FullTile

get all the tiles that are part of the continent that contains the given x, y

func (*Map) GetEncounter

func (mapObject *Map) GetEncounter(x int, y int) *ExtraEncounter

func (*Map) GetMagicNode

func (mapObject *Map) GetMagicNode(x int, y int) *ExtraMagicNode

func (*Map) GetMeldedNodes

func (mapObject *Map) GetMeldedNodes(melder Wizard) []*ExtraMagicNode

func (*Map) GetRoadNeighbors

func (mapObject *Map) GetRoadNeighbors(x int, y int) map[Direction]bool

returns a map where for each direction, if the value is true then there is a road there

func (*Map) GetSquareAreaAround

func (mapObject *Map) GetSquareAreaAround(x int, y int, radius int) map[image.Point]FullTile

Returns a square with a side of (radius * 2 + 1), and x, y in the center. May be useful for some spells or area effects Radius has to be >= 0

func (*Map) GetTile

func (mapObject *Map) GetTile(tileX int, tileY int) FullTile

func (*Map) GetTileImage

func (mapObject *Map) GetTileImage(tileX int, tileY int, animationCounter uint64, scaler util.Scaler) (*ebiten.Image, error)

func (*Map) HasCorruption

func (mapObject *Map) HasCorruption(x int, y int) bool

func (*Map) HasMagicNode

func (mapObject *Map) HasMagicNode(x int, y int) bool

func (*Map) HasOpenTower

func (mapObject *Map) HasOpenTower(x int, y int) bool

func (*Map) HasVolcano

func (mapObject *Map) HasVolcano(x int, y int) bool

func (*Map) Height

func (mapObject *Map) Height() int

func (*Map) OnShore

func (mapObject *Map) OnShore(x int, y int) bool

func (*Map) RemoveBonus

func (mapObject *Map) RemoveBonus(x int, y int)

func (*Map) RemoveCorruption

func (mapObject *Map) RemoveCorruption(x int, y int)

func (*Map) RemoveEncounter

func (mapObject *Map) RemoveEncounter(x int, y int)

func (*Map) RemoveRoad

func (mapObject *Map) RemoveRoad(x int, y int)

func (*Map) RemoveVolcano

func (mapObject *Map) RemoveVolcano(x int, y int)

func (*Map) ResetCache

func (mapObject *Map) ResetCache()

func (*Map) SetBonus

func (mapObject *Map) SetBonus(x int, y int, bonus data.BonusType)

func (*Map) SetCorruption

func (mapObject *Map) SetCorruption(x int, y int)

func (*Map) SetPlaneTower

func (mapObject *Map) SetPlaneTower(x int, y int)

an open plane tower

func (*Map) SetRoad

func (mapObject *Map) SetRoad(x int, y int, enchanted bool)

func (*Map) SetVolcano

func (mapObject *Map) SetVolcano(x int, y int, caster Wizard)

func (*Map) TileDistance

func (mapObject *Map) TileDistance(x1 int, y1 int, x2 int, y2 int) int

distance in tiles between two points

func (*Map) TileHeight

func (mapObject *Map) TileHeight() int

func (*Map) TileWidth

func (mapObject *Map) TileWidth() int

func (*Map) TilesPerColumn

func (mapObject *Map) TilesPerColumn(screenHeight int) int

func (*Map) TilesPerRow

func (mapObject *Map) TilesPerRow(screenWidth int) int

func (*Map) Width

func (mapObject *Map) Width() int

func (*Map) WrapX

func (mapObject *Map) WrapX(x int) int

func (*Map) XDistance

func (mapObject *Map) XDistance(x1 int, x2 int) int

return the shortest x distance between two points, taking into account the map wrapping result: WrapX(x1 + distance) = x2

type MiniMapCity

type MiniMapCity interface {
	GetX() int
	GetY() int
	GetBanner() data.BannerType
}

type Wizard

type Wizard interface {
	GetBanner() data.BannerType
}

Jump to

Keyboard shortcuts

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