public bool Equals(FunctionDef other) { if (ReferenceEquals(other, null)) { return(false); } if (ReferenceEquals(other, this)) { return(true); } if (!object.Equals(Signature, other.Signature)) { return(false); } if (!Attr.Equals(other.Attr)) { return(false); } if (!nodeDef_.Equals(other.nodeDef_)) { return(false); } if (!Ret.Equals(other.Ret)) { return(false); } return(Equals(_unknownFields, other._unknownFields)); }
internal void FastAddItem(Attr attr) { _items.Add(attr); if (attr.NamespaceUri == null) CallHandlers(attr.LocalName, attr.Value); }
public Form2() { InitializeComponent(); att[0] = new Attr("sin", 4, 8); this.comboBox1.Items.Add(att[0].Name); att[1] = new Attr("cos", 6, 9); this.comboBox1.Items.Add(att[1].Name); att[2] = new Attr("exp", 4, 5); this.comboBox1.Items.Add(att[2].Name); }
private List <Types.MetaDataInfo> getDynamicVariables(Assembly assembly) { List <Types.MetaDataInfo> result = new List <Types.MetaDataInfo>(); foreach (Type t in assembly.GetTypes()) { foreach (FieldInfo property in t.GetFields(BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) { Types.MetaDataInfo m = new Types.MetaDataInfo(); foreach (Object Attr in property.GetCustomAttributes(false)) { if (Attr.GetType().Name.ToLower().StartsWith("output")) { m.Name = property.Name; } if (Attr.GetType().Name.ToLower().StartsWith("units")) { m.Units = Attr.ToString(); } if (Attr.GetType().Name.ToLower().StartsWith("description")) { m.Description = Attr.ToString(); } //m.IsArray = false; FIXME } if (m.Name != null) { result.Add(m); } } foreach (var method in t.GetProperties(BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) { Types.MetaDataInfo m = new Types.MetaDataInfo(); foreach (Object Attr in method.GetCustomAttributes(false)) { if (Attr.GetType().Name.ToLower().StartsWith("output")) { m.Name = method.Name; } if (Attr.GetType().Name.ToLower().StartsWith("description")) { m.Description = Attr.ToString(); } } if (m.Name != null) { result.Add(m); } } } #if false //FIXME work on this... var methods = assembly.GetTypes() .SelectMany(typ => typ.GetMethods(BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) .Where(m => m.GetCustomAttributes(false).Length > 0) .ToArray(); #endif return(result); }
public virtual void Run() { ServiceInstances .Where(kv => kv.Value is IExecService) .Select(kv => new { a = Attr.Get <ExecOrderAttribute>(GetServiceType(kv.Key)), s = (IExecService)kv.Value }) .OrderBy(t => t.a.Order) .ForEach(t => t.s.Run()); }
/// <summary> /// ToolbarTB /// </summary> /// <param name="attr">attr</param> public ToolbarTB(Attr attr) { this.MaxLength = attr.MaxLength; this.Text = attr.DefaultVal.ToString(); this.ReadOnly = attr.UIIsReadonly; this.Style.Clear(); this.CssClass = "DGTB" + WebUser.Style; }
protected ValidationResult InvokeIsValid(string value) { var method = Attr.GetType().GetMethod("IsValid", BindingFlags.Instance | BindingFlags.NonPublic); var valContext = new ValidationContext(this, null, null); var args = new object[] { value, valContext }; return(method.Invoke(Attr, args) as ValidationResult); }
public static string StringIt(Attr type, int?val) { if (type <= Attr.Null || !val.HasValue) { return(""); } return(StringIt(type, val.Value)); }
// Does it have this stat at all? // TODO: should I listen to fake/pred? public bool HasStat(Attr stat, int fake = -1, bool pred = false) { if (GetValue(stat, fake, pred) > 0) { return(true); } return(false); }
private float GetHeroProperty(Attr attr) { if (HeroAttr().ContainsKey(attr)) { return(HeroAttr()[attr]); } return(0); }
/// <summary> /// 得到纬度的实体集合,通过属性。 /// </summary> /// <param name="attrOfD">纬度属性</param> /// <returns>EntitiesNoName</returns> protected EntitiesNoName GetEntitiesNoNameByAttrKey(string attrOfD) { Attr attr = this.HisEns.GetNewEntity.EnMap.GetAttrByKey(attrOfD); EntitiesNoName ens = (EntitiesNoName)attr.HisFKEns; ens.RetrieveAll(); return(ens); }
internal void CopyFrom(RuneAttr lhs) { Type = lhs.Type; BaseValue = lhs.BaseValue; Enchanted = lhs.Enchanted; GrindBonus = lhs.GrindBonus; OnChange(0, 0); }
private void Attrs(Attr attr1, Attr attr2, Attr attr3, Attr attr4, Attr attr5) { Attr(attr1); Attr(attr2); Attr(attr3); Attr(attr4); Attr(attr5); }
public void BindEnum(UserRegedit ur, Attr attr, string cfgVal) { //this.Pub1.AddTable("width=95%"); //this.Pub1.AddCaptionLeft("请选择其中的一项或者多项"); this.Pub1.AddTableNormal(); this.Pub1.AddTRGroupTitle(2, "请选择其中的一项或者多项"); this.Pub1.AddTR(); //this.Pub1.AddTDTitle("IDX"); this.Pub1.AddTDGroupTitle("style='width:50px;text-align:center'", "序"); this.Pub1.AddTDBegin("class='GroupTitle'"); this.Pub1.Add("<input type=checkbox text='选择全部' name=checkedAll id='checkedAll' onclick='SelectAll()' ><label for='checkedAll'>选择全部</label> "); //this.Pub1.Add("<TD class=Title>"); //this.Pub1.Add("<input type=checkbox text='选择全部' name=checkedAll onclick='SelectAll()' >选择全部"); //Button btn = new Button(); //btn.ID = "Btn_Save1"; //btn.Text = " OK "; //btn.CssClass = "Btn"; this.Pub1.AddSpace(1); LinkBtn btn = new LinkBtn(false, NamesOfBtn.Save + "1", "确定"); btn.SetDataOption("iconCls", "'icon-save'"); btn.Click += new EventHandler(btn_Click); this.Pub1.Add(btn); //this.Pub1.Add("</TD>"); this.Pub1.AddTDEnd(); this.Pub1.AddTREnd(); SysEnums ses = new SysEnums(attr.UIBindKey); int idx = 0; bool is1 = false; foreach (SysEnum item in ses) { idx++; is1 = this.Pub1.AddTR(is1); this.Pub1.AddTDIdx(idx); CheckBox cb = new CheckBox(); cb.Text = item.Lab; cb.ID = "CB_" + item.IntKey; cb.Checked = cfgVal.Contains("." + item.IntKey + "."); this.Pub1.AddTD(cb); this.Pub1.AddTREnd(); } this.Pub1.AddTableEnd(); this.Pub1.AddBR(); //btn = new Button(); //btn.ID = "Btn_Save"; //btn.Text = " OK "; //btn.CssClass = "Btn"; this.Pub1.AddSpace(1); btn = new LinkBtn(false, NamesOfBtn.Save, "确定"); btn.Click += new EventHandler(btn_Click); this.Pub1.Add(btn); }
private void ModifyMetaDataAttribute(BeginTag tag, string attributeName, string valueToChangeTo) { Attr valueAttr = tag.GetAttribute(attributeName); if (valueAttr != null && valueToChangeTo != null) { valueAttr.Value = valueToChangeTo; } }
public override void Render(RenderingBuffer buffer) { Attr attr = Colors.Blend(Color.DarkCyan, Color.DarkBlue); buffer.FillRectangle(0, 0, ActualWidth, ActualHeight, UnicodeTable.MediumShade, attr); int filled = ( int )(ActualWidth * (Percent * 0.01)); buffer.FillRectangle(0, 0, filled, ActualHeight, UnicodeTable.DarkShade, attr); }
protected void Page_Load(object sender, EventArgs e) { this.BindTop(); if (this.RefNo == null) { /*请选择要设置的字段*/ MapAttrs mattrs = new MapAttrs(); mattrs.Retrieve(MapAttrAttr.FK_MapData, this.FK_MapData); //this.Pub1.AddFieldSet("请选择要设置的字段"); this.Pub1.AddEasyUiPanelInfoBegin("选择要设置的字段"); this.Pub1.AddUL("class='navlist'"); foreach (MapAttr en in mattrs) { if (en.UIVisible == false && en.UIIsEnable == false) { continue; } //this.Pub1.AddLi("?FK_MapData=" + this.FK_MapData + "&RefNo=" + en.MyPK + "&ExtType=AutoFull", en.KeyOfEn + " - " + en.Name); this.Pub1.Add("<li style=\"font-weight:bold\"><div><a href=\"?FK_MapData=" + this.FK_MapData + "&RefNo=" + en.MyPK + "&ExtType=AutoFull\"><span class=\"nav\">" + en.KeyOfEn + " - " + en.Name + "</span></a></div></li>"); ; } this.Pub1.AddULEnd(); //this.Pub1.AddFieldSetEnd(); this.Pub1.AddEasyUiPanelInfoEnd(); return; } MapAttr mattr = new MapAttr(this.RefNo); Attr attr = mattr.HisAttr; this.Title = "为[" + mattr.KeyOfEn + "][" + mattr.Name + "]设置自动完成"; // this.ToE("GuideNewField"); switch (attr.MyDataType) { case BP.DA.DataType.AppRate: case BP.DA.DataType.AppMoney: case BP.DA.DataType.AppInt: case BP.DA.DataType.AppFloat: BindNumType(mattr); break; case BP.DA.DataType.AppString: BindStringType(mattr); break; default: BindStringType(mattr); break; } }
public void OnEntityAttrChanged(CEntity target, Attr attr, object value) { if (!this._idToHud.TryGetValue(target.rid, out HUD hud)) { return; } hud.OnEntityAttrChanged(attr, value); }
string SetAttri(Attr newAtt) { var db = GMDataBaseSystem.database.GetJsonDatabase(GMDataBaseSystem.DBName.StrDictionary); string str = ""; str = string.Format("{0}+{1}\n", db.SearchForKey(newAtt.k.ToString()), newAtt.v); return(str); }
internal void RaiseChangedEvent(Attr attr, String newValue, String oldValue) { var element = default(Element); if (_owner.TryGetTarget(out element)) { element.AttributeChanged(attr.LocalName, attr.NamespaceUri, oldValue, newValue); } }
internal void FastAddItem(Attr attr) { _items.Add(attr); if (attr.NamespaceUri == null) { CallHandlers(attr.LocalName, attr.Value); } }
private void ModifyMetaDataAsNecessary(BeginTag tag) { if (_metaData == null) { return; } Attr nameAttr = tag.GetAttribute(HTMLTokens.Name); if (nameAttr == null) { nameAttr = tag.GetAttribute(HTMLTokens.HttpEquiv); } if (nameAttr != null) { switch (nameAttr.Value.ToUpper(CultureInfo.InvariantCulture)) { case (HTMLTokens.Author): ModifyMetaDataAttribute(tag, HTMLTokens.Content, _metaData.Author); break; case (HTMLTokens.ContentType): ModifyMetaDataAttribute(tag, HTMLTokens.Content, string.Format(CultureInfo.InvariantCulture, "text/html; {0}", _metaData.Charset)); break; case (HTMLTokens.Charset): ModifyMetaDataAttribute(tag, HTMLTokens.Content, _metaData.Charset); break; case (HTMLTokens.Description): ModifyMetaDataAttribute(tag, HTMLTokens.Content, _metaData.Description); break; case (HTMLTokens.Generator): ModifyMetaDataAttribute(tag, HTMLTokens.Content, _metaData.Generator); break; case (HTMLTokens.CopyRight): ModifyMetaDataAttribute(tag, HTMLTokens.Content, _metaData.CopyRight); break; case (HTMLTokens.Keywords): ModifyMetaDataAttribute(tag, HTMLTokens.Content, _metaData.KeywordString); break; case (HTMLTokens.Pragma): ModifyMetaDataAttribute(tag, HTMLTokens.Content, _metaData.Pragma); break; case (HTMLTokens.Robots): ModifyMetaDataAttribute(tag, HTMLTokens.Content, _metaData.Robots); break; } _emittedMetaData.Add(nameAttr.Value.ToUpper(CultureInfo.InvariantCulture)); } }
public static void ImprimirAtributos(Attr pAtributo) { Console.ForegroundColor = ConsoleColor.Cyan; Console.Write(pAtributo.Visibility + " "); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.Write(pAtributo.Type + " "); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine(pAtributo.Name); Console.ForegroundColor = ConsoleColor.White; }
public float CheckAttrRelation(Attr skillAttr, Attr pokemonAttr1, Attr pokemonAttr2) { int skillAttrIndex = (int)skillAttr; int pokemonAttr1Index = (int)pokemonAttr1; int pokemonAttr2Index = (int)pokemonAttr2; float result = _attrRelationsArray[skillAttrIndex, pokemonAttr1Index]; return(result * _attrRelationsArray[skillAttrIndex, pokemonAttr2Index]); }
protected override void OnAttrChanged(Attr attr, object value) { switch (attr) { case Attr.Bounds: this.worldBounds = (Core.FMath.FBounds)value; break; } base.OnAttrChanged(attr, value); }
private void button4_Click(object sender, EventArgs e) { int II = this.comboBox1.Items.Count; if (II < 50) { att[II] = new Attr(comboBox1.Text, Convert.ToByte(this.textBox3.Text), Convert.ToInt32(this.textBox4.Text)); this.comboBox1.Items.Add(this.comboBox1.Text); } else MessageBox.Show("Слишком длинный список"); }
private int[] PrebuildAttribute(Attr a) { int[] vs = new int[32]; for (int i = 0; i < 16; i++) { vs[i] = GetValue(a, i, false); vs[i + 16] = GetValue(a, i, true); } return(vs); }
protected virtual void OnAttrChanged(Attr attr, object oldValue, object value) { switch (attr) { case Attr.Scale: this.size = this._data.size * ( float )value; break; } SyncEventHelper.EntityAttrChanged(this.rid, attr, oldValue, value); }
public void FillRectangle(int x, int y, int w, int h, char c, Attr attributes) { for (int _x = 0; _x < w; _x++) { for (int _y = 0; _y < h; _y++) { SetPixel(x + _x, y + _y, c, attributes); } } }
public static int? ApplyModifiers(this IAttrSource target, Attr attr) { var applicable = target.GetModifiersFor(attr); var baseValue = target.GetBaseValue(attr); if (applicable.Length == 0) return baseValue; var modified = applicable.Aggregate(baseValue ?? 0, (i, mod) => mod.Modify(target, i)); return (modified == 0 && baseValue == null) ? (int?) null : modified; }
public static void toXmlImpl(Env env, StringBuilder sb, Attr node) { sb.append(' '); sb.append(node.getNodeName()); sb.append('='); sb.append('"'); sb.append(node.getNodeValue()); sb.append('"'); }
public AttrSelector(Attr attr) { if (!Enum.IsDefined(typeof(Attr), attr)) { throw new TypeInitializationException(typeof(AttrSelector).FullName, new ArgumentException($"{attr} is an invalid Attr.")); } this.attr = attr; }
public static string GetXmlAttrString(Element element, string name) { Attr at = element.GetAttributeNode(name); if (at != null) { return(at.GetValue()); } return(null); }
public float CheckAttrRelation(Attr skillAttr, Attr pokemonAttr1, Attr pokemonAttr2) { int skillAttrIndex = (int) skillAttr; int pokemonAttr1Index = (int) pokemonAttr1; int pokemonAttr2Index = (int) pokemonAttr2; float result = _attrRelationsArray[skillAttrIndex, pokemonAttr1Index]; return result * _attrRelationsArray[skillAttrIndex, pokemonAttr2Index]; }
public ActionResult ShowAttribute(string name) { Attr attr = systemdb.GetAllAttributes().FirstOrDefault(a => name == a.Name); if (attr == null) { return(NotFound()); } return(View("ShowAttribute", attr)); }
internal void RaiseChangedEvent(Attr attr, String newValue, String oldValue) { var owner = Owner; if (attr.NamespaceUri == null) CallHandlers(attr.LocalName, newValue); if (owner != null) owner.AttributeChanged(attr.LocalName, attr.NamespaceUri, oldValue); }
public Pokemon(int index) { Dictionary<string, string> dict = DataController.instance.pokemonsDataList[index - 1]; _id = IDController.id; _nameC = dict["nameC"]; _nameE = dict["nameE"]; _lv = 100; _charactor = Charactor.Hardy; _attr1 = (Attr) int.Parse (dict["attr1"]); _attr2 = (Attr) int.Parse (dict["attr2"]); attack = CalcADSValue (dict, "attackRV"); magicAttack = CalcADSValue (dict, "magicAttackRV"); defend = CalcADSValue (dict, "defendRV"); magicDefend = CalcADSValue (dict, "magicDefendRV"); speed = CalcADSValue (dict, "speedRV"); CharactorCalculator.instance.CharactorRevise (this); HP = CalcHPValue (dict); curHP = HP; _attackBuff = new Buff (BuffType.Attack, this); _magicAttackBuff = new Buff (BuffType.MagicAttack, this); _defendBuff = new Buff (BuffType.Defend, this); _magicDefendBuff = new Buff (BuffType.MagicDefend, this); _speedBuff = new Buff (BuffType.Speed, this); _skill1 = SkillGenerator.Create (); _skill2 = SkillGenerator.Create (); _skill3 = SkillGenerator.Create (); _skill4 = SkillGenerator.Create (); string[] skillIndex = dict["canLearnSkillsList"].Split (','); for (int i = 0; i < skillIndex.Length; i++) { canLearnSkillList.Add (int.Parse (skillIndex[i])); } _generation = dict["generation"]; }
public void Circles(SVG svgDoc, XmlNode parent, Attr attr) { int oldIndex = this.genes.Index; this.genes.Index = DEFAULT_CIRCLE_INDEX; XmlNode mainGroup = svgDoc.Group(parent, attr); int numRings = (int)(this.genes.Next() * (float)CIRCLE_RING_RANGE) + CIRCLE_RING_MIN; int harmonic = this.harmonic; for (int r = 0; r < numRings; r++) { int numCircs = (int)((this.genes.Next() * (float)CIRCLE_CIRC_RANGE) + CIRCLE_CIRC_MIN) * harmonic; float circRadii = this.genes.Next() * CIRC_RADII_MAX; float ringRadii = this.genes.Next() * CIRC_RADII_MAX; float angCirc = (float)(Math.PI * 2.0) / (float)numCircs; float ringPhase = this.genes.Next() < 0.5f ? 0.0f : (angCirc * 0.5f); float strokeWidth = this.genes.Next() * MAX_STROKE_WIDTH; for (int c = 0; c < numCircs; c++) { float cx = (float)Math.Sin(angCirc * c) * ringRadii + MIDX; float cy = (float)Math.Cos(angCirc * c) * ringRadii + MIDY; svgDoc.Circle(mainGroup, cx, cy, circRadii, new Attr() { {"fill", "none"}, {"stroke", "black"}, {"stroke-width", strokeWidth.ToString("0.###")} }); } } this.genes.Index = oldIndex; }
public List<Attr> ParseIt2(byte[] inputStr) { Scanner scanner = new Scanner(); scanner.Input(inputStr); List<Attr> props = new List<Attr>(); List<byte> token; string tok1; Attr atr; token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes(".0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); Console.WriteLine("1. token={0}", tok1); if (tok1.Equals("Received")) { token = scanner.AcceptUntil(ASCIIEncoding.ASCII.GetBytes("\r\n")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); Console.WriteLine("2. token={0}", tok1); bool found = false; while (!found) { scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); Console.WriteLine("3. token={0}", tok1); if (tok1.Equals("From")) { found = true; } else { token = scanner.AcceptUntil(ASCIIEncoding.ASCII.GetBytes("\r\n")); string tok2 = ASCIIEncoding.ASCII.GetString(token.ToArray()); } } token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes(":")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); Console.WriteLine("4. token={0}", tok1); if (tok1.Equals(":")) { scanner.SkipEmpty(); token = scanner.AcceptUntil(ASCIIEncoding.ASCII.GetBytes("<")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes("<")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes("@.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); Console.WriteLine("token={0}", tok1); scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes(">")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); } bool inLoop = true; while (inLoop) { scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes("-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); if (tok1.Equals("To")) { atr = new Attr(); string tokenName = tok1; atr.name = tokenName; scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes(":")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); token = scanner.AcceptUntil(ASCIIEncoding.ASCII.GetBytes("<")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes("<")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes("@.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); Console.WriteLine("token={0}", tok1); atr.value = tok1; props.Add(atr); scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes(">")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); } else if (tok1.Equals("Subject")) { atr = new Attr(); string tokenName = tok1; atr.name = tokenName; scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes(":")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); token = scanner.AcceptUntil(ASCIIEncoding.ASCII.GetBytes("\r\n")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); atr.value = tok1; props.Add(atr); scanner.SkipEmpty(); } else if (tok1.Equals("MIME-Version")) { atr = new Attr(); string tokenName = tok1; atr.name = tokenName; scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes(":")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); token = scanner.AcceptUntil(ASCIIEncoding.ASCII.GetBytes("\r\n")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); atr.value = tok1; props.Add(atr); scanner.SkipEmpty(); //inLoop = false; } else if (tok1.Equals("Content-Type")) { atr = new Attr(); string tokenName = tok1; atr.name = tokenName; scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes(":")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); token = scanner.AcceptUntil(ASCIIEncoding.ASCII.GetBytes("\r\n")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); Console.WriteLine("token={0}", tok1); atr.value = tok1; props.Add(atr); scanner.SkipEmpty(); } else if (tok1.Length == 0) { inLoop = false; } else { atr = new Attr(); string tokenName = tok1; atr.name = tokenName; scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes(":")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); token = scanner.AcceptUntil(ASCIIEncoding.ASCII.GetBytes("\r\n")); string tokenValue = ASCIIEncoding.ASCII.GetString(token.ToArray()); atr.value = tokenValue; scanner.SkipEmpty(); props.Add(atr); Console.WriteLine("Attribute: {0}={1}", atr.name, atr.value); } } } return props; }
public void SetPixelSafe(int x, int y, char c, Attr attr) { if (buffer.GetLength(0) > x && buffer.GetLength(1) > y) SetPixel(x, y, c, attr); }
// Gets the value of that Attribute on this rune public int GetValue(Attr stat, int FakeLevel, bool PredictSubs) { // the stat can only be present once per rune, early exit if (MainType == stat) { if (FakeLevel <= Level || FakeLevel > 15 || Grade < 3) { return MainValue; } else { return MainValues[MainType][Grade - 3][FakeLevel]; } } // Need to be able to load in null values (requiring int?) but xType shouldn't be a Type if xValue is null if (InnateType == stat) return InnateValue ?? 0; // Here, if a subs type is null, there is not further subs (it's how runes work), so we quit early. if (PredictSubs == false) { if (Sub1Type == stat || Sub1Type == Attr.Null) return Sub1Value ?? 0; if (Sub2Type == stat || Sub2Type == Attr.Null) return Sub2Value ?? 0; if (Sub3Type == stat || Sub3Type == Attr.Null) return Sub3Value ?? 0; if (Sub4Type == stat || Sub4Type == Attr.Null) return Sub4Value ?? 0; } else { // count how many upgrades have gone into the rune int maxUpgrades = Math.Min(4, (int)Math.Floor(FakeLevel / (double)3)); int upgradesGone = Math.Min(4, (int)Math.Floor(Level / (double)3)); // how many new sub are to appear (0 legend will be 4 - 4 = 0, 6 rare will be 4 - 3 = 1, 6 magic will be 4 - 2 = 2) int subNew = 4 - Rarity; // how many subs will go into existing stats (0 legend will be 4 - 0 - 0 = 4, 6 rare will be 4 - 1 - 2 = 1, 6 magic will be 4 - 2 - 2 = 0) int subEx = maxUpgrades - upgradesGone - subNew; int subVal = (subNew > 0 ? 1 : 0); if (Sub1Type == stat || Sub1Type == Attr.Null) return Sub1Value + subEx ?? subVal; if (Sub2Type == stat || Sub2Type == Attr.Null) return Sub2Value + subEx ?? subVal; if (Sub3Type == stat || Sub3Type == Attr.Null) return Sub3Value + subEx ?? subVal; if (Sub4Type == stat || Sub4Type == Attr.Null) return Sub4Value + subEx ?? subVal; } return 0; }
// Ask the rune for the value of the Attribute type as a string public static string StringIt(Attr type, bool suffix = false) { string ret = ""; switch (type) { case Attr.HealthFlat: case Attr.HealthPercent: ret += "HP"; break; case Attr.AttackPercent: case Attr.AttackFlat: ret += "ATK"; break; case Attr.DefenseFlat: case Attr.DefensePercent: ret += "DEF"; break; case Attr.Speed: ret += "SPD"; break; case Attr.CritRate: ret += "CRI Rate"; break; case Attr.CritDamage: ret += "CRI Dmg"; break; case Attr.Accuracy: ret += "Accuracy"; break; case Attr.Resistance: ret += "Resistance"; break; } if (type.ToString().Contains("Percent") || type == Attr.CritRate || type == Attr.CritDamage || type == Attr.Accuracy || type == Attr.Resistance) ret += "%"; return ret; }
public static string StringIt(Attr type, int? val) { if (type == Attr.Null || !val.HasValue) return ""; return StringIt(type, val.Value); }
public PlusMod(Card source, Attr attribute, Func<IAttrSource, int> getAmount) { Source = source; Attribute = attribute; GetAmount = getAmount; }
internal void FastAddItem(Attr attr) { _items.Add(attr); }
public SetMod(Card source, Attr attribute, int to) { Source = source; Attribute = attribute; To = to; }
public List<Attr> ParseIt(byte[] inputStr) { Scanner scanner = new Scanner(); scanner.Input(inputStr); List<Attr> props = new List<Attr>(); List<byte> token; string tok1; Attr atr; for (int i = 0; i < 4; i++) { atr = new Attr(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); atr.name = tok1; scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes(":")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); token = scanner.AcceptUntil(ASCIIEncoding.ASCII.GetBytes("\r\n")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); atr.value = tok1; props.Add(atr); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes("\r")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes("\n")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); } token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes("\r")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes("\n")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); //token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,;_$% ")); token = scanner.AcceptUntil(ASCIIEncoding.ASCII.GetBytes("\r\n")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); //------------------ for (int i = 0; i < 9; i++) { atr = new Attr(); token = scanner.AcceptUntil(ASCIIEncoding.ASCII.GetBytes(":")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); atr.name = tok1; scanner.SkipEmpty(); token = scanner.AcceptRun(ASCIIEncoding.ASCII.GetBytes(":")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); scanner.SkipEmpty(); token = scanner.AcceptUntil(ASCIIEncoding.ASCII.GetBytes("\r\n")); tok1 = ASCIIEncoding.ASCII.GetString(token.ToArray()); atr.value = tok1; props.Add(atr); scanner.SkipEmpty(); } return props; }
/// <summary> /// Renders string using attr, but if character is prefixed with underscore, /// symbol will use specialAttrs instead. To render underscore pass two underscores. /// Example: "_File" renders File when 'F' is rendered using specialAttrs. /// </summary> private static int renderString( string s, RenderingBuffer buffer, int x, int y, int maxWidth, Attr attr, Attr specialAttr) { bool underscore = false; int j = 0; for ( int i = 0; i < s.Length && j < maxWidth; i++ ) { char c; if ( underscore ) { c = s[ i ]; } else { if ( s[ i ] == '_' ) { underscore = true; continue; } else { c = s[ i ]; } } Attr a; if ( j + 2 >= maxWidth && j >= 2 && s.Length > maxWidth ) { c = '.'; a = attr; } else { a = underscore ? specialAttr : attr; } buffer.SetPixel( x + j, y, c, a ); j++; underscore = false; } return j; }
public PlusMod(Card source, Attr attribute, int amount) { Source = source; Attribute = attribute; GetAmount = x => amount; }
public void InitObj(Attr attr) { InitObj(attr.MaxLife,attr.CurLife,attr.Attack,attr.Defence); }
public Rune(Rune rhs) { ID = rhs.ID; Set = rhs.Set; Grade = rhs.Grade; Slot = rhs.Slot; Level = rhs.Level; //FakeLevel = rhs.FakeLevel; //PredictSubs = rhs.PredictSubs; Locked = rhs.Locked; AssignedId = rhs.AssignedId; AssignedName = rhs.AssignedName; Assigned = rhs.Assigned; Swapped = rhs.Swapped; MainType = rhs.MainType; MainValue = rhs.MainValue; InnateType = rhs.InnateType; InnateValue = rhs.InnateValue; Sub1Type = rhs.Sub1Type; Sub1Value = rhs.Sub1Value; Sub2Type = rhs.Sub2Type; Sub2Value = rhs.Sub2Value; Sub3Type = rhs.Sub3Type; Sub3Value = rhs.Sub3Value; Sub4Type = rhs.Sub4Type; Sub4Value = rhs.Sub4Value; Parent = rhs; }
public void RenderStringSafe( string s, int x, int y, Attr attr ) { for ( int i = 0; i < s.Length; i++ ) { SetPixelSafe( x + i, y, s[i], attr ); } }
public static string StringIt(Attr type, int val) { string ret = StringIt(type); ret += " +" + val; if (type.ToString().Contains("Percent") || type == Attr.CritRate || type == Attr.CritDamage || type == Attr.Accuracy || type == Attr.Resistance) { ret += "%"; } return ret; }
public void SetPixel(int x, int y, Attr attr) { buffer[x, y].Attributes = attr; }
public double GetEfficiency(Attr a, int val) { if (a == Attr.Null) return 0; if (a == Attr.HealthFlat || a == Attr.AttackFlat || a == Attr.DefenseFlat) return val / 2 / (double)(5 * subUpgrades[a][Grade - 1]); return val / (double) (5 * subUpgrades[a][Grade - 1]); }
public void SetPixel(int x, int y, char c, Attr attr) { buffer[x, y].UnicodeChar = c; buffer[x, y].Attributes = attr; }
// Does it have this stat at all? public bool HasStat(Attr stat, int fake, bool pred) { if (GetValue(stat, fake, pred) > 0) return true; return false; }
protected void RenderBorders( RenderingBuffer buffer, Point a, Point b, bool singleOrDouble, Attr attrs ) { if ( singleOrDouble ) { // Corners buffer.SetPixel(a.X, a.Y, UnicodeTable.SingleFrameTopLeftCorner, attrs); buffer.SetPixel(b.X, b.Y, UnicodeTable.SingleFrameBottomRightCorner, attrs); buffer.SetPixel(a.X, b.Y, UnicodeTable.SingleFrameBottomLeftCorner, attrs); buffer.SetPixel(b.X, a.Y, UnicodeTable.SingleFrameTopRightCorner, attrs); // Horizontal & vertical frames buffer.FillRectangle(a.X + 1, a.Y, b.X - a.X - 1, 1, UnicodeTable.SingleFrameHorizontal, attrs); buffer.FillRectangle(a.X + 1, b.Y, b.X - a.X - 1, 1, UnicodeTable.SingleFrameHorizontal, attrs); buffer.FillRectangle(a.X, a.Y + 1, 1, b.Y - a.Y - 1, UnicodeTable.SingleFrameVertical, attrs); buffer.FillRectangle(b.X, a.Y + 1, 1, b.Y - a.Y - 1, UnicodeTable.SingleFrameVertical, attrs); } else { // Corners buffer.SetPixel( a.X, a.Y, UnicodeTable.DoubleFrameTopLeftCorner, attrs ); buffer.SetPixel( b.X, b.Y, UnicodeTable.DoubleFrameBottomRightCorner, attrs ); buffer.SetPixel( a.X, b.Y, UnicodeTable.DoubleFrameBottomLeftCorner, attrs ); buffer.SetPixel( b.X, a.Y, UnicodeTable.DoubleFrameTopRightCorner, attrs ); // Horizontal & vertical frames buffer.FillRectangle( a.X + 1, a.Y, b.X - a.X - 1, 1, UnicodeTable.DoubleFrameHorizontal, attrs ); buffer.FillRectangle( a.X + 1, b.Y, b.X - a.X - 1, 1, UnicodeTable.DoubleFrameHorizontal, attrs ); buffer.FillRectangle( a.X, a.Y + 1, 1, b.Y - a.Y - 1, UnicodeTable.DoubleFrameVertical, attrs ); buffer.FillRectangle( b.X, a.Y + 1, 1, b.Y - a.Y - 1, UnicodeTable.DoubleFrameVertical, attrs ); } }