Home /Modules/gameplay/MoveOutcome.sleela

MoveOutcome.sleela

lib/gameplay/MoveOutcome.sleela · 123 line(s) · sleela

<< lib/gameplay/MoveOutcome.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines MoveOutcome, the result record every GameMove returns —
     what happened on this turn, in a form the game loop and the player can both
     read. It carries a headline, whether the move succeeded, and the concrete
     gains (experience, cash, file/tact/rolls) the move produced.
   
   MoveOutcome is a NATURAL / LOADABLE MODULE sharing the common module contract
   (load / loaded / moduleName / describe). It is a plain carrier: moves fill it
   in, the turn applies it to the Player, and describe() narrates it.
   
   Family: gameplay. >>
#sleela 2.5
material;
< Unified SLeeLa SDK front-end object. >
class MoveOutcome {
  < ---- 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 = 10336;
  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; }

  static final String MODULE = "MoveOutcome";

  int loadedFlag;
  < which move produced this >
  String moveName;
  < one-line summary of what happened >
  String headline;
  < did the move land? >
  boolean success;
  < experience granted >
  int xpGain;
  < cash granted (net; may be 0) >
  int cashGain;
  < courtroom file granted >
  int fileGain;
  < courtroom tact granted >
  int tactGain;
  < courtroom rolls granted >
  int rollsGain;

  < --- loadable-module contract ------------------------------------------ >
  void load() {
    loadedFlag = 1;
    moveName = "";
    headline = "";
    success = false;
    xpGain = 0; cashGain = 0; fileGain = 0; tactGain = 0; rollsGain = 0;
  }
  boolean loaded() { return loadedFlag == 1; }
  String moduleName() { return MODULE; }

  void begin(String move) { load(); moveName = move; }
  void say(String line) { headline = line; }
  void succeed() { success = true; }

  void addXp(int n)    { if (n > 0) { xpGain = xpGain + n; } }
  void addCash(int n)  { cashGain = cashGain + n; }
  void addFile(int n)  { if (n > 0) { fileGain = fileGain + n; } }
  void addTact(int n)  { if (n > 0) { tactGain = tactGain + n; } }
  void addRolls(int n) { if (n > 0) { rollsGain = rollsGain + n; } }

  < Apply everything this outcome granted to a Player, in one shot. >
  void applyTo(Player p) {
    if (p == null) { return; }
    p.gainExperience(xpGain);
    p.earn(cashGain);
    p.gainFile(fileGain);
    p.gainTact(tactGain);
    p.gainRolls(rollsGain);
  }

  boolean landed() { return success; }
  String move() { return moveName; }
  String summary() { return headline; }

  String yn(boolean v) { if (v) { return "yes"; } return "no"; }

  String describe() {
    return MODULE + " [" + moveName + "] success=" + yn(success)
         + " xp=" + xpGain + " cash=" + cashGain
         + " file=" + fileGain + " tact=" + tactGain + " rolls=" + rollsGain
         + " :: " + headline;
  }
}