Skip to content

Commit

Permalink
Fix minions being asleep when they shouldn't be
Browse files Browse the repository at this point in the history
Fixes #131.
  • Loading branch information
beheh committed Sep 17, 2016
1 parent 64967d1 commit 22af358
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Work around HearthSim/HearthstoneJSON#36
- Fix Shifter Zerus in hidden hand
- Improve Scrubber performance
- Fix minions being asleep when they shouldn't be

## [0.6.0] - 2016-08-21
### Added
Expand Down
10 changes: 10 additions & 0 deletions ts/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ class Entity {
return this.getTag(GameTag.ZONE_POSITION);
}

public isAsleep(controller?: Entity): boolean {
return (
this.getTag(GameTag.NUM_TURNS_IN_PLAY) == 0 &&
this.getTag(GameTag.CHARGE) <= 0 &&
!this.getTag(GameTag.UNTOUCHABLE) &&
!this.getTag(GameTag.AUTOATTACK) &&
(!controller || controller.getTag(GameTag.CURRENT_PLAYER))
);
}

public getTag(key:number):number {
return this.tags ? (+this.tags.get('' + key) || 0) : 0;
}
Expand Down
4 changes: 4 additions & 0 deletions ts/components/game/Minion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class Minion extends EntityInPlay<EntityInPlayProps> {
})
}

if (data.mechanics && data.mechanics.indexOf("AUTOATTACK") !== -1) {
entity = entity.setTag(GameTag.AUTOATTACK, 1);
}

let components = [
<InPlayCardArt
key="art"
Expand Down
4 changes: 1 addition & 3 deletions ts/components/game/visuals/InPlayCardArt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ class InPlayCardArt extends React.Component<EntityProps, {}> {
});
}

if (entity.getTag(GameTag.NUM_TURNS_IN_PLAY) == 0 &&
entity.getTag(GameTag.CHARGE) <= 0 &&
(!controller || controller.getTag(GameTag.CURRENT_PLAYER))) {
if (entity.isAsleep(controller)) {
images.push({
image: "effect_sleep.png",
classes: ["effect-sleep"]
Expand Down

0 comments on commit 22af358

Please sign in to comment.