Skip to content

RarityText

Namespace Nfty.Core.Stats in assembly Nfty.Core.

public static class RarityText

How a share is written down, for every surface that shows one.

Remarks

It exists for the reason SpaceText does, and it was needed for the same reason too. Three surfaces printed a rarity and each carried its own copy of the decision: the report formatted 0.00, the ingredient pane rounded to one place in its view model and interpolated the bare double, and the Set browser's converter interpolated it bare as well. Two of the three were CULTURE-SENSITIVE — string interpolation and Avalonia's StringFormat both take the current culture — so a machine set to de-DE printed 4,17% on a screen whose own comment said every figure it shows is invariant.

A rare trait is the case this is really about. Rounding a share to two places and printing the result turns every trait under a hundredth of a percent into 0% — the same string an ABSENT trait gets — so a one-in-a-million chase item and a trait no asset carries read identically. That matters more the bigger a collection is, which is precisely when someone is looking. RarityText.Percent() floors at <0.01% instead: five characters, so a fixed column still lines up, and unmistakably not zero.

Fields

None

public const string None = "—";

What is shown where there is no share to show.

Smallest

public const double Smallest = 0.01;

The smallest share printed as a figure; anything smaller floors to a marker.

Remarks

Two decimal places is the precision RarityAttribute is already stored at, so this is the resolution the data actually carries rather than a display choice made here.

Methods

Odds(double)

public static string Odds(double percent);

The same share read as odds: one in this many.

Parameters

  • percent (double) - The share, out of 100.

Returns. e.g. 1 in 24, or RarityText.None when there are no odds to state.

Remarks

A percentage compares traits to each other; odds are what "how rare is this one" actually asks. 4.17% against 2.08% reads as a near-miss where "1 in 24" against "1 in 48" does not. Derived from the percentage rather than stored beside it, so the two cannot drift.

Thousands-separated, which is where this came from: the Set browser's converter printed 1 in 100000 while the combined-chance line one inch above it printed 1 in 100,000 through SelectionOdds.Describe — the same unit, on the same rail, in two shapes. Only visible once the odds reach five digits, so only on a big collection.

A zero share has no odds and gets RarityText.None: a trait no asset carries is not "1 in infinity", and infinity is not an answer anyone wants on a card.

Percent(double)

public static string Percent(double percent);

A share, 0..100, as every surface prints one.

Parameters

  • percent (double) - The share, out of 100.

Returns. e.g. 50%, 4.17%, <0.01%, or 0%.

Remarks

Trailing zeros are dropped (0.##) because these are read down a column of mixed magnitudes rather than compared digit for digit — the opposite of the DNA-space figures, which state a fixed mantissa so their decimal points line up. Non-finite input prints as no share at all: a share that is not a number is not a small number.