From f7f0e44256eef16f915515e682eef2a8f4f4d6ff Mon Sep 17 00:00:00 2001 From: Alexander Zeier Date: Sat, 1 Oct 2016 17:11:06 +0200 Subject: [PATCH 1/2] Show milled cards Closes #141. --- CHANGELOG.md | 1 + less/entities.less | 4 ++++ ts/components/GameWidget.tsx | 3 ++- ts/components/GameWrapper.tsx | 5 ++++- ts/components/game/Card.tsx | 4 ++++ ts/components/game/Player.tsx | 28 ++++++++++++++++++++++++++-- ts/components/game/TwoPlayerGame.tsx | 5 ++++- ts/state/GameStateTracker.ts | 10 +++++++++- 8 files changed, 54 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65ce077e..d440eaf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Show C'Thun stats in opponent hand (#133, @azeier) - 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) ### Changed - Update dependencies diff --git a/less/entities.less b/less/entities.less index ddc8e010..cf05fb04 100644 --- a/less/entities.less +++ b/less/entities.less @@ -99,6 +99,10 @@ font-size: 1.45em; } + &.discarded { + filter: drop-shadow(0px 0px 7px rgba(255,0,0,1)) grayscale(70%); + } + &:hover { z-index: 51; diff --git a/ts/components/GameWidget.tsx b/ts/components/GameWidget.tsx index 92cbedb5..8c8eb47d 100644 --- a/ts/components/GameWidget.tsx +++ b/ts/components/GameWidget.tsx @@ -220,7 +220,8 @@ export default class GameWidget extends React.Component; + hideCards={!this.state.isRevealingCards} + diffs={this.state.gameState && this.state.gameState.diffs} />; let log = ; } interface GameWrapperState { @@ -134,6 +136,7 @@ export default class GameWrapper extends React.Component; default: return
Unsupported player count ({playerCount}).
diff --git a/ts/components/game/Card.tsx b/ts/components/game/Card.tsx index f974b7a1..227e1915 100644 --- a/ts/components/game/Card.tsx +++ b/ts/components/game/Card.tsx @@ -12,6 +12,7 @@ interface CardProps extends EntityProps, OptionProps, React.ClassAttributes { @@ -75,6 +76,9 @@ export default class Card extends React.Component { if (this.props.mulligan) { classNames.push("mulligan"); } + if (this.props.discarded) { + classNames.push("discarded"); + } let title = entity.cardId; let description = null; diff --git a/ts/components/game/Player.tsx b/ts/components/game/Player.tsx index 063bec0e..8c176533 100644 --- a/ts/components/game/Player.tsx +++ b/ts/components/game/Player.tsx @@ -20,7 +20,7 @@ import Minion from "./Minion"; import {Zone, CardType, GameTag, ChoiceType, Mulligan, PlayState, BlockType} from "../../enums" import { OptionCallbackProps, CardDataProps, CardOracleProps, AssetDirectoryProps, CardArtDirectory, - GameStateDescriptorStackProps, HideCardsProps, MulliganOracleProps + GameStateDescriptorStackProps, HideCardsProps, MulliganOracleProps, GameStateDiff } from "../../interfaces"; import GameStateDescriptor from "../../state/GameStateDescriptor"; @@ -32,6 +32,7 @@ interface PlayerProps extends OptionCallbackProps, CardDataProps, CardOracleProp choices: ChoiceList; isTop: boolean; isCurrent: boolean; + diffs?: Immutable.Set; } export default class Player extends React.Component { @@ -46,7 +47,30 @@ export default class Player extends React.Component { let activatedHeroPower = false; let action = null; - if(this.props.descriptors.count() > 0 && !this.props.choices) { + + 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) { + let entity = this.props.entities.get(Zone.GRAVEYARD).get(diff.entity); + if (entity) { + action =
; + return false; + } + } + }); + } + + if(!action && this.props.descriptors.count() > 0 && !this.props.choices) { this.props.descriptors.forEach((descriptor: GameStateDescriptor, index: number) => { let outer = this.props.descriptors.get(index + 1); let type = descriptor.type; diff --git a/ts/components/game/TwoPlayerGame.tsx b/ts/components/game/TwoPlayerGame.tsx index 2ca6bff8..96b31a89 100644 --- a/ts/components/game/TwoPlayerGame.tsx +++ b/ts/components/game/TwoPlayerGame.tsx @@ -3,7 +3,7 @@ import * as Immutable from "immutable"; import { EntityProps, OptionCallbackProps, CardDataProps, CardOracleProps, AssetDirectoryProps, - GameStateDescriptorStackProps, HideCardsProps, MulliganOracleProps + GameStateDescriptorStackProps, HideCardsProps, MulliganOracleProps, GameStateDiff } from "../../interfaces"; import Entity from "../../Entity"; import Player from "./Player"; @@ -22,6 +22,7 @@ interface TwoPlayerGameProps extends EntityProps, CardDataProps, CardOracleProps options: Immutable.Map>>; choices: Immutable.Map; endTurnOption?: Option; + diffs?: Immutable.Set; } export default class TwoPlayerGame extends React.Component { @@ -50,6 +51,7 @@ export default class TwoPlayerGame extends React.Component {this.props.optionCallback && ); diff --git a/ts/state/GameStateTracker.ts b/ts/state/GameStateTracker.ts index 02bc116b..183451a1 100644 --- a/ts/state/GameStateTracker.ts +++ b/ts/state/GameStateTracker.ts @@ -3,12 +3,13 @@ import * as Stream from "stream"; import GameStateMutator from "./GameStateMutator"; import PushDescriptorMutator from "./mutators/PushDescriptorMutator"; import IncrementTimeMutator from "./mutators/IncrementTimeMutator"; -import {BlockType, GameTag, MetaDataType, Step} from "../enums"; +import {BlockType, GameTag, MetaDataType, Step, Zone} from "../enums"; import PopDescriptorMutator from "./mutators/PopDescriptorMutator"; import SetChoicesMutator from "./mutators/SetChoicesMutator"; import EnrichDescriptorMutator from "./mutators/EnrichDescriptorMutator"; import SetOptionsMutator from "./mutators/SetOptionsMutator"; import TagChangeMutator from "./mutators/TagChangeMutator"; +import ShowEntityMutator from "./mutators/ShowEntityMutator"; /** * Follows the initial game state by applying incoming mutators to the game state. @@ -179,6 +180,13 @@ export default class GameStateTracker extends Stream.Transform { } } + //discards + if(mutator instanceof ShowEntityMutator) { + if(mutator.tags.get(''+GameTag.ZONE) === Zone.GRAVEYARD) { + timeStep = 2; + } + } + // step when playable options are available if (mutator instanceof SetOptionsMutator) { timeStep = 0; From df5823f4a53c8eff43cd4b8da4065a8cf643dffc Mon Sep 17 00:00:00 2001 From: Alexander Zeier Date: Sat, 1 Oct 2016 17:25:56 +0200 Subject: [PATCH 2/2] Show cards discarded from hand Closes #125. --- CHANGELOG.md | 1 + ts/components/game/Player.tsx | 2 +- ts/state/GameStateTracker.ts | 4 ++++ ts/state/mutators/TagChangeMutator.ts | 9 ++++++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d440eaf9..f8e3c926 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/ts/components/game/Player.tsx b/ts/components/game/Player.tsx index 8c176533..6e37e2de 100644 --- a/ts/components/game/Player.tsx +++ b/ts/components/game/Player.tsx @@ -50,7 +50,7 @@ export default class Player extends React.Component { 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 =