<commit_before>﻿using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using LessonTypes = Lesson.LessonTypes;
using CardStates = GenericCard.CardStates;
using CardTypes = GenericCard.CardTypes;


public class InPlay : MonoBehaviour {

    public List<GenericCard> Cards;

    public Player _Player;

    private static readonly Vector3 LESSON_POSITION_OFFSET = new Vector3(-255f, -60f, 15f);
    private static readonly Vector3 CREATURE_POSITION_OFFSET = new Vector3(5f, -60f, 15f);

    private static readonly Vector2 LESSON_SPACING = new Vector2(80f, 15f);
    private static readonly Vector2 CREATURE_SPACING = new Vector2(80f, 36f);

    public float InPlayTweenTime;

    public void Start()
    {
        Cards = new List<GenericCard>();
    }

    public void Add(GenericCard card)
    {
        Cards.Add(card);
        card.transform.parent = transform;

        switch (card.CardType)
        {
            case CardTypes.LESSON:
                AnimateLessonToBoard(card);
                break;
            case CardTypes.CREATURE:
                AnimateCreatureToBoard(card);
                break;
        }

        (card as PersistentCard).OnEnterInPlayAction();
    }

    public void Remove(GenericCard card)
    {
        Cards.Remove(card);

        switch (card.CardType)
        {
            case CardTypes.LESSON:
                RearrangeLessons();
                break;
            case CardTypes.CREATURE:
                RearrangeCreatures();
                break;
        }

        (card as PersistentCard).OnExitInPlayAction();
    }

    public List<GenericCard> GetCreaturesInPlay()
    {
        return Cards.FindAll(c => c.CardType == CardTypes.CREATURE);
    }

    public List<GenericCard> GetLessonsInPlay()
    {
        return Cards.FindAll(c => c.CardType == CardTypes.LESSON);
    }

    private void AnimateCreatureToBoard(GenericCard card)
    {
        Vector3 cardPosition = GetTargetPositionForCard(card);
        Helper.AddTweenToQueue(card, cardPosition, 0.3f, 0f, CardStates.IN_PLAY, false, card.State == CardStates.IN_HAND);
    }

    private void AnimateLessonToBoard(GenericCard card)
    {
        Vector3 cardPosition = GetTargetPositionForCard(card);
        Helper.AddTweenToQueue(card, cardPosition, 0.3f, 0f, CardStates.IN_PLAY, false, card.State == CardStates.IN_HAND);
    }

    

    private void RearrangeLessons()
    {
        Cards.FindAll(card => card.CardType == CardTypes.LESSON).ForEach(card => 
        {
            Vector3 cardPosition = GetTargetPositionForCard(card);
            Helper.TweenCardToPosition(card, cardPosition, CardStates.IN_PLAY);
        });
    }
    private void RearrangeCreatures()
    {
        Cards.FindAll(card => card.CardType == CardTypes.CREATURE).ForEach(card => 
        {
            Vector3 cardPosition = GetTargetPositionForCard(card);
            Helper.TweenCardToPosition(card, cardPosition, CardStates.IN_PLAY);
        });
    }

    private Vector3 GetTargetPositionForCard(GenericCard card)
    {
        int position = Cards.FindAll(c => c.CardType == card.CardType).IndexOf(card);

        Vector3 cardPosition = new Vector3();

        switch (card.CardType)
        {
            case CardTypes.LESSON:
                cardPosition = LESSON_POSITION_OFFSET;
                cardPosition.x += (position % 3) * LESSON_SPACING.x;
                cardPosition.y -= (int)(position / 3) * LESSON_SPACING.y;<commit_msg>public variable Cards is now a property<commit_after>﻿using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using LessonTypes = Lesson.LessonTypes;
using CardStates = GenericCard.CardStates;
using CardTypes = GenericCard.CardTypes;


public class InPlay : MonoBehaviour {

    public List<GenericCard> Cards {
        get { return _Cards; }
    }

    private List<GenericCard> _Cards = new List<GenericCard>();

    public Player _Player;

    private static readonly Vector3 LESSON_POSITION_OFFSET = new Vector3(-255f, -60f, 15f);
    private static readonly Vector3 CREATURE_POSITION_OFFSET = new Vector3(5f, -60f, 15f);

    private static readonly Vector2 LESSON_SPACING = new Vector2(80f, 15f);
    private static readonly Vector2 CREATURE_SPACING = new Vector2(80f, 36f);

    public float InPlayTweenTime;

    public void Add(GenericCard card)
    {
        _Cards.Add(card);
        card.transform.parent = transform;

        switch (card.CardType)
        {
            case CardTypes.LESSON:
                AnimateLessonToBoard(card);
                break;
            case CardTypes.CREATURE:
                AnimateCreatureToBoard(card);
                break;
        }

        (card as PersistentCard).OnEnterInPlayAction();
    }

    public void Remove(GenericCard card)
    {
        _Cards.Remove(card);

        switch (card.CardType)
        {
            case CardTypes.LESSON:
                RearrangeLessons();
                break;
            case CardTypes.CREATURE:
                RearrangeCreatures();
                break;
        }

        (card as PersistentCard).OnExitInPlayAction();
    }

    public List<GenericCard> GetCreaturesInPlay()
    {
        return _Cards.FindAll(c => c.CardType == CardTypes.CREATURE);
    }

    public List<GenericCard> GetLessonsInPlay()
    {
        return _Cards.FindAll(c => c.CardType == CardTypes.LESSON);
    }

    private void AnimateCreatureToBoard(GenericCard card)
    {
        Vector3 cardPosition = GetTargetPositionForCard(card);
        Helper.AddTweenToQueue(card, cardPosition, 0.3f, 0f, CardStates.IN_PLAY, false, card.State == CardStates.IN_HAND);
    }

    private void AnimateLessonToBoard(GenericCard card)
    {
        Vector3 cardPosition = GetTargetPositionForCard(card);
        Helper.AddTweenToQueue(card, cardPosition, 0.3f, 0f, CardStates.IN_PLAY, false, card.State == CardStates.IN_HAND);
    }

    

    private void RearrangeLessons()
    {
        _Cards.FindAll(card => card.CardType == CardTypes.LESSON).ForEach(card => 
        {
            Vector3 cardPosition = GetTargetPositionForCard(card);
            Helper.TweenCardToPosition(card, cardPosition, CardStates.IN_PLAY);
        });
    }
    private void RearrangeCreatures()
    {
        _Cards.FindAll(card => card.CardType == CardTypes.CREATURE).ForEach(card => 
        {
            Vector3 cardPosition = GetTargetPositionForCard(card);
            Helper.TweenCardToPosition(card, cardPosition, CardStates.IN_PLAY);
        });
    }

    private Vector3 GetTargetPositionForCard(GenericCard card)
    {
        int position = _Cards.FindAll(c => c.CardType == card.CardType).IndexOf(card);

        Vector3 cardPosition = new Vector3();

        switch (card.CardType)
        {
            case CardTypes.LESSON:
                cardPosition = LESSON_POSITION_OFFSET;
                cardPosition.x += (position % 3) * LESSON_SPACING.x;
                cardPosition.y -= (int)(position / 3) * LESSON_SPACING.y;
{'fraction_non_alphanumeric': 0.09181636726546906, 'fraction_numerical': 0.012261191901910464, 'mean_word_length': 2.4573681616559884, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 26, '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': '5422608', 'n_tokens_mistral': 2155, 'n_tokens_neox': 2017, 'n_words': 413}