コード例 #1
0
        public static bool MeetsCondition(
            HasFreeInventorySlots condition,
            Player player,
            Event eventInstance,
            QuestBase questBase
            )
        {
            var quantity = condition.Quantity;

            if (condition.UseVariable)
            {
                switch (condition.VariableType)
                {
                case VariableTypes.PlayerVariable:
                    quantity = (int)player.GetVariableValue(condition.VariableId).Integer;

                    break;

                case VariableTypes.ServerVariable:
                    quantity = (int)ServerVariableBase.Get(condition.VariableId)?.Value.Integer;
                    break;
                }
            }

            // Check if the user has (or does not have when negated) the desired amount of inventory slots.
            var slots = player.FindOpenInventorySlots().Count;

            if ((!condition.Negated && slots >= quantity) || (condition.Negated && slots < quantity))
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
        private void LoadVariableList()
        {
            cmbVariable.Items.Clear();
            if (rdoPlayerVariables.Checked)
            {
                cmbVariable.Items.AddRange(PlayerVariableBase.Names);
                cmbVariable.SelectedIndex = PlayerVariableBase.ListIndex(mMyCommand.VariableId);

                if (cmbVariable.SelectedIndex != -1)
                {
                    UpdateMinMaxValues(
                        PlayerVariableBase.Get(PlayerVariableBase.IdFromList(cmbVariable.SelectedIndex)).Type
                        );
                }
            }
            else
            {
                cmbVariable.Items.AddRange(ServerVariableBase.Names);
                cmbVariable.SelectedIndex = ServerVariableBase.ListIndex(mMyCommand.VariableId);

                if (cmbVariable.SelectedIndex != -1)
                {
                    UpdateMinMaxValues(
                        ServerVariableBase.Get(ServerVariableBase.IdFromList(cmbVariable.SelectedIndex)).Type
                        );
                }
            }
        }
コード例 #3
0
        private void AssignEditorItem(Guid id)
        {
            if (id != Guid.Empty)
            {
                IDatabaseObject obj = null;
                if (rdoPlayerVariables.Checked)
                {
                    obj = PlayerVariableBase.Get(id);
                }
                else if (rdoGlobalVariables.Checked)
                {
                    obj = ServerVariableBase.Get(id);
                }

                if (obj != null)
                {
                    mEditorItem = obj;
                    if (!mChanged.Contains(obj))
                    {
                        mChanged.Add(obj);
                        obj.MakeBackup();
                    }
                }
            }
            UpdateEditor();
        }
コード例 #4
0
        public static bool MeetsCondition(
            HasItemCondition condition,
            Player player,
            Event eventInstance,
            QuestBase questBase
            )
        {
            var quantity = condition.Quantity;

            if (condition.UseVariable)
            {
                switch (condition.VariableType)
                {
                case VariableTypes.PlayerVariable:
                    quantity = (int)player.GetVariableValue(condition.VariableId).Integer;

                    break;

                case VariableTypes.ServerVariable:
                    quantity = (int)ServerVariableBase.Get(condition.VariableId)?.Value.Integer;
                    break;
                }
            }

            if ((!condition.Negated && player.CountItems(condition.ItemId) >= quantity) || (condition.Negated && player.CountItems(condition.ItemId) < quantity))
            {
                return(true);
            }

            return(false);
        }
コード例 #5
0
        public static bool MeetsCondition(
            VariableIsCondition condition,
            Player player,
            Event eventInstance,
            QuestBase questBase
            )
        {
            VariableValue value = null;

            if (condition.VariableType == VariableTypes.PlayerVariable)
            {
                value = player.GetVariableValue(condition.VariableId);
            }
            else if (condition.VariableType == VariableTypes.ServerVariable)
            {
                value = ServerVariableBase.Get(condition.VariableId)?.Value;
            }

            if (value == null)
            {
                value = new VariableValue();
            }

            return(CheckVariableComparison(value, condition.Comparison, player, eventInstance));
        }
コード例 #6
0
        private void btnAddFolder_Click(object sender, EventArgs e)
        {
            var folderName = "";
            var result     = DarkInputBox.ShowInformation(
                Strings.VariableEditor.folderprompt, Strings.VariableEditor.foldertitle, ref folderName,
                DarkDialogButton.OkCancel
                );

            if (result == DialogResult.OK && !string.IsNullOrEmpty(folderName))
            {
                if (!cmbFolder.Items.Contains(folderName))
                {
                    if (lstVariables.SelectedNode != null && lstVariables.SelectedNode.Tag != null)
                    {
                        if (rdoPlayerVariables.Checked)
                        {
                            var obj = PlayerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
                            obj.Folder = folderName;
                            mExpandedFolders.Add(folderName);
                        }
                        else if (rdoGlobalVariables.Checked)
                        {
                            var obj = ServerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
                            obj.Folder = folderName;
                            mGlobalExpandedFolders.Add(folderName);
                        }

                        InitEditor();
                        cmbFolder.Text = folderName;
                    }
                }
            }
        }
コード例 #7
0
        public static bool CheckVariableComparison(
            VariableValue currentValue,
            BooleanVariableComparison comparison,
            Player player,
            Event instance
            )
        {
            VariableValue compValue = null;

            if (comparison.CompareVariableId != Guid.Empty)
            {
                if (comparison.CompareVariableType == VariableTypes.PlayerVariable)
                {
                    compValue = player.GetVariableValue(comparison.CompareVariableId);
                }
                else if (comparison.CompareVariableType == VariableTypes.ServerVariable)
                {
                    compValue = ServerVariableBase.Get(comparison.CompareVariableId)?.Value;
                }
            }
            else
            {
                compValue         = new VariableValue();
                compValue.Boolean = comparison.Value;
            }

            if (compValue == null)
            {
                compValue = new VariableValue();
            }

            if (currentValue.Type == 0)
            {
                currentValue.Boolean = false;
            }

            if (compValue.Type != currentValue.Type)
            {
                return(false);
            }

            if (comparison.ComparingEqual)
            {
                return(currentValue.Boolean == compValue.Boolean);
            }
            else
            {
                return(currentValue.Boolean != compValue.Boolean);
            }
        }
コード例 #8
0
 private void nudVariableValue_ValueChanged(object sender, EventArgs e)
 {
     if (lstVariables.SelectedNode != null && lstVariables.SelectedNode.Tag != null)
     {
         if (rdoGlobalVariables.Checked)
         {
             var obj = ServerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
             if (obj != null)
             {
                 obj.Value.Integer = (long)nudVariableValue.Value;
                 UpdateSelection();
             }
         }
     }
 }
コード例 #9
0
 private void txtStringValue_TextChanged(object sender, EventArgs e)
 {
     if (lstVariables.SelectedNode != null && lstVariables.SelectedNode.Tag != null)
     {
         if (rdoGlobalVariables.Checked)
         {
             var obj = ServerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
             if (obj != null)
             {
                 obj.Value.String = txtStringValue.Text;
                 UpdateSelection();
             }
         }
     }
 }
コード例 #10
0
 private void cmbVariable_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (rdoPlayerVariables.Checked)
     {
         UpdateMinMaxValues(
             PlayerVariableBase.Get(PlayerVariableBase.IdFromList(cmbVariable.SelectedIndex)).Type
             );
     }
     else
     {
         UpdateMinMaxValues(
             ServerVariableBase.Get(ServerVariableBase.IdFromList(cmbVariable.SelectedIndex)).Type
             );
     }
 }
コード例 #11
0
 private void txtId_TextChanged(object sender, EventArgs e)
 {
     if (lstVariables.SelectedNode != null && lstVariables.SelectedNode.Tag != null)
     {
         if (rdoPlayerVariables.Checked)
         {
             var obj = PlayerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
             obj.TextId = txtId.Text;
         }
         else if (rdoGlobalVariables.Checked)
         {
             var obj = ServerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
             obj.TextId = txtId.Text;
         }
     }
 }
コード例 #12
0
        private void cmbBooleanValue_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstVariables.SelectedNode != null && lstVariables.SelectedNode.Tag != null)
            {
                if (rdoGlobalVariables.Checked)
                {
                    var obj = ServerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
                    if (obj != null)
                    {
                        obj.Value.Boolean = Convert.ToBoolean(cmbBooleanValue.SelectedIndex);
                        UpdateSelection();
                    }
                }

                UpdateSelection();
            }
        }
コード例 #13
0
 private void UpdateSelection()
 {
     if (lstVariables.SelectedNode != null && lstVariables.SelectedNode.Tag != null)
     {
         grpEditor.Show();
         if (rdoPlayerVariables.Checked)
         {
             var obj = PlayerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
             lstVariables.SelectedNode.Text = obj.Name;
             grpValue.Hide();
         }
         else if (rdoGlobalVariables.Checked)
         {
             var obj = ServerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
             lstVariables.SelectedNode.Text = obj.Name + " = " + obj.Value.ToString(obj.Type);
         }
     }
 }
コード例 #14
0
        private void cmbFolder_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstVariables.SelectedNode != null && lstVariables.SelectedNode.Tag != null)
            {
                if (rdoPlayerVariables.Checked)
                {
                    var obj = PlayerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
                    obj.Folder = cmbFolder.Text;
                }
                else if (rdoGlobalVariables.Checked)
                {
                    var obj = ServerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
                    obj.Folder = cmbFolder.Text;
                }

                InitEditor();
            }
        }
コード例 #15
0
        private void cmbVariableType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstVariables.SelectedNode != null && lstVariables.SelectedNode.Tag != null)
            {
                if (rdoPlayerVariables.Checked)
                {
                    var obj = PlayerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
                    obj.Type = (VariableDataTypes)(cmbVariableType.SelectedIndex + 1);
                }
                else if (rdoGlobalVariables.Checked)
                {
                    var obj = ServerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
                    obj.Type = (VariableDataTypes)(cmbVariableType.SelectedIndex + 1);
                }

                InitValueGroup();
                UpdateSelection();
            }
        }
コード例 #16
0
        private void InitValueGroup()
        {
            if (rdoPlayerVariables.Checked)
            {
                grpValue.Hide();
            }
            else
            {
                if (lstVariables.SelectedNode != null && lstVariables.SelectedNode.Tag != null)
                {
                    var obj = ServerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
                    cmbBooleanValue.Hide();
                    nudVariableValue.Hide();
                    txtStringValue.Hide();
                    switch (obj.Type)
                    {
                    case VariableDataTypes.Boolean:
                        cmbBooleanValue.Show();
                        cmbBooleanValue.SelectedIndex = Convert.ToInt32(obj.Value.Boolean);

                        break;

                    case VariableDataTypes.Integer:
                        nudVariableValue.Show();
                        nudVariableValue.Value = obj.Value.Integer;

                        break;

                    case VariableDataTypes.Number:
                        break;

                    case VariableDataTypes.String:
                        txtStringValue.Show();
                        txtStringValue.Text = obj.Value.String;

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }
        }
コード例 #17
0
        private void lstVariables_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (mChangingName)
            {
                return;
            }

            if (lstVariables.SelectedNode == null || lstVariables.SelectedNode.Tag == null)
            {
                mEditorItem = null;
                UpdateEditor();

                return;
            }

            var id = (Guid)lstVariables.SelectedNode.Tag;

            if (id != Guid.Empty)
            {
                IDatabaseObject obj = null;
                if (rdoPlayerVariables.Checked)
                {
                    obj = PlayerVariableBase.Get(id);
                }
                else if (rdoGlobalVariables.Checked)
                {
                    obj = ServerVariableBase.Get(id);
                }

                if (obj != null)
                {
                    mEditorItem = obj;
                    if (!mChanged.Contains(obj))
                    {
                        mChanged.Add(obj);
                        obj.MakeBackup();
                    }
                }
            }

            UpdateEditor();
        }
コード例 #18
0
 private void txtObjectName_TextChanged(object sender, EventArgs e)
 {
     if (lstVariables.SelectedNode != null && lstVariables.SelectedNode.Tag != null)
     {
         grpEditor.Show();
         grpValue.Hide();
         if (rdoPlayerVariables.Checked)
         {
             var obj = PlayerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
             obj.Name = txtObjectName.Text;
             lstVariables.SelectedNode.Text = obj.Name;
         }
         else if (rdoGlobalVariables.Checked)
         {
             var obj = ServerVariableBase.Get((Guid)lstVariables.SelectedNode.Tag);
             obj.Name = txtObjectName.Text;
             lstVariables.SelectedNode.Text = obj.Name + " = " + obj.Value.ToString();
         }
     }
 }
コード例 #19
0
        //GameObjectPacket
        private static void HandlePacket(GameObjectPacket packet)
        {
            var id      = packet.Id;
            var deleted = packet.Deleted;
            var json    = "";

            if (!packet.Deleted)
            {
                json = packet.Data;
            }

            switch (packet.Type)
            {
            case GameObjectType.Animation:
                if (deleted)
                {
                    var anim = AnimationBase.Get(id);
                    anim.Delete();
                }
                else
                {
                    var anim = new AnimationBase(id);
                    anim.Load(json);
                    try
                    {
                        AnimationBase.Lookup.Set(id, anim);
                    }
                    catch (Exception exception)
                    {
                        Log.Error($"Another mystery NPE. [Lookup={AnimationBase.Lookup}]");
                        if (exception.InnerException != null)
                        {
                            Log.Error(exception.InnerException);
                        }

                        Log.Error(exception);
                        Log.Error($"{nameof(id)}={id},{nameof(anim)}={anim}");

                        throw;
                    }
                }

                break;

            case GameObjectType.Class:
                if (deleted)
                {
                    var cls = ClassBase.Get(id);
                    cls.Delete();
                }
                else
                {
                    var cls = new ClassBase(id);
                    cls.Load(json);
                    ClassBase.Lookup.Set(id, cls);
                }

                break;

            case GameObjectType.Item:
                if (deleted)
                {
                    var itm = ItemBase.Get(id);
                    itm.Delete();
                }
                else
                {
                    var itm = new ItemBase(id);
                    itm.Load(json);
                    ItemBase.Lookup.Set(id, itm);
                }

                break;

            case GameObjectType.Npc:
                if (deleted)
                {
                    var npc = NpcBase.Get(id);
                    npc.Delete();
                }
                else
                {
                    var npc = new NpcBase(id);
                    npc.Load(json);
                    NpcBase.Lookup.Set(id, npc);
                }

                break;

            case GameObjectType.Projectile:
                if (deleted)
                {
                    var proj = ProjectileBase.Get(id);
                    proj.Delete();
                }
                else
                {
                    var proj = new ProjectileBase(id);
                    proj.Load(json);
                    ProjectileBase.Lookup.Set(id, proj);
                }

                break;

            case GameObjectType.Quest:
                if (deleted)
                {
                    var qst = QuestBase.Get(id);
                    qst.Delete();
                }
                else
                {
                    var qst = new QuestBase(id);
                    qst.Load(json);
                    foreach (var tsk in qst.Tasks)
                    {
                        qst.OriginalTaskEventIds.Add(tsk.Id, tsk.CompletionEventId);
                    }

                    QuestBase.Lookup.Set(id, qst);
                }

                break;

            case GameObjectType.Resource:
                if (deleted)
                {
                    var res = ResourceBase.Get(id);
                    res.Delete();
                }
                else
                {
                    var res = new ResourceBase(id);
                    res.Load(json);
                    ResourceBase.Lookup.Set(id, res);
                }

                break;

            case GameObjectType.Shop:
                if (deleted)
                {
                    var shp = ShopBase.Get(id);
                    shp.Delete();
                }
                else
                {
                    var shp = new ShopBase(id);
                    shp.Load(json);
                    ShopBase.Lookup.Set(id, shp);
                }

                break;

            case GameObjectType.Spell:
                if (deleted)
                {
                    var spl = SpellBase.Get(id);
                    spl.Delete();
                }
                else
                {
                    var spl = new SpellBase(id);
                    spl.Load(json);
                    SpellBase.Lookup.Set(id, spl);
                }

                break;

            case GameObjectType.CraftTables:
                if (deleted)
                {
                    var cft = CraftingTableBase.Get(id);
                    cft.Delete();
                }
                else
                {
                    var cft = new CraftingTableBase(id);
                    cft.Load(json);
                    CraftingTableBase.Lookup.Set(id, cft);
                }

                break;

            case GameObjectType.Crafts:
                if (deleted)
                {
                    var cft = CraftBase.Get(id);
                    cft.Delete();
                }
                else
                {
                    var cft = new CraftBase(id);
                    cft.Load(json);
                    CraftBase.Lookup.Set(id, cft);
                }

                break;

            case GameObjectType.Map:
                //Handled in a different packet
                break;

            case GameObjectType.Event:
                var wasCommon = false;
                if (deleted)
                {
                    var evt = EventBase.Get(id);
                    wasCommon = evt.CommonEvent;
                    evt.Delete();
                }
                else
                {
                    var evt = new EventBase(id);
                    evt.Load(json);
                    wasCommon = evt.CommonEvent;
                    EventBase.Lookup.Set(id, evt);
                }

                if (!wasCommon)
                {
                    return;
                }

                break;

            case GameObjectType.PlayerVariable:
                if (deleted)
                {
                    var pvar = PlayerVariableBase.Get(id);
                    pvar.Delete();
                }
                else
                {
                    var pvar = new PlayerVariableBase(id);
                    pvar.Load(json);
                    PlayerVariableBase.Lookup.Set(id, pvar);
                }

                break;

            case GameObjectType.ServerVariable:
                if (deleted)
                {
                    var svar = ServerVariableBase.Get(id);
                    svar.Delete();
                }
                else
                {
                    var svar = new ServerVariableBase(id);
                    svar.Load(json);
                    ServerVariableBase.Lookup.Set(id, svar);
                }

                break;

            case GameObjectType.Tileset:
                var obj = new TilesetBase(id);
                obj.Load(json);
                TilesetBase.Lookup.Set(id, obj);
                if (Globals.HasGameData && !packet.AnotherFollowing)
                {
                    GameContentManager.LoadTilesets();
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            GameObjectUpdatedDelegate?.Invoke(packet.Type);
        }
コード例 #20
0
        public void InitEditor()
        {
            var selectedId  = Guid.Empty;
            var folderNodes = new Dictionary <string, TreeNode>();

            if (lstVariables.SelectedNode != null && lstVariables.SelectedNode.Tag != null)
            {
                selectedId = (Guid)lstVariables.SelectedNode.Tag;
            }

            lstVariables.Nodes.Clear();

            //Fix Title
            if (rdoPlayerVariables.Checked)
            {
                grpVariables.Text = rdoPlayerVariables.Text;
            }
            else
            {
                grpVariables.Text = rdoGlobalVariables.Text;
            }

            grpEditor.Hide();
            cmbBooleanValue.Hide();
            nudVariableValue.Hide();
            txtStringValue.Hide();

            //Collect folders
            var mFolders = new List <string>();

            cmbFolder.Items.Clear();
            cmbFolder.Items.Add("");

            if (rdoPlayerVariables.Checked)
            {
                foreach (var itm in PlayerVariableBase.Lookup)
                {
                    if (!string.IsNullOrEmpty(((PlayerVariableBase)itm.Value).Folder) &&
                        !mFolders.Contains(((PlayerVariableBase)itm.Value).Folder))
                    {
                        mFolders.Add(((PlayerVariableBase)itm.Value).Folder);
                        if (!mKnownFolders.Contains(((PlayerVariableBase)itm.Value).Folder))
                        {
                            mKnownFolders.Add(((PlayerVariableBase)itm.Value).Folder);
                        }
                    }
                }

                mKnownFolders.Sort();
                cmbFolder.Items.AddRange(mKnownFolders.ToArray());
                lblId.Text = Strings.VariableEditor.textidpv;
            }
            else if (rdoGlobalVariables.Checked)
            {
                foreach (var itm in ServerVariableBase.Lookup)
                {
                    if (!string.IsNullOrEmpty(((ServerVariableBase)itm.Value).Folder) &&
                        !mFolders.Contains(((ServerVariableBase)itm.Value).Folder))
                    {
                        mFolders.Add(((ServerVariableBase)itm.Value).Folder);
                        if (!mGlobalKnownFolders.Contains(((ServerVariableBase)itm.Value).Folder))
                        {
                            mGlobalKnownFolders.Add(((ServerVariableBase)itm.Value).Folder);
                        }
                    }
                }

                mGlobalKnownFolders.Sort();
                cmbFolder.Items.AddRange(mGlobalKnownFolders.ToArray());
                lblId.Text = Strings.VariableEditor.textidgv;
            }

            mFolders.Sort();

            lstVariables.Sorted = !btnChronological.Checked;

            if (!btnChronological.Checked && !CustomSearch())
            {
                foreach (var folder in mFolders)
                {
                    var node = lstVariables.Nodes.Add(folder);
                    node.ImageIndex         = 0;
                    node.SelectedImageIndex = 0;
                    folderNodes.Add(folder, node);
                }
            }

            var itemPairs = rdoPlayerVariables.Checked ? PlayerVariableBase.ItemPairs : ServerVariableBase.ItemPairs;

            foreach (var itm in itemPairs)
            {
                var node = new TreeNode(itm.Value);
                if (rdoGlobalVariables.Checked)
                {
                    node.Text = node.Text +
                                " = " +
                                ServerVariableBase.Get(itm.Key).Value.ToString(ServerVariableBase.Get(itm.Key).Type);
                }

                node.Tag                = itm.Key;
                node.ImageIndex         = 1;
                node.SelectedImageIndex = 1;

                var folder = "";
                if (rdoPlayerVariables.Checked)
                {
                    folder = PlayerVariableBase.Get(itm.Key).Folder;
                }

                if (rdoGlobalVariables.Checked)
                {
                    folder = ServerVariableBase.Get(itm.Key).Folder;
                }

                if (!string.IsNullOrEmpty(folder) && !btnChronological.Checked && !CustomSearch())
                {
                    var folderNode = folderNodes[folder];
                    folderNode.Nodes.Add(node);
                    if (itm.Key == selectedId)
                    {
                        folderNode.Expand();
                    }
                }
                else
                {
                    lstVariables.Nodes.Add(node);
                }

                if (CustomSearch())
                {
                    if (!node.Text.ToLower().Contains(txtSearch.Text.ToLower()))
                    {
                        node.Remove();
                    }
                }

                if (itm.Key == selectedId)
                {
                    lstVariables.SelectedNode = node;
                }
            }

            var selectedNode = lstVariables.SelectedNode;

            if (!btnChronological.Checked)
            {
                lstVariables.Sort();
            }

            lstVariables.SelectedNode = selectedNode;
            var expandedFolders = mExpandedFolders;

            if (rdoGlobalVariables.Checked)
            {
                expandedFolders = mGlobalExpandedFolders;
            }

            foreach (var node in expandedFolders)
            {
                if (folderNodes.ContainsKey(node))
                {
                    folderNodes[node].Expand();
                }
            }

            UpdateEditor();
        }
コード例 #21
0
        public static bool CheckVariableComparison(
            VariableValue currentValue,
            IntegerVariableComparison comparison,
            Player player,
            Event instance
            )
        {
            long compareAgainst = 0;

            VariableValue compValue = null;

            if (comparison.CompareVariableId != Guid.Empty)
            {
                if (comparison.CompareVariableType == VariableTypes.PlayerVariable)
                {
                    compValue = player.GetVariableValue(comparison.CompareVariableId);
                }
                else if (comparison.CompareVariableType == VariableTypes.ServerVariable)
                {
                    compValue = ServerVariableBase.Get(comparison.CompareVariableId)?.Value;
                }
            }
            else
            {
                compValue         = new VariableValue();
                compValue.Integer = comparison.Value;
            }

            if (compValue == null)
            {
                compValue = new VariableValue();
            }

            if (currentValue.Type == 0)
            {
                currentValue.Integer = 0;
            }

            if (compValue.Type != currentValue.Type)
            {
                return(false);
            }

            var varVal = currentValue.Integer;

            compareAgainst = compValue.Integer;

            switch (comparison.Comparator) //Comparator
            {
            case VariableComparators.Equal:
                if (varVal == compareAgainst)
                {
                    return(true);
                }

                break;

            case VariableComparators.GreaterOrEqual:
                if (varVal >= compareAgainst)
                {
                    return(true);
                }

                break;

            case VariableComparators.LesserOrEqual:
                if (varVal <= compareAgainst)
                {
                    return(true);
                }

                break;

            case VariableComparators.Greater:
                if (varVal > compareAgainst)
                {
                    return(true);
                }

                break;

            case VariableComparators.Less:
                if (varVal < compareAgainst)
                {
                    return(true);
                }

                break;

            case VariableComparators.NotEqual:
                if (varVal != compareAgainst)
                {
                    return(true);
                }

                break;
            }

            return(false);
        }