public MediaTypeSearchCriteria(MediaType types, MatchRule typeMatchRule) { if (types == MediaType.None) throw new ArgumentException("No type specified", "types"); this.types = types; this.typeMatchRule = typeMatchRule; }
public QuantitySearchCriteria(QuantityField fields, long quantity, CompareOperator compareOperator, MatchRule fieldMatchRule) { if (quantity < 0) throw new ArgumentOutOfRangeException("quantity"); this.quantityFields = fields; this.quantity = quantity; this.compareOperator = compareOperator; this.fieldMatchRule = fieldMatchRule; }
private void Init(MatchRule rule) { _matchRule = rule; SubItems.Clear(); //first row is actual item, all others are "sub-items" Text = rule.StartTagRegexValue; SubItems.Add(rule.EndTagRegexValue); string tagType = rule.TagType == MatchRule.TagTypeOption.TagPair ? "Tag Pair" : "Placeholder"; SubItems.Add(tagType); string isTranslatable = rule.IsContentTranslatable ? "Translatable" : "Not translatable"; SubItems.Add(isTranslatable); }
public void AllRules_Call_NotNullOrEmpty() { var rules = MatchRule.AllRules(); Assert.IsNotEmpty(rules); }
/// <summary> /// Starts a free kick. /// </summary> public unsafe override void Start() { #region 站位回合 var random = manager.Match; // 当前回合加1 manager.Match.Status.Round++; manager.Match.RoundInit(); manager.Match.Status.Break(EnumMatchBreakState.DirectKick); // 射门目标 Coordinate target = (manager.Side == Side.Home) ? manager.Match.Pitch.AwayGoal : manager.Match.Pitch.HomeGoal; // 已经移动位置后的球员列表 List <IPlayer> finArray = new List <IPlayer>(Defines.Match.MAX_PLAYER_COUNT * 2); #region 罚球人相关 // 找出罚球人,罚球人为任意球属性最高的球员(不包含守门员) IPlayer takeKickPlayer = MatchRule.GetHighestPropertyPlayer(manager, PlayerProperty.FreeKick); if (takeKickPlayer == null) // 如果没有可以罚球的球员,返回 { return; } takeKickPlayer.Status.Hasball = true; finArray.Add(takeKickPlayer); // 罚球人站到球面前 takeKickPlayer.Status.ForceState(IdleState.Instance); takeKickPlayer.MoveTo(point); takeKickPlayer.Rotate(point); #endregion #region 找出人墙区 const int distance = 20; // 离人墙的距离 const int pDistance = 5; // 人墙间的距离 const int pDistanceY = 10; double xdiff = point.X - target.X; double ydiff = point.Y - target.Y; if (xdiff == 0) { xdiff = 1; } if (ydiff == 0) { ydiff = 5; //ydiff = 1; } double tDistance = target.Distance(point); // 总距离 double l = xdiff / -ydiff; // 斜率 double x0 = point.X - xdiff / tDistance * distance; double y0 = point.Y - ydiff / tDistance * distance; #region 填充人墙坐标 int wallPlayerCount = random.RandomBool() ? 2 : 3; List <Coordinate> wallPoints = new List <Coordinate>(wallPlayerCount); if (wallPlayerCount == 2) { double x = x0 - pDistance / 2 * xdiff / tDistance; double y = y0 + pDistanceY / 2 * ydiff / tDistance; wallPoints.Add(new Coordinate(x, y)); x = x0 + pDistance / 2 * xdiff / tDistance; y = y0 - pDistanceY / 2 * ydiff / tDistance; wallPoints.Add(new Coordinate(x, y)); } else { // wall player count = 3 double x = x0 - pDistance * xdiff / tDistance; double y = y0 + pDistanceY * ydiff / tDistance; wallPoints.Add(new Coordinate(x, y)); x = x0; y = y0; wallPoints.Add(new Coordinate(x, y)); x = x0 + pDistance * xdiff / tDistance; y = y0 - pDistanceY * ydiff / tDistance; wallPoints.Add(new Coordinate(x, y)); } #endregion #region 摆人墙 // 从防守方找出离球最近的人摆人墙 double * defenders = stackalloc double[Defines.Match.MAX_PLAYER_COUNT - 1]; List <IPlayer> array = new List <IPlayer>(Defines.Match.MAX_PLAYER_COUNT - 1); int length = 0; foreach (var p in manager.Opponent.Players) { if (p.SkillLock) { continue; } if (p.Input.AsPosition == Position.Goalkeeper || p.Input.AsPosition == Position.Forward) { continue; } defenders[length] = p.Current.SimpleDistance(point); array.Add(p); length++; } int[] indexes = Utility.SortMinDoubleArrayIndexQuick(defenders, length); for (int i = 0; i < wallPlayerCount; i++) { if (i >= array.Count) { continue; // 修正人墙人数不够引发异常 } Coordinate p = wallPoints[i]; array[indexes[i]].MoveTo(p); finArray.Add(array[indexes[i]]); } #endregion #endregion #region 防守方剩余球员站位 foreach (var p in manager.Opponent.Players) { if (p.SkillLock) { continue; } if (!finArray.Contains(p)) { if (p.Input.AsPosition == Position.Goalkeeper) { p.MoveTo(p.Status.Default); } else { p.MoveTo(CloseMove(p.Status.HalfDefault.X, p.Status.HalfDefault.Y)); } } p.Status.ForceState(IdleState.Instance); p.Rotate(manager.Match.Football.Current); } #endregion #region 进攻方剩余球员站位 IPlayer lastMan = manager.Opponent.Status.LastPlayer; // 最后一个防守人 if (null == lastMan) { lastMan = FindOutLastDefender(); } foreach (var p in manager.Players) { if (p.SkillLock) { continue; } if (p.ClientId != takeKickPlayer.ClientId) { if (p.Input.AsPosition == Position.Goalkeeper) { p.MoveTo(p.Status.Default); } else { if (p.Input.AsPosition == Position.Forward) { // 前锋挤压阵型 int excursion = (manager.Side == Side.Home) ? -random.RandomInt32(0, 10) : random.RandomInt32(0, 10); p.MoveTo(lastMan.Current.X + excursion, p.Status.HalfDefault.Y); } else { // 其余进攻球员 double x = (p.Manager.Side == Side.Home) ? p.Status.HalfDefault.X * 1.6 : p.Status.HalfDefault.X * 1.6 - Defines.Pitch.MAX_WIDTH * 0.6; double y = p.Status.HalfDefault.Y; p.MoveTo(CloseMove(x, y)); } } } p.Status.ForceState(IdleState.Instance); p.Rotate(manager.Match.Football.Current); } #endregion // 停顿时间 for (int i = 0; i < 4; i++) { manager.Match.SaveRpt(); manager.Match.Status.Round++; manager.Match.RoundInit(); } #endregion #region 开球回合 manager.Match.RoundInit(); takeKickPlayer.Status.ForceState(FreekickShootState.Instance); SkillEngine.SkillImpl.SkillFacade.TriggerPlayerSkills(takeKickPlayer, 0, true); takeKickPlayer.Action(); IPlayer gk = manager.Opponent.GetPlayersByPosition(Position.Goalkeeper)[0]; // gk.Decide(); gk.QuickDecide(); gk.Action(); manager.Match.SaveRpt(); #endregion }
private void init() { LocalMatchRule = new MatchRule(defualtRule); //MatchStack = new Stack<State>(); }
/// <summary> /// 验证和正则表达式是否匹配 /// </summary> /// <param name="box">验证框</param> /// <param name="regexPattern">表达式</param> /// <returns></returns> public static ValidBox Match(this ValidBox box, string regexPattern) { var newBox = new MatchRule(regexPattern).ToValidBox(); return(ValidBox.Merge(box, newBox)); }
public MatchForTest(TTeam teamA, TTeam teamB, MatchRule rule, ISetCounter setCounter) : base(teamA, teamB, rule, setCounter) { }
public RegexRuleListItem(MatchRule rule) { Init(rule); }
public unsafe override void Start() { var random = manager.Match; #region 站位回合 manager.Match.Status.Round++; // 当前回合加1 manager.Match.RoundInit(); #region 找出罚球人-> 找出离球最近的人 IPlayer takeKickPlayer = MatchRule.GetClosestPlayerFromBallInMySide(manager); if (takeKickPlayer == null) { return; } takeKickPlayer.Status.Hasball = true; #endregion manager.Match.Football.MoveTo(point); takeKickPlayer.MoveTo(point); takeKickPlayer.Rotate((manager.Side == Side.Home) ? manager.Match.Pitch.AwayGoal : manager.Match.Pitch.HomeGoal); takeKickPlayer.Status.ForceState(IdleState.Instance); bool isHome = takeKickPlayer.Manager.Side == Side.Home; Coordinate coor; double x, y; var atkPlayers = takeKickPlayer.Manager.Players; IPlayer atkPlayer = null; //进攻球员 foreach (var p in atkPlayers) { if (p.Disable) { continue; } if (p.ClientId == takeKickPlayer.ClientId) { continue; } if (p.Input.AsPosition == Position.Goalkeeper) { coor = p.Status.Default; } else { x = isHome ? (p.Status.Default.X + 100) : (p.Status.Default.X - 100); y = p.Status.Default.Y; if (y <= 38) { y += 20; } else if (y >= 98) { y -= 20; } coor = MatchRule.RandPointInRect(random, new Coordinate(x, y), 3, 8); } p.Status.ForceState(IdleState.Instance); p.MoveTo(coor); p.Rotate(point); } //防守球员 int uStep = 60; int dStep = 76; foreach (var p in takeKickPlayer.Manager.Opponent.Players) { if (p.Disable) { continue; } if (p.ClientId == takeKickPlayer.ClientId) { continue; } if (p.Input.AsPosition == Position.Goalkeeper) { coor = p.Status.Default; } else { x = isHome ? (p.Status.Default.X + 60) : (p.Status.Default.X - 60); y = p.Status.Default.Y; coor = new Coordinate(x, y); atkPlayer = MatchRule.GetNearPlayerInRound(coor, atkPlayers, 20); if (null != atkPlayer) { coor = MatchRule.GetNearPointInLine(atkPlayer.Current, coor, 8); } else { coor = MatchRule.RandPointInRect(random, coor, 5, 15); if (38 < coor.Y && coor.Y <= 68) { coor.Y = uStep; uStep += 2; } else if (68 < coor.Y && coor.Y <= 98) { coor.Y = dStep; dStep -= 2; } } if (coor.Y <= 38) { coor.Y += 20; } else if (coor.Y >= 98) { coor.Y -= 20; } } p.Status.ForceState(IdleState.Instance); p.MoveTo(coor); p.Rotate(point); } // 停顿时间 for (int i = 0; i < 4; i++) { manager.Match.SaveRpt(); manager.Match.Status.Round++; manager.Match.RoundInit(); } #endregion #region 开球回合 manager.Match.RoundInit(); takeKickPlayer.Status.ForceState(PassState.Instance); takeKickPlayer.Status.State.Enter(takeKickPlayer); #region 如果没有合适的传球人 if (takeKickPlayer.Status.PassStatus.PassTarget == null) // 没有合适传球的人 { takeKickPlayer.Status.PassStatus.PassTarget = PassTargetDecideRule.PassClosest(takeKickPlayer); } #endregion if (takeKickPlayer.Current.SimpleDistance(takeKickPlayer.Status.PassStatus.PassTarget.Current) <= Defines.Player.SHORT_PASS_MAX_RANGEPow) { takeKickPlayer.Status.ForceState(ShortPassState.Instance); } else { takeKickPlayer.Status.ForceState(LongPassState.Instance); } takeKickPlayer.Rotate(takeKickPlayer.Status.PassStatus.PassTarget.Current); takeKickPlayer.Action(); manager.Match.SaveRpt(); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="MatchStandalone{TTeam}"/> class. /// </summary> /// <param name="teamA">Team a.</param> /// <param name="teamB">Team b.</param> /// <param name="rule">Rule.</param> /// <param name="initialService">The team that serves initially.</param> /// <param name="setCounter">The set counter.</param> /// <exception cref="ArgumentException">Occures when the <paramref name="initialService"/> is equal to neither <paramref name="teamA"/> nor <paramref name="teamB"/>.</exception> public MatchStandalone(TTeam teamA, TTeam teamB, MatchRule rule, EnumTeams initialService, ISetCounter setCounter) : base(teamA, teamB, rule, setCounter) { }
public void RoundInit() { _status.MatchState = _football.IsInAir ? AirBallState.Instance : DefaultBallState.Instance; _status.GoalState = false; _status.FoulState = EnumMatchFoulState.None; _status.FoulPlayer = null; _status.Break(EnumMatchBreakState.None); _football.TurnFlag = false; short round = _status.Round; int minute = MatchRule.ConvertRound2Minute(round, _status.TotalRound); int sectionNo = -1; bool minuteFlag = false; if (round == 0) { sectionNo = 0; minuteFlag = true; } else if (_status.Minute != minute) { minuteFlag = true; if (minute == 46) { sectionNo = 1; } } if (sectionNo >= 0) { _status.SectionNo = sectionNo; HomeManager.SectionInit(sectionNo); AwayManager.SectionInit(sectionNo); SkillFacade.TriggerManagerSkills(HomeManager, 0); SkillFacade.TriggerManagerSkills(AwayManager, 0); foreach (var player in HomeManager.Players) { SkillFacade.TriggerPlayerSkills(player, 0); } foreach (var player in AwayManager.Players) { SkillFacade.TriggerPlayerSkills(player, 0); } } if (minuteFlag) { _status.Minute = (short)minute; HomeManager.MinuteInit(); AwayManager.MinuteInit(); } if (sectionNo >= 0) { _openSide = _openSide == Side.Home ? Side.Away : Side.Home; _status.Break(EnumMatchBreakState.SectionOpen); Openball(_openSide == Side.Home ? _homeManager : _awayManager); } if (null != _status.BallHandler && _status.BallHandler.Disable) { _status.IsNoBallHandler = true; } if (_status.IsNoBallHandler) { RefreshBallHandler(); } if (HomeManager.IsAttackSide) { AwayManager.RoundInit(); HomeManager.RoundInit(); } else { HomeManager.RoundInit(); AwayManager.RoundInit(); } }
/// <summary> /// Starts a free kick. /// 执行一次间接任意球 /// </summary> public unsafe override void Start() { #region 站位回合 var random = manager.Match; manager.Match.Status.Round++; // 当前回合加1 manager.Match.RoundInit(); if (!_isOutBorder) { manager.Match.Status.Break(EnumMatchBreakState.IndirectKick); } #region 找出罚球人-> 找出离球最近的人 IPlayer takeKickPlayer = MatchRule.GetClosestPlayerFromBallInMySide(manager); if (takeKickPlayer == null) { return; } takeKickPlayer.Status.Hasball = true; #endregion // 罚球人站到球面前 takeKickPlayer.Status.ForceState(IdleState.Instance); takeKickPlayer.MoveTo(point); takeKickPlayer.Rotate((manager.Side == Side.Home) ? manager.Match.Pitch.AwayGoal : manager.Match.Pitch.HomeGoal); #region 防守方移动至防守位置 foreach (IPlayer p in takeKickPlayer.Manager.Opponent.Players) { // 下场及有异常状态的球员不移动位置 if (p.SkillLock) { continue; } Coordinate coor; if (p.Input.AsPosition != Position.Goalkeeper) { coor = CloseMove(p.Status.HalfDefault.X, p.Status.HalfDefault.Y); } else { coor = p.Status.Default; } p.Status.ForceState(IdleState.Instance); p.MoveTo(coor); p.Rotate(point); } #endregion #region 进攻方除罚球人移动至进攻位置 foreach (IPlayer p in takeKickPlayer.Manager.Players) { // 下场及有异常状态的球员不移动位置 if (p.SkillLock) { continue; } if (p.ClientId == takeKickPlayer.ClientId) { continue; } if (p.Input.AsPosition == Position.Goalkeeper) { p.MoveTo(p.Status.Default); p.Rotate(point); p.Status.ForceState(IdleState.Instance); continue; } double x = (p.Manager.Side == Side.Home) ? p.Status.HalfDefault.X * 1.6 : p.Status.HalfDefault.X * 1.6 - Defines.Pitch.MAX_WIDTH * 0.6; double y = p.Status.Default.Y; y = random.RandomBool() ? y + 5 : y - 5; Coordinate coor = CloseMove(x, y); p.Status.ForceState(IdleState.Instance); p.MoveTo(coor); p.Rotate(point); } #endregion // 停顿时间 for (int i = 0; i < 4; i++) { manager.Match.SaveRpt(); manager.Match.Status.Round++; manager.Match.RoundInit(); } #endregion #region 开球回合 manager.Match.RoundInit(); takeKickPlayer.Status.ForceState(PassState.Instance); //边线球 if (manager.Match.Football.IsOutBorder) { takeKickPlayer.Status.SubState.SetSubState(EnumSubState.HandThrow, manager.Match.Status.Round); takeKickPlayer.Status.ForceState(ShortPassState.Instance); takeKickPlayer.DecideEnd(); takeKickPlayer.Status.PassStatus.PassTarget = PassTargetDecideRule.PassClosest(takeKickPlayer); } else { takeKickPlayer.Status.State.Enter(takeKickPlayer); #region 如果没有合适的传球人 if (takeKickPlayer.Status.PassStatus.PassTarget == null) // 没有合适传球的人 { takeKickPlayer.Status.PassStatus.PassTarget = PassTargetDecideRule.PassClosest(takeKickPlayer); } #endregion if (takeKickPlayer.Current.SimpleDistance(takeKickPlayer.Status.PassStatus.PassTarget.Current) < Defines.Player.SHORT_PASS_MAX_RANGEPow) { takeKickPlayer.Status.ForceState(ShortPassState.Instance); } else { takeKickPlayer.Status.ForceState(LongPassState.Instance); } } takeKickPlayer.Rotate(takeKickPlayer.Status.PassStatus.PassTarget.Current); takeKickPlayer.Action(); manager.Match.SaveRpt(); #endregion }
/* get the sql search condition of this/these field/fields */ string IFreeTextSearchField.GetSqlSearchCondition(string searchString, TextCompareOperator compareOperator, MatchRule fieldMatchRule) { StringBuilder sql = new StringBuilder(); if (this.ContainsField(AnyName)) { // search name fields of _all_ possible volume itemtypes (e.g. DirectoryName, FileName, ...) SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.Name", searchString), fieldMatchRule); } else { if (this.ContainsField(DirectoryName)) { SearchUtils.Append( sql, compareOperator.GetSqlCompareString("Items.Name", searchString) + string.Format(" AND (Items.ItemType = {0})", (int)VolumeItemType.DirectoryVolumeItem), fieldMatchRule ); } if (this.ContainsField(FileName)) { SearchUtils.Append( sql, compareOperator.GetSqlCompareString("Items.Name", searchString) + string.Format(" AND (Items.ItemType = {0})", (int)VolumeItemType.FileVolumeItem), fieldMatchRule ); } } if (this.ContainsField(Keywords)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.Keywords", searchString), fieldMatchRule); } if (this.ContainsField(Location)) { SearchUtils.Append( sql, compareOperator.GetSqlCompareString("Items.Location", searchString) + string.Format(" AND ((Items.ItemType = {0}) OR (Items.ItemType = {1}))", (int)VolumeItemType.FileVolumeItem, (int)VolumeItemType.DirectoryVolumeItem), fieldMatchRule ); } if (this.ContainsField(Note)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.Note", searchString), fieldMatchRule); } #if ALLOW_FREETEXTSEARCH_MIMETYPE if (this.ContainsField(MimeType)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.MimeType", searchString), fieldMatchRule); } #endif #if ALLOW_FREETEXTSEARCH_METADATA if (this.ContainsField(MetaData)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.MetaData", searchString), fieldMatchRule); } #endif return sql.ToString(); }
/* get the sql search condition of this/these field/fields */ string IFreeTextSearchField.GetSqlSearchCondition(string searchString, TextCompareOperator compareOperator, MatchRule fieldMatchRule) { StringBuilder sql = new StringBuilder(); if (this.ContainsField(Title)) SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Title", searchString), fieldMatchRule); if (this.ContainsField(LoanedTo)) SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Loaned_To", searchString), fieldMatchRule); if (this.ContainsField(Description)) SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Description", searchString), fieldMatchRule); if (this.ContainsField(Keywords)) SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Keywords", searchString), fieldMatchRule); return sql.ToString(); }
/* get the sql search condition of this/these field/fields */ string IFreeTextSearchField.GetSqlSearchCondition(string searchString, TextCompareOperator compareOperator, MatchRule fieldMatchRule) { StringBuilder sql = new StringBuilder(); if (this.ContainsField(Title)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Title", searchString), fieldMatchRule); } if (this.ContainsField(LoanedTo)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Loaned_To", searchString), fieldMatchRule); } if (this.ContainsField(Description)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Description", searchString), fieldMatchRule); } if (this.ContainsField(Keywords)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Keywords", searchString), fieldMatchRule); } return(sql.ToString()); }
/* get the sql search condition of this/these field/fields */ internal string GetSqlSearchCondition(long quantity, CompareOperator compareOperator, MatchRule fieldMatchRule) { StringBuilder sql = new StringBuilder(); string strQuantity = quantity.ToString(); if (this.ContainsField(Files)) SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Files", strQuantity), fieldMatchRule); if (this.ContainsField(Dirs)) SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Dirs", strQuantity), fieldMatchRule); if (this.ContainsField(Size)) SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Size", strQuantity), fieldMatchRule); return sql.ToString(); }
public QuantitySearchCriteria(QuantityField fields, long quantity, CompareOperator compareOperator, MatchRule fieldMatchRule) { if (quantity < 0) { throw new ArgumentOutOfRangeException("quantity"); } this.quantityFields = fields; this.quantity = quantity; this.compareOperator = compareOperator; this.fieldMatchRule = fieldMatchRule; }
public void SetRule(MatchRule rule) { Init(rule); }
public RequestRegistrationModel(string localPath, MatchRule <int> port, MatchRule <Body> body, MatchRule <Headers> headers, MatchRule <string> query, MatchRule <Method> method) { LocalPath = localPath; Port = port; Body = body; Headers = headers; Query = query; Method = method; }
public TagMatch(InlineType inlineType, Match match, MatchRule matchRule) { _match = match; InlineType = inlineType; MatchRule = matchRule; }
/// <summary> /// 创建个性化菜单按钮,menuButton公众号的所有个性化菜单,最多只能设置为跳转到3个域名下的链接;matchrule共六个字段,均可为空,但至少要有一个匹配信息是不为空的 /// </summary> /// <param name="menuButton">菜单按钮数组,其中链接跳转不能多于3个</param> /// <param name="matchRule">matchrule共六个字段,均可为空,但不能全部为空,至少要有一个匹配信息是不为空的</param> /// <returns>微信服务返回的创建结果</returns> public WeChatResult <MenuCreateInfo> CreatePersonalMenu(List <MenuButton> menuButtonList, MatchRule matchRule) { if (menuButtonList == null) { return(null); } if (matchRule == null) { matchRule = new MatchRule() { country = "中国", province = "广东", language = "zh_CN" } } ; string menuBtnData = JsonConvert.SerializeObject(new { button = menuButtonList, matchrule = "{0}" }); //开始生成菜单按钮的个性化匹配规则 //country、province、city组成地区信息,将按照country、province、city的顺序进行验证,要符合地区信息表的内容。 //地区信息从大到小验证 StringBuilder ruleBuilder = new StringBuilder(); ruleBuilder.Append("{"); if (!string.IsNullOrEmpty(matchRule.tag_id)) { ruleBuilder.Append($"\"tag_id\":\"{matchRule.tag_id}\","); } if (matchRule.sex.HasValue) { ruleBuilder.Append($"\"sex\":\"{matchRule.sex}\","); } if (!string.IsNullOrEmpty(matchRule.country)) { ruleBuilder.Append($"\"country\":\"{matchRule.country}\","); } if (!string.IsNullOrEmpty(matchRule.province)) { ruleBuilder.Append($"\"province\":\"{matchRule.province}\","); } if (!string.IsNullOrEmpty(matchRule.city)) { ruleBuilder.Append($"\"city\":\"{matchRule.city}\","); } if (matchRule.client_platform_type.HasValue) { ruleBuilder.Append($"\"client_platform_type\":\"{matchRule.client_platform_type}\","); } if (!string.IsNullOrEmpty(matchRule.language)) { ruleBuilder.Append($"\"language\":\"{matchRule.language}\","); } if (ruleBuilder.ToString().EndsWith(",")) { ruleBuilder.Remove(ruleBuilder.Length - 1, 1); } ruleBuilder.Append("}"); string[] menuBtnSplitAry = menuBtnData.Split("\"{0}\"");//把"{0}"替换成matchRule对象 menuBtnData = string.Join(ruleBuilder.ToString(), menuBtnSplitAry); string accessToken = connect.GetAccessToken(); string url = "https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token=" + accessToken;//POST string resultStr = SimulateRequest.HttpPost(url, menuBtnData); WeChatResult <MenuCreateInfo> weChatResult = new WeChatResult <MenuCreateInfo>(resultStr); if (weChatResult.errcode != WeChatErrorCode.SUCCESS) { SystemLogHelper.Warn(GetType().FullName, $"创建个性化菜单CreatePersonalMenu,微信服务报错:{weChatResult}"); } return(weChatResult); }
/// <summary> /// custom Match Rule /// </summary> /// <param name="rule">User-defined rule</param> public void SetMatchRule(MatchRule rule) { LocalMatchRule = rule; }
/// <summary> /// Kicks the penalty kick. /// 罚点球 /// </summary> public unsafe override void Start() { #region 站位回合 var random = manager.Match; // 当前回合加1 manager.Match.Status.Round++; manager.Match.Status.Break(EnumMatchBreakState.PenaltyKick); #region 找出罚球人-> 找出离球最近的人 // 找出罚球人,罚球人为任意球属性最高的球员(不包含守门员) IPlayer takeKickPlayer = MatchRule.GetHighestPropertyPlayer(manager, PlayerProperty.FreeKick); if (takeKickPlayer == null) // 没有可以罚球的人,跳出逻辑 { return; } takeKickPlayer.Status.Hasball = true; #endregion // 罚球人站到球面前 takeKickPlayer.Status.ForceState(IdleState.Instance); takeKickPlayer.MoveTo(point); takeKickPlayer.Rotate((manager.Side == Side.Home) ? manager.Match.Pitch.AwayGoal : manager.Match.Pitch.HomeGoal); #region 防守方移动至防守位置 var region = (manager.Side == Side.Home) ? manager.Match.Pitch.AwayPenaltyRegion : manager.Match.Pitch.HomePenaltyRegion; foreach (IPlayer p in takeKickPlayer.Manager.Opponent.Players) { Coordinate coor; if (p.Input.AsPosition != Position.Goalkeeper) { coor = CloseMove(p.Status.HalfDefault.X, p.Status.HalfDefault.Y); } else { coor = p.Status.Default; } if (p.Input.AsPosition == Position.Fullback) // 将防守人移动至禁区线上 { if (region.Start.X == 0) { coor = new Coordinate(region.End.X, coor.Y); } else { coor = new Coordinate(region.Start.X, coor.Y); } } p.Status.ForceState(IdleState.Instance); p.MoveTo(coor); p.Rotate(point); } #endregion #region 进攻方除罚球人移动至进攻位置 foreach (IPlayer p in takeKickPlayer.Manager.Players) { if (p.ClientId == takeKickPlayer.ClientId) { continue; } if (p.Input.AsPosition == Position.Goalkeeper) { p.MoveTo(p.Status.Default); p.Rotate(point); p.Status.ForceState(IdleState.Instance); continue; } double x = (p.Manager.Side == Side.Home) ? p.Status.HalfDefault.X * 1.6 : p.Status.HalfDefault.X * 1.6 - Defines.Pitch.MAX_WIDTH * 0.6; double y = p.Status.HalfDefault.Y; y = random.RandomBool() ? y + 5 : y - 5; Coordinate coor = CloseMove(x, y); p.Status.ForceState(IdleState.Instance); p.MoveTo(coor); p.Rotate(point); } #endregion #region 防止除罚球人外任何人进入禁区 foreach (IManager m in manager.Match.Managers) { foreach (IPlayer player in m.Players) { if (player.ClientId == takeKickPlayer.ClientId) { continue; } if (player.Input.AsPosition == Position.Goalkeeper) { continue; } if (region.IsCoordinateInRegion(player.Current)) { if (region.Start.X == 0) { player.MoveTo(region.End.X, player.Current.Y); } else { player.MoveTo(region.Start.X, player.Current.Y); } } } } #endregion // 停顿时间 for (int i = 0; i < 4; i++) { manager.Match.SaveRpt(); manager.Match.Status.Round++; manager.Match.RoundInit(); } #endregion #region 开球回合 takeKickPlayer.Status.ForceState(VolleyShootState.Instance); takeKickPlayer.AddFinishingBuff(1); takeKickPlayer.Action(); IPlayer gk = manager.Opponent.GetPlayersByPosition(Position.Goalkeeper)[0]; gk.QuickDecide(); gk.Action(); manager.Match.SaveRpt(); #endregion }
/* get the sql search condition of this/these type/types */ internal string GetSqlSearchCondition(MatchRule typeMatchRule) { StringBuilder sql = new StringBuilder(); if (this.ContainsType(Audio)) SearchUtils.Append(sql, "Items.MimeType LIKE 'audio/%'", typeMatchRule); if (this.ContainsType(Video)) SearchUtils.Append(sql, "Items.MimeType LIKE 'video/%'", typeMatchRule); if (this.ContainsType(Image)) SearchUtils.Append(sql, "Items.MimeType LIKE 'image/%'", typeMatchRule); if (this.ContainsType(Text)) SearchUtils.Append(sql, "Items.MimeType LIKE 'text/%'", typeMatchRule); if (this.ContainsType(Directory)) SearchUtils.Append(sql, "Items.MimeType = 'x-directory/normal'", typeMatchRule); return sql.ToString(); }
/// <summary> /// 创建个性化菜单 /// </summary> /// <param name="button">一级菜单项, 1~3个</param> /// <param name="matchrule">匹配规则</param> /// <param name="config"></param> /// <returns></returns> public static Task <AddConditionalResult> AddConditional(Button[] button, MatchRule matchrule, ApiConfig config = null) { return(ApiHelper.PostResult <AddConditionalResult>("https://api.weixin.qq.com/cgi-bin/menu/addconditional?$acac$", new { button, matchrule }, config)); }
/* get the sql search condition of this/these field/fields */ string IFreeTextSearchField.GetSqlSearchCondition(string searchString, TextCompareOperator compareOperator, MatchRule fieldMatchRule) { StringBuilder sql = new StringBuilder(); if (this.ContainsField(AnyName)) { // search name fields of _all_ possible volume itemtypes (e.g. DirectoryName, FileName, ...) SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.Name", searchString), fieldMatchRule); } else { if (this.ContainsField(DirectoryName)) { SearchUtils.Append( sql, compareOperator.GetSqlCompareString("Items.Name", searchString) + string.Format(" AND (Items.ItemType = {0})", (int)VolumeItemType.DirectoryVolumeItem), fieldMatchRule ); } if (this.ContainsField(FileName)) { SearchUtils.Append( sql, compareOperator.GetSqlCompareString("Items.Name", searchString) + string.Format(" AND (Items.ItemType = {0})", (int)VolumeItemType.FileVolumeItem), fieldMatchRule ); } } if (this.ContainsField(Keywords)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.Keywords", searchString), fieldMatchRule); } if (this.ContainsField(Location)) { SearchUtils.Append( sql, compareOperator.GetSqlCompareString("Items.Location", searchString) + string.Format(" AND ((Items.ItemType = {0}) OR (Items.ItemType = {1}))", (int)VolumeItemType.FileVolumeItem, (int)VolumeItemType.DirectoryVolumeItem), fieldMatchRule ); } if (this.ContainsField(Note)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.Note", searchString), fieldMatchRule); } #if ALLOW_FREETEXTSEARCH_MIMETYPE if (this.ContainsField(MimeType)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.MimeType", searchString), fieldMatchRule); } #endif #if ALLOW_FREETEXTSEARCH_METADATA if (this.ContainsField(MetaData)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.MetaData", searchString), fieldMatchRule); } #endif return(sql.ToString()); }
public void ParseArgsMaxAllowed() { string ruleText = @"arg63='Foo'"; MatchRule.Parse(ruleText); }
/// <summary> /// 配置文件配置规则(多项配置换行): /// {DllRelativePathOfImpl="BLL.dll",ImplementNameSpace="BLL.SaleOrder",MatchImplExpression="^data.+",InterFaceName="IGetSaleOrderInfo",IgnoreCase=true} /// {DllRelativePathOfImpl="BLL.dll",ImplementNameSpace="BLL.MemberManage.impl",MatchImplExpression="^produce.+",InterFaceName="BLL.MemberManage.IProduceMaintain",IgnoreCase=true} /// </summary> /// <returns></returns> private static EList <CKeyValue> MatchRules() { EList <CKeyValue> list = new EList <CKeyValue>(); string file = Path.Combine(rootPath, configFile); if (!File.Exists(file)) { defaultConfig(file); } if (!File.Exists(file)) { return(list); } LogsRange logsRange1 = new LogsRange(); string[] arr = File.ReadAllLines(file); MatchRule mr = null; string FieldName = ""; string FieldValue = ""; int n = 0; Match m = null; PropertyInfo pi = null; object v = null; RuleType tag = RuleType.none; object entity = null; string s = "";// @"(?<FieldName>[^\{\=\,\s]+)\s*\=\s*((""(?<FieldValue>[^""\}\,]+)"")|(?<FieldValue>[^""\}\=\,\s]+))"; s = @"(?<FieldName>[^\{\=\,\s]+)\s*\=\s*((""(?<FieldValue>[^""]+)"")|(?<FieldValue>[^""\}\=\,\s]+))"; Regex rg = new Regex(s, RegexOptions.IgnoreCase); foreach (string item in arr) { s = item; n = 0; tag = RuleType.none; while (rg.IsMatch(s) && 20 > n) { m = rg.Match(s); FieldName = m.Groups["FieldName"].Value; FieldValue = m.Groups["FieldValue"].Value; if (0 == n) { pi = GetPropertyInfoByName(typeof(DbInfo), FieldName); tag = null != pi ? RuleType.DbInfo : tag; if (null == pi) { pi = GetPropertyInfoByName(typeof(MatchRule), FieldName); tag = null != pi ? RuleType.MatchRule : tag; if (RuleType.MatchRule == tag) { mr = new MatchRule(); } } if (null == pi) { pi = GetPropertyInfoByName(typeof(LogsRange), FieldName); tag = null != pi ? RuleType.LogsRange : tag; } } if (RuleType.DbInfo == tag) { pi = GetPropertyInfoByName(typeof(DbInfo), FieldName); entity = ImplementAdapter.dbInfo; } else if (RuleType.MatchRule == tag) { pi = GetPropertyInfoByName(typeof(MatchRule), FieldName); entity = mr; } else if (RuleType.LogsRange == tag) { pi = GetPropertyInfoByName(typeof(LogsRange), FieldName); entity = logsRange1; } if (null != pi) { v = DJTools.ConvertTo(FieldValue, pi.PropertyType); try { entity.GetType().GetProperty(pi.Name).SetValue(entity, v, null); } catch { } } s = s.Replace(m.Groups[0].Value, ""); n++; } if (RuleType.MatchRule == tag) { if (string.IsNullOrEmpty(mr.MatchImplExpression)) { continue; } if (string.IsNullOrEmpty(mr.InterFaceName)) { continue; } list.Add(new CKeyValue() { Key = mr.InterFaceName, Value = mr }); mr = null; } } errorLevels1.Clear(); ErrorLevels el1 = ErrorLevels.severe; bool bool1 = Enum.TryParse(logsRange1.upperLimit, out el1); if (!bool1) { el1 = ErrorLevels.severe; } errorLevels1.Add(el1); ErrorLevels el2 = ErrorLevels.debug; bool1 = Enum.TryParse(logsRange1.lowerLimit, out el2); if (!bool1) { el2 = ErrorLevels.debug; } errorLevels1.Add(el2); return(list); }
public void ParseArgsMoreThanAllowed() { string ruleText = @"arg64='Foo'"; MatchRule.Parse(ruleText); }