예제 #1
0
 // copy constructors
 public NumerologySystem(NumerologySystem numerology_system)
 {
     if (numerology_system != null)
     {
         Name = numerology_system.Name;
         Scope = numerology_system.Scope;
         LetterValues.Clear();
         foreach (char key in numerology_system.Keys)
         {
             LetterValues.Add(key, numerology_system[key]);
         }
         AddToLetterLNumber = numerology_system.AddToLetterLNumber;
         AddToLetterWNumber = numerology_system.AddToLetterWNumber;
         AddToLetterVNumber = numerology_system.AddToLetterVNumber;
         AddToLetterCNumber = numerology_system.AddToLetterCNumber;
         AddToLetterLDistance = numerology_system.AddToLetterLDistance;
         AddToLetterWDistance = numerology_system.AddToLetterWDistance;
         AddToLetterVDistance = numerology_system.AddToLetterVDistance;
         AddToLetterCDistance = numerology_system.AddToLetterCDistance;
         AddToWordWNumber = numerology_system.AddToWordWNumber;
         AddToWordVNumber = numerology_system.AddToWordVNumber;
         AddToWordCNumber = numerology_system.AddToWordCNumber;
         AddToWordWDistance = numerology_system.AddToWordWDistance;
         AddToWordVDistance = numerology_system.AddToWordVDistance;
         AddToWordCDistance = numerology_system.AddToWordCDistance;
         AddToVerseVNumber = numerology_system.AddToVerseVNumber;
         AddToVerseCNumber = numerology_system.AddToVerseCNumber;
         AddToVerseVDistance = numerology_system.AddToVerseVDistance;
         AddToVerseCDistance = numerology_system.AddToVerseCDistance;
         AddToChapterCNumber = numerology_system.AddToChapterCNumber;
     }
 }
예제 #2
0
 public NumerologySystem(NumerologySystem numerology_system)
     : this(numerology_system.Name)
 {
     if (numerology_system != null)
     {
         this.letter_values.Clear();
         if (letter_values != null)
         {
             foreach (char key in numerology_system.Keys)
             {
                 this.letter_values.Add(key, numerology_system[key]);
             }
         }
     }
 }
예제 #3
0
 public NumerologySystem(NumerologySystem numerology_system)
     : this(numerology_system.Name)
 {
     if (numerology_system != null)
     {
         letter_values_sum = 0L;
         this.letter_values.Clear();
         if (letter_values != null)
         {
             foreach (char key in numerology_system.Keys)
             {
                 long value = numerology_system[key];
                 letter_values_sum += value;
                 this.letter_values.Add(key, value);
             }
         }
     }
 }
예제 #4
0
파일: Server.cs 프로젝트: ATouhou/QuranCode
    private static void LoadNumerologySystem(string numerology_system_name, Book book, string dynamic_text, bool overwrite)
    {
        try
        {
            string filename = Globals.VALUES_FOLDER + "/" + numerology_system_name + ".txt";
            if ((overwrite) || (!File.Exists(filename)))
            {
                File.Copy(Globals.VALUES_FOLDER + "/" + "Offline" + "/" + numerology_system_name + ".txt", filename, true);
                if (!File.Exists(filename))
                {
                    filename = Globals.VALUES_FOLDER + "/" + "Offline" + "/" + NumerologySystem.FAVORITE_NUMERORLOGY_SYSTEM + ".txt";
                }
            }

            if (File.Exists(filename))
            {
                List<string> lines = DataAccess.LoadLines(filename);

                if (s_numerology_system != null)
                {
                    // copy current numerology system and only change the name
                    s_loaded_numerology_system = new NumerologySystem(s_numerology_system, numerology_system_name);
                }
                else
                {
                    // create a new numerology system
                    s_loaded_numerology_system = new NumerologySystem(numerology_system_name);
                }

                // update letter-values
                if (s_loaded_numerology_system != null)
                {
                    s_loaded_numerology_system.LetterValues.Clear();
                    foreach (string line in lines)
                    {
                        string[] parts = line.Split('\t');
                        if (parts.Length == 2)
                        {
                            s_loaded_numerology_system.LetterValues.Add(parts[0][0], long.Parse(parts[1]));
                        }
                        else
                        {
                            throw new Exception(filename + " file format must be:\r\n\tLetter TAB Value");
                        }
                    }

                    // create a new object and rebuild it in case its scope is not Book
                    s_numerology_system = new NumerologySystem(s_loaded_numerology_system);
                    BuildNumerologySystem(book, dynamic_text);
                }
            }
        }
        catch
        {
            // ignore
        }
    }
예제 #5
0
 // copy constructor with new name
 public NumerologySystem(NumerologySystem numerology_system, string numerology_system_name)
     : this(numerology_system)
 {
     if (numerology_system != null)
     {
         Name = numerology_system_name;
     }
 }
예제 #6
0
    private static void FindBismAllahEqualsAlFatihaIndex(Client client, string extra)
    {
        if (client == null) return;
        if (client.Book == null) return;
        if (client.NumerologySystem == null) return;

        NumerologySystem backup_numerology_system = new NumerologySystem(client.NumerologySystem);

        long target_difference;
        try
        {
            target_difference = long.Parse(extra);
        }
        catch
        {
            target_difference = 0L;
        }

        // zero difference between Value(BismAllah) and ValueIndex(Al-Fatiha)
        List<ZeroDifferenceNumerologySystem> good_numerology_systems = new List<ZeroDifferenceNumerologySystem>();

        NumberType[] number_types = (NumberType[])Enum.GetValues(typeof(NumberType));
        foreach (NumberType number_type in number_types)
        {
            if (
                (number_type == NumberType.Prime) ||
                (number_type == NumberType.AdditivePrime) ||
                (number_type == NumberType.PurePrime) ||
                (number_type == NumberType.Composite) ||
                (number_type == NumberType.AdditiveComposite) ||
                (number_type == NumberType.PureComposite)
               )
            {
                NumerologySystemScope[] numerology_system_scopes = (NumerologySystemScope[])Enum.GetValues(typeof(NumerologySystemScope));
                foreach (NumerologySystemScope numerology_system_scope in numerology_system_scopes)
                {
                    switch (numerology_system_scope)
                    {
                        case NumerologySystemScope.Book:
                            {
                                client.BuildNumerologySystem(client.Book.Text);
                            }
                            break;
                        case NumerologySystemScope.Selection:
                            {
                                client.BuildNumerologySystem(client.Book.Chapters[0].Text);
                            }
                            break;
                        case NumerologySystemScope.HighlightedText:
                            {
                                client.BuildNumerologySystem(client.Book.Verses[0].Text);
                            }
                            break;
                        default:
                            break;
                    }

                    // Quran 74:30 "Over It Nineteen."
                    int PERMUTATIONS = 524288; // 2^19
                    for (int i = 0; i < PERMUTATIONS; i++)
                    {
                        client.NumerologySystem.AddToLetterLNumber = ((i & 262144) != 0);
                        client.NumerologySystem.AddToLetterWNumber = ((i & 131072) != 0);
                        client.NumerologySystem.AddToLetterVNumber = ((i & 65536) != 0);
                        client.NumerologySystem.AddToLetterCNumber = ((i & 32768) != 0);
                        client.NumerologySystem.AddToLetterLDistance = ((i & 16384) != 0);
                        client.NumerologySystem.AddToLetterWDistance = ((i & 8192) != 0);
                        client.NumerologySystem.AddToLetterVDistance = ((i & 4096) != 0);
                        client.NumerologySystem.AddToLetterCDistance = ((i & 2048) != 0);
                        client.NumerologySystem.AddToWordWNumber = ((i & 1024) != 0);
                        client.NumerologySystem.AddToWordVNumber = ((i & 512) != 0);
                        client.NumerologySystem.AddToWordCNumber = ((i & 256) != 0);
                        client.NumerologySystem.AddToWordWDistance = ((i & 128) != 0);
                        client.NumerologySystem.AddToWordVDistance = ((i & 64) != 0);
                        client.NumerologySystem.AddToWordCDistance = ((i & 32) != 0);
                        client.NumerologySystem.AddToVerseVNumber = ((i & 16) != 0);
                        client.NumerologySystem.AddToVerseCNumber = ((i & 8) != 0);
                        client.NumerologySystem.AddToVerseVDistance = ((i & 4) != 0);
                        client.NumerologySystem.AddToVerseCDistance = ((i & 2) != 0);
                        client.NumerologySystem.AddToChapterCNumber = ((i & 1) != 0);

                        long alfatiha_value = client.CalculateValue(client.Book.Chapters[0]);
                        int alfatiha_value_index = -1;
                        switch (number_type)
                        {
                            case NumberType.Prime:
                                {
                                    alfatiha_value_index = Numbers.IndexOfPrime(alfatiha_value);
                                }
                                break;
                            case NumberType.AdditivePrime:
                                {
                                    alfatiha_value_index = Numbers.IndexOfAdditivePrime(alfatiha_value);
                                }
                                break;
                            case NumberType.PurePrime:
                                {
                                    alfatiha_value_index = Numbers.IndexOfPurePrime(alfatiha_value);
                                }
                                break;
                            case NumberType.Composite:
                                {
                                    alfatiha_value_index = Numbers.IndexOfComposite(alfatiha_value);
                                }
                                break;
                            case NumberType.AdditiveComposite:
                                {
                                    alfatiha_value_index = Numbers.IndexOfAdditiveComposite(alfatiha_value);
                                }
                                break;
                            case NumberType.PureComposite:
                                {
                                    alfatiha_value_index = Numbers.IndexOfPureComposite(alfatiha_value);
                                }
                                break;
                            default:
                                break;
                        }

                        if (alfatiha_value_index != -1)
                        {
                            long bismAllah_value = client.CalculateValue(client.Book.Chapters[0].Verses[0]);

                            long difference = bismAllah_value - (long)alfatiha_value_index;
                            if (Math.Abs(difference) <= target_difference)
                            {
                                ZeroDifferenceNumerologySystem good_numerology_system = new ZeroDifferenceNumerologySystem();
                                good_numerology_system.NumerologySystem = new NumerologySystem(client.NumerologySystem);
                                good_numerology_system.NumberType = number_type;
                                good_numerology_system.BismAllahValue = bismAllah_value;
                                good_numerology_system.AlFatihaValue = alfatiha_value;
                                good_numerology_system.AlFatihaValueIndex = alfatiha_value_index;
                                good_numerology_systems.Add(good_numerology_system);
                            }
                        }

                    } // next PERMUTATION

                } // next NumerologySystemScope

                string filename = "FindBismAllahEqualsAlFatiha" + number_type.ToString() + "IndexSystem" + Globals.OUTPUT_FILE_EXT;
                string path = Globals.RESEARCH_FOLDER + "/" + filename;

                StringBuilder str = new StringBuilder();
                str.AppendLine("TextMode" +
                        "\t" + "LetterOrder" +
                        "\t" + "LetterValues" +
                        "\t" + "Scope" +
                        "\t" + "AddToLetterLNumber" +
                        "\t" + "AddToLetterWNumber" +
                        "\t" + "AddToLetterVNumber" +
                        "\t" + "AddToLetterCNumber" +
                        "\t" + "AddToLetterLDistance" +
                        "\t" + "AddToLetterWDistance" +
                        "\t" + "AddToLetterVDistance" +
                        "\t" + "AddToLetterCDistance" +
                        "\t" + "AddToWordWNumber" +
                        "\t" + "AddToWordVNumber" +
                        "\t" + "AddToWordCNumber" +
                        "\t" + "AddToWordWDistance" +
                        "\t" + "AddToWordVDistance" +
                        "\t" + "AddToWordCDistance" +
                        "\t" + "AddToVerseVNumber" +
                        "\t" + "AddToVerseCNumber" +
                        "\t" + "AddToVerseVDistance" +
                        "\t" + "AddToVerseCDistance" +
                        "\t" + "AddToChapterCNumber" +
                        "\t" + "BismAllahValue" +
                        "\t" + "AlFatihaIndex"
                    );
                foreach (ZeroDifferenceNumerologySystem good_numerology_system in good_numerology_systems)
                {
                    str.Append(good_numerology_system.NumerologySystem.ToTabbedString());
                    str.Append("\t" + good_numerology_system.BismAllahValue.ToString());
                    str.Append("\t" + good_numerology_system.AlFatihaValueIndex.ToString());
                    str.AppendLine();
                }
                PublicStorage.SaveText(path, str.ToString());
                PublicStorage.DisplayFile(path);

                // clear for next NumberType
                good_numerology_systems.Clear();

            } // if NumberType

        } // next NumberType

        client.NumerologySystem = backup_numerology_system;
    }