Skip to content

Commit

Permalink
Show cards discarded from hand
Browse files Browse the repository at this point in the history
Closes #125.
  • Loading branch information
azeier authored and beheh committed Oct 6, 2016
1 parent f7f0e44 commit df5823f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Show C'Thun as a minion during ritual (#137, @azeier)
- Highlight Hero Power when it's played (#140, @azeier)
- Show cards discarded from the deck (#141, @azeier)
- Show cards discarded from the hand (#125, @azeier)

### Changed
- Update dependencies
Expand Down
2 changes: 1 addition & 1 deletion ts/components/game/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class Player extends React.Component<PlayerProps, void> {

if (this.props.diffs && this.props.diffs.count() > 0) {
this.props.diffs.forEach(diff => {
if (diff.tag === GameTag.ZONE && diff.current === Zone.GRAVEYARD && diff.previous === Zone.DECK) {
if (diff.tag === GameTag.ZONE && diff.current === Zone.GRAVEYARD && (diff.previous === Zone.DECK || diff.previous === Zone.HAND)) {
let entity = this.props.entities.get(Zone.GRAVEYARD).get(diff.entity);
if (entity) {
action = <div className="played"><Card
Expand Down
4 changes: 4 additions & 0 deletions ts/state/GameStateTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ export default class GameStateTracker extends Stream.Transform {
timeStep = 1;
}
}
if(mutator.tag === GameTag.ZONE && mutator.value === Zone.GRAVEYARD
&& (mutator.getPrevious() === Zone.DECK || mutator.getPrevious() === Zone.HAND)) {
timeStep = 2;
}
}

//discards
Expand Down
9 changes: 8 additions & 1 deletion ts/state/mutators/TagChangeMutator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default class TagChangeMutator implements GameStateMutator {
public id: number;
public tag: number;
public value: number;
private previous: number;

constructor(id: number, tag: number, value: number) {
this.id = +id;
Expand All @@ -22,6 +23,8 @@ export default class TagChangeMutator implements GameStateMutator {
return state;
}

this.previous = oldEntity.getTag(this.tag);

let newEntity = oldEntity.setTag(this.tag, this.value);

if (newEntity === oldEntity) {
Expand All @@ -32,12 +35,16 @@ export default class TagChangeMutator implements GameStateMutator {
let diff: GameStateDiff = {
entity: this.id,
tag: this.tag,
previous: oldEntity.getTag(this.tag),
previous: this.previous,
current: this.value,
};

return state
.apply(new ReplaceEntityMutator(newEntity))
.apply(new AddDiffsMutator([diff]));
}

public getPrevious(): number {
return this.previous;
}
}

0 comments on commit df5823f

Please sign in to comment.