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; } }
/// <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 ); } } }
public void DeleteCompleteDialogueResult(string choiceID) { DbCommands.UpdateTableField( "PlayerChoices", "MarkDialogueCompleted", "0", "ChoiceIDs = " + choiceID); }
public void DeleteNodePlayerChoice() { DbCommands.UpdateTableField( "PlayerChoices", "NextNodes", "null", "ChoiceIDs = " + (playerChoicesListUI.GetSelectedItemFromGroup(playerChoicesListUI.SelectedChoice) as PlayerChoice).MyID); }
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(); }
public void MarkDialogueComplete(string choiceID) { bool isDialogueComplete = Convert.ToBoolean(DbCommands.GetCountFromTable("PlayerChoices", "ChoiceIDs = " + choiceID + " AND MarkDialogueCompleted = 1")); if (isDialogueComplete) { int activatedDialogueCount = DbCommands.GetCountFromTable("ActivatedDialogues", "SaveIDs = 0 AND Completed = 0 AND DialogueIDs = " + currentDialogueID); if (activatedDialogueCount > 0) { DbCommands.UpdateTableField("ActivatedDialogues", "Completed", "1", "SaveIDs = 0 AND DialogueIDs = " + currentDialogueID); } } }
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); }
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); }
private void UpdateGrammarTallies() { if (relatedGrammarList != null) { foreach (string[] grammarArray in relatedGrammarList) { int grammarID = int.Parse(grammarArray[0]); int currentTally = int.Parse(DbCommands.GetFieldValueFromTable( "DiscoveredVocabGrammar", "CorrectTallies", "SaveIDs = 0 " + "AND RuleIDs = " + grammarID.ToString() )); currentTally += tallyModifier; tallyShiftTotal += tallyModifier; if (currentTally >= 0) { if (currentTally <= highestTallyPossible) { DbCommands.UpdateTableField( "DiscoveredVocabGrammar", "CorrectTallies", currentTally.ToString(), "SaveIDs = 0 " + "AND RuleIDs = " + grammarID.ToString() ); } } else { currentTally = 0; } if (!grammarDetailsDict.ContainsKey(grammarID)) { string[] details = new string[2]; details[0] = currentTally.ToString(); grammarDetailsDict.Add(grammarID, details); } } } }
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]); } } } }
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; } }
public void ActivateNewDialogue(string choiceID) { Debugging.PrintDbTable("ActivatedDialogues"); int countDialogueActivateResults = DbCommands.GetCountFromQry(DbQueries.GetDialogueActivateCountFromChoiceIDqry(choiceID)); if (countDialogueActivateResults > 0) { print("Dialogue ACTIVATING!!!!"); List <string[]> dialogueActivatedList; DbCommands.GetDataStringsFromQry(DbQueries.GetCurrentActivateDialoguePlayerChoiceResultQry(choiceID), out dialogueActivatedList); foreach (string[] activatedDialogue in dialogueActivatedList) { //get characters related to activated dialogue. Set active dialogues related to each character to completed List <string[]> charactersRelatedToDialogue; DbCommands.GetDataStringsFromQry(DbQueries.GetCharsRelatedToDialogue(activatedDialogue[1]), out charactersRelatedToDialogue); foreach (string[] characterName in charactersRelatedToDialogue) { List <string[]> activeDialoguesWithCharacter; string charname = characterName[0]; DbCommands.GetDataStringsFromQry(DbQueries.GetActiveDialoguesWithCharacter(charname), out activeDialoguesWithCharacter, characterName[0]); foreach (string[] dialogueWithChar in activeDialoguesWithCharacter) { string dialogueID = dialogueWithChar[0]; print("printing active dialogues with " + charname); Debugging.PrintDbQryResults(DbQueries.GetActiveDialoguesWithCharacter(charname), charname); DbCommands.UpdateTableField("ActivatedDialogues", "Completed", "1", "DialogueIDs = " + dialogueID + " AND SaveIDs = 0"); Debugging.PrintDbTable("ActivatedDialogues"); } } DbCommands.InsertTupleToTable("ActivatedDialogues", activatedDialogue[1], "0", "0"); //activate dialogues in dialogue activated list } } }
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"; } } } } }