private void CardAddedToPlay(ICardInPlay cardInPlay) { var heroInPlay = cardInPlay as IHeroInPlay; if (heroInPlay != null) { var heroViewModel = new PlayerCardInPlayViewModel<IHeroCard>(dispatcher, heroInPlay); Dispatch(() => heroes.Add(heroViewModel)); return; } PlayerCardInPlayViewModel viewModel = null; var allyInPlay = cardInPlay as IAllyInPlay; if (allyInPlay != null) { viewModel = new PlayerCardInPlayViewModel<IAllyCard>(dispatcher, allyInPlay); } var attachmentInPlay = cardInPlay as IAttachmentInPlay; if (attachmentInPlay != null) { viewModel = new PlayerCardInPlayViewModel<IAttachmentCard>(dispatcher, attachmentInPlay); } var treasureInPlay = cardInPlay as ITreasureInPlay; if (treasureInPlay != null) { viewModel = new PlayerCardInPlayViewModel<ITreasureCard>(dispatcher, treasureInPlay); } if (viewModel == null) return; Dispatch(() => cardsInPlay.Add(viewModel)); }
private void CardAddedToPlay(ICardInPlay cardInPlay) { var heroInPlay = cardInPlay as IHeroInPlay; if (heroInPlay != null) { var heroViewModel = new PlayerCardInPlayViewModel <IHeroCard>(dispatcher, heroInPlay); Dispatch(() => heroes.Add(heroViewModel)); return; } PlayerCardInPlayViewModel viewModel = null; var allyInPlay = cardInPlay as IAllyInPlay; if (allyInPlay != null) { viewModel = new PlayerCardInPlayViewModel <IAllyCard>(dispatcher, allyInPlay); } var attachmentInPlay = cardInPlay as IAttachmentInPlay; if (attachmentInPlay != null) { viewModel = new PlayerCardInPlayViewModel <IAttachmentCard>(dispatcher, attachmentInPlay); } var treasureInPlay = cardInPlay as ITreasureInPlay; if (treasureInPlay != null) { viewModel = new PlayerCardInPlayViewModel <ITreasureCard>(dispatcher, treasureInPlay); } if (viewModel == null) { return; } Dispatch(() => cardsInPlay.Add(viewModel)); }