<commit_before>﻿using System.IO;
using System.Linq;
using HarryPotterUnity.Cards.PlayRequirements;
using HarryPotterUnity.DeckGeneration.Requirements;
using HarryPotterUnity.Enums;
using JetBrains.Annotations;
using UnityEditor;
using UnityEngine;

namespace HarryPotterExtensions
{
    [UsedImplicitly]
    public class CreateCardWindow : EditorWindow 
    {
        private struct CreateCardRequest
        {
            public string CardName { get; set; }
            public Texture2D CardGraphic { get; set; }

            public Type CardType { get; set; }
            public ClassificationTypes Classification { get; set; }

            public bool AddLessonRequirement { get; set; }
            public LessonTypes LessonType { get; set; }
            public int LessonAmtRequired { get; set; }
            
            public bool AddCardLimit { get; set; }
            public int MaxAllowedInDeck { get; set; }

            public bool IsValid
            {
                get
                {
                    return CardGraphic != null && !string.IsNullOrEmpty(CardName);
                }
            }
        }
        

        [MenuItem("Harry Potter TCG/Add New Card"), UsedImplicitly]
        public static void AddCard()
        {
            GetWindow(typeof(CreateCardWindow), true, "New Card");
        }

        private CreateCardRequest _cardRequest;
        

        private static void CreateCard(CreateCardRequest request)
        {
            GameObject card = InstantiateCardTemplate();
            card.transform.name = request.CardName;

            Material newMaterial = CreateNewMaterial(request);
            card.transform.FindChild("Front").gameObject.GetComponent<Renderer>().material = newMaterial;

            if (request.AddLessonRequirement)
            {
                var newComponent = card.AddComponent<LessonRequirement>();
                newComponent.AmountRequired = request.LessonAmtRequired;
                newComponent.LessonType = request.LessonType;
            }

            if (request.AddCardLimit)
            {
                var newComponent = card.AddComponent<DeckCardLimitRequirement>();
                newComponent.MaximumAmountAllowed = request.MaxAllowedInDeck;
            }

            //TODO: Create prefab and focus project window
            //Selection.activeObject = AssetDatabase.LoadMainAssetAtPath("Assets/Prefabs/"+prefabName+".prefab");
            //EditorUtility.FocusProjectWindow();
        }
<commit_msg>add notes and adjust namespaces<commit_after>﻿using System.Linq;
using HarryPotterUnity.Cards.PlayRequirements;
using HarryPotterUnity.DeckGeneration.Requirements;
using HarryPotterUnity.Enums;
using JetBrains.Annotations;
using UnityEditor;
using UnityEngine;

namespace HarryPotterExtensions
{
    [UsedImplicitly]
    public class CreateCardWindow : EditorWindow 
    {
        private struct CreateCardRequest
        {
            public string CardName { get; set; }
            public Texture2D CardGraphic { get; set; }

            public Type CardType { get; set; }
            public ClassificationTypes Classification { get; set; }

            public bool AddLessonRequirement { get; set; }
            public LessonTypes LessonType { get; set; }
            public int LessonAmtRequired { get; set; }
            
            public bool AddCardLimit { get; set; }
            public int MaxAllowedInDeck { get; set; }

            public bool IsValid
            {
                get
                {
                    return CardGraphic != null && !string.IsNullOrEmpty(CardName);
                }
            }
        }
        

        [MenuItem("Harry Potter TCG/Add New Card"), UsedImplicitly]
        public static void AddCard()
        {
            GetWindow(typeof(CreateCardWindow), true, "New Card");
        }

        private CreateCardRequest _cardRequest;
        

        private static void CreateCard(CreateCardRequest request)
        {
            GameObject card = InstantiateCardTemplate();
            card.transform.name = request.CardName;

            Material newMaterial = CreateNewMaterial(request);
            card.transform.FindChild("Front").gameObject.GetComponent<Renderer>().material = newMaterial;

            if (request.AddLessonRequirement)
            {
                var newComponent = card.AddComponent<LessonRequirement>();
                newComponent.AmountRequired = request.LessonAmtRequired;
                newComponent.LessonType = request.LessonType;
            }

            if (request.AddCardLimit)
            {
                var newComponent = card.AddComponent<DeckCardLimitRequirement>();
                newComponent.MaximumAmountAllowed = request.MaxAllowedInDeck;
            }

            //TODO: Create script: http://answers.unity3d.com/questions/12599/editor-script-need-to-create-class-script-automati.html
            //TODO: Create prefab and focus project window
            //Selection.activeObject = AssetDatabase.LoadMainAssetAtPath("Assets/Prefabs/"+prefabName+".prefab");
            //EditorUtility.FocusProjectWindow();
        }

{'fraction_non_alphanumeric': 0.07816449543068248, 'fraction_numerical': 0.0015555123468792534, 'mean_word_length': 2.04558910597987, 'pattern_counts': {'":': 0, '<': 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': '132834', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1260, 'n_words': 280}