Skip to content

Commit

Permalink
Fix: Room.getEventLog() may return string (#245)
Browse files Browse the repository at this point in the history
* fix: Room.getEventLog() may return string

* run dtslint

* docs: update changelog

---------

Co-authored-by: Wyatt Lipscomb <[email protected]>
  • Loading branch information
WyattSL and Wyatt Lipscomb authored Sep 13, 2023
1 parent 4c6dc6d commit 71265a9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Update `Game.structures` type to `OwnedStructure` ([#211](https://github.com/screepers/typed-screeps/pull/211))
- Refactor: Decoupling `FilterOption` and `FindConstant` and improve `FilterOption` ([#238](https://github.com/screepers/typed-screeps/pull/238))
- Fix: Mark `Spawning.directions` as optional ([#244](https://github.com/screepers/typed-screeps/pull/244))
- Fix: `Room.getEventLog()` may return string ([#245](https://github.com/screepers/typed-screeps/pull/245))

### Removed

Expand Down
6 changes: 5 additions & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4286,7 +4286,11 @@ interface Room {
/**
* Returns an array of events happened on the previous tick in this room.
*/
getEventLog(raw?: boolean): EventItem[];
getEventLog(raw?: false): EventItem[];
/**
* Returns an raw JSON string of events happened on the previous tick in this room.
*/
getEventLog(raw: true): string;
/**
* A shorthand to `Memory.rooms[room.name]`. You can use it for quick access the room’s specific memory data object.
*/
Expand Down
5 changes: 4 additions & 1 deletion dist/screeps-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,10 @@ function resources(o: GenericStore): ResourceConstant[] {

{
room.getEventLog();
room.getEventLog(true);
const eventStr = room.getEventLog(true);
if (eventStr.includes(`build:4`)) {
// Build occured on last tick.
}

const events = room.getEventLog();

Expand Down
6 changes: 5 additions & 1 deletion src/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ interface Room {
/**
* Returns an array of events happened on the previous tick in this room.
*/
getEventLog(raw?: boolean): EventItem[];
getEventLog(raw?: false): EventItem[];
/**
* Returns an raw JSON string of events happened on the previous tick in this room.
*/
getEventLog(raw: true): string;
/**
* A shorthand to `Memory.rooms[room.name]`. You can use it for quick access the room’s specific memory data object.
*/
Expand Down

0 comments on commit 71265a9

Please sign in to comment.