Home /Modules/gameplay/NewDesireMove.sleela

NewDesireMove.sleela

lib/gameplay/NewDesireMove.sleela · 145 line(s) · sleela

<< lib/gameplay/NewDesireMove.sleela
   SLeeLa Standard Library Definition.
   Definition: Move (c) — create a new desire. You review a slate of likeable,
     medium portfolio decisions across realistic industries. Reviewing them
     earns you standing in your Management Courtroom — file, tact, or banked
     rolls — and the decision you back resolves into profit and a futures read.
     The game's one law applies: big bets are always winners, where you find
     them. So when a BIG one shows up, bet big.
   
   A concrete GameMove: override resolve() to offer the slate, grant courtroom
   standing, and resolve the chosen bet into profit. Family: gameplay. >>
#sleela 2.5
material;
class NewDesireMove extends GameMove {
  < ---- 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 = 10339;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-16";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | 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; }

  < the decision the player backed >
  PortfolioDecision chosen;
  < a simple futures read, derived from the result >
  int futuresOutlook;

  void setUp() {
    load();
    declare("Create a New Desire", CHOICE_NEW_DESIRE);
    chosen = null;
    futuresOutlook = 0;
  }

  MoveOutcome resolve(Player p) {
    MoveOutcome out = new MoveOutcome();
    out.begin("Create a New Desire");
    chosen = null;
    futuresOutlook = 0;
    if (dice == null || p == null) {
      out.say("No roller or player; no desire to create.");
      return out;
    }

    < Reviewing likeable medium portfolio decisions always teaches you >
    < something — you gain courtroom standing just for doing the work. >
    out.addXp(2);
    < tact, from reading the room >
    out.addTact(1);
    < sometimes a useful file >
    if (dice.rollUnder(40)) { out.addFile(1); }
    < sometimes a banked roll >
    if (dice.rollUnder(25)) { out.addRolls(1); }

    < The slate: three realistic industries. The third is a BIG bet — and in >
    < this game a found big bet always wins, so it is the one to back. >
    PortfolioDecision a = offer("Logistics",  5000, 55, 18, PortfolioDecision.SIZE_MEDIUM);
    PortfolioDecision b = offer("Healthcare", 8000, 45, 22, PortfolioDecision.SIZE_MEDIUM);
    PortfolioDecision big = offer("Energy", 20000, 50, 30, PortfolioDecision.SIZE_BIG);

    < Bet big where you find it. Otherwise, back the higher-expected medium. >
    if (big.isGuaranteed()) {
      chosen = big;
    } else if (expected(b) >= expected(a)) {
      chosen = b;
    } else {
      chosen = a;
    }

    int profit = chosen.resolve(dice);
    if (profit > 0) {
      out.succeed();
      out.addCash(profit);
      < A win sharpens your futures read and your experience. >
      futuresOutlook = profit / 100;
      out.addXp(3);
      out.say("Backed the " + chosen.sizeName() + " "
            + chosen.industryName() + " bet and WON: profit=" + profit
            + ", futures=+" + futuresOutlook + ".");
    } else {
      < negative outlook on a loss >
      futuresOutlook = profit / 100;
      out.say("Backed the " + chosen.sizeName() + " "
            + chosen.industryName() + " bet and lost " + (0 - profit)
            + "; futures=" + futuresOutlook + ".");
    }
    return out;
  }

  < Build one offered decision bound to the player's industry slate. >
  PortfolioDecision offer(String industry, int stake, int winPct, int multX10, int size) {
    PortfolioDecision d = new PortfolioDecision();
    d.load();
    d.offer(industry, stake, winPct, multX10, size);
    return d;
  }

  < Expected value of a (non-guaranteed) decision, in cents, for comparison: >
  < win% * (stake*mult/10 - stake) - (100-win%)*stake, scaled down by 100. >
  int expected(PortfolioDecision d) {
    int winPct = d.effectiveWinPercent();
    int grossWin = (d.stake() * d.multiplierTimesTen()) / 10;
    int netWin = grossWin - d.stake();
    int ev = (winPct * netWin - (100 - winPct) * d.stake()) / 100;
    return ev;
  }

  PortfolioDecision backed() { return chosen; }
  int futures() { return futuresOutlook; }
}