Skip to content

Commit 0c9bf2c

Browse files
added in between to static numeric variable comparison (AscensionGameDev#2668)
1 parent e181f38 commit 0c9bf2c

File tree

7 files changed

+105
-32
lines changed

7 files changed

+105
-32
lines changed

Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionMetadata/IntegerVariableComparison.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Intersect.Enums;
21
using Intersect.Framework.Core.GameObjects.Events;
32

43
namespace Intersect.Framework.Core.GameObjects.Conditions.ConditionMetadata;
@@ -13,5 +12,7 @@ public partial class IntegerVariableComparison : VariableComparison
1312

1413
public long Value { get; set; }
1514

15+
public long MaxValue { get; set; }
16+
1617
public bool TimeSystem { get; set; }
1718
}

Framework/Intersect.Framework.Core/GameObjects/Events/VariableComparator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ public enum VariableComparator
1313
Less,
1414

1515
NotEqual,
16+
17+
Between,
1618
}

Intersect.Editor/Forms/Editors/Events/Event Commands/Conditions/ConditionControl_PlayerStat.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ public void InitLocalization()
2727
}
2828

2929
cmbLevelComparator.Items.Clear();
30-
for (var i = 0; i < Strings.EventConditional.comparators.Count; i++)
31-
{
32-
cmbLevelComparator.Items.Add(Strings.EventConditional.comparators[i]);
33-
}
30+
cmbLevelComparator.Items.AddRange(Strings.EventConditional.comparators.Values.ToArray());
3431

3532
chkStatIgnoreBuffs.Text = Strings.EventConditional.ignorestatbuffs;
3633
}

Intersect.Editor/Forms/Editors/Events/Event Commands/Conditions/ConditionControl_Variable.Designer.cs

Lines changed: 47 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Intersect.Editor/Forms/Editors/Events/Event Commands/Conditions/ConditionControl_Variable.cs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public ConditionControl_Variable(EventCommandConditionalBranch parent)
1818

1919
nudVariableValue.Minimum = long.MinValue;
2020
nudVariableValue.Maximum = long.MaxValue;
21+
nudVariableMaxValue.Minimum = long.MinValue;
22+
nudVariableMaxValue.Maximum = long.MaxValue;
23+
2124
InitLocalization();
2225
}
2326

@@ -41,11 +44,7 @@ public void InitLocalization()
4144
rdoVarCompareGuildVar.Text = Strings.EventConditional.guildvariablevalue;
4245
rdoVarCompareUserVar.Text = Strings.EventConditional.UserVariableValue;
4346
cmbNumericComparitor.Items.Clear();
44-
for (var i = 0; i < Strings.EventConditional.comparators.Count; i++)
45-
{
46-
cmbNumericComparitor.Items.Add(Strings.EventConditional.comparators[i]);
47-
}
48-
47+
cmbNumericComparitor.Items.AddRange(Strings.EventConditional.comparators.Values.ToArray());
4948
cmbNumericComparitor.SelectedIndex = 0;
5049

5150
//Boolean Variable
@@ -359,6 +358,7 @@ private void TryLoadVariableIntegerComparison(VariableComparison comparison)
359358
{
360359
rdoVarCompareStaticValue.Checked = true;
361360
nudVariableValue.Value = integerComparison.Value;
361+
nudVariableMaxValue.Value = integerComparison.MaxValue;
362362
}
363363

364364
UpdateNumericVariableElements();
@@ -435,6 +435,10 @@ private IntegerVariableComparison GetNumericVariableComparison()
435435
if (rdoVarCompareStaticValue.Checked)
436436
{
437437
comparison.Value = (long)nudVariableValue.Value;
438+
if (comparison.Comparator == VariableComparator.Between)
439+
{
440+
comparison.MaxValue = (long)nudVariableMaxValue.Value;
441+
}
438442
}
439443
else if (rdoVarCompareGlobalVar.Checked)
440444
{
@@ -483,10 +487,23 @@ private StringVariableComparison GetStringVariableComparison()
483487
private void UpdateNumericVariableElements()
484488
{
485489
nudVariableValue.Enabled = rdoVarCompareStaticValue.Checked;
490+
nudVariableMaxValue.Enabled =
491+
rdoVarCompareStaticValue.Checked &&
492+
cmbNumericComparitor.SelectedIndex == (int)VariableComparator.Between;
493+
494+
var isBetween =
495+
rdoVarCompareStaticValue.Checked &&
496+
cmbNumericComparitor.SelectedIndex == (int)VariableComparator.Between;
497+
498+
rdoVarComparePlayerVar.Enabled = rdoVarComparePlayerVar.Checked || !isBetween;
486499
cmbComparePlayerVar.Enabled = rdoVarComparePlayerVar.Checked;
500+
rdoVarCompareGlobalVar.Enabled = rdoVarCompareGlobalVar.Checked || !isBetween;
487501
cmbCompareGlobalVar.Enabled = rdoVarCompareGlobalVar.Checked;
502+
rdoVarCompareGuildVar.Enabled = rdoVarCompareGuildVar.Checked || !isBetween;
488503
cmbCompareGuildVar.Enabled = rdoVarCompareGuildVar.Checked;
504+
rdoVarCompareUserVar.Enabled = rdoVarCompareUserVar.Checked || !isBetween;
489505
cmbCompareUserVar.Enabled = rdoVarCompareUserVar.Checked;
506+
rdoTimeSystem.Enabled = rdoTimeSystem.Checked || !isBetween;
490507
}
491508

492509
#endregion
@@ -588,5 +605,15 @@ private void lblStringTextVariables_Click(object sender, EventArgs e)
588605
BrowserUtils.Open("http://www.ascensiongamedev.com/community/topic/749-event-text-variables/");
589606
}
590607

608+
private void cmbNumericComparitor_SelectedIndexChanged(object sender, EventArgs e)
609+
{
610+
if (cmbNumericComparitor.SelectedIndex == (int)VariableComparator.Between && !rdoVarCompareStaticValue.Checked)
611+
{
612+
rdoVarCompareStaticValue.Checked = true;
613+
}
614+
615+
UpdateNumericVariableElements();
616+
}
617+
591618
#endregion
592619
}

Intersect.Editor/Localization/Strings.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,10 @@ public static string GetVariableComparisonString(IntegerVariableComparison compa
479479
case VariableComparator.NotEqual:
480480
pVar = EventConditionDesc.notequal.ToString(value);
481481

482+
break;
483+
case VariableComparator.Between:
484+
pVar = EventConditionDesc.Between.ToString(value, comparison.MaxValue);
485+
482486
break;
483487
}
484488

@@ -2457,14 +2461,15 @@ public partial struct EventConditional
24572461
{1, @"Contains"}
24582462
};
24592463

2460-
public static Dictionary<int, LocalizedString> comparators = new Dictionary<int, LocalizedString>
2464+
public static Dictionary<VariableComparator, LocalizedString> comparators = new()
24612465
{
2462-
{0, @"Equal To"},
2463-
{1, @"Greater Than or Equal To"},
2464-
{2, @"Less Than or Equal To"},
2465-
{3, @"Greater Than"},
2466-
{4, @"Less Than"},
2467-
{5, @"Does Not Equal"}
2466+
{VariableComparator.Equal, @"Equal To"},
2467+
{VariableComparator.GreaterOrEqual, @"Greater Than or Equal To"},
2468+
{VariableComparator.LesserOrEqual, @"Less Than or Equal To"},
2469+
{VariableComparator.Greater, @"Greater Than"},
2470+
{VariableComparator.Less, @"Less Than"},
2471+
{VariableComparator.NotEqual, @"Does Not Equal"},
2472+
{VariableComparator.Between, @"Between"},
24682473
};
24692474

24702475
public static Dictionary<ConditionType, LocalizedString> conditions = new Dictionary<ConditionType, LocalizedString>
@@ -2663,6 +2668,8 @@ public partial struct EventConditionDesc
26632668

26642669
public static LocalizedString beforetask = @", Before Task: {00}";
26652670

2671+
public static LocalizedString Between = @"between {00} and {01}";
2672+
26662673
public static LocalizedString checkequippedslot = @"Player has slot {00} occupied";
26672674

26682675
public static LocalizedString Class = @"Player's class is {00}";

Intersect.Server.Core/Entities/Events/Conditions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,13 @@ Event instance
691691
return true;
692692
}
693693

694+
break;
695+
case VariableComparator.Between:
696+
if (varVal >= comparison.Value && varVal <= comparison.MaxValue)
697+
{
698+
return true;
699+
}
700+
694701
break;
695702
}
696703

0 commit comments

Comments
 (0)