Skip to content

Commit

Permalink
Merge pull request #172 from screepers/ptr
Browse files Browse the repository at this point in the history
July 2020 Game update
  • Loading branch information
pyrodogg authored Jun 22, 2020
2 parents 876a1ed + a77cf04 commit 5a8d094
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 5 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [3.1.3] - 2020-06-22

- Add constants `CPU_UNLOCK`, `PIXEL`, `ACCESS_KEY` ([#172](https://github.com/screepers/typed-screeps/pull/172))
- Add `Game.cpu.generatePixel()` ([#172](https://github.com/screepers/typed-screeps/pull/172))
- Add `Game.cpu.unlock()`, `Game.cpu.unlocked`, and `Game.cpu.unlockedTime` ([#172](https://github.com/screepers/typed-screeps/pull/172))

## [3.1.2] - 2020-05-12

### Added
Expand Down Expand Up @@ -286,7 +292,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Initial public `npm` release.

[unreleased]: https://github.com/screepers/typed-screeps/compare/v3.1.2...HEAD
[unreleased]: https://github.com/screepers/typed-screeps/compare/v3.1.3...HEAD
[3.1.3]: https://github.com/screepers/typed-screeps/compare/v3.1.2...v3.1.3
[3.1.2]: https://github.com/screepers/typed-screeps/compare/v3.1.1...v3.1.2
[3.1.1]: https://github.com/screepers/typed-screeps/compare/v3.1.0...v3.1.1
[3.1.0]: https://github.com/screepers/typed-screeps/compare/v3.0.1...v3.1.0
Expand Down
34 changes: 32 additions & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for Screeps 3.1.2
// Type definitions for Screeps 3.1.3
// Project: https://github.com/screeps/screeps
// Definitions by: Marko Sulamägi <https://github.com/MarkoSulamagi>
// Nhan Ho <https://github.com/NhanHo>
Expand Down Expand Up @@ -322,6 +322,11 @@ declare const RESOURCE_ESSENCE: RESOURCE_ESSENCE;
declare const RESOURCES_ALL: ResourceConstant[];

declare const SUBSCRIPTION_TOKEN: SUBSCRIPTION_TOKEN;
declare const CPU_UNLOCK: CPU_UNLOCK;
declare const PIXEL: PIXEL;
declare const ACCESS_KEY: ACCESS_KEY;

declare const PIXEL_CPU_COST: 5000;

declare const CONTROLLER_LEVELS: { [level: number]: number };
declare const CONTROLLER_STRUCTURES: Record<BuildableStructureConstant, { [level: number]: number }>;
Expand Down Expand Up @@ -736,6 +741,8 @@ declare const BOOSTS: {
};
};

declare const INTERSHARD_RESOURCES: [SUBSCRIPTION_TOKEN, CPU_UNLOCK, PIXEL, ACCESS_KEY];

declare const COMMODITIES: Record<
CommodityConstant | MineralConstant | RESOURCE_GHODIUM,
{
Expand Down Expand Up @@ -1519,7 +1526,7 @@ interface Game {
*/
powerCreeps: { [creepName: string]: PowerCreep };
/**
* An object with your global resources that are bound to the account, like subscription tokens. Each object key is a resource constant, values are resources amounts.
* An object with your global resources that are bound to the account, like pixels or cpu unlocks. Each object key is a resource constant, values are resources amounts.
*/
resources: { [key: string]: any };
/**
Expand Down Expand Up @@ -1652,6 +1659,15 @@ interface CPU {
* An object with limits for each shard with shard names as keys. You can use `setShardLimits` method to re-assign them.
*/
shardLimits: CPUShardLimits;
/**
* Whether full CPU is currently unlocked for your account.
*/
unlocked: boolean;
/**
* The time in milliseconds since UNIX epoch time until full CPU is unlocked for your account.
* This property is not defined when full CPU is not unlocked for your account or it's unlocked with a subscription.
*/
unlockedTime: number | undefined;

/**
* Get amount of CPU time used from the beginning of the current game tick. Always returns 0 in the Simulation mode.
Expand Down Expand Up @@ -1685,6 +1701,17 @@ interface CPU {
* Player code execution stops immediately.
*/
halt?(): never;
/**
* Generate 1 pixel resource unit for 5000 CPU from your bucket.
*/
generatePixel(): OK | ERR_NOT_ENOUGH_RESOURCES;

/**
* Unlock full CPU for your account for additional 24 hours.
* This method will consume 1 CPU unlock bound to your account (See `Game.resources`).
* If full CPU is not currently unlocked for your account, it may take some time (up to 5 minutes) before unlock is applied to your account.
*/
unlock(): OK | ERR_NOT_ENOUGH_RESOURCES | ERR_FULL;
}

interface HeapStatistics {
Expand Down Expand Up @@ -2501,6 +2528,9 @@ type RESOURCE_EMANATION = "emanation";
type RESOURCE_ESSENCE = "essence";

type SUBSCRIPTION_TOKEN = "token";
type CPU_UNLOCK = "cpuUnlock";
type PIXEL = "pixel";
type ACCESS_KEY = "accessKey";

type TOMBSTONE_DECAY_PER_PART = 5;

Expand Down
17 changes: 17 additions & 0 deletions dist/screeps-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ function resources(o: GenericStore): ResourceConstant[] {
}
}

// Game.cpu.unlock()
{
if (!Game.cpu.unlocked) {
if (!Game.cpu.unlockedTime) {
const unlock_state = Game.cpu.unlock();
if (unlock_state === OK) {
// Unlimited cosmic power!
}
}
}
}

// Game.getObjectById(id)

{
Expand Down Expand Up @@ -885,3 +897,8 @@ function atackPower(creep: Creep) {

creep.withdraw(factory, RESOURCE_PHLEGM);
}

// <strike>Horse armor!</strike>Pixels!
{
const ret: OK | ERR_NOT_ENOUGH_RESOURCES | ERR_FULL = Game.cpu.generatePixel();
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typed-screeps",
"version": "3.1.2",
"version": "3.1.3",
"description": "Strong TypeScript declarations for the game Screeps.",
"repository": "screepers/typed-screeps",
"types": "./dist/index.d.ts",
Expand Down
7 changes: 7 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ declare const RESOURCE_ESSENCE: RESOURCE_ESSENCE;
declare const RESOURCES_ALL: ResourceConstant[];

declare const SUBSCRIPTION_TOKEN: SUBSCRIPTION_TOKEN;
declare const CPU_UNLOCK: CPU_UNLOCK;
declare const PIXEL: PIXEL;
declare const ACCESS_KEY: ACCESS_KEY;

declare const PIXEL_CPU_COST: 5000;

declare const CONTROLLER_LEVELS: { [level: number]: number };
declare const CONTROLLER_STRUCTURES: Record<BuildableStructureConstant, { [level: number]: number }>;
Expand Down Expand Up @@ -721,6 +726,8 @@ declare const BOOSTS: {
};
};

declare const INTERSHARD_RESOURCES: [SUBSCRIPTION_TOKEN, CPU_UNLOCK, PIXEL, ACCESS_KEY];

declare const COMMODITIES: Record<
CommodityConstant | MineralConstant | RESOURCE_GHODIUM,
{
Expand Down
2 changes: 1 addition & 1 deletion src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface Game {
*/
powerCreeps: { [creepName: string]: PowerCreep };
/**
* An object with your global resources that are bound to the account, like subscription tokens. Each object key is a resource constant, values are resources amounts.
* An object with your global resources that are bound to the account, like pixels or cpu unlocks. Each object key is a resource constant, values are resources amounts.
*/
resources: { [key: string]: any };
/**
Expand Down
20 changes: 20 additions & 0 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ interface CPU {
* An object with limits for each shard with shard names as keys. You can use `setShardLimits` method to re-assign them.
*/
shardLimits: CPUShardLimits;
/**
* Whether full CPU is currently unlocked for your account.
*/
unlocked: boolean;
/**
* The time in milliseconds since UNIX epoch time until full CPU is unlocked for your account.
* This property is not defined when full CPU is not unlocked for your account or it's unlocked with a subscription.
*/
unlockedTime: number | undefined;

/**
* Get amount of CPU time used from the beginning of the current game tick. Always returns 0 in the Simulation mode.
Expand Down Expand Up @@ -102,6 +111,17 @@ interface CPU {
* Player code execution stops immediately.
*/
halt?(): never;
/**
* Generate 1 pixel resource unit for 5000 CPU from your bucket.
*/
generatePixel(): OK | ERR_NOT_ENOUGH_RESOURCES;

/**
* Unlock full CPU for your account for additional 24 hours.
* This method will consume 1 CPU unlock bound to your account (See `Game.resources`).
* If full CPU is not currently unlocked for your account, it may take some time (up to 5 minutes) before unlock is applied to your account.
*/
unlock(): OK | ERR_NOT_ENOUGH_RESOURCES | ERR_FULL;
}

interface HeapStatistics {
Expand Down
3 changes: 3 additions & 0 deletions src/literals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,9 @@ type RESOURCE_EMANATION = "emanation";
type RESOURCE_ESSENCE = "essence";

type SUBSCRIPTION_TOKEN = "token";
type CPU_UNLOCK = "cpuUnlock";
type PIXEL = "pixel";
type ACCESS_KEY = "accessKey";

type TOMBSTONE_DECAY_PER_PART = 5;

Expand Down

0 comments on commit 5a8d094

Please sign in to comment.