<< lib/gameplay/PortfolioDecision.sleela SLeeLa Standard Library Definition. Definition: Defines PortfolioDecision, one likeable, medium-sized bet on a realistic industry that a Player reviews during move (c), "create a new desire". Each decision has an industry, a stake, a win chance, and a multiplier — and a size, because the game's one law is: big bets are always winners, where you find them. Bet big. PortfolioDecision is a NATURAL / LOADABLE MODULE sharing the common module contract (load / loaded / moduleName / describe). It models the bet and resolves it against a DiceRoll into a profit, but it does not touch the Player directly; the move that owns it decides what to do with the result. Family: gameplay. >> #sleela 2.5 material; < Unified SLeeLa SDK front-end object. > class PortfolioDecision { < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- > << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader, or catalog can read and (where appropriate) override this record. Values are faithful to the subject's real origin where publicly known. >> String metaVersion = "1.0.0"; int metaId = 10342; String metaAuthor = "Kiro Agent"; String metaDate = "2026-10-16"; String metaCopyright = "SLeeLa project"; String metaTrademark = "none"; String metaCorporation = "none"; < metaOrigin: National | | International | Galactic > String metaOrigin = "International"; String metaBirthDate = "2026-10-07"; < metaScienceRating: maturity/robustness on a 1..10 scale > int metaScienceRating = 9; < metaNationalSchedule: a real, citable instrument or "none" > String metaNationalSchedule = "none"; String getMetaVersion() { return metaVersion; } void setMetaVersion(String v) { metaVersion = v; } int getMetaId() { return metaId; } void setMetaId(int v) { metaId = v; } String getAuthor() { return metaAuthor; } void setAuthor(String v) { metaAuthor = v; } String getDate() { return metaDate; } void setDate(String v) { metaDate = v; } String getCopyright() { return metaCopyright; } void setCopyright(String v) { metaCopyright = v; } String getTrademark() { return metaTrademark; } void setTrademark(String v) { metaTrademark = v; } String getCorporation() { return metaCorporation; } void setCorporation(String v) { metaCorporation = v; } String getOrigin() { return metaOrigin; } void setOrigin(String v) { metaOrigin = v; } String getBirthDate() { return metaBirthDate; } void setBirthDate(String v) { metaBirthDate = v; } int getScienceRating() { return metaScienceRating; } void setScienceRating(int v) { metaScienceRating = v; } String getNationalSchedule() { return metaNationalSchedule; } void setNationalSchedule(String v) { metaNationalSchedule = v; } static final String MODULE = "PortfolioDecision"; < Bet sizes. "Big" is special: in this game a found big bet always pays. > static final int SIZE_SMALL = 0; static final int SIZE_MEDIUM = 1; static final int SIZE_BIG = 2; int loadedFlag; < e.g. "Energy", "Logistics", "Healthcare" > String industry; < what the player puts in > int stakeCents; < base chance the bet pays (0..100) > int winPercent; < payout multiple x10 (so 25 = 2.5x), on a win > int multiplierX10; < one of SIZE_* > int size; < whether resolve() has run > boolean resolved; < the outcome, once resolved > boolean won; < net profit (payout - stake) once resolved > int profitCents; < --- loadable-module contract ------------------------------------------ > void load() { loadedFlag = 1; industry = "Unspecified"; stakeCents = 0; winPercent = 0; multiplierX10 = 0; size = SIZE_MEDIUM; resolved = false; won = false; profitCents = 0; } boolean loaded() { return loadedFlag == 1; } String moduleName() { return MODULE; } void offer(String ind, int stake, int winChance, int multX10, int betSize) { if (ind != null) { industry = ind; } if (stake < 0) { stake = 0; } if (winChance < 0) { winChance = 0; } if (winChance > 100) { winChance = 100; } if (multX10 < 0) { multX10 = 0; } stakeCents = stake; winPercent = winChance; multiplierX10 = multX10; if (betSize < SIZE_SMALL || betSize > SIZE_BIG) { betSize = SIZE_MEDIUM; } size = betSize; resolved = false; won = false; profitCents = 0; } < The game's one law: a BIG bet, once you've found it, always wins. Smaller > < bets must roll under their win chance like everyone else. > boolean isGuaranteed() { return size == SIZE_BIG; } int effectiveWinPercent() { if (isGuaranteed()) { return 100; } return winPercent; } < Resolve the bet against a roller. Profit = payout - stake on a win, else > < the stake is lost. Big bets always land, so bet big where you find them. > int resolve(DiceRoll dice) { resolved = true; boolean hit = false; if (isGuaranteed()) { hit = true; } else if (dice != null) { hit = dice.rollUnder(winPercent); } won = hit; if (hit) { int payout = (stakeCents * multiplierX10) / 10; profitCents = payout - stakeCents; } else { profitCents = 0 - stakeCents; } return profitCents; } String industryName() { return industry; } int stake() { return stakeCents; } int multiplierTimesTen() { return multiplierX10; } int betSize() { return size; } boolean isResolved() { return resolved; } boolean didWin() { return won; } int profit() { return profitCents; } String sizeName() { if (size == SIZE_SMALL) { return "small"; } if (size == SIZE_BIG) { return "BIG"; } return "medium"; } String yn(boolean v) { if (v) { return "yes"; } return "no"; } String describe() { return MODULE + " " + industry + " size=" + sizeName() + " stake=" + stakeCents + " win%=" + effectiveWinPercent() + " multX10=" + multiplierX10 + " resolved=" + yn(resolved) + " won=" + yn(won) + " profit=" + profitCents; } }