city

package
v0.0.0-...-64ed9ee Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const MAX_CITY_CITIZENS = 25

Variables

This section is empty.

Functions

func ReadCityNames

func ReadCityNames(cache *lbx.LbxCache) ([]string, error)

Types

type CatchmentProvider

type CatchmentProvider interface {
	GetCatchmentArea(x int, y int) map[image.Point]maplib.FullTile
	OnShore(x int, y int) bool
	TileDistance(x1 int, y1 int, x2 int, y2 int) int
}

type City

type City struct {
	Population int
	Farmers    int
	Workers    int
	Rebels     int
	Name       string
	Plane      data.Plane
	// the race of the towns people
	Race      data.Race
	X         int
	Y         int
	Outpost   bool
	Buildings *set.Set[buildinglib.Building]

	Enchantments *set.Set[Enchantment]

	CatchmentProvider CatchmentProvider
	CityServices      CityServicesProvider
	ReignProvider     ReignProvider

	// reset every turn, keeps track of whether the player sold a building
	SoldBuilding bool

	// how many hammers the city has produced towards the current project
	Production        float32
	ProducingBuilding buildinglib.Building
	ProducingUnit     units.Unit

	BuildingInfo buildinglib.BuildingInfos
}

func MakeCity

func MakeCity(name string, x int, y int, race data.Race, buildingInfo buildinglib.BuildingInfos, catchmentProvider CatchmentProvider, cityServices CityServicesProvider, reignProvider ReignProvider) *City

FIXME: Add plane?

func (*City) AddBuilding

func (city *City) AddBuilding(building buildinglib.Building)

func (*City) AddEnchantment

func (city *City) AddEnchantment(enchantment data.CityEnchantment, owner data.BannerType)

func (*City) AllowedBuildings

func (city *City) AllowedBuildings(what buildinglib.Building) []buildinglib.Building

func (*City) AllowedUnits

func (city *City) AllowedUnits(what buildinglib.Building) []units.Unit

func (*City) BaseFoodLevel

func (city *City) BaseFoodLevel() int

compute amount of available food on tiles in catchment area

func (*City) CancelEnchantment

func (city *City) CancelEnchantment(enchantment data.CityEnchantment, owner data.BannerType)

Used when an enchantment removal is an explicit player action (e.g. disabling a specific enchantment from a city screen)

func (*City) Citizens

func (city *City) Citizens() int

func (*City) ComputeForeignTrade

func (city *City) ComputeForeignTrade() float64

return the percent of foreign trade bonus

population of other city * 0.5% if same race
population of other city * 1% if different

func (*City) ComputePossibleBuildings

func (city *City) ComputePossibleBuildings() *set.Set[buildinglib.Building]

return the buildings that can be built, based on what the city already has and what dependencies are met

func (*City) ComputePossibleUnits

func (city *City) ComputePossibleUnits() []units.Unit

func (*City) ComputePower

func (city *City) ComputePower() int

power production from buildings and citizens

func (*City) ComputeSubsistenceFarmers

func (city *City) ComputeSubsistenceFarmers() int

FIXME: take enchantments into account * https://masterofmagic.fandom.com/wiki/Farmer

func (*City) ComputeTotalBonusPercent

func (city *City) ComputeTotalBonusPercent() float64

return the bonus gold percent, capped at citizens*3

func (*City) ComputeUnrest

func (city *City) ComputeUnrest() int

func (*City) ComputeUpkeep

func (city *City) ComputeUpkeep() int

func (*City) ComputeWildGame

func (city *City) ComputeWildGame() int

func (*City) DoNextTurn

func (city *City) DoNextTurn(mapObject *maplib.Map) []CityEvent

do all the stuff needed per turn increase population, add production, add food/money, etc

func (*City) FameForCaptureOrRaze

func (city *City) FameForCaptureOrRaze(captured bool) int

pass in true to compute fame for capturing, and false to compute fame for razing/losing

func (*City) FarmerFoodProduction

func (city *City) FarmerFoodProduction(farmers int) int

func (*City) FoodProductionRate

func (city *City) FoodProductionRate() int

func (*City) GetBanner

func (city *City) GetBanner() data.BannerType

func (*City) GetBuildableBuildings

func (city *City) GetBuildableBuildings() *set.Set[buildinglib.Building]

returns the set of buildings that could possibly be built by this city, taking terrain dependencies into account

func (*City) GetEnchantmentsCastBy

func (city *City) GetEnchantmentsCastBy(banner data.BannerType) []Enchantment

func (*City) GetOutpostHouses

func (city *City) GetOutpostHouses() int

func (*City) GetSightRange

func (city *City) GetSightRange() int

func (*City) GetSize

func (city *City) GetSize() CitySize

func (*City) GetWeaponBonus

func (city *City) GetWeaponBonus() data.WeaponBonus

if the city contains an alchemist's guild then new units get one of the following bonuses

  • magic weapon
  • mythril weapon (if mythril ore in catchment area)
  • adamantium weapon (if adamantium ore in catchment area)

func (*City) GetX

func (city *City) GetX() int

func (*City) GetY

func (city *City) GetY() int

func (*City) GoldBank

func (city *City) GoldBank() int

func (*City) GoldBonus

func (city *City) GoldBonus(percent float64) int

gold from cities connected via roads, ocean, and river

func (*City) GoldMarketplace

func (city *City) GoldMarketplace() int

func (*City) GoldMerchantsGuild

func (city *City) GoldMerchantsGuild() int

func (*City) GoldMinerals

func (city *City) GoldMinerals() int

func (*City) GoldProsperity

func (city *City) GoldProsperity() int

func (*City) GoldSurplus

func (city *City) GoldSurplus() int

func (*City) GoldTaxation

func (city *City) GoldTaxation() int

func (*City) GoldTradeGoods

func (city *City) GoldTradeGoods() int

func (*City) GrowOutpost

func (city *City) GrowOutpost() CityEvent

func (*City) HasAnyOfEnchantments

func (city *City) HasAnyOfEnchantments(enchantmentsToCheck ...data.CityEnchantment) bool

Returns true if the city has at least one of the enchantments from arguments

func (*City) HasEnchantment

func (city *City) HasEnchantment(check data.CityEnchantment) bool

func (*City) HasFortress

func (city *City) HasFortress() bool

func (*City) HasSummoningCircle

func (city *City) HasSummoningCircle() bool

func (*City) HasWall

func (city *City) HasWall() bool

func (*City) HasWallOfDarkness

func (city *City) HasWallOfDarkness() bool

func (*City) HasWallOfFire

func (city *City) HasWallOfFire() bool

func (*City) MaximumCitySize

func (city *City) MaximumCitySize() int

returns the maximum number of citizens. population is citizens * 1000

func (*City) NonRebels

func (city *City) NonRebels() int

func (*City) OnShore

func (city *City) OnShore() bool

true if the city is adjacent to a water tile

func (*City) PopulationGrowthRate

func (city *City) PopulationGrowthRate() int

func (*City) PowerAlchemistsGuild

func (city *City) PowerAlchemistsGuild() int

func (*City) PowerCathedral

func (city *City) PowerCathedral() float64

func (*City) PowerCitizens

func (city *City) PowerCitizens() int

func (*City) PowerDarkRituals

func (city *City) PowerDarkRituals() float64

func (*City) PowerFortress

func (city *City) PowerFortress() int

func (*City) PowerMinerals

func (city *City) PowerMinerals() int

func (*City) PowerMoonBonus

func (city *City) PowerMoonBonus() float64

func (*City) PowerParthenon

func (city *City) PowerParthenon() float64

func (*City) PowerShrine

func (city *City) PowerShrine() float64

func (*City) PowerTemple

func (city *City) PowerTemple() float64

func (*City) PowerWizardsGuild

func (city *City) PowerWizardsGuild() int

func (*City) ProducingString

func (city *City) ProducingString() string

func (*City) ProducingTurnsLeft

func (city *City) ProducingTurnsLeft() int

func (*City) ProductionFarmers

func (city *City) ProductionFarmers() float32

func (*City) ProductionForestersGuild

func (city *City) ProductionForestersGuild() float32

func (*City) ProductionInspirations

func (city *City) ProductionInspirations() float32

func (*City) ProductionMechaniciansGuild

func (city *City) ProductionMechaniciansGuild() float32

func (*City) ProductionMinersGuild

func (city *City) ProductionMinersGuild() float32

func (*City) ProductionSawmill

func (city *City) ProductionSawmill() float32

func (*City) ProductionTerrain

func (city *City) ProductionTerrain() float32

func (*City) ProductionWorkers

func (city *City) ProductionWorkers() float32

func (*City) RemoveAllEnchantmentsByOwner

func (city *City) RemoveAllEnchantmentsByOwner(owner data.BannerType)

remove all enchantments owned by a specific wizard

func (*City) RemoveEnchantments

func (city *City) RemoveEnchantments(enchantmentsToRemove ...data.CityEnchantment)

Used when an enchantment removal is caused by some mechanic (e.g. consecration spell).

func (*City) RequiredFood

func (city *City) RequiredFood() int

amount of food needed to feed the citizens

func (*City) ResearchProduction

func (city *City) ResearchProduction() int

func (*City) ResetCitizens

func (city *City) ResetCitizens()

func (*City) String

func (city *City) String() string

func (*City) SurplusFood

func (city *City) SurplusFood() int

func (*City) TileDistance

func (city *City) TileDistance(x int, y int) int

distance to a tile from where the city is

func (*City) UpdateUnrest

func (city *City) UpdateUnrest()

func (*City) WorkProductionRate

func (city *City) WorkProductionRate() float32

type CityEvent

type CityEvent interface {
}

type CityEventCityAbandoned

type CityEventCityAbandoned struct {
}

type CityEventNewBuilding

type CityEventNewBuilding struct {
	Building buildinglib.Building
}

type CityEventNewUnit

type CityEventNewUnit struct {
	Unit        units.Unit
	WeaponBonus data.WeaponBonus
	Experience  int
}

type CityEventOutpostDestroyed

type CityEventOutpostDestroyed struct {
}

type CityEventOutpostHamlet

type CityEventOutpostHamlet struct {
}

type CityEventPopulationGrowth

type CityEventPopulationGrowth struct {
	Size int
	Grow bool
}

type CityServicesProvider

type CityServicesProvider interface {
	FindRoadConnectedCities(city *City) []*City
	GoodMoonActive() bool
	BadMoonActive() bool
	PopulationBoomActive(city *City) bool
	PlagueActive(city *City) bool
	GetAllGlobalEnchantments() map[data.BannerType]*set.Set[data.Enchantment]
}

type CitySize

type CitySize int
const (
	CitySizeHamlet CitySize = iota
	CitySizeVillage
	CitySizeTown
	CitySizeCity
	CitySizeCapital
)

func (CitySize) String

func (citySize CitySize) String() string

type Enchantment

type Enchantment struct {
	Enchantment data.CityEnchantment
	// this keeps track of the owning wizard by implicitly associating a banner to the wizard that cast it
	Owner data.BannerType
}

type ReignProvider

type ReignProvider interface {
	HasDivinePower() bool
	HasInfernalPower() bool
	HasLifeBooks() bool
	HasDeathBooks() bool
	TotalBooks() int
	GetRulingRace() data.Race
	GetTaxRate() fraction.Fraction
	GetBanner() data.BannerType
	GetGlobalEnchantments() *set.Set[data.Enchantment]
	GetUnits(x int, y int, plane data.Plane) []units.StackUnit
}

Jump to

Keyboard shortcuts

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