Home /Modules/gameplay/AskForHelpMove.sleela

AskForHelpMove.sleela

lib/gameplay/AskForHelpMove.sleela · 117 line(s) · sleela

<< lib/gameplay/AskForHelpMove.sleela
   SLeeLa Standard Library Definition.
   Definition: Move (b) โ€” ask for help or new routes. A straight 50/50. Win the
     flip and the Inference Engine lets you LOOK at your Expected Future as it is
     being modeled, so you can see whether you are on schedule in your own custom
     game. Lose the flip and your Boss instead hands you a Detailed Report with
     some Game-Engineering moves already decided โ€” and you pay for that
     information based on the Quality of your Person/Citizen.
   
   A concrete GameMove: override resolve() to flip, then either read the future
   or buy the report. The future it modeled and the report it bought are stashed
   on the move so the turn can show them. Family: gameplay. >>
#sleela 2.5
material;
class AskForHelpMove 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 = 10293;
  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; }

  < cents, before quality scaling >
  static final int BASE_REPORT_COST = 2000;

  < populated on a winning flip >
  ExpectedFuture lastFuture;
  < populated on a losing flip >
  DetailedReport lastReport;

  void setUp() {
    load();
    declare("Ask for Help / New Routes", CHOICE_ASK_HELP);
    lastFuture = null;
    lastReport = null;
  }

  MoveOutcome resolve(Player p) {
    MoveOutcome out = new MoveOutcome();
    out.begin("Ask for Help / New Routes");
    lastFuture = null;
    lastReport = null;
    if (dice == null || engine == null || p == null) {
      out.say("No roller, engine, or player; no help available.");
      return out;
    }

    < the 50/50 >
    boolean win = dice.coinFlip();
    if (win) {
      < You get to see your Expected Future being modeled live. >
      lastFuture = engine.model(p, turnNumber);
      out.succeed();
      out.addXp(3);
      if (lastFuture.onSchedule()) {
        out.say("50/50 won: you're ON SCHEDULE. gap=" + lastFuture.scheduleGap());
      } else {
        out.say("50/50 won: you're BEHIND by " + lastFuture.scheduleGap()
              + " turn(s) โ€” time to re-route.");
      }
    } else {
      < The boss steps in with a pre-decided brief; you pay by your quality. >
      lastReport = engine.brief(p, BASE_REPORT_COST);
      if (lastReport.paid()) {
        out.succeed();
        out.addXp(2);
        < a report is paper; paper is file >
        out.addFile(1);
        out.say("50/50 lost, but bought the Boss's brief ("
              + lastReport.moves() + " moves) for " + lastReport.price() + "c.");
      } else {
        out.say("50/50 lost and couldn't afford the Boss's brief (needed "
              + lastReport.price() + "c).");
      }
    }
    return out;
  }

  ExpectedFuture future() { return lastFuture; }
  DetailedReport report() { return lastReport; }
}