public override double Compare(Node node) { var bdn = node as BibliographicDescriptionNode; if (bdn == null) { throw new Exception("Not Bibliographic DescriptionNode"); } double difference = 0; difference += TitleNode.Compare(bdn.TitleNode); if (difference < 0.05 || difference > 0.25) { return(difference); } difference += AutorRangeNode.Compare(bdn.AutorRangeNode); difference += PublisherNode.Compare(bdn.PublisherNode); difference += CityNode.Compare(bdn.CityNode); difference += YearNode.Compare(bdn.YearNode); difference += PageCountNode.Compare(bdn.PageCountNode); return(difference); }
public BibliographicDescriptionNode(string title, IEnumerable <string> autors, string publisher, string city, string year, string pageCount) { TitleNode = new TitleNode(title); AutorRangeNode = new AutorRangeNode(autors); PublisherNode = new PublisherNode(publisher); CityNode = new CityNode(city); YearNode = new YearNode(year); PageCountNode = new PageCountNode(pageCount); }
/// <summary> /// 设置称号属性展示 /// </summary> /// <param name="id"></param> public void SetTitleAttribute(int id) { //"[00ff00]" + "20" +"[-]" if (id == 0) { titleAttributeT.gameObject.SetActive(false); return; } else { titleAttributeT.gameObject.SetActive(true); } if (FSDataNodeTable <TitleNode> .GetSingleton().DataNodeList.ContainsKey(id)) { titleNode = FSDataNodeTable <TitleNode> .GetSingleton().DataNodeList[id]; powerLabel.text = "力量:" + "[00ff00]" + "+" + titleNode.power + "[-]"; intelligenceLabel.text = "智力:" + "[00ff00]" + "+" + titleNode.intelligence + "[-]"; agilityLabel.text = "敏捷:" + "[00ff00]" + "+" + titleNode.agility + "[-]"; hpLabel.text = "生命值:" + "[00ff00]" + "+" + titleNode.hp + "[-]"; attackLabel.text = "攻击:" + "[00ff00]" + "+" + titleNode.attack + "[-]"; armorLabel.text = "护甲:" + "[00ff00]" + "+" + titleNode.armor + "[-]"; magic_resistLabel.text = "磨抗:" + "[00ff00]" + "+" + titleNode.magicresist + "[-]"; criticalLabel.text = "暴击:" + "[00ff00]" + "+" + titleNode.critical + "[-]"; dodgeLabel.text = "闪避:" + "[00ff00]" + "+" + titleNode.dodge + "[-]"; hitratioLabel.text = "命中:" + "[00ff00]" + "+" + titleNode.hitratio + "[-]"; armorpenetrationLabel.text = "护甲穿透:" + "[00ff00]" + "+" + titleNode.armorpenetration + "[-]"; magicpenetrationLabel.text = "魔法穿透:" + "[00ff00]" + "+" + titleNode.magic_penetration + "[-]"; suckbloodLabel.text = "吸血:" + "[00ff00]" + "+" + titleNode.suck_blood + "[-]"; tenacityLabel.text = "韧性:" + "[00ff00]" + "+" + titleNode.tenacity + "[-]"; mspeed.text = "移动速度:" + "[00ff00]" + "+" + titleNode.movementspeed + "[-]"; aspeed.text = "攻击速度:" + "[00ff00]" + "+" + titleNode.attackspeed + "[-]"; fanwei.text = "可视范围:" + "[00ff00]" + "+" + titleNode.strikingdistance + "[-]"; powerLabel.gameObject.SetActive(titleNode.power > 0 ? true : false); intelligenceLabel.gameObject.SetActive(titleNode.intelligence > 0 ? true : false); agilityLabel.gameObject.SetActive(titleNode.agility > 0 ? true : false); hpLabel.gameObject.SetActive(titleNode.hp > 0 ? true : false); attackLabel.gameObject.SetActive(titleNode.attack > 0 ? true : false); armorLabel.gameObject.SetActive(titleNode.armor > 0 ? true : false); magic_resistLabel.gameObject.SetActive(titleNode.magicresist > 0 ? true : false); criticalLabel.gameObject.SetActive(titleNode.critical > 0 ? true : false); dodgeLabel.gameObject.SetActive(titleNode.dodge > 0 ? true : false); hitratioLabel.gameObject.SetActive(titleNode.hitratio > 0 ? true : false); armorpenetrationLabel.gameObject.SetActive(titleNode.armorpenetration > 0 ? true : false); magicpenetrationLabel.gameObject.SetActive(titleNode.magic_penetration > 0 ? true : false); suckbloodLabel.gameObject.SetActive(titleNode.suck_blood > 0 ? true : false); tenacityLabel.gameObject.SetActive(titleNode.tenacity > 0 ? true : false); mspeed.gameObject.SetActive(titleNode.movementspeed > 0 ? true : false); aspeed.gameObject.SetActive(titleNode.attackspeed > 0 ? true : false); fanwei.gameObject.SetActive(titleNode.strikingdistance > 0 ? true : false); grid.Reposition(); } }
public bool ChangeTitleStateResult(CReadPacket packet) { Debug.Log("ChangeTitleStateResult"); Dictionary <string, object> data = packet.data; playerData.GetInstance().getEnergyData.resolt = int.Parse(data["ret"].ToString()); if (playerData.GetInstance().getEnergyData.resolt == 0) { int titleID = int.Parse(data["titleId"].ToString()); int type = int.Parse(data["oprType"].ToString()); //如果是穿戴 if (type == 1) { //回复成功后 UIPlayerTitlePanel.Instance.ShowPrompt("装备成功"); if (playerData.GetInstance().selfData.playerTitleDic.ContainsKey(titleID)) { if (FSDataNodeTable <TitleNode> .GetSingleton().DataNodeList.ContainsKey(titleID)) { TitleNode titleNode = FSDataNodeTable <TitleNode> .GetSingleton().DataNodeList[titleID]; playerData.GetInstance().selfData.playerTitleName = titleNode.titlename; playerData.GetInstance().selfData.playerTitleId = titleNode.titleid; UIPlayerTitlePanel.Instance.SetPlayerTitleName(playerData.GetInstance().selfData.playerTitleName); UIPlayerTitlePanel.Instance.RefreshPanel();//刷新界面 } } }//如果是卸下 else if (type == 2) { //回复成功后 UIPlayerTitlePanel.Instance.ShowPrompt("卸下称号"); playerData.GetInstance().selfData.playerTitleName = ""; playerData.GetInstance().selfData.playerTitleId = 0; UIPlayerTitlePanel.Instance.SetPlayerTitleName(""); UIPlayerTitlePanel.Instance.RefreshPanel();//刷新界面 } } else { Debug.Log(data["desc"].ToString()); } return(true); }
public override void VisitTitle(TitleNode node) { Write("<", new string('-', node.Level), ">"); StartDump(); AggregateChildren(node); string content = StopDump(); if (content.HasMultipleLine() || content.Length > RecommendedLineSize) { WriteLine(); } else { Write(" "); } Write(content); }
public override void Info(object obj) { base.Info(obj); titleNode = (TitleNode)obj; pathWay.text = titleNode.des; //先判断是否已经激活 if (playerData.GetInstance().selfData.playerTitleDic.ContainsKey(titleNode.titleid)) { noNactivetedT.gameObject.SetActive(false); usefullLife.gameObject.SetActive(true);//激活状态才有 有效期 usefullLife.text = SubstringTime(playerData.GetInstance().selfData.playerTitleDic[titleNode.titleid]); titleName.text = titleNode.titlename; //icon.GetComponent<UISprite>().color = new Color(1, 1, 1); titleName.GetComponent <UILabel>().color = new Color(1, 1, 1f); //然后在判断是否当前携带的 if (titleNode.titleid == playerData.GetInstance().selfData.playerTitleId) { onPlayerBody.gameObject.SetActive(true); //显示对号 putonBtn.gameObject.SetActive(false); //隐藏穿上按钮 getoffBtn.gameObject.SetActive(true); //显示脱下按钮 } else { onPlayerBody.gameObject.SetActive(false); //隐藏对号 putonBtn.gameObject.SetActive(true); //显示穿上按钮 getoffBtn.gameObject.SetActive(false); //隐藏脱下按钮 } } else { //未激活称号 noNactivetedT.gameObject.SetActive(true); usefullLife.gameObject.SetActive(false); titleName.text = titleNode.titlename;//未激活的称号图标为灰色 titleName.GetComponent <UILabel>().color = new Color(0.5f, 0.5f, 0.5f); onPlayerBody.gameObject.SetActive(false); putonBtn.gameObject.SetActive(false); putonBtn.gameObject.SetActive(false); } }
private static async Task AnnounceAchievement(SocketGuildUser user, TitleNode title) { AchievementNotifyEmbed ane = new AchievementNotifyEmbed(user, title); if ((int)title.Difficulty > (int)TitleNode.DifficultyLevel.HARD && !(title.Difficulty == TitleNode.DifficultyLevel.SECRET_EASY || title.Difficulty == TitleNode.DifficultyLevel.SECRET_MEDIUM || title.Difficulty == TitleNode.DifficultyLevel.SECRET_HARD)) { await BotUtils.DMUserAsync(user, ane.GetEmbed()); ane.Header = $"{user.GetDisplayName()} got an achievement!"; await ane.Display(ServerData.BotChannel); } else { await BotUtils.DMUserAsync(user, ane.GetEmbed()); // Don't notify for smaller achievements /*bool sent = await BotUtils.DMUserAsync(user, ane.GetEmbed()); * * if(!sent) { * await ane.Display(ServerData.BotChannel); // Notify the user somehow * }*/ } }
public static async Task AddTitle(SocketGuildUser user, int titleid) { if (!NodeMap.ContainsKey(titleid)) { KLog.Error($"Attempted to give user {BotUtils.GetFullUsername(user)} invalid title ID #{titleid}"); return; } TitleNode node = NodeMap[titleid]; if (node == null) { KLog.Error($"Attempted to give user {BotUtils.GetFullUsername(user)} null title with ID #{titleid}"); return; } UserDataNode u = UserDataManager.GetUserData(user); if (u.Titles == null) { u.Titles = new List <int>(); } if (u.Titles.Contains(titleid)) { return; // Don't give duplicate titles } u.Titles.Add(titleid); node.OnComplete(user); KLog.Important($"User {BotUtils.GetFullUsername(user)} has earned title {node.Name}"); UserDataManager.SaveUserData(); await AnnounceAchievement(user, node); }
public AchievementNotifyEmbed(SocketGuildUser user, TitleNode title) { Title = title; User = user; }
/// <summary> /// /// </summary> /// <param name="metaString"></param> /// <param name="_stream"></param> /// <param name="htmls"></param> /// <param name="_includeSolutions"></param> /// <param name="studentNameAddedToPrint"></param> public static void PDFToStream(string metaString, Stream _stream, IEnumerable <HTML> htmls, bool _includeSolutions, string studentNameAddedToPrint) { int errorCount = 0; errorCount = htmls.Count(h => h.hardErrors.Count > 0); if ((errorCount > 0) && MessageBox.Show("some rows had errors in them and will not show up in the PDF - do you wish to continue?", "", MessageBoxButton.YesNo) == MessageBoxResult.No) { return; } using (Document document = new Document()) { using (PdfWriter _writer = PdfWriter.GetInstance(document, _stream)) { List <Action <PdfWriter, Rectangle> > pageActions = new List <Action <PdfWriter, Rectangle> >(); _writer.PageEvent = new AllFormsPageEvent(pageActions); Dictionary <string, PdfFormField> radioGroups = new Dictionary <string, PdfFormField>(); document.Open(); document.AddAuthor(metaString); //MUST HAPPEN AFTER DOC OPEN //optional studentNameAddedToPrint if (!string.IsNullOrWhiteSpace(studentNameAddedToPrint)) { TitleNode title = new TitleNode(studentNameAddedToPrint); document.Add(title.element); } PdfPTable questionsTable = new PdfPTable(2); questionsTable.SplitLate = true; //splits row that is too large questionsTable.SplitRows = false; //allows rows to split string previousTitle = string.Empty; foreach (HTML html in htmls.Where(h => h.hardErrors.Count == 0)) { if (html.title != previousTitle) { PdfPCell titleCell = html.titleCellNode().cell(); titleCell.Border = PdfPCell.NO_BORDER; titleCell.Padding = 10f; questionsTable.AddCell(titleCell); previousTitle = html.title; } foreach (CellNode cell in html.cellNodes) { //add actions for input fields foreach (FieldNode node in cell.descendants.OfType <FieldNode>()) { node.actionId = pageActions.Count.ToString(); if (node is RadioNode) { PdfFormField radioGroup; if (!radioGroups.TryGetValue(node.fieldName, out radioGroup)) { radioGroup = PdfFormField.CreateRadioButton(_writer, false); radioGroup.FieldName = node.fieldName; radioGroups.Add(node.fieldName, radioGroup); } pageActions.Add((node as RadioNode).radioAction(radioGroup)); } else { pageActions.Add(node.action); } } //add cell to document PdfPCell pcell = cell.cell(); //pcell.Border = PdfPCell.NO_BORDER; pcell.Padding = 10f; questionsTable.AddCell(pcell); } } questionsTable.CompleteRow(); document.Add(questionsTable); if (_includeSolutions) { document.Add(Chunk.NEXTPAGE); Paragraph solutionsPara = new Paragraph("Solutions \n"); solutionsPara.Add(string.Join("\n", htmls.OfType <QuestionAssignmentHTML>().Select(h => h.solutionPlainText("\n")))); document.Add(solutionsPara); } document.Close(); } //end of using writer } //end of using document }
public override void VisitTitle(TitleNode node) { Write("<h", node.Level.ToString(), ">"); JoinChildren(node, "<br />" + NewLine); Write("</h", node.Level.ToString(), ">"); }
public override void VisitTitle(TitleNode node) { Write(new string('#', node.Level) + " "); AggregateChildren(node); }
public override Embed GetEmbed() { EmbedBuilder eb = new EmbedBuilder(); eb.WithTitle("Titles"); eb.WithColor(BotUtils.Kamtro); if (SelectedTitle == null) { // if the embed is on the home page AKA title list page eb.WithColor(BotUtils.Kamtro); string txt = ""; if (AchievementManager.TitleCount() <= 0) { txt = "Titles not available. Contact Caron or Arcy."; } else if (AchievementManager.TitleCount() <= MAX_TITLES_DISPLAYED) { for (int i = 0; i < Titles.Count; i++) { txt += MakeBold($"{(Cursor == i ? CustomEmotes.CursorAnimated : CustomEmotes.CursorBlankSpace)}{Titles[i].Item2.Name}", UserDataManager.HasTitle(User, Titles[i].Item1)) + "\n"; } } else { if (Start != 0) { txt += "***[...]***\n"; } for (int i = Start; i <= Math.Min(Titles.Count - 1, MAX_TITLES_DISPLAYED + Start); i++) { // display titles starting from Start txt += MakeBold($"{(Cursor == i ? CustomEmotes.CursorAnimated : CustomEmotes.CursorBlankSpace)}{Titles[i].Item2.Name}", UserDataManager.HasTitle(User, Titles[i].Item1)) + "\n"; } if (Start < Titles.Count - 1 - MAX_TITLES_DISPLAYED) { txt += "***[...]***"; } } eb.AddField("Title List", txt.TrimEnd('\n')); MenuOptions.Find((x) => x.Icon == ReactionHandler.SELECT_STR).Description = "Select"; } else { // if it's on a title page TitleNode tn = AchievementManager.GetTitle(SelectedTitle.Value); eb.WithColor(tn.GetColor()); eb.AddField("Title Name", tn.Name); if (tn.Secret) { eb.AddField("Secret", "This is a secret title!"); } eb.AddField("Kamtroken Reward", $"{tn.KamtrokenReward}", true); eb.AddField("Temp Rep Reward", $"{tn.TempRepReward}", true); // section for additional rewards // most common of these is the perm rep increase // Kamtro god will also pimp out your profile string add = ""; if (tn.PermRepReward > 0) { add += $"Earning this title will increase the number of rep points you get each week by {tn.PermRepReward}!\n"; } if (SelectedTitle.Value == 0) { add += "This title will add a special badge to your profile!"; } if (!string.IsNullOrWhiteSpace(add)) { eb.AddField("Additional Rewards:", add.TrimEnd('\n')); } MenuOptions.Find((x) => x.Icon == ReactionHandler.SELECT_STR).Description = "Equip Title"; } if (NoTitleNotify) { NoTitleNotify = false; eb.AddField("Alert", "You don't have this title unlocked!"); } if (TitleEquipedNotify) { TitleEquipedNotify = false; eb.AddField("Success", "Title Equipped!"); } AddMenu(eb); return(eb.Build()); }
public override IDocumentNode VisitParagraph(DashParser.ParagraphContext context) { IEnumerable <IDocumentNode> content; IEnumerable <ParserRuleContext> rules = context.GetRules(); DashParser.TitleHeaderContext titleHeader = context.titleHeader(); if (titleHeader != null) { int titleLevel = ((ValueNode <int>)titleHeader.Accept(this)).Value; content = rules.Skip(1).Select(x => x.Accept(this)).NotNulls(); var titleNode = new TitleNode { Level = titleLevel }; titleNode.Children.AddRange(content.Cast <TitleNode.IChild>()); return(titleNode); } DashParser.HeaderContext header = context.header(); if (header != null) { rules = rules.Skip(1); _paragraphMode = null; _titleMode = null; } content = rules.Select(x => x.Accept(this)).NotNulls(); IDocumentNode node; if (header != null) { var paragraphNode = new ParagraphNode { Class = (header.Accept(this) as ValueNode <string>)?.Value }; paragraphNode.Children.AddRange(content.Cast <ParagraphNode.IChild>()); node = paragraphNode; } else if (_paragraphMode != null) { var paragraphNode = new ParagraphNode { Class = _paragraphMode }; paragraphNode.Children.AddRange(content.Cast <ParagraphNode.IChild>()); node = paragraphNode; } else if (_titleMode != null) { var titleNode = new TitleNode { Level = _titleMode.Value }; titleNode.Children.AddRange(content.Cast <TitleNode.IChild>()); node = titleNode; } else { var paragraphNode = new ParagraphNode(); paragraphNode.Children.AddRange(content.Cast <ParagraphNode.IChild>()); node = paragraphNode; } return(node); }
public abstract void VisitTitle(TitleNode node);
private bool FriendsRecommendResult(CReadPacket packet) { Debug.Log(" FriendsRecommendResult 推荐好友"); Dictionary <string, object> data = packet.data; int result = int.Parse(data["ret"].ToString()); if (result == 0) { if (data.ContainsKey("item")) { playerData.GetInstance().friendListData.RecommendfriendList.Clear(); if (null != data["item"] as object[]) { object[] goodList = data["item"] as object[]; for (int i = 0; i < goodList.Length; i++) { Dictionary <string, object> goodInfo = (Dictionary <string, object>)goodList[i]; FriendData info = new FriendData(); if (goodInfo.ContainsKey("nm")) { info.Name = goodInfo["nm"].ToString(); } if (goodInfo.ContainsKey("id")) { info.PlayerId = long.Parse(goodInfo["id"].ToString()); } if (goodInfo.ContainsKey("aid")) { info.AcountPlayerId = long.Parse(goodInfo["aid"].ToString()); } if (goodInfo.ContainsKey("ptf")) { if (null != FSDataNodeTable <RoleIconAttrNode> .GetSingleton().FindDataByType(int.Parse(goodInfo["ptf"].ToString()))) { RoleIconAttrNode vo = FSDataNodeTable <RoleIconAttrNode> .GetSingleton().FindDataByType(int.Parse(goodInfo["ptf"].ToString())); info.PlayerFrame = vo.icon_name; } } if (goodInfo.ContainsKey("lv")) { info.Level = int.Parse(goodInfo["lv"].ToString()); } if (goodInfo.ContainsKey("hlv")) { info.HeroLevel = int.Parse(goodInfo["hlv"].ToString()); } if (goodInfo.ContainsKey("pt")) { if (null != FSDataNodeTable <HeroNode> .GetSingleton().FindDataByType(int.Parse(goodInfo["pt"].ToString()))) { HeroNode vo = FSDataNodeTable <HeroNode> .GetSingleton().FindDataByType(int.Parse(goodInfo["pt"].ToString())); info.PlayerIcon = vo.icon_name + "_head"; } } if (goodInfo.ContainsKey("afc")) { info.Fighting = int.Parse(goodInfo["afc"].ToString()); } if (goodInfo.ContainsKey("tl")) { if (0 != int.Parse(goodInfo["tl"].ToString())) { if (null != FSDataNodeTable <TitleNode> .GetSingleton().FindDataByType(int.Parse(goodInfo["tl"].ToString()))) { TitleNode vo = FSDataNodeTable <TitleNode> .GetSingleton().FindDataByType(int.Parse(goodInfo["tl"].ToString())); info.Title = vo.titlename; } } else { info.Title = "称号:无"; } } playerData.GetInstance().friendListData.RecommendfriendList.Add(info); } if (playerData.GetInstance().friendListData.RecommendfriendList.Count > 0) { List <FriendData> itemLt = new List <FriendData>(); playerData.GetInstance().friendListData.RecommendfriendList.Sort((a, b) => b.Fighting - a.Fighting); FriendData temp = null; for (int i = 0; i < playerData.GetInstance().friendListData.RecommendfriendList.Count; i++) { for (int j = i + 1; j < playerData.GetInstance().friendListData.RecommendfriendList.Count; j++) { if (playerData.GetInstance().friendListData.RecommendfriendList[j].Fighting == playerData.GetInstance().friendListData.RecommendfriendList[i].Fighting && playerData.GetInstance().friendListData.RecommendfriendList[j].Level > playerData.GetInstance().friendListData.RecommendfriendList[i].Level) { temp = playerData.GetInstance().friendListData.RecommendfriendList[j]; playerData.GetInstance().friendListData.RecommendfriendList[j] = playerData.GetInstance().friendListData.RecommendfriendList[i]; playerData.GetInstance().friendListData.RecommendfriendList[i] = temp; } } } } } } return(true); } else { Control.ShowGUI(UIPanleID.UITooltips, EnumOpenUIType.DefaultUIOrSecond, false, data["desc"].ToString()); return(false); } }