Stats

open class Stats(production: Float, food: Float, gold: Float, science: Float, culture: Float, happiness: Float, faith: Float) : Iterable<Stats.StatValuePair>

A container for the seven basic "currencies" in Unciv, Mutable, allowing for easy merging of sources and applying bonuses.

Supports e.g. for ((key,value) in <Stats>) - the iterator will skip zero values automatically.

Also possible: <Stats>.values.sum() and similar aggregates over a Sequence.

Constructors

Stats
Link copied to clipboard
fun Stats(production: Float = 0f, food: Float = 0f, gold: Float = 0f, science: Float = 0f, culture: Float = 0f, happiness: Float = 0f, faith: Float = 0f)

Types

Companion
Link copied to clipboard
object Companion
StatValuePair
Link copied to clipboard
data class StatValuePair(key: Stat, value: Float)

Represents one key/value pair returned by the iterator

Functions

add
Link copied to clipboard
fun add(other: Stats)

Adds each value of another Stats instance to this one in place

fun add(stat: Stat, value: Float): Stats

Adds the value parameter to the instance value specified by stat in place

asSequence
Link copied to clipboard
fun asSequence(): Sequence<Stats.StatValuePair>

Enables iteration over the non-zero Stat/value pairs. Explicit use unnecessary - Stats is iterable directly.

clear
Link copied to clipboard
fun clear()

Reset all values to zero (in place)

clone
Link copied to clipboard
fun clone(): Stats
div
Link copied to clipboard
operator fun div(number: Float): Stats
equals
Link copied to clipboard
fun equals(otherStats: Stats): Boolean

Compares two instances. Not callable via ==.

open operator fun equals(other: Any?): Boolean
forEach
Link copied to clipboard
open fun forEach(p0: Consumer<in Stats.StatValuePair>)
get
Link copied to clipboard
operator fun get(stat: Stat): Float

Indexed read of a value for a given Stat, e.g. this.gold == this[Stat.Gold]

hashCode
Link copied to clipboard
open fun hashCode(): Int
isEmpty
Link copied to clipboard
fun isEmpty(): Boolean
iterator
Link copied to clipboard
open operator override fun iterator(): Iterator<Stats.StatValuePair>

Returns an iterator over the elements of this object, wrapped as StatValuePairs

plus
Link copied to clipboard
operator fun plus(stats: Stats): Stats
set
Link copied to clipboard
operator fun set(stat: Stat, value: Float)

Indexed write of a value for a given Stat, e.g. this.gold += 1f is equivalent to this[Stat.Gold] += 1f

spliterator
Link copied to clipboard
open fun spliterator(): Spliterator<Stats.StatValuePair>
times
Link copied to clipboard
operator fun times(number: Float): Stats
operator fun times(number: Int): Stats
timesInPlace
Link copied to clipboard
fun timesInPlace(number: Float)

Multiplies each value of this instance by number in place

toString
Link copied to clipboard
open override fun toString(): String

Not only a debug helper. It returns a string representing the content, already translated.

toStringWithDecimals
Link copied to clipboard
fun toStringWithDecimals(): String

Properties

culture
Link copied to clipboard
var culture: Float = 0f
faith
Link copied to clipboard
var faith: Float = 0f
food
Link copied to clipboard
var food: Float = 0f
gold
Link copied to clipboard
var gold: Float = 0f
happiness
Link copied to clipboard
var happiness: Float = 0f
mapView
Link copied to clipboard
private val mapView: Map<Stat, KMutableProperty0<Float>>
production
Link copied to clipboard
var production: Float = 0f
science
Link copied to clipboard
var science: Float = 0f
values
Link copied to clipboard
val values: Sequence<Float>

Enables aggregates over the values, never empty

Inheritors

NamedStats
Link copied to clipboard

Sources

jvm source
Link copied to clipboard