//OLD //public class SetVariableCommand : EventCommand //{ // public VariableMods ModType { get; set; } = VariableMods.Set; // public int Value { get; set; } // public int HighValue { get; set; } // public Guid DuplicateVariableId { get; set; } //} private static JObject ConvertSetVariableCommand(JObject obj) { var cmd = new SetVariableCommand(); if (obj.ContainsKey("VariableId")) { cmd.VariableId = Guid.Parse(obj["VariableId"].ToString()); } if (obj.ContainsKey("VariableType") && int.Parse(obj["VariableType"].ToString()) == 1) { cmd.VariableType = VariableTypes.ServerVariable; } else { cmd.VariableType = VariableTypes.PlayerVariable; } if (obj.ContainsKey("SyncParty") && bool.Parse(obj["SyncParty"].ToString())) { cmd.SyncParty = true; } else { cmd.SyncParty = false; } var mod = new IntegerVariableMod(); cmd.Modification = mod; if (obj.ContainsKey("Value")) { mod.Value = long.Parse(obj["Value"].ToString()); } if (obj.ContainsKey("DupVariableId")) { mod.DuplicateVariableId = Guid.Parse(obj["DupVariableId"].ToString()); } if (obj.ContainsKey("HighValue")) { mod.HighValue = long.Parse(obj["HighValue"].ToString()); } if (obj.ContainsKey("ModType")) { mod.ModType = (VariableMods)int.Parse(obj["ModType"].ToString()); } var newJson = JsonConvert.SerializeObject( cmd, typeof(EventCommand), new JsonSerializerSettings() { Formatting = Formatting.None, TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace } ); return(JObject.Parse(newJson)); }
private IntegerVariableMod GetNumericVariableMod() { var mod = new IntegerVariableMod(); if (optNumericSet.Checked && optNumericStaticVal.Checked) { mod.ModType = VariableMods.Set; mod.Value = (int)nudNumericValue.Value; } else if (optNumericAdd.Checked && optNumericStaticVal.Checked) { mod.ModType = VariableMods.Add; mod.Value = (int)nudNumericValue.Value; } else if (optNumericSubtract.Checked && optNumericStaticVal.Checked) { mod.ModType = VariableMods.Subtract; mod.Value = (int)nudNumericValue.Value; } else if (optNumericMultiply.Checked && optNumericStaticVal.Checked) { mod.ModType = VariableMods.Multiply; mod.Value = (int)nudNumericValue.Value; } else if (optNumericDivide.Checked && optNumericStaticVal.Checked) { mod.ModType = VariableMods.Divide; mod.Value = (int)nudNumericValue.Value; } else if (optNumericLeftShift.Checked && optNumericStaticVal.Checked) { mod.ModType = VariableMods.LeftShift; mod.Value = (int)nudNumericValue.Value; } else if (optNumericRightShift.Checked && optNumericStaticVal.Checked) { mod.ModType = VariableMods.RightShift; mod.Value = (int)nudNumericValue.Value; } else if (optNumericRandom.Checked) { mod.ModType = VariableMods.Random; mod.Value = (int)nudLow.Value; mod.HighValue = (int)nudHigh.Value; if (mod.HighValue < mod.Value) { var n = mod.Value; mod.Value = mod.HighValue; mod.HighValue = n; } } else if (optNumericSystemTime.Checked) { mod.ModType = VariableMods.SystemTime; } else if (optNumericClonePlayerVar.Checked) { if (optNumericSet.Checked) { mod.ModType = VariableMods.DupPlayerVar; } else if (optNumericAdd.Checked) { mod.ModType = VariableMods.AddPlayerVar; } else if (optNumericSubtract.Checked) { mod.ModType = VariableMods.SubtractPlayerVar; } else if (optNumericMultiply.Checked) { mod.ModType = VariableMods.MultiplyPlayerVar; } else if (optNumericDivide.Checked) { mod.ModType = VariableMods.DividePlayerVar; } else if (optNumericLeftShift.Checked) { mod.ModType = VariableMods.LeftShiftPlayerVar; } else { mod.ModType = VariableMods.RightShiftPlayerVar; } mod.DuplicateVariableId = PlayerVariableBase.IdFromList(cmbNumericClonePlayerVar.SelectedIndex); } else if (optNumericCloneGlobalVar.Checked) { if (optNumericSet.Checked) { mod.ModType = VariableMods.DupGlobalVar; } else if (optNumericAdd.Checked) { mod.ModType = VariableMods.AddGlobalVar; } else if (optNumericSubtract.Checked) { mod.ModType = VariableMods.SubtractGlobalVar; } else if (optNumericMultiply.Checked) { mod.ModType = VariableMods.MultiplyGlobalVar; } else if (optNumericDivide.Checked) { mod.ModType = VariableMods.DivideGlobalVar; } else if (optNumericLeftShift.Checked) { mod.ModType = VariableMods.LeftShiftGlobalVar; } else { mod.ModType = VariableMods.RightShiftGlobalVar; } mod.DuplicateVariableId = ServerVariableBase.IdFromList(cmbNumericCloneGlobalVar.SelectedIndex); } return(mod); }
private void TryLoadNumericMod(VariableMod varMod) { if (varMod == null) { varMod = new IntegerVariableMod(); } if (varMod.GetType() == typeof(IntegerVariableMod)) { var mod = (IntegerVariableMod)varMod; switch (mod.ModType) { case VariableMods.Set: optNumericSet.Checked = true; optNumericStaticVal.Checked = true; nudNumericValue.Value = mod.Value; break; case VariableMods.Add: optNumericAdd.Checked = true; optNumericStaticVal.Checked = true; nudNumericValue.Value = mod.Value; break; case VariableMods.Subtract: optNumericSubtract.Checked = true; optNumericStaticVal.Checked = true; nudNumericValue.Value = mod.Value; break; case VariableMods.Random: optNumericRandom.Checked = true; nudLow.Value = mod.Value; nudHigh.Value = mod.HighValue; break; case VariableMods.SystemTime: optNumericSystemTime.Checked = true; break; case VariableMods.DupPlayerVar: optNumericSet.Checked = true; optNumericClonePlayerVar.Checked = true; cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.DupGlobalVar: optNumericSet.Checked = true; optNumericCloneGlobalVar.Checked = true; cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.AddPlayerVar: optNumericAdd.Checked = true; optNumericClonePlayerVar.Checked = true; cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.AddGlobalVar: optNumericAdd.Checked = true; optNumericCloneGlobalVar.Checked = true; cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.SubtractPlayerVar: optNumericSubtract.Checked = true; optNumericClonePlayerVar.Checked = true; cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.SubtractGlobalVar: optNumericSubtract.Checked = true; optNumericCloneGlobalVar.Checked = true; cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); break; } } }
private void TryLoadNumericMod(VariableMod varMod) { if (varMod == null) { varMod = new IntegerVariableMod(); } if (varMod.GetType() == typeof(IntegerVariableMod)) { var mod = (IntegerVariableMod)varMod; //Should properly seperate static value, player & global vars into a seperate enum. //But technical debt :/ switch (mod.ModType) { case VariableMods.Set: optNumericSet.Checked = true; optNumericStaticVal.Checked = true; nudNumericValue.Value = mod.Value; break; case VariableMods.Add: optNumericAdd.Checked = true; optNumericStaticVal.Checked = true; nudNumericValue.Value = mod.Value; break; case VariableMods.Subtract: optNumericSubtract.Checked = true; optNumericStaticVal.Checked = true; nudNumericValue.Value = mod.Value; break; case VariableMods.Multiply: optNumericMultiply.Checked = true; optNumericStaticVal.Checked = true; nudNumericValue.Value = mod.Value; break; case VariableMods.Divide: optNumericDivide.Checked = true; optNumericStaticVal.Checked = true; nudNumericValue.Value = mod.Value; break; case VariableMods.LeftShift: optNumericLeftShift.Checked = true; optNumericStaticVal.Checked = true; nudNumericValue.Value = mod.Value; break; case VariableMods.RightShift: optNumericRightShift.Checked = true; optNumericStaticVal.Checked = true; nudNumericValue.Value = mod.Value; break; case VariableMods.Random: optNumericRandom.Checked = true; nudLow.Value = mod.Value; nudHigh.Value = mod.HighValue; break; case VariableMods.SystemTime: optNumericSystemTime.Checked = true; break; case VariableMods.DupPlayerVar: optNumericSet.Checked = true; optNumericClonePlayerVar.Checked = true; cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.DupGlobalVar: optNumericSet.Checked = true; optNumericCloneGlobalVar.Checked = true; cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.AddPlayerVar: optNumericAdd.Checked = true; optNumericClonePlayerVar.Checked = true; cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.AddGlobalVar: optNumericAdd.Checked = true; optNumericCloneGlobalVar.Checked = true; cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.SubtractPlayerVar: optNumericSubtract.Checked = true; optNumericClonePlayerVar.Checked = true; cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.SubtractGlobalVar: optNumericSubtract.Checked = true; optNumericCloneGlobalVar.Checked = true; cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.MultiplyPlayerVar: optNumericMultiply.Checked = true; optNumericClonePlayerVar.Checked = true; cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.MultiplyGlobalVar: optNumericMultiply.Checked = true; optNumericCloneGlobalVar.Checked = true; cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.DividePlayerVar: optNumericDivide.Checked = true; optNumericClonePlayerVar.Checked = true; cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.DivideGlobalVar: optNumericDivide.Checked = true; optNumericCloneGlobalVar.Checked = true; cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.LeftShiftPlayerVar: optNumericLeftShift.Checked = true; optNumericClonePlayerVar.Checked = true; cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.LeftShiftGlobalVar: optNumericLeftShift.Checked = true; optNumericCloneGlobalVar.Checked = true; cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.RightShiftPlayerVar: optNumericRightShift.Checked = true; optNumericClonePlayerVar.Checked = true; cmbNumericClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId); break; case VariableMods.RightShiftGlobalVar: optNumericRightShift.Checked = true; optNumericCloneGlobalVar.Checked = true; cmbNumericCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId); break; } } }
private static string GetVariableModText(SetVariableCommand command, IntegerVariableMod mod) { var varvalue = ""; switch (mod.ModType) { case Enums.VariableMods.Set: varvalue = Strings.EventCommandList.setvariable.ToString(mod.Value); break; case Enums.VariableMods.Add: varvalue = Strings.EventCommandList.addvariable.ToString(mod.Value); break; case Enums.VariableMods.Subtract: varvalue = Strings.EventCommandList.subtractvariable.ToString(mod.Value); break; case Enums.VariableMods.Random: varvalue = Strings.EventCommandList.randvariable.ToString(mod.Value, mod.HighValue); break; case Enums.VariableMods.SystemTime: varvalue = Strings.EventCommandList.systemtimevariable; break; case Enums.VariableMods.DupPlayerVar: varvalue = Strings.EventCommandList.dupplayervariable.ToString( PlayerVariableBase.GetName(mod.DuplicateVariableId) ); break; case Enums.VariableMods.DupGlobalVar: varvalue = Strings.EventCommandList.dupglobalvariable.ToString( ServerVariableBase.GetName(mod.DuplicateVariableId) ); break; case Enums.VariableMods.AddPlayerVar: varvalue = Strings.EventCommandList.addplayervariable.ToString( PlayerVariableBase.GetName(mod.DuplicateVariableId) ); break; case Enums.VariableMods.AddGlobalVar: varvalue = Strings.EventCommandList.addglobalvariable.ToString( ServerVariableBase.GetName(mod.DuplicateVariableId) ); break; case Enums.VariableMods.SubtractPlayerVar: varvalue = Strings.EventCommandList.subtractplayervariable.ToString( PlayerVariableBase.GetName(mod.DuplicateVariableId) ); break; case Enums.VariableMods.SubtractGlobalVar: varvalue = Strings.EventCommandList.subtractglobalvariable.ToString( ServerVariableBase.GetName(mod.DuplicateVariableId) ); break; } if (command.VariableType == VariableTypes.PlayerVariable) { return(Strings.EventCommandList.playervariable.ToString( PlayerVariableBase.GetName(command.VariableId), varvalue )); } if (command.VariableType == VariableTypes.ServerVariable) { return(Strings.EventCommandList.globalvariable.ToString( ServerVariableBase.GetName(command.VariableId), varvalue )); } return(Strings.EventCommandList.invalid); }