SubscriptionModel.sleela
lib/citizen/character/SubscriptionModel.sleela · 85 line(s) · sleela
<< lib/citizen/character/SubscriptionModel.sleela
SLeeLa Standard Library Definition.
Definition: SubscriptionModel — recurring revenue from subscribers who each
pay the same price every month and leave at a steady churn rate. The
classic "predictable until it isn't" business.
A concrete BusinessModel: subclass, declare identity in setUp(), and override
the revenue/cost hooks. Revenue is subscribers x price, minus the ones who
quietly cancelled this month. Family: character. >>
#sleela 2.5
material;
class SubscriptionModel extends BusinessModel {
< ---- 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 = 10411;
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; }
< paying seats right now >
int subscribers;
< monthly price per subscriber >
int priceCents;
< share who cancel each month (0..100) >
int churnPercent;
< cost to serve one subscriber per month >
int serviceCostCents;
void setUp(int seats, int price, int churn, int serviceCost) {
load();
configure("Subscription", KIND_SUBSCRIPTION);
if (seats < 0) { seats = 0; }
if (price < 0) { price = 0; }
if (churn < 0) { churn = 0; }
if (churn > 100) { churn = 100; }
if (serviceCost < 0) { serviceCost = 0; }
subscribers = seats;
priceCents = price;
churnPercent = churn;
serviceCostCents = serviceCost;
setUnits(seats);
}
< Subscribers who are still around after this month's churn pay full price. >
int retained() { return subscribers - (subscribers * churnPercent) / 100; }
int monthlyRevenue() { return retained() * priceCents; }
int monthlyCost() { return subscribers * serviceCostCents; }
}