A repository for a FoundryVTT plugin for Kingmaker homebrew.

Adding kingdom classes

+169 -25
+1 -1
src/kingdom-sheet.ts
··· 1 - import Kingdom from "./kingdom"; 1 + import { Kingdom } from "./kingdom"; 2 2 3 3 interface NPCPF2e { 4 4 flags: {
+168 -24
src/kingdom.ts
··· 8 8 * @property {string} government - The id of the government 9 9 * @property {string} heartland - The id of the heartland 10 10 * @property {string[]} boosts - An array of free boosts for the Kingdom 11 - * @property {object} leaders - Leaders of the kingdom. 11 + * @property {LeaderInfo} leaders - Leaders of the kingdom. 12 12 * @property {string[]} feats - An array of feats for the Kingdom 13 13 * @property {number} size - The size of the Kingdom 14 - * @property {object} resourceDice - The resource dice for the Kingdom 15 - * @property {object} commodities - The commodities for the Kingdom 16 - * @property {object} resourcePoints - The resource points for the Kingdom 17 - * @property {object} unrest - The unrest for the Kingdom 18 - * @property {object} ruin - The ruin for the Kingdom 19 - * @property {object[]} groups - Other groups the Kingdom has relations with 20 - * @property {object} krp - The Kingdom Reputation Points 14 + * @property {ResourceInfo} resourceDice - The resource dice for the Kingdom 15 + * @property {CommodityInfo} commodities - The commodities for the Kingdom 16 + * @property {ResourceInfo} resourcePoints - The resource points for the Kingdom 17 + * @property {ResourceLimitInfo} unrest - The unrest for the Kingdom 18 + * @property {RuinInfo} ruin - The ruin for the Kingdom 19 + * @property {Relation[]} groups - Other groups the Kingdom has relations with 20 + * @property {ResourceLimitInfo} krp - The Kingdom Reputation Points 21 21 * @property {string[]} settlements - An array of Scene IDs for the Kingdom's settlements 22 22 * @property {number} level - The level of the Kingdom 23 23 */ 24 - export default class Kingdom { 24 + export class Kingdom { 25 25 name: string; 26 26 charter: data.Charter; 27 27 government: data.Government; 28 28 heartland: data.Heartland; 29 29 boosts: data.Boost[]; 30 - leaders: object; 30 + leaders: LeaderInfo; 31 31 feats: string[]; 32 32 size: number; 33 - resourceDice: object; 34 - commodities: object; 35 - resourcePoints: object; 36 - unrest: object; 37 - ruin: object; 38 - groups: object[]; 39 - krp: object; 33 + resourceDice: ResourceInfo; 34 + commodities: CommodityInfo; 35 + resourcePoints: ResourceInfo; 36 + unrest: ResourceLimitInfo; 37 + ruin: RuinInfo; 38 + groups: Relation[]; 39 + krp: ResourceLimitInfo; 40 40 settlements: string[]; 41 41 level: number; 42 42 ··· 57 57 boost: data.Boost.None 58 58 }; 59 59 this.boosts = []; 60 - this.leaders = {}; 60 + this.leaders = new LeaderInfo(); 61 61 this.feats = []; 62 62 this.size = 0; 63 - this.resourceDice = {}; 64 - this.commodities = {}; 65 - this.resourcePoints = {}; 66 - this.unrest = {}; 67 - this.ruin = {}; 63 + this.resourceDice = new ResourceInfo(); 64 + this.commodities = new CommodityInfo(); 65 + this.resourcePoints = new ResourceInfo(); 66 + this.unrest = new ResourceLimitInfo(); 67 + this.ruin = new RuinInfo(); 68 68 this.groups = []; 69 - this.krp = {}; 69 + this.krp = new ResourceLimitInfo(); 70 70 this.settlements = []; 71 71 } 72 + } 73 + 74 + /** 75 + * Information about a Kingdom's leaders. 76 + * @typedef {Object} LeaderInfo 77 + * @property {string} ruler - The actor ID of the ruler 78 + * @property {string} counselor - The actor ID of the counselor 79 + * @property {string} viceroy - The actor ID of the viceroy 80 + * @property {string} emissary - The actor ID of the emissary 81 + * @property {string} warden - The actor ID of the warden 82 + * @property {stirng} general - The actor ID of the general 83 + * @property {string} magister - The actor ID of the magister 84 + * @property {string} treasurer - The actor ID of the treasurer 85 + */ 86 + export class LeaderInfo { 87 + ruler: string; 88 + counselor: string; 89 + viceroy: string; 90 + emissary: string; 91 + warden: string; 92 + general: string; 93 + magister: string; 94 + treasurer: string; 95 + 96 + constructor() { 97 + this.ruler = ""; 98 + this.counselor = ""; 99 + this.viceroy = ""; 100 + this.emissary = ""; 101 + this.warden = ""; 102 + this.general = ""; 103 + this.magister = ""; 104 + this.treasurer = ""; 105 + } 106 + } 107 + 108 + /** 109 + * Information about a resource. This resource has a Next and Current value. 110 + * @typedef {Object} ResourceInfo 111 + * @property {number} next - The amount to add on the next turn. 112 + * @property {number} current - The current value of this resource. 113 + */ 114 + export class ResourceInfo { 115 + next: number; 116 + current: number; 117 + 118 + constructor() { 119 + this.next = 0; 120 + this.current = 0; 121 + } 122 + } 123 + 124 + /** 125 + * Information about the Kingdom's commodities 126 + * @typedef {Object} CommodityInfo 127 + * @property {ResourceInfo} ore - The amount of Ore the Kingdom has 128 + * @property {ResourceInfo} lumber - The amount of Lumber the Kingdom has 129 + * @property {ResourceInfo} stone - The amount of Stone the Kingdom has 130 + * @property {ResourceInfo} food - The amount of Food the Kingdom has 131 + * @property {ResourceInfo} luxuries - The amount of Luxuries the Kingdom has 132 + */ 133 + export class CommodityInfo { 134 + ore: ResourceInfo; 135 + lumber: ResourceInfo; 136 + stone: ResourceInfo; 137 + food: ResourceInfo; 138 + luxuries: ResourceInfo; 139 + 140 + constructor() { 141 + this.ore = new ResourceInfo(); 142 + this.lumber = new ResourceInfo(); 143 + this.stone = new ResourceInfo(); 144 + this.food = new ResourceInfo(); 145 + this.luxuries = new ResourceInfo(); 146 + } 147 + } 148 + 149 + /** 150 + * Information about a resource. This resource has Next, Current, and Threshold values. 151 + * @typedef {Object} ResourceLimitInfo 152 + * @property {number} next - The amount to add on the next turn. 153 + * @property {number} current - The current value of this resource. 154 + * @property {number} threshold - The maximum value of this resource. 155 + */ 156 + export class ResourceLimitInfo { 157 + next: number; 158 + current: number; 159 + threshold: number; 160 + 161 + constructor() { 162 + this.next = 0; 163 + this.current = 0; 164 + this.threshold = 0; 165 + } 166 + } 167 + 168 + /** 169 + * Information about the Kingdom's Ruin values. 170 + * @typedef {Object} RuinInfo 171 + * @property {ResourceLimitInfo} corruption - The amount of Corruption a Kingdom has 172 + * @property {ResourceLimitInfo} crime - The amount of Crime a Kingdom has 173 + * @property {ResourceLimitInfo} decay - The amount of Decay a Kingdom has 174 + * @property {ResourceLimitInfo} strife - The amount of Strife a Kingdom has 175 + */ 176 + export class RuinInfo { 177 + corruption: ResourceLimitInfo; 178 + crime: ResourceLimitInfo; 179 + decay: ResourceLimitInfo; 180 + strife: ResourceLimitInfo; 181 + 182 + constructor() { 183 + this.corruption = new ResourceLimitInfo(); 184 + this.crime = new ResourceLimitInfo(); 185 + this.decay = new ResourceLimitInfo(); 186 + this.strife = new ResourceLimitInfo(); 187 + } 188 + } 189 + 190 + /** 191 + * Information about a relation with another group the Kingdom has. 192 + * @typedef {Object} Relation 193 + * @property {string} name - The name of the group 194 + * @property {string} relation - The type of relation the Kingdom has with this group 195 + * @property {number} dc - The base Negotiation DC for this group 196 + * @property {boolean} atWar - Is the Kingdom at war with this group? 197 + */ 198 + export class Relation { 199 + name: string; 200 + relation: RelationType; 201 + dc: number; 202 + atWar: boolean; 203 + 204 + constructor() { 205 + this.name = ""; 206 + this.relation = RelationType.None; 207 + this.dc = 0; 208 + this.atWar = false; 209 + } 210 + } 211 + 212 + export enum RelationType { 213 + None = "none", 214 + TradeAgreement = "tradeAgreement", 215 + DiplomaticRelations = "diplomaticRelations" 72 216 }