Skip to content

Reference

tilttek/luck-tokens
TypeRole
LuckTokensGrants, spends, passes and refreshes tokens; gives the balances and the ledger; erases a member
TableRulesThe kinds of tokens of a table and its game masters; read from plain values or JSON
TokenKindA kind of token: key, name, cap, scope, refresh, carry-over, grants, transfers
HolderScopeCharacter or Player
RefreshNever or EachSession
GrantPolicyGameMasters or Anyone
ReceiptThe entries an operation wrote, the balance it left, and whether it was a replay
BalanceHow many tokens of a kind a holder has
Ledger\LedgerEntryOne entry of the ledger: position, operation, type, kind, holder, change, balance, actor, time, reason, session
Ledger\EntryTypeGranted, Spent, TransferredOut, TransferredIn, Refreshed or SessionStarted
Event\TokensGrantedTokens granted
Event\TokensSpentTokens spent
Event\TokensTransferredTokens passed from one holder to another
Event\SessionStartedA session started, with its refreshes
Event\HolderErasedA member erased under a pseudonym, with the number of entries rewritten
Contract\TokenRulesThe rules of the tables
Contract\TokenLedgerWhere the ledgers are kept, with their indexes; erases a member under a pseudonym
Contract\HolderAccessWhether an actor controls the tokens of a holder
Store\InMemoryTokenRulesThe rules in memory
Store\InMemoryTokenLedgerThe ledgers in memory
Store\SelfAccessEach holder controls their own tokens

Instant is internal: the one way the library writes a time, in UTC.

Exceptions

ExceptionThrown when
Exception\LuckTokensExceptionThe interface of every exception of the library
Exception\InvalidTokenRuleA kind, rules, an amount, an identifier, a reason or a ledger entry the library refuses
Exception\TokenRefusedAn operation the rules do not allow: a table or a kind not known, an actor who may not, the cap, a balance too low, a transfer not allowed, an identifier reused, a session started already, a ledger full
Exception\LedgerConflictOther writers kept the ledger busy three times in a row

Nothing is written when an exception is thrown. Each message says what was expected, as member:8 holds 0 "fate"; 1 cannot be spent nor given.