<commit_before>// React view of a card
import React from "react";
require("../scss/style.scss");

let Card = React.createClass({
  render() {
    
    let cssClass = this.props.cardInfo.hasFocus ? 'playing-card active-card' : 'playing-card';
    let cssClassAttacked = this.props.cardInfo.hasAttacked ? 'has-attacked-card' : '';
    let cssClassJustPlayed = this.props.cardInfo.enteredPlayThisTurn ? 'just-played-card' : '';
    let combinedCSS = cssClass + ' ' + cssClassAttacked + ' ' + cssClassJustPlayed; 
    return (
        <div className={combinedCSS} onClick={this.clickCard}>
        {this.props.cardInfo.name}
        <br />
        {this.props.cardInfo.attack}/{this.props.cardInfo.defense}
      </div>
    );
  
  },

  // click cards in current player's hand or board
  clickCard: function() {

    // can click opponent's in play cards i
    // after player has clicked his own in play card to attack
    var hasActiveCard = false;
    var fromAttackIndex = 0;
    var attackingCard;
    for (var card of window.game.current().board) {
      if (card.hasFocus) {
        attackingCard = card;
        hasActiveCard = true;
        break;
      }
      fromAttackIndex++;
    }
    var toIndex = window.game.opponent().board.indexOf(this.props.cardInfo);
    if (toIndex != -1 && hasActiveCard) {
      var move = {"op":"attack", 
                  "from":fromAttackIndex,
                  "to": toIndex
                 };
      window.client.makeLocalMove(move);
      window.client.gameView.forceUpdate();
      card.hasAttacked = true;
      return;      
    }

    // can click to play cards in hand
    var fromIndex = window.game.current().hand.indexOf(this.props.cardInfo);
    if (fromIndex != -1) {
      this.playFromHand(fromIndex, this.props.cardInfo);
      return;
    }
    
    // can click a card in play if it's in the player's board
    // and it's not summoning sick or already attacked
    fromIndex = window.game.current().board.indexOf(this.props.cardInfo);
    if (fromIndex != -1 && 
        !this.props.cardInfo.enteredPlayThisTurn &&
        !this.props.cardInfo.hasAttacked) {
      this.clickCardInPlay(fromIndex, this.props.cardInfo);
      return;
    }

    // if it's not in their hand or board, then do nothing
<commit_msg>comments<commit_after>// React view of a card
import React from "react";
require("../scss/style.scss");

let Card = React.createClass({
  render() {
    
    let cssClass = this.props.cardInfo.hasFocus ? 'playing-card active-card' : 'playing-card';
    let cssClassAttacked = this.props.cardInfo.hasAttacked ? 'has-attacked-card' : '';
    let cssClassJustPlayed = this.props.cardInfo.enteredPlayThisTurn ? 'just-played-card' : '';
    let combinedCSS = cssClass + ' ' + cssClassAttacked + ' ' + cssClassJustPlayed; 
    return (
        <div className={combinedCSS} onClick={this.clickCard}>
        {this.props.cardInfo.name}
        <br />
        {this.props.cardInfo.attack}/{this.props.cardInfo.defense}
      </div>
    );
  
  },

  // click cards in current player's hand or board
  clickCard: function() {
    
    // ATTACK
    // can click opponent's in play cards
    // after player has clicked his own in play card to attack
    var hasActiveCard = false;
    var fromAttackIndex = 0;
    var attackingCard;
    for (var card of window.game.current().board) {
      if (card.hasFocus) {
        attackingCard = card;
        hasActiveCard = true;
        break;
      }
      fromAttackIndex++;
    }
    var toIndex = window.game.opponent().board.indexOf(this.props.cardInfo);
    if (toIndex != -1 && hasActiveCard) {
      this.attack(fromAttackIndex, toIndex, attackingCard)
      return;      
    }

    // PLAY CARD FROM HAND
    // can click to play cards in hand
    var fromIndex = window.game.current().hand.indexOf(this.props.cardInfo);
    if (fromIndex != -1) {
      this.playFromHand(fromIndex, this.props.cardInfo);
      return;
    }
    
    // HIGHLIGHT CARD, OR SMASH FACE IF ALREADY HIIGHLIGHTED
    // can click a card in play if it's in the player's board
    // and it's not summoning sick or already attacked
    fromIndex = window.game.current().board.indexOf(this.props.cardInfo);
    if (fromIndex != -1 && 
        !this.props.cardInfo.enteredPlayThisTurn &&
        !this.props.cardInfo.hasAttacked) {
      this.clickCardInPlay(fromIndex, this.props.cardInfo);
      return;
    }

    // if it's not in their hand or board, then do nothing

  },
  
  // smash creature's face
  attackCreature: function(fromAttackIndex, toIndex, attackingCard) {
    var move = {"op":"attack", 
                "from":fromAttackIndex,
                "to": toIndex
               };
    window.client.makeLocalMove(move);
    window.client.gameView.forceUpdate();
    attackingCard.hasAttacked = true;
{'fraction_non_alphanumeric': 0.12208818635607321, 'fraction_numerical': 0.0016638935108153079, 'mean_word_length': 2.487309644670051, 'pattern_counts': {'":': 6, '<': 9, '<?xml version=': 0, '>': 9, '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': '5658025', 'n_tokens_mistral': 1510, 'n_tokens_neox': 1457, 'n_words': 354}