/// <summary> /// Attempt to start the quest. If successful, adds the quest to the list of quests. /// </summary> public void TryStart() { if (StartConditions != null) { if (StartConditions.All(cond => cond.CheckSatisfied())) { Program.Renderer.Player.ActiveQuests.Add((ID, CurrentStage)); Program.Renderer.AddCheck(Stages[CurrentStage]); } } }
public List <MatchResult> Validate(PropertyInfo actualProperty, object actualObj, object expectedObj, ParentContext parentContext = null) { var expectedProp = GetExpectedProperty(expectedObj, actualProperty); if (StartConditions.Any() && StartConditions.Any(x => x.CanStrategyStart(actualProperty, actualObj, expectedObj)) == false) { return(new List <MatchResult>()); } var expected = GetPropertyValue(expectedProp, expectedObj); var actual = GetPropertyValue(actualProperty, actualObj); if ((expected == null && actual != null) || (expected != null && actual == null)) { var result = new List <MatchResult>(); var fail = new MatchResult { Success = false, Expected = expected ?? SpecialValues.Null, Actual = actual ?? SpecialValues.Null }; if (parentContext != null) { fail.Parent = parentContext; } result.Add(fail); return(result); } if (expected == null) { return(new List <MatchResult>()); } if (parentContext != null) { if (parentContext.IsRecursive(actual)) { return(new List <MatchResult>()); } parentContext.ActualObj = actual; } return(InternalValidate(actualProperty, actualObj, expectedObj, parentContext)); }
/// <summary> /// Removes the currently selected condition on the currently selected tabPage. /// </summary> public void RemoveCondition() { if (SelectedTabControlIndex == 0 && SelectedStartCondition != null) { StartConditions.Remove(SelectedStartCondition); } else if (SelectedTabControlIndex == 1 && SelectedCancelCondition != null) { CancelConditions.Remove(SelectedCancelCondition); } else if (SelectedTabControlIndex == 2 && SelectedSubmitCondition != null) { SubmitConditions.Remove(SelectedSubmitCondition); } NotifyOfPropertyChange(() => CanRemoveCondition); NotifyOfPropertyChange(() => CanGenerate); }
/// <summary> /// Adds a new condition to the selected tabPage. /// </summary> public void AddCondition() { if (SelectedTabControlIndex == 0) { StartConditions.Add(new Condition()); } else if (SelectedTabControlIndex == 1) { CancelConditions.Add(new Condition()); } else { SubmitConditions.Add(new Condition()); } NotifyOfPropertyChange(() => CanRemoveCondition); NotifyOfPropertyChange(() => CanGenerate); }
public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine($"Quest => {Id}, Type => {Type}"); stringBuilder.AppendLine("Start conditions => "); stringBuilder.AppendLine(StartConditions.ToString()); stringBuilder.AppendLine("Complete conditions => "); stringBuilder.AppendLine("Humans =>"); stringBuilder.AppendLine(CompleteConditions[Race.Humans].ToString()); stringBuilder.AppendLine("Borgs =>"); stringBuilder.AppendLine(CompleteConditions[Race.Borguzands].ToString()); stringBuilder.AppendLine("Krips =>"); stringBuilder.AppendLine(CompleteConditions[Race.Criptizoids].ToString()); stringBuilder.AppendLine("Reward =>"); stringBuilder.AppendLine(Rewards.ToString()); return(stringBuilder.ToString()); }
public void Load(XElement element) { Id = element.GetString("id"); Type = element.GetEnum <QuestType>("type"); var startConditionsElement = element.Element("start_conditions"); StartConditions.Load(startConditionsElement); var humansCompleteConditions = element.Element("complete_conditions").Element("humans"); var borgsCompleteConditions = element.Element("complete_conditions").Element("borgs"); var kripsCompleteConditions = element.Element("complete_conditions").Element("krips"); QuestConditionCollection humanComplete = new QuestConditionCollection(); humanComplete.Load(humansCompleteConditions); QuestConditionCollection borgsComple = new QuestConditionCollection(); borgsComple.Load(borgsCompleteConditions); QuestConditionCollection kripsComplete = new QuestConditionCollection(); kripsComplete.Load(kripsCompleteConditions); CompleteConditions.TryAdd(Race.Humans, humanComplete); CompleteConditions.TryAdd(Race.Borguzands, borgsComple); CompleteConditions.TryAdd(Race.Criptizoids, kripsComplete); var rewardsElement = element.Element("rewards"); if (rewardsElement != null) { Rewards.Load(rewardsElement); } }
private void CalcValues(object sender, EventArgs e) { j++; var clickedButton = (Button)sender; if (clickedButton.Name == "btn_step0") { SetCostButtonsEnabled(); btn_step0.Enabled = false; double bo = double.Parse(tbb0.Text); double so = double.Parse(tbso.Text); int n = int.Parse(tbn.Text); double k = double.Parse(tbk.Text); double r = double.Parse(tbr.Text); double at = double.Parse(tba.Text); double b = double.Parse(tbb.Text); tbb0.Enabled = false; tbso.Enabled = false; tbn.Enabled = false; tbk.Enabled = false; tbr.Enabled = false; tba.Enabled = false; tbb.Enabled = false; var sc = new StartConditions(so, bo, n, r, at, b, k); func = new Functions(sc); double Cn = func.FindCN(); SetCNText(Cn); sharesCost = func.GetPrevSharesCost(); bondsCost = func.GetPrevBondsCost(); SetStepText(j - 1); double x = func.FindCN(); gammaval = func.FindGamma(j, sharesCost); bettaval = func.FindBetta(x, gammaval, sharesCost, bondsCost); if (gammaval == 0 && bettaval == 0) { errortext.Visible = true; //break; } SetGammaText(gammaval); SetBettaText(bettaval); } else if ((j - 1) != func.sc.N) { SetStepText(j - 1); double newSharesCost = 0; double newBondsCost = 0; switch (clickedButton.Name) { case "btn_up": newSharesCost = func.GetIncreasedSharesCost(sharesCost, func.sc.b); newBondsCost = func.GetIncreasedBondsCost(bondsCost, func.sc.b); break; case "btn_down": newSharesCost = func.GetLoweredSharesCost(sharesCost, func.sc.a); newBondsCost = func.GetLoweredBondsCost(bondsCost, func.sc.a); break; } double x = func.FindCN(); double gamma = func.FindGamma(j, newSharesCost); double betta = func.FindBetta(x, gammaval, newSharesCost, newBondsCost); sharesCost = newSharesCost; bondsCost = newBondsCost; if (gamma != 0 && betta != 0) { gammaval = gamma; bettaval = betta; SetGammaText(gammaval); SetBettaText(bettaval); } else { GiveMoneyBack(); } } else if ((j - 1) == func.sc.N) { HideValuesForLastStep(); SetStepText(j - 1); endtime.Visible = true; SetCostButtonsUnenabled(); double newSharesCost = 0; switch (clickedButton.Name) { case "btn_up": newSharesCost = func.GetIncreasedSharesCost(sharesCost, func.sc.b); if (Math.Max(0, newSharesCost - func.sc.K) != 0) { double funcPay = Math.Max(0, newSharesCost - func.sc.K); SetFuncPayText(funcPay); } else { GiveMoneyBack(); } break; case "btn_down": newSharesCost = func.GetLoweredSharesCost(sharesCost, func.sc.a); if (Math.Max(0, newSharesCost - func.sc.K) != 0) { double funcPay = Math.Max(0, newSharesCost - func.sc.K); SetFuncPayText(funcPay); } else { GiveMoneyBack(); } break; } } }
public bool StartConditionsMet(PropertyInfo actualProperty, object actualObj, object expectedObj , PropertyInfo expectedProperty = null) { return(StartConditions.All(x => x.CanStrategyStart(actualProperty, actualObj, expectedObj))); }