···11-import Kingdom from "./kingdom";
11+import { Kingdom } from "./kingdom";
2233interface NPCPF2e {
44 flags: {
+168-24
src/kingdom.ts
···88 * @property {string} government - The id of the government
99 * @property {string} heartland - The id of the heartland
1010 * @property {string[]} boosts - An array of free boosts for the Kingdom
1111- * @property {object} leaders - Leaders of the kingdom.
1111+ * @property {LeaderInfo} leaders - Leaders of the kingdom.
1212 * @property {string[]} feats - An array of feats for the Kingdom
1313 * @property {number} size - The size of the Kingdom
1414- * @property {object} resourceDice - The resource dice for the Kingdom
1515- * @property {object} commodities - The commodities for the Kingdom
1616- * @property {object} resourcePoints - The resource points for the Kingdom
1717- * @property {object} unrest - The unrest for the Kingdom
1818- * @property {object} ruin - The ruin for the Kingdom
1919- * @property {object[]} groups - Other groups the Kingdom has relations with
2020- * @property {object} krp - The Kingdom Reputation Points
1414+ * @property {ResourceInfo} resourceDice - The resource dice for the Kingdom
1515+ * @property {CommodityInfo} commodities - The commodities for the Kingdom
1616+ * @property {ResourceInfo} resourcePoints - The resource points for the Kingdom
1717+ * @property {ResourceLimitInfo} unrest - The unrest for the Kingdom
1818+ * @property {RuinInfo} ruin - The ruin for the Kingdom
1919+ * @property {Relation[]} groups - Other groups the Kingdom has relations with
2020+ * @property {ResourceLimitInfo} krp - The Kingdom Reputation Points
2121 * @property {string[]} settlements - An array of Scene IDs for the Kingdom's settlements
2222 * @property {number} level - The level of the Kingdom
2323 */
2424-export default class Kingdom {
2424+export class Kingdom {
2525 name: string;
2626 charter: data.Charter;
2727 government: data.Government;
2828 heartland: data.Heartland;
2929 boosts: data.Boost[];
3030- leaders: object;
3030+ leaders: LeaderInfo;
3131 feats: string[];
3232 size: number;
3333- resourceDice: object;
3434- commodities: object;
3535- resourcePoints: object;
3636- unrest: object;
3737- ruin: object;
3838- groups: object[];
3939- krp: object;
3333+ resourceDice: ResourceInfo;
3434+ commodities: CommodityInfo;
3535+ resourcePoints: ResourceInfo;
3636+ unrest: ResourceLimitInfo;
3737+ ruin: RuinInfo;
3838+ groups: Relation[];
3939+ krp: ResourceLimitInfo;
4040 settlements: string[];
4141 level: number;
4242···5757 boost: data.Boost.None
5858 };
5959 this.boosts = [];
6060- this.leaders = {};
6060+ this.leaders = new LeaderInfo();
6161 this.feats = [];
6262 this.size = 0;
6363- this.resourceDice = {};
6464- this.commodities = {};
6565- this.resourcePoints = {};
6666- this.unrest = {};
6767- this.ruin = {};
6363+ this.resourceDice = new ResourceInfo();
6464+ this.commodities = new CommodityInfo();
6565+ this.resourcePoints = new ResourceInfo();
6666+ this.unrest = new ResourceLimitInfo();
6767+ this.ruin = new RuinInfo();
6868 this.groups = [];
6969- this.krp = {};
6969+ this.krp = new ResourceLimitInfo();
7070 this.settlements = [];
7171 }
7272+}
7373+7474+/**
7575+ * Information about a Kingdom's leaders.
7676+ * @typedef {Object} LeaderInfo
7777+ * @property {string} ruler - The actor ID of the ruler
7878+ * @property {string} counselor - The actor ID of the counselor
7979+ * @property {string} viceroy - The actor ID of the viceroy
8080+ * @property {string} emissary - The actor ID of the emissary
8181+ * @property {string} warden - The actor ID of the warden
8282+ * @property {stirng} general - The actor ID of the general
8383+ * @property {string} magister - The actor ID of the magister
8484+ * @property {string} treasurer - The actor ID of the treasurer
8585+ */
8686+export class LeaderInfo {
8787+ ruler: string;
8888+ counselor: string;
8989+ viceroy: string;
9090+ emissary: string;
9191+ warden: string;
9292+ general: string;
9393+ magister: string;
9494+ treasurer: string;
9595+9696+ constructor() {
9797+ this.ruler = "";
9898+ this.counselor = "";
9999+ this.viceroy = "";
100100+ this.emissary = "";
101101+ this.warden = "";
102102+ this.general = "";
103103+ this.magister = "";
104104+ this.treasurer = "";
105105+ }
106106+}
107107+108108+/**
109109+ * Information about a resource. This resource has a Next and Current value.
110110+ * @typedef {Object} ResourceInfo
111111+ * @property {number} next - The amount to add on the next turn.
112112+ * @property {number} current - The current value of this resource.
113113+ */
114114+export class ResourceInfo {
115115+ next: number;
116116+ current: number;
117117+118118+ constructor() {
119119+ this.next = 0;
120120+ this.current = 0;
121121+ }
122122+}
123123+124124+/**
125125+ * Information about the Kingdom's commodities
126126+ * @typedef {Object} CommodityInfo
127127+ * @property {ResourceInfo} ore - The amount of Ore the Kingdom has
128128+ * @property {ResourceInfo} lumber - The amount of Lumber the Kingdom has
129129+ * @property {ResourceInfo} stone - The amount of Stone the Kingdom has
130130+ * @property {ResourceInfo} food - The amount of Food the Kingdom has
131131+ * @property {ResourceInfo} luxuries - The amount of Luxuries the Kingdom has
132132+ */
133133+export class CommodityInfo {
134134+ ore: ResourceInfo;
135135+ lumber: ResourceInfo;
136136+ stone: ResourceInfo;
137137+ food: ResourceInfo;
138138+ luxuries: ResourceInfo;
139139+140140+ constructor() {
141141+ this.ore = new ResourceInfo();
142142+ this.lumber = new ResourceInfo();
143143+ this.stone = new ResourceInfo();
144144+ this.food = new ResourceInfo();
145145+ this.luxuries = new ResourceInfo();
146146+ }
147147+}
148148+149149+/**
150150+ * Information about a resource. This resource has Next, Current, and Threshold values.
151151+ * @typedef {Object} ResourceLimitInfo
152152+ * @property {number} next - The amount to add on the next turn.
153153+ * @property {number} current - The current value of this resource.
154154+ * @property {number} threshold - The maximum value of this resource.
155155+ */
156156+export class ResourceLimitInfo {
157157+ next: number;
158158+ current: number;
159159+ threshold: number;
160160+161161+ constructor() {
162162+ this.next = 0;
163163+ this.current = 0;
164164+ this.threshold = 0;
165165+ }
166166+}
167167+168168+/**
169169+ * Information about the Kingdom's Ruin values.
170170+ * @typedef {Object} RuinInfo
171171+ * @property {ResourceLimitInfo} corruption - The amount of Corruption a Kingdom has
172172+ * @property {ResourceLimitInfo} crime - The amount of Crime a Kingdom has
173173+ * @property {ResourceLimitInfo} decay - The amount of Decay a Kingdom has
174174+ * @property {ResourceLimitInfo} strife - The amount of Strife a Kingdom has
175175+ */
176176+export class RuinInfo {
177177+ corruption: ResourceLimitInfo;
178178+ crime: ResourceLimitInfo;
179179+ decay: ResourceLimitInfo;
180180+ strife: ResourceLimitInfo;
181181+182182+ constructor() {
183183+ this.corruption = new ResourceLimitInfo();
184184+ this.crime = new ResourceLimitInfo();
185185+ this.decay = new ResourceLimitInfo();
186186+ this.strife = new ResourceLimitInfo();
187187+ }
188188+}
189189+190190+/**
191191+ * Information about a relation with another group the Kingdom has.
192192+ * @typedef {Object} Relation
193193+ * @property {string} name - The name of the group
194194+ * @property {string} relation - The type of relation the Kingdom has with this group
195195+ * @property {number} dc - The base Negotiation DC for this group
196196+ * @property {boolean} atWar - Is the Kingdom at war with this group?
197197+ */
198198+export class Relation {
199199+ name: string;
200200+ relation: RelationType;
201201+ dc: number;
202202+ atWar: boolean;
203203+204204+ constructor() {
205205+ this.name = "";
206206+ this.relation = RelationType.None;
207207+ this.dc = 0;
208208+ this.atWar = false;
209209+ }
210210+}
211211+212212+export enum RelationType {
213213+ None = "none",
214214+ TradeAgreement = "tradeAgreement",
215215+ DiplomaticRelations = "diplomaticRelations"
72216}