Home /Modules/character/Character.sleela

Character.sleela

lib/character/Character.sleela · 208 line(s) · sleela

<< lib/character/Character.sleela
   SLeeLa Character base model.
   
   Character retains its existing optional BusinessModel/economy behavior and
   also exposes a neutral, optional life-capability profile for human or
   fictional character simulations. Capability values are scenario inputs, not
   clinical, psychometric, or factual assessments. Zero means unknown/unset. >>
#sleela 2.5
material;
class Character {
  < ---- 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 = 11450;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-21";
  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 = "Character";

  int loadedFlag;
  String name;
  String tagline;
  int grit;
  int reputation;
  int cashCents;
  BusinessModel model;

  < Optional life-capability profile. Scale: 1..30; 0 = unknown. >
  int intelligence;
  int creativity;
  int systemsThinking;
  int technicalInnovation;
  int execution;
  int exploration;
  int collaboration;
  int resilience;
  int sustainability;
  String capabilityProfileStatus;
  String capabilityProfileSource;

  void load() {
    loadedFlag = 1;
    name = "Nameless Founder";
    tagline = "We're pre-revenue but post-vision.";
    grit = 50;
    reputation = 50;
    cashCents = 0;
    model = null;
    intelligence = 0;
    creativity = 0;
    systemsThinking = 0;
    technicalInnovation = 0;
    execution = 0;
    exploration = 0;
    collaboration = 0;
    resilience = 0;
    sustainability = 0;
    capabilityProfileStatus = "unknown";
    capabilityProfileSource = "";
  }

  boolean loaded() { return loadedFlag == 1; }
  String moduleName() { return MODULE; }

  void introduce(String who, String pitch, int startingGrit, int startingCash) {
    if (who != null) { name = who; }
    if (pitch != null) { tagline = pitch; }
    grit = clamp(startingGrit);
    reputation = 50;
    if (startingCash >= 0) { cashCents = startingCash; }
  }

  void adopt(BusinessModel chosen) { model = chosen; }
  boolean hasModel() { return model != null && model.ready(); }

  int liveAMonth() {
    if (!hasModel()) { return 0; }
    int profit = model.monthlyProfit();
    cashCents = cashCents + profit;
    if (profit > 0) {
      reputation = clamp(reputation + 3);
      grit = clamp(grit + 1);
    } else {
      reputation = clamp(reputation - 2);
      grit = clamp(grit - 5);
    }
    return profit;
  }

  int runMonths(int months) {
    int total = 0;
    int i = 0;
    while (i < months) {
      total = total + liveAMonth();
      i = i + 1;
    }
    return total;
  }

  < Zero explicitly represents an unknown stat; populated scores use 1..30. >
  boolean setLifeCapabilities(int intel, int create, int systems, int innovation,
                              int execute, int explore, int collaborate,
                              int recover, int sustain, String status, String source) {
    if (!validStat(intel) || !validStat(create) || !validStat(systems)
        || !validStat(innovation) || !validStat(execute) || !validStat(explore)
        || !validStat(collaborate) || !validStat(recover) || !validStat(sustain)) {
      return false;
    }
    intelligence = intel;
    creativity = create;
    systemsThinking = systems;
    technicalInnovation = innovation;
    execution = execute;
    exploration = explore;
    collaboration = collaborate;
    resilience = recover;
    sustainability = sustain;
    if (status != null) { capabilityProfileStatus = status; }
    if (source != null) { capabilityProfileSource = source; }
    return true;
  }

  boolean validStat(int value) { return value >= 0 && value <= 30; }

  < Classic ability-score modifier; a game/simulation convention only. >
  int intelligenceModifier() {
    if (intelligence == 0) { return 0; }
    return floorHalf(intelligence - 10);
  }

  < Normalized planning index, not measured human cognitive throughput. >
  < INT 10 -> 100; each point above/below 10 shifts index by five. >
  int intelligencePlanningIndex() {
    if (intelligence == 0) { return 0; }
    return 100 + (intelligence - 10) * 5;
  }

  int floorHalf(int value) {
    if (value >= 0) { return value / 2; }
    return (value - 1) / 2;
  }

  boolean hasLifeCapabilities() {
    return intelligence > 0 || creativity > 0 || systemsThinking > 0
        || technicalInnovation > 0 || execution > 0 || exploration > 0
        || collaboration > 0 || resilience > 0 || sustainability > 0;
  }

  boolean stillStanding() { return cashCents >= 0 && grit > 0; }
  boolean thriving() { return hasModel() && model.profitable() && reputation >= 60; }
  int cash() { return cashCents; }
  int reputationScore() { return reputation; }
  int gritScore() { return grit; }
  String characterName() { return name; }
  int modelKind() { if (!hasModel()) { return BusinessModel.KIND_NONE; } return model.modelKind(); }
  String modelName() { if (model == null) { return "none"; } return model.name(); }

  int clamp(int v) {
    if (v < 0) { return 0; }
    if (v > 100) { return 100; }
    return v;
  }

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

  String describe() {
    return MODULE + " name=" + name + " model=" + modelName()
         + " cash=" + cashCents + " reputation=" + reputation
         + " grit=" + grit + " lifeCapabilities=" + yn(hasLifeCapabilities())
         + " thriving=" + yn(thriving()) + " standing=" + yn(stillStanding());
  }
}