Skip to content

Purse beta ​

Class of @v12-engine/engine/ai

ts
export declare class Purse

What a computer player has to spend this think (ai.purse): its resources less what is promised and held, spent through spend. Rebuilt from the picture each think

Members ​

constructor ​

ts
constructor(registry: Registry);

Constructs a new instance of the Purse class

affords ​

ts
affords(cost: Cost | undefined, spare?: number, priority?: number): boolean;

Whether a cost can be paid by someone this important, with spare of the money left over after it (a luxury waits for gold to spare): out of what is free, and what is held by anyone less important

available ​

ts
available(priority?: number): Cost;

What someone this important may spend: what is free, and what is held by anyone less important

begin ​

ts
begin(view: AiView): void;

Starts the think's ledger from the picture: the player's resources, less what its builders on their way will pay (promised). Every hold of the think before is dropped: whoever still wants one makes it again

free ​

ts
free: Cost;

What is free to spend now, by resource: less with every spend and reserve of the think. view.me.purse is this

holdings ​

ts
holdings(): Readonly<Record<string, {
        cost: Readonly<Cost>;
        priority: number;
    }>>;

Every hold, by name: what and how important

inspect ​

ts
inspect(): PurseReport;

The ledger for the report: what is free, what is promised, what is held and by whom

money ​

ts
readonly money: ResourceId;

The resource most things cost (Registry.currency): what affords keeps spare of

promised ​

ts
promised: Cost;

What builders on their way to a site will pay as they get there, by resource

release ​

ts
release(id: string): void;

Lets a hold go: what it held is free again this think

reservation ​

ts
reservation(id: string): Readonly<Cost> | undefined;

What is held under a name

reserve ​

ts
reserve(id: string, cost: Cost, priority?: number): void;

Holds a cost aside under a name (a goal's id, a want's) for the rest of the think, with how important the holder is (0 when left out): what is free is less by it, so that nothing less important spends what is saved up. Made again each think by whoever still saves; a second hold under the same name replaces the first

reserved ​

ts
reserved(): Cost;

What is held altogether, by resource

shortOf ​

ts
shortOf(cost: Cost | undefined, priority?: number): ResourceId | undefined;

The resource a cost is short of, out of what someone this important may spend: none when it can be paid

spend ​

ts
spend(cost: Cost | undefined, priority?: number): boolean;

Pays a cost, for a command sent this think: out of what is free first, then out of what is held by anyone less important (the least important first), whose holds are less by that much. False, and nothing paid, when it cannot be

spent ​

ts
spent: Cost;

What was paid this think (spend), by resource: with promised, never more than the picture's resources (ai/checks.ts)