Buildings & City

Fire Crystal table

A table of the Fire Crystals and Refined Fire Crystals that each building needs to reach each Fire Crystal level, FC 1 to FC 10. The module builds the columns, one row for each building, and a total for each column.

fireCrystalLevels() holds the ten FC 1 to FC 10 badge icons used as column headers. The costs come from the level costs in Buildings.


Types

FireCrystalTable

FieldTypeDescription
columnsFireCrystalTableColumn[]One column for each level and resource
rowsFireCrystalTableRow[]One row for each building with a Fire Crystal cost
totalsnumber[]The sum of each column, in the order of columns

FireCrystalTableColumn

FieldTypeDescription
levelFireCrystalLevelThe level badge
resourceFireCrystalResource'fireCrystals' or 'refinedFireCrystals'
itemItemThe resource's entry in Items, with icon

FireCrystalTableRow

FieldTypeDescription
buildingIdstringid of the building
namestringBuilding name
imgstring?Path to the building's icon
cells(number | null)[]One value for each column, in order. null when there is no cost

FireCrystalLevel

FieldTypeDescription
idstringStable identifier, such as fc-5
namestringDisplay name, such as FC 5
levelnumberLevel from 1 to 10
imgstringPath to the badge icon

FireCrystalLevelRange

FieldTypeDescription
fromnumberFirst level to keep, 1 to 10
tonumberLast level to keep, 1 to 10

Functions

import { fireCrystalLevels, fireCrystalTable } from 'whiteout-survival-data'

fireCrystalTable() // all levels, all buildings
fireCrystalTable(source, range) // custom buildings and an optional level range
fireCrystalLevels() // the ten level badges
FunctionReturnsDescription
fireCrystalTable(source?, range?)FireCrystalTableThe table. source defaults to all buildings. range keeps the levels from to to.
fireCrystalLevels()FireCrystalLevelQueryThe ten level badges. It has the shared query methods.

Terminal methods

fireCrystalLevels() has no filters of its own.

MethodReturnsDescription
.get()FireCrystalLevel[]All results
.first()FireCrystalLevel | undefinedFirst result
.find(id)FireCrystalLevel | undefinedFind by id
.findByName(name)FireCrystalLevel | undefinedCase-insensitive exact name match
.search(query)FireCrystalLevel[]Case-insensitive partial name match
.count()numberNumber of results

Ranges

Pass { from, to } as the second argument to keep only the levels from from to to. Use { from: 1, to: 5 } and { from: 6, to: 10 } for two tables. columns, every row, and totals hold only those levels, and a Refined Fire Crystals column appears only for a level that costs any.

Every range has the same rows, so tables of one split line up. fireCrystalTable() throws RangeError when from or to is not a level from 1 to 10, or when from is above to.


Examples

import { fireCrystalLevels, fireCrystalTable } from 'whiteout-survival-data'

const table = fireCrystalTable()

// Column headers: one badge per level, then one resource icon per column
table.columns.map((c) => `${c.level.name} ${c.item.name}`)
// ['FC 1 Fire Crystal', 'FC 2 Fire Crystal', ..., 'FC 6 Fire Crystal', 'FC 6 Refined Fire Crystal', ...]

// A cell lines up with the column of the same index
const furnace = table.rows.find((row) => row.buildingId === 'furnace')
furnace?.cells.slice(0, 5) // [660, 790, 1190, 1400, 1675]

// Total of each column across the buildings
table.totals[0] // 1970

// Only FC 6 to FC 10
const late = fireCrystalTable(undefined, { from: 6, to: 10 })
late.columns.length // 10
late.totals[0] // 3105

fireCrystalLevels().find('fc-5')?.img // '/images/fire-crystal/fc-5.png'

Notes

There is a Fire Crystals column for every level. A Refined Fire Crystals column follows it for each level where some building pays Refined Fire Crystals, which is FC 6 to FC 10. That gives 15 columns.

A cell is null when the building has no cost for the level, and a null cell counts as 0 in totals. A row exists only for a building with a Fire Crystal cost, so the table has 8 rows: Furnace, Embassy, Command Center, the three Camps, War Academy, and Infirmary.

The cost of a level is the sum of the five upgrades that end at its base row. FC 1 adds up 30-1 to 30-4 and FC 1. FC 2 adds up FC 1-1 to FC 1-4 and FC 2. FC 6 adds up FC 5-1 to FC 5-4 and FC 6. FC 10 has no sub-levels, so it adds up FC 9-1 to FC 9-4 and FC 10.

War Academy has no 30-1 to 30-4 levels, and its FC 1 row has no cost, so its FC 1 cell is null.


Next steps

Previous
Facilities