#pragma once
#include <cstdint>
#include <string>
#include <vector>
#include <mw/crypto.hpp>
#include <mw/error.hpp>
#include "card.h"
/// Current pool weight and normalized probability for one card.
struct CardPoolEntry
{
/// Eligible card.
Card card;
/// Weight scaled so the largest represented weight is one.
double scaled_weight;
/// Weight divided by the represented total.
double probability;
};
/// Calculate and sample the current positive-rarity card pool.
class CardPoolService
{
public:
/// Build probability entries in card-ID order.
std::vector<CardPoolEntry> calculate(
const std::vector<Card>& cards) const;
/// Select one entry using eight cryptographically random bytes.
mw::E<CardPoolEntry> select(
const std::vector<CardPoolEntry>& entries,
mw::CryptoInterface& crypto) const;
};
/// Format a represented pool probability for a card page.
std::string formatProbability(double probability);