/// <summary> /// Добавление типа /// </summary> /// <param name="typeCode">Код типа</param> /// <returns>Тип</returns> public Type Add(TypeCode typeCode) { Type type = null; switch (typeCode) { case TypeCode.Limiteds: type = new Limited(); break; case TypeCode.Scalars: type = new Scalar(); break; case TypeCode.Arrays: type = new Array(); break; case TypeCode.Enums: type = new Enum(); break; } _types.Add(type); return(type); }
public string Force(IStatus s) { string log = null; //RuleHelper.Require(s, new List<string> { "LV", "EXP" }); Limited exp = s["EXP"] as Limited; if (exp != null) { int levelup = 0; while (exp.Max == exp.Value) { exp.Value -= exp.Max; exp.Max += s["LV"].Get() * 100; s["LV"].Add(1); levelup++; } if (levelup > 0) { log = $":event: {levelup} Level UP! you are now {s["LV"]}."; } } return(log); }
public override int GetHashCode() { return(HashCodeHelper.GetHashCode( Limited.GetHashCode(), MaxLimit.GetHashCode(), Remaining.GetHashCode(), ResetAfter.GetHashCode(), RetryAfter.GetHashCode())); }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (Type == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Type"); } if (Limited != null) { Limited.Validate(); } }
public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer) { var limited = new Limited(); object value; if (dictionary.TryGetValue(StuffName, out value)) { // limited.Stuff = serializer.ConvertToType<string>(value); // Actually it's get only. } if (dictionary.TryGetValue(StatusName, out value)) { limited.Status = serializer.ConvertToType <LimitedStatus>(value); } return(limited); }
private int Query(uint alias) { if (Forbidden.Contains(alias)) { return(0); } if (Limited.Contains(alias)) { return(1); } if (SemiLimited.Contains(alias)) { return(2); } return(3); }
public void Add(uint cardId, int qualification) { switch (qualification) { case 0: Forbidden.Add(cardId); break; case 1: Limited.Add(cardId); break; case 2: SemiLimited.Add(cardId); break; default: return; } uint code = cardId; Hash = Hash ^ ((code << 18) | (code >> 14)) ^ ((code << (27 + qualification)) | (code >> (5 - qualification))); }