コード例 #1
0
 private void UpdateReadTally()
 {
     readTally = int.Parse(DbCommands.GetFieldValueFromTable(
                               "DiscoveredVocab",
                               "ReadCorrectTallies",
                               "SaveIDs = 0 " +
                               "AND EnglishText = " + DbCommands.GetParameterNameFromValue(vocab[0]) + " " +
                               "AND WelshText = " + DbCommands.GetParameterNameFromValue(vocab[1]),
                               vocab[0],
                               vocab[1]
                               ));
     readTally       += tallyModifier;
     tallyShiftTotal += tallyModifier;
     if (readTally >= 0)
     {
         if (readTally <= highestTallyPossible)
         {
             DbCommands.UpdateTableField(
                 "DiscoveredVocab",
                 "ReadCorrectTallies",
                 readTally.ToString(),
                 "SaveIDs = 0 " +
                 "AND EnglishText = " + DbCommands.GetParameterNameFromValue(vocab[0]) + " " +
                 "AND WelshText = " + DbCommands.GetParameterNameFromValue(vocab[1]),
                 vocab[0],
                 vocab[1]
                 );
         }
     }
     else
     {
         readTally = 0;
     }
 }
コード例 #2
0
ファイル: NPCs.cs プロジェクト: krothwell/WelshLearningRPG
    /// <summary>
    /// Check a list of npc names from the database against the npc names in the current scene so
    /// if the names are not there (meaning they have been removed from the scene) then the table
    /// of characters is updated to remove the scene from the character table scene field and in
    /// turn informs the user using the data dialogue UI.
    /// </summary>
    /// <param name="namesList">A list of character names</param>
    private void UpdateCharsInDbNoLongerInScene(List <string[]> namesList)
    {
        NPCs npcs = FindObjectOfType <NPCs>();

        foreach (string[] nameBox in namesList)
        {
            string npcName = nameBox[0];
            string npcParam;
            if (npcName == "")
            {
                npcParam = "''";
            }
            else
            {
                npcParam = DbCommands.GetParameterNameFromValue(npcName);
            }
            if (!npcs.IsNameInCharDict(npcName))
            {
                DbCommands.UpdateTableField(
                    "Characters",
                    "Scenes",
                    "null",
                    "CharacterNames = " + npcParam,
                    npcName
                    );
            }
        }
    }
コード例 #3
0
            public void UpdateTranslation()
            {
                string newEn = englishText.GetComponent <InputField>().text;
                string newCy = welshText.GetComponent <InputField>().text;

                /* We need to check if we are updating a value with more than one entry in translations. If so, a new value needs to be inserted
                 * to English / Welsh tables to avoid changing all of the translation entry values to the same value. This results in the translation
                 * needing to be updated rather than the English / Welsh as would otherwise be updated and the update cascaded.*/
                if (DbCommands.GetCountFromTable("VocabTranslations",
                                                 "EnglishText = " + DbCommands.GetParameterNameFromValue(CurrentEnglish),
                                                 CurrentEnglish)
                    > 1)
                {
                    DbCommands.InsertTupleToTable("EnglishVocab", newEn);
                    DbCommands.UpdateTableField("VocabTranslations",
                                                "EnglishText",
                                                newEn,
                                                "EnglishText = " + DbCommands.GetParameterNameFromValue(CurrentEnglish) +
                                                " AND " +
                                                "WelshText = " + DbCommands.GetParameterNameFromValue(CurrentWelsh),
                                                CurrentEnglish, CurrentWelsh);
                }
                else
                {
                    print("Updating English tbl");
                    DbCommands.UpdateTableField("EnglishVocab",
                                                "EnglishText",
                                                newEn,
                                                "EnglishText = " + DbCommands.GetParameterNameFromValue(CurrentEnglish),
                                                CurrentEnglish);
                    print("success");
                }
                if (DbCommands.GetCountFromTable("VocabTranslations",
                                                 "WelshText = " + DbCommands.GetParameterNameFromValue(CurrentWelsh), CurrentWelsh)
                    > 1)
                {
                    DbCommands.InsertTupleToTable("Welsh", newCy);
                    DbCommands.UpdateTableField("VocabTranslations",
                                                "WelshText",
                                                newCy,
                                                "EnglishText = " + DbCommands.GetParameterNameFromValue(newEn) +
                                                " AND " + //newEn must be used since it will have been update before, rather than simultaneously.
                                                "WelshText = " + DbCommands.GetParameterNameFromValue(CurrentWelsh),
                                                CurrentEnglish, CurrentWelsh);
                }
                else
                {
                    DbCommands.UpdateTableField("WelshVocab",
                                                "WelshText",
                                                newCy,
                                                "WelshText =  " + DbCommands.GetParameterNameFromValue(CurrentWelsh),
                                                CurrentWelsh);
                }
                CurrentEnglish = newEn;
                CurrentWelsh   = newCy;
                grammarListUI.FillRulesNotSelected();
            }
コード例 #4
0
 public void UpdateQuestInDb(string questName, string newName, string questDescription)
 {
     string[,] fields = new string[, ] {
         { "QuestNames", newName },
         { "QuestDescriptions", questDescription }
     };
     DbCommands.UpdateTableTuple("Quests",
                                 "QuestNames = " + DbCommands.GetParameterNameFromValue(questName),
                                 fields,
                                 questName);
 }
コード例 #5
0
        private string GetDialogueID(Character character)
        {
            string qry = "SELECT CharacterDialogues.DialogueIDs FROM CharacterDialogues "
                         + "INNER JOIN ActivatedDialogues ON CharacterDialogues.DialogueIDs = ActivatedDialogues.DialogueIDs "
                         + "WHERE CharacterDialogues.CharacterNames = " + DbCommands.GetParameterNameFromValue(character.CharacterName)
                         + " AND ActivatedDialogues.Completed = 0"
                         + " AND ActivatedDialogues.SaveIDs = 0";
            string dialogueID = DbCommands.GetFieldValueFromQry(qry, "DialogueIDs", character.CharacterName);

            Debugging.PrintDbQryResults(qry, character.CharacterName);
            //Debugging.PrintDbTable("ActivatedDialogues");
            return(dialogueID);
        }
コード例 #6
0
        public void EditSelectedQuest()
        {
            editMode = true;
            activateQuestDetailsBtn.GetComponent <Text>().text = "Edit quest";
            DisplayQuestDetails();
            activateQuestDetailsBtn.GetComponent <Button>().interactable = false;
            Quest  quest     = (GetSelectedItemFromGroup(selectedQuest) as Quest);
            string questName = quest.MyName;

            string[] questsData = DbCommands.GetTupleFromTable("Quests",
                                                               "QuestNames = " + DbCommands.GetParameterNameFromValue(questName), "QuestNames", questName);
            inputQuestDetailsName.text = questsData[0];
            inputQuestDetailsDesc.text = questsData[1];
        }
コード例 #7
0
            public void UpdateProficiency()
            {
                string newName      = proficiencyText.GetComponent <InputField>().text;
                string newThreshold = thresholdText.GetComponent <InputField>().text;

                DbCommands.UpdateTableField("Proficiencies",
                                            "ProficiencyNames",
                                            newName,
                                            "ProficiencyNames = " + DbCommands.GetParameterNameFromValue(CurrentProficiencyName),
                                            CurrentProficiencyName);
                DbCommands.UpdateTableField("Proficiencies",
                                            "Thresholds",
                                            newThreshold,
                                            "ProficiencyNames = " + DbCommands.GetParameterNameFromValue(newName),
                                            newName);
                CurrentProficiencyName = newName;
                CurrentThreshold       = int.Parse(newThreshold);
            }
コード例 #8
0
        public void CompleteTaskPart(string partID, string taskID, string questName)
        {
            DbCommands.InsertTupleToTable("CompletedQuestTaskParts", partID, "0");
            //print("inserted tuple to completed task parts");
            int taskPartsCount = DbCommands.GetCountFromTable("QuestTaskParts", "TaskIDs = " + taskID);
            //print("task parts with id " + taskID + " = " + taskPartsCount);
            int taskPartsCompletedCount = DbCommands.GetCountFromQry(DbQueries.GetTaskPartsCompleteFromTaskID(taskID, "0"));

            //print("task parts completed with id " + taskID + " = " + taskPartsCompletedCount);
            //Debugging.PrintDbTable("CompletedQuestTaskParts");
            if (taskPartsCount == taskPartsCompletedCount)
            {
                DbCommands.UpdateTableField("QuestTasksActivated", "Completed", "1", "TaskIDs = " + taskID + " AND SaveIDs = 0");
                int tasksCount = DbCommands.GetCountFromTable(
                    "QuestTasks",
                    "QuestNames = " + DbCommands.GetParameterNameFromValue(questName),
                    questName);
                string[] taskResults = DbCommands.GetTupleFromQry(DbQueries.GetAllTaskResultsQry(taskID));
                //string startDialogueID = DbCommands.GetFieldValueFromTable("QuestTaskStartDialogueResults", "DialogueIDs", "TaskIDs = " + taskID);
                string endCombatWithCharName = taskResults[0];
                string startDialogueID       = taskResults[1];
                if (endCombatWithCharName != "")
                {
                    combatUI.EndCombatWithCharacter(endCombatWithCharName);
                }
                if (startDialogueID != "")
                {
                    print(startDialogueID);
                    DbCommands.InsertTupleToTable("ActivatedDialogues", startDialogueID, "0", "0");
                    dialogueUI.StartNewDialogue(startDialogueID);
                }
                int tasksCompletedCount = DbCommands.GetCountFromQry(
                    DbQueries.GetTasksCompleteFromQuestName(questName, "0"),
                    questName);
                if (tasksCount == tasksCompletedCount)
                {
                    DbCommands.UpdateTableField("QuestsActivated",
                                                "Completed", "1",
                                                "SaveIDs = 0 AND QuestNames = " + DbCommands.GetParameterNameFromValue(questName),
                                                questName);
                }
            }
            SetQuestDetails(questName);
        }
コード例 #9
0
 public void UpdateInsertTag()
 {
     if (tagDetailsInput.text != null)
     {
         if (editingTag)
         {
             string[,] fieldVals = new string[, ] {
                 { "Tags", tagDetailsInput.text },
             };
             TranslationTag tt     = GetSelectedItemFromGroup(SelectedTag) as TranslationTag;
             string         tagTxt = tt.GetComponent <TranslationTag>().TagText;
             DbCommands.UpdateTableTuple("TranslationTags", "Tags = " + DbCommands.GetParameterNameFromValue(tagTxt), fieldVals, tagTxt);
             tt.GetComponent <TranslationTag>().UpdateTagDisplay(tagDetailsInput.text);
         }
         else
         {
             DbCommands.InsertTupleToTable("TranslationTags", tagDetailsInput.text);
             FillDisplayFromDb(DbQueries.GetTaggedVocabDisplayQry(), tagsList.transform, BuildTag);
         }
     }
 }
コード例 #10
0
    private void UpdateWriteSkillPoints()
    {
        WriteProficienciesHandler profienciesHandler = new WriteProficienciesHandler(vocab[0], vocab[1]);
        string writeTallyProficiency;
        int    threshold;

        profienciesHandler.GetProficiencyDetailsFromTally(writeTally, out writeTallyProficiency, out threshold);
        int writeProficiencyAcquired = DbCommands.GetCountFromTable(
            "AcquiredVocabWriteSkills",
            "EnglishText = " + DbCommands.GetParameterNameFromValue(vocab[0]) +
            " AND WelshText = " + DbCommands.GetParameterNameFromValue(vocab[1]) +
            " AND ProficiencyNames = " + DbCommands.GetParameterNameFromValue(writeTallyProficiency) +
            " AND SaveIDs = 0",
            vocab[0],
            vocab[1],
            writeTallyProficiency
            );

        if (writeProficiencyAcquired < 1)
        {
            if (writeTally >= threshold)
            {
                DbCommands.InsertTupleToTable("AcquiredVocabWriteSkills",
                                              vocab[0],
                                              vocab[1],
                                              writeTallyProficiency,
                                              "0");
                skillPointsGainedTotal++;
                vocabSkillIncremented = true;
                if (highestTallyPossible > writeTally)
                {
                    DbCommands.UpdateTableField("DiscoveredVocab", "WriteCorrectTallies", "0",
                                                "SaveIDs = 0 " +
                                                "AND EnglishText = " + DbCommands.GetParameterNameFromValue(vocab[0]) + " " +
                                                "AND WelshText = " + DbCommands.GetParameterNameFromValue(vocab[1]),
                                                vocab[0], vocab[1]);
                }
            }
        }
    }
コード例 #11
0
    private void UpdateWriteTally()
    {
        Debug.Log(vocab[0]);
        Debug.Log(vocab[1]);
        string tallyStr = (DbCommands.GetFieldValueFromTable(
                               "DiscoveredVocab",
                               "WriteCorrectTallies",
                               "SaveIDs = 0 " +
                               "AND EnglishText = " + DbCommands.GetParameterNameFromValue(vocab[0]) + " " +
                               "AND WelshText = " + DbCommands.GetParameterNameFromValue(vocab[1]),
                               vocab[0],
                               vocab[1]
                               ));

        Debug.Log(tallyStr);
        writeTally       = int.Parse(tallyStr);
        writeTally      += tallyModifier;
        tallyShiftTotal += tallyModifier;
        if (writeTally >= 0)
        {
            if (writeTally <= highestTallyPossible)
            {
                DbCommands.UpdateTableField(
                    "DiscoveredVocab",
                    "WriteCorrectTallies",
                    writeTally.ToString(),
                    "SaveIDs = 0 " +
                    "AND EnglishText = " + DbCommands.GetParameterNameFromValue(vocab[0]) + " " +
                    "AND WelshText = " + DbCommands.GetParameterNameFromValue(vocab[1]),
                    vocab[0],
                    vocab[1]
                    );
            }
        }
        else
        {
            writeTally = 0;
        }
    }
コード例 #12
0
 private void UpdateGrammarSkillPoints()
 {
     foreach (KeyValuePair <int, string[]> pair in grammarDetailsDict)
     {
         int    currentTally = int.Parse(pair.Value[0]);
         int    threshold;
         string grammarProficiency;
         GrammarProficienciesHandler grammarProficienciesHandler = new GrammarProficienciesHandler(pair.Key.ToString());
         grammarProficienciesHandler.GetProficiencyDetailsFromTally(currentTally, out grammarProficiency, out threshold);
         int grammarProficiencyAcquired = DbCommands.GetCountFromTable(
             "AcquiredGrammarSkills",
             "RuleIDs = " + pair.Key.ToString() +
             " AND ProficiencyNames = " + DbCommands.GetParameterNameFromValue(grammarProficiency) +
             " AND SaveIDs = 0",
             grammarProficiency);
         if (grammarProficiencyAcquired < 1)
         {
             if (currentTally >= threshold)
             {
                 DbCommands.InsertTupleToTable("AcquiredGrammarSkills",
                                               pair.Key.ToString(),
                                               grammarProficiency,
                                               "0");
                 skillPointsGainedTotal++;
                 pair.Value[1] = "+";
                 if (highestTallyPossible > currentTally)
                 {
                     DbCommands.UpdateTableField("DiscoveredVocabGrammar", "CorrectTallies", "0",
                                                 "SaveIDs = 0 " +
                                                 "AND RuleIDs = " + pair.Key.ToString() +
                                                 ";");
                     pair.Value[0] = "0";
                 }
             }
         }
     }
 }
コード例 #13
0
            /* */
            public void DeleteTranslation()
            {
                string[,] translationFields = new string[, ] {
                    { "EnglishText", CurrentEnglish }, { "WelshText", CurrentWelsh }
                };
                string[,] englishFields = new string[, ] {
                    { "EnglishText", CurrentEnglish }
                };
                string[,] welshFields = new string[, ] {
                    { "WelshText", CurrentWelsh }
                };
                int translationsWithEnglish = DbCommands.GetCountFromTable("VocabTranslations",
                                                                           "EnglishText = " + DbCommands.GetParameterNameFromValue(CurrentEnglish),
                                                                           CurrentEnglish);
                int translationsWithWelsh = DbCommands.GetCountFromTable("VocabTranslations",
                                                                         "WelshText = " + DbCommands.GetParameterNameFromValue(CurrentWelsh),
                                                                         CurrentWelsh);

                if (translationsWithEnglish <= 1 && translationsWithWelsh <= 1)
                {
                    DbCommands.DeleteTupleInTable("EnglishVocab", englishFields);
                    DbCommands.DeleteTupleInTable("WelshVocab", welshFields);
                }
                else if (translationsWithEnglish > 1 && translationsWithWelsh <= 1)
                {
                    DbCommands.DeleteTupleInTable("VocabTranslations", translationFields);
                    DbCommands.DeleteTupleInTable("WelshVocab", welshFields);
                }
                else if (translationsWithEnglish <= 1 && translationsWithWelsh > 1)
                {
                    DbCommands.DeleteTupleInTable("VocabTranslations", translationFields);
                    DbCommands.DeleteTupleInTable("EnglishVocab", englishFields);
                }
                else if (translationsWithEnglish > 1 && translationsWithWelsh > 1)
                {
                    DbCommands.DeleteTupleInTable("VocabTranslations", translationFields);
                }
                Destroy(gameObject);
                grammarListUI.FillRulesNotSelected();
            }
コード例 #14
0
 public void SetQuestDetails(string questName)
 {
     string[] questData = DbCommands.GetTupleFromTable("Quests", "QuestNames = " + DbCommands.GetParameterNameFromValue(questName), "QuestNames", questName);
     selectedQuestTitleLbl.text       = questData[0];
     selectedQuestDescriptionLbl.text = questData[1];
     DisplayTasksRelatedToQuest(questName);
 }
コード例 #15
0
        private void InsertWorldItemsNotInDbFromScene(string scene)
        {
            WorldItems worldItems = FindObjectOfType <WorldItems>();

            foreach (string[] worldItemDetailsArray in worldItems.WorldItemList)
            {
                bool itemExists = DbCommands.IsRecordInTable("PremadeWorldItems",
                                                             "StartingLocationX = " + DbCommands.GetParameterNameFromValue(worldItemDetailsArray[0]) + " AND " +
                                                             "StartingLocationY = " + DbCommands.GetParameterNameFromValue(worldItemDetailsArray[1]) + " AND " +
                                                             "StartingLocationZ = " + DbCommands.GetParameterNameFromValue(worldItemDetailsArray[2]) + " AND " +
                                                             "StartingParentPath = " + DbCommands.GetParameterNameFromValue(worldItemDetailsArray[3]) + " AND " +
                                                             "StartingSceneNames = " + DbCommands.GetParameterNameFromValue(scene),
                                                             worldItemDetailsArray[0],
                                                             worldItemDetailsArray[1],
                                                             worldItemDetailsArray[2],
                                                             worldItemDetailsArray[3],
                                                             scene
                                                             );
                if (!itemExists)
                {
                    DbCommands.InsertTupleToTable("PremadeWorldItems",
                                                  worldItemDetailsArray[0],   //x
                                                  worldItemDetailsArray[1],   //y
                                                  worldItemDetailsArray[2],   //z
                                                  worldItemDetailsArray[3],   //parent
                                                  scene,
                                                  worldItemDetailsArray[4]);  //item name
                }
            }
        }