Player.sleela
lib/gameplay/Player.sleela · 143 line(s) · sleela
<< lib/gameplay/Player.sleela
SLeeLa Standard Library Definition.
Definition: Defines Player, the actor who takes a turn in the gameplay
package. A Player carries experience, a Person/Citizen quality score (which
sets the price they pay for information), cash, and the three things a turn
can grant them โ file, tact, and rolls โ plus a Management Courtroom to keep
them in.
Player is a NATURAL / LOADABLE MODULE sharing the common module contract
(load / loaded / moduleName / describe). The quality score is the hinge of
move (b): a higher-quality Person/Citizen is charged more for the Inference
Engine's information, because good information finds the people who can use it.
Family: gameplay. >>
#sleela 2.5
material;
< Unified SLeeLa SDK front-end object. >
class Player {
< ---- 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 = 10341;
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 = "Player";
int loadedFlag;
< the player's name at the table >
String handle;
< more experience per turn is the whole point >
int experience;
< Person/Citizen quality, 0..100 (sets info price) >
int quality;
< what they can spend on reports >
int cashCents;
< 0..100 โ how much the boss "gets" them this turn >
int bossUnderstanding;
< where file / tact / rolls accumulate >
ManagementCourtroom courtroom;
< --- loadable-module contract ------------------------------------------ >
void load() {
loadedFlag = 1;
handle = "Player One";
experience = 0;
quality = 50;
cashCents = 0;
bossUnderstanding = 50;
courtroom = new ManagementCourtroom();
courtroom.load();
}
boolean loaded() { return loadedFlag == 1; }
String moduleName() { return MODULE; }
void introduce(String name, int startQuality, int startCash) {
if (name != null) { handle = name; }
quality = clamp(startQuality);
if (startCash >= 0) { cashCents = startCash; }
}
< --- turn rewards ------------------------------------------------------- >
void gainExperience(int xp) { if (xp > 0) { experience = experience + xp; } }
void raiseBossUnderstanding(int d) { bossUnderstanding = clamp(bossUnderstanding + d); }
< The price of information scales with the Player's own quality: a better >
< Person/Citizen pays more, because the report is worth more to them. >
int infoPriceCents(int baseCents) {
if (baseCents < 0) { baseCents = 0; }
return baseCents + (baseCents * quality) / 100;
}
< Try to pay for information. Returns true if the player could afford it. >
boolean payForInfo(int baseCents) {
int price = infoPriceCents(baseCents);
if (price > cashCents) { return false; }
cashCents = cashCents - price;
return true;
}
void earn(int cents) { if (cents > 0) { cashCents = cashCents + cents; } }
< Convenience pass-throughs to the courtroom. >
void gainFile(int n) { courtroom.addFile(n); }
void gainTact(int n) { courtroom.addTact(n); }
void gainRolls(int n) { courtroom.addRolls(n); }
int xp() { return experience; }
int qualityScore() { return quality; }
int cash() { return cashCents; }
int bossRapport() { return bossUnderstanding; }
ManagementCourtroom management() { return courtroom; }
String name() { return handle; }
int clamp(int v) {
if (v < 0) { return 0; }
if (v > 100) { return 100; }
return v;
}
String describe() {
return MODULE + " " + handle + " xp=" + experience
+ " quality=" + quality + " cash=" + cashCents
+ " boss=" + bossUnderstanding + "; " + courtroom.describe();
}
}