public static int SaveQuestConnectionRequirement(QuestConnectionRequirement input, QuestConnection connection) { IQuestRepository repo = new EFQuestRepository(); var QuestConnectionRequirement = repo.QuestConnectionRequirements.FirstOrDefault(q => q.Id == input.Id); // QuestState dbState = repo.QuestStates.FirstOrDefault(s => s.Id == state.Id); if (QuestConnectionRequirement == null) { QuestConnectionRequirement = new QuestConnectionRequirement { QuestId = connection.QuestId, }; } QuestConnectionRequirement.Id = input.Id; QuestConnectionRequirement.Operator = input.Operator; QuestConnectionRequirement.RequirementType = input.RequirementType; QuestConnectionRequirement.RequirementValue = input.RequirementValue; if (input.VariabledbName != null) { QuestConnectionRequirement.VariabledbName = input.VariabledbName.ToUpper(); } QuestConnectionRequirement.QuestConnectionId = repo.QuestConnections.FirstOrDefault(q => q.Id == connection.Id); QuestConnectionRequirement.QuestConnectionRequirementName = input.QuestConnectionRequirementName; QuestConnectionRequirement.RollModifier = input.RollModifier; QuestConnectionRequirement.RollOffset = input.RollOffset; QuestConnectionRequirement.IsRandomRoll = input.IsRandomRoll; repo.SaveQuestConnectionRequirement(QuestConnectionRequirement); return(QuestConnectionRequirement.Id); }
public void SaveQuestConnectionRequirement(QuestConnectionRequirement QuestConnectionRequirement) { if (QuestConnectionRequirement.Id == 0) { context.QuestConnectionRequirements.Add(QuestConnectionRequirement); } else { var editMe = context.QuestConnectionRequirements.Find(QuestConnectionRequirement.Id); if (editMe != null) { // dbEntry.Name = QuestConnectionRequirement.Name; // dbEntry.Message = QuestConnectionRequirement.Message; // dbEntry.TimeStamp = QuestConnectionRequirement.TimeStamp; } } try { context.SaveChanges(); } catch (OptimisticConcurrencyException) { //context.(RefreshMode.ClientWins, dbModels.Models.QuestConnectionRequirement); //context.SaveChanges(); } // context.SaveChanges(); }
public virtual ActionResult QuestConnectionRequirement(int Id, int QuestId, int QuestConnectionId) { IQuestRepository repo = new EFQuestRepository(); var QuestConnectionRequirement = repo.QuestConnectionRequirements.FirstOrDefault(q => q.Id == Id); var connection = repo.QuestConnections.FirstOrDefault(q => q.Id == QuestConnectionId); if (QuestConnectionRequirement == null) { QuestConnectionRequirement = new QuestConnectionRequirement { QuestId = QuestId, QuestConnectionRequirementName = "[UNNAMED REQUIREMENT]", }; QuestConnectionRequirement.QuestConnectionId = connection; } else { } var output = new QuestConnectionRequirementFormViewModel(); output.QuestConnectionRequirement = QuestConnectionRequirement; output.QuestConnection = connection; return(PartialView(MVC.QuestWriter.Views.QuestConnectionRequirement, output)); }
private static bool ExpressionIsTrue(float playerValue, QuestConnectionRequirement q) { var requirementValue = Convert.ToSingle(q.RequirementValue); var isAvailable = false; if (q.Operator == (int)QuestStatics.Operator.Less_Than) { if (playerValue < requirementValue) { isAvailable = true; } } else if (q.Operator == (int)QuestStatics.Operator.Less_Than_Or_Equal) { if (playerValue <= requirementValue) { isAvailable = true; } } else if (q.Operator == (int)QuestStatics.Operator.Equal_To) { if (playerValue == requirementValue) { isAvailable = true; } } else if (q.Operator == (int)QuestStatics.Operator.Greater_Than_Or_Equal) { if (playerValue >= requirementValue) { isAvailable = true; } } else if (q.Operator == (int)QuestStatics.Operator.Greater_Than) { if (playerValue > requirementValue) { isAvailable = true; } } else if (q.Operator == (int)QuestStatics.Operator.Not_Equal_To) { if (playerValue != requirementValue) { isAvailable = true; } } return(isAvailable); }
/// <summary> /// Return the player's stat of a given QuestConnectionRequirement. Ex: player has 50 luck /// </summary> /// <param name="q">QuestConnectionRequirement to be evaluated</param> /// <param name="buffs">The player's stats</param> /// <returns></returns> private static float GetValueFromType(QuestConnectionRequirement q, BuffBox buffs) { float playerValue = 0; // get correct ability type requirement if (q.RequirementType == (int)QuestStatics.RequirementType.Discipline) { playerValue = buffs.Discipline(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Perception) { playerValue = buffs.Perception(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Charisma) { playerValue = buffs.Charisma(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Fortitude) { playerValue = buffs.Fortitude(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Agility) { playerValue = buffs.Agility(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Allure) { playerValue = buffs.Allure(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Magicka) { playerValue = buffs.Magicka(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Succour) { playerValue = buffs.Succour(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Luck) { playerValue = buffs.Luck(); } return(playerValue); }