public VariableContainer Serialize() { var result = new VariableContainer(); result.Set("sell", SerializeMany(SellOffers)); result.Set("buy", SerializeMany(BuyOffers)); return(result); }
public void Save() { var vars = new VariableContainer(); vars.Set("gold", new Serializable.Decimal(Gold)); vars.Set("health", new Serializable.Decimal(Health)); vars.Set("totalDamage", new Serializable.Decimal(TotalDamage)); vars.Set("attackers", Attacker.Save(Attackers)); GlobalVariables.Variables.Set(_key, vars); }
public VariableContainer Serialize() { var result = new VariableContainer(); result.Set("UserId", UserId); result.Set("Price", new Serializable.Decimal(Price)); result.Set("Count", new Serializable.Int(Count)); result.Set("Created", new Serializable.Decimal(Created.ToUnixTimeSeconds())); result.Set("ItemId", new Serializable.String(ItemId)); return(result); }
public static VariableContainer Serialize <T>(IState <T> state) where T : IState <T> { var container = new VariableContainer(); container.Set("stateId", new Serializable.String(state.StateId)); var innerState = state.Serialize(); container.Set("state", innerState); return(container); }
private void Save(Variables variables) { var vars = new VariableContainer(); vars.Set("gold", new Serializable.Decimal(variables.Gold)); vars.Set("health", new Serializable.Decimal(variables.Health)); vars.Set("totalDamage", new Serializable.Decimal(variables.TotalDamage)); vars.Set("attackers", Attacker.Save(variables.Attackers)); lock (GlobalVariables.Variables) { GlobalVariables.Variables.Set(GlobalVariablesKey, vars); } }
public VariableContainer Serialize() { var result = new VariableContainer(); result.Set("Selling", new Serializable.Bool(Selling)); result.Set("SelectedItemId", new Serializable.String(SelectedItemId)); result.Set("SelectedItemPrice", new Serializable.Decimal(SelectedItemPrice)); if (SelectedItemCount != null) { result.Set("SelectedItemCount", new Serializable.Int((int)SelectedItemCount)); } return(result); }
public static SerializableList Save(IEnumerable <Attacker> attackers) { var result = new SerializableList(); foreach (var attacker in attackers) { var container = new VariableContainer(); container.Set("damageDealed", new Serializable.Decimal(attacker.DamageDealed)); container.Set("userId", attacker.UserId); result.Add(container); } return(result); }
public void Serialize(VariableContainer container) { container.Set(nameof(ArtifactId), new Serializable.String(ArtifactId)); container.Set(nameof(Gold), new Serializable.Decimal(Gold)); container.Set(nameof(KnowledgeGroup), new Serializable.Int((int)KnowledgeGroup)); container.Set(nameof(KnowledgeMinimal), new Serializable.Decimal(KnowledgeMinimal)); container.Set(nameof(KnowledgeRequired), new Serializable.Decimal(KnowledgeRequired)); container.Set(nameof(Name), new Serializable.String(Name)); container.Set(nameof(Defence), new Serializable.Decimal(Defence)); container.Set(nameof(DefencedPlaces), new Serializable.Int((int)DefencedPlaces)); container.Set(nameof(Damage), new Serializable.Decimal(Damage)); container.Set(nameof(Health), new Serializable.Decimal(Health)); }
public void Dispose() { var container = new VariableContainer(); Stats.Serialize(container); _roomVariables.Set("monster_stats", container); }
public VariableContainer Serialize() { var result = new VariableContainer(); foreach (var offer in this) { result.Set(offer.Key, offer.Value.Serialize()); } return(result); }
public void PlainTest() { var container = new VariableContainer(); Assert.Empty(container.Keys()); container.Set("test_variable", new Serializable.Int(1)); Assert.Single(container.Keys(), "test_variable"); var value = container.Get <Serializable.Int>("test_variable"); Assert.Equal(1, (int)value); }
private VariableContainer DefaultMessengers(VariableContainer variables, ChatId chatId) { var availableChats = variables.Get <VariableContainer>(RootVariable); if (availableChats != null) { return(DefaultMessengersInner(availableChats, chatId)); } var container = new VariableContainer(); variables.Set(RootVariable, container); return(DefaultMessengersInner(container, chatId)); }
public void NestedTest() { var containerA = new VariableContainer(); Assert.Empty(containerA.Keys()); var containerB = new VariableContainer(); Assert.Empty(containerB.Keys()); var containerC = new VariableContainer(); Assert.Empty(containerC.Keys()); containerC.Set("test_c", new Serializable.Bool(true)); containerB.Set("test_b", new Serializable.String("test")); containerB.Set("nested_c", containerC); containerA.Set("test_a", new Serializable.Int(1)); containerA.Set("nested_b", containerB); Assert.Equal(1, (int)containerA.Get <Serializable.Int>("test_a")); var nestedB = containerA.Get <VariableContainer>("nested_b"); Assert.NotNull(nestedB); Assert.Equal("test", nestedB.Get <Serializable.String>("test_b")); var nestedC = containerB.Get <VariableContainer>("nested_c"); Assert.NotNull(nestedC); Assert.Equal(true, (bool)nestedC.Get <Serializable.Bool>("test_c")); }
public VariableContainer Serialize() { var result = new VariableContainer(); result.Set("SelectedItemId", new Serializable.String(SelectedItemId)); result.Set("SelectedPriceGroup", new Serializable.Int(SelectedPriceGroup)); result.Set("SelectedItemPrice", new Serializable.Int(SelectedItemPrice)); result.Set("MaxQuantityAvailable", new Serializable.Int(MaxQuantityAvailable)); result.Set("QuantitySelected", new Serializable.Int(QuantitySelected)); result.Set("Selling", new Serializable.Bool(Selling)); return(result); }
private VariableContainer DefaultMessengersInner(VariableContainer availableChats, ChatId chatId) { var chat = chatId.Id.ToString(); var availableMessengers = availableChats.Get <VariableContainer>(chat); if (availableMessengers != null) { return(availableMessengers); } availableMessengers = new VariableContainer(); var defaultId = _messengers[0].Id; availableMessengers.Set(defaultId.ToString(), new Serializable.Bool(true)); availableChats.Set(chat, availableMessengers); return(availableMessengers); }