<commit_before>import { UserSelectedCard } from 'app/model/userSelectedCard';
import { AngularFireAuth } from 'angularfire2/auth';
import { GameService } from './../services/game.service';
import { Story } from './../model/story';
import { Game } from './../model/game';
import { CardDeckService } from './../services/card-deck.service';
import { GameControllerComponent } from './../game-controller/game-controller.component';
import { Component, OnInit, Input } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
//import 'rxjs/first';

@Component({
  selector: 'app-game',
  templateUrl: './game.component.html',
  styleUrls: ['./game.component.css'],
})
export class GameComponent implements OnInit {
  cards;
  hideFront: boolean;
  hideBack: boolean;
  cardDeck: string;
  game: Game = new Game();
  story: Story = new Story();
  stories: any[];
  currentStories: any[];
  currentCard: string;
  userStoryCards: any[];
  flipped: boolean = false;
  //theCard: string = '100';

  constructor(private router: Router, private _cardDeckService: CardDeckService, private route: ActivatedRoute,
    private gameService: GameService, private auth: AngularFireAuth) {
    this.route.data
      .do(data => console.log("Check for key:", data.game))
      .subscribe(data => this.game = data.game);

    this.gameService.getGameStories(this.game.$key)
      .subscribe(myStories => {

        this.stories = myStories;

      });
    this.gameService.getCurrentStory(this.game.$key)
      .do(story => this.story = story)
      .switchMap(story => this.gameService.getStoryUserCards(this.game.$key, story.$key))
      .subscribe(storyCards => { this.userStoryCards = storyCards });

  }

  ngOnInit() {


    //this.hideFront = false;
    //this.hideBack = true;

    //console.log("Router data from new game:",this.);

    console.log("card set is...", this.game.cardSet);
    this.cardDeck = this.game.cardSet;
    this.cards = this._cardDeckService.getCards(this.cardDeck);

  }

  flipCards() {
    if (this.flipped == false) {
      this.gameService.markFlippedFlag(this.game.$key, this.story.$key, "unhidden");
      this.flipped = true;
    } else {
      this.gameService.markFlippedFlag(this.game.$key, this.story.$key, "hidden");
      this.flipped = false;
    }
    console.log('flip the cards!');
    //this.hideFront =true;
    //this.hideBack = false;
  }

  resetCards() {
    this.gameService.markFlippedFlag(this.game.$key, this.story.$key, "hidden");
    this.gameService.deleteGameStoryCards(this.game.$key, this.story.$key);
    this.currentCard = null;
    this.cards = this._cardDeckService.getCards(this.cardDeck);
  }

  selectedCard(card: string) {

    this.currentCard = card;
    console.log("selected card: ", this.currentCard, this.auth.auth.currentUser.displayName);

    this.gameService.addCardToStory(this.game.$key, this.story.$key, this.auth.auth.currentUser.uid, this.currentCard, this.auth.auth.currentUser.displayName);
    this.gameService.markFlippedFlag(this.game.$key, this.story.$key, "hidden");
    //this.hideFront = false;
    //this.hideBack = true;
  }

  storyChange(event) {
    // this.story = event;
    // this.gameService.getStoryUserCards(this.game.$key, this.story.$key)
    //   .subscribe(storyCards => { this.userStoryCards = storyCards; });
  }

}

<commit_msg>fixed bug where selecting different story didn't clear selected card.<commit_after>import { UserSelectedCard } from 'app/model/userSelectedCard';
import { AngularFireAuth } from 'angularfire2/auth';
import { GameService } from './../services/game.service';
import { Story } from './../model/story';
import { Game } from './../model/game';
import { CardDeckService } from './../services/card-deck.service';
import { GameControllerComponent } from './../game-controller/game-controller.component';
import { Component, OnInit, Input } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
//import 'rxjs/first';

@Component({
  selector: 'app-game',
  templateUrl: './game.component.html',
  styleUrls: ['./game.component.css'],
})
export class GameComponent implements OnInit {
  cards;
  hideFront: boolean;
  hideBack: boolean;
  cardDeck: string;
  game: Game = new Game();
  story: Story = new Story();
  stories: any[];
  currentStories: any[];
  currentCard: string;
  userStoryCards: any[];
  flipped: boolean = false;
  //theCard: string = '100';

  constructor(private router: Router, private _cardDeckService: CardDeckService, private route: ActivatedRoute,
    private gameService: GameService, private auth: AngularFireAuth) {
    this.route.data
      .do(data => console.log("Check for key:", data.game))
      .subscribe(data => this.game = data.game);

    this.gameService.getGameStories(this.game.$key)
      .subscribe(myStories => {

        this.stories = myStories;

      });
    this.gameService.getCurrentStory(this.game.$key)
      .do(story => this.story = story)
      .switchMap(story => this.gameService.getStoryUserCards(this.game.$key, story.$key))
      .subscribe(storyCards => { this.userStoryCards = storyCards });

  }

  ngOnInit() {


    //this.hideFront = false;
    //this.hideBack = true;

    //console.log("Router data from new game:",this.);

    console.log("card set is...", this.game.cardSet);
    this.cardDeck = this.game.cardSet;
    this.cards = this._cardDeckService.getCards(this.cardDeck);

  }

  flipCards() {
    if (this.flipped == false) {
      this.gameService.markFlippedFlag(this.game.$key, this.story.$key, "unhidden");
      this.flipped = true;
    } else {
      this.gameService.markFlippedFlag(this.game.$key, this.story.$key, "hidden");
      this.flipped = false
        ;
    }
    console.log('flip the cards!');
    //this.hideFront =true;
    //this.hideBack = false;
  }

  resetCards() {
    this.gameService.markFlippedFlag(this.game.$key, this.story.$key, "hidden");
    this.gameService.deleteGameStoryCards(this.game.$key, this.story.$key);
    this.currentCard = null;
    this.cards = this._cardDeckService.getCards(this.cardDeck);
  }

  selectedCard(card: string) {

    this.currentCard = card;
    console.log("selected card: ", this.currentCard, this.auth.auth.currentUser.displayName);

    this.gameService.addCardToStory(this.game.$key, this.story.$key, this.auth.auth.currentUser.uid, this.currentCard, this.auth.auth.currentUser.displayName);
    this.gameService.markFlippedFlag(this.game.$key, this.story.$key, "hidden");
    //this.hideFront = false;
    //this.hideBack = true;
  }

  storyChange(event) {
    // this.story = event;
    // this.gameService.getStoryUserCards(this.game.$key, this.story.$key)
    //   .subscribe(storyCards => { this.userStoryCards = storyCards; });
    this.currentCard = null;
    this.cards = this._cardDeckService.getCards(this.cardDeck);
  }

}


{'fraction_non_alphanumeric': 0.15625911876276627, 'fraction_numerical': 0.0011672016340822876, 'mean_word_length': 3.542743538767396, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '902651', 'n_tokens_mistral': 2235, 'n_tokens_neox': 2203, 'n_words': 409}