diff --git a/Shared/PlasmaShared/ISpringieService/RatingCategory.cs b/Shared/PlasmaShared/ISpringieService/RatingCategory.cs index fea5adc3d..e63bbbe1c 100644 --- a/Shared/PlasmaShared/ISpringieService/RatingCategory.cs +++ b/Shared/PlasmaShared/ISpringieService/RatingCategory.cs @@ -11,4 +11,8 @@ public enum RatingCategoryFlags { Casual = 1, MatchMaking = 2, Planetwars = 4 } + public enum RatingSearchOption + { + Any = 0, None = 1, Casual = 2, Competitive = 3, Planetwars = 4 + } } diff --git a/Zero-K.info/Controllers/BattlesController.cs b/Zero-K.info/Controllers/BattlesController.cs index 6e8976fd5..af17ac75f 100644 --- a/Zero-K.info/Controllers/BattlesController.cs +++ b/Zero-K.info/Controllers/BattlesController.cs @@ -67,6 +67,8 @@ public class BattleSearchModel public YesNoAny Mission { get; set; } public YesNoAny Bots { get; set; } public YesNoAny Victory { get; set; } + public YesNoAny Matchmaker { get; set; } + public RatingSearchOption Rating { get; set; } public RankSelector Rank { get; set; } = RankSelector.Undefined; public int? MinLength { get; set; } @@ -166,6 +168,34 @@ public ActionResult Index(BattleSearchModel model) { q = q.Where(b => b.Rank == rank); } + if (model.Matchmaker != YesNoAny.Any) + { + var bval = model.Matchmaker == YesNoAny.Yes; + q = q.Where(b => b.IsMatchMaker == bval); + } + + if (model.Rating != RatingSearchOption.Any) + { + switch (model.Rating) + { + case RatingSearchOption.Competitive: + q = q.Where(b => b.ApplicableRatings.HasFlag(RatingCategoryFlags.MatchMaking)); + break; + case RatingSearchOption.Casual: + q = q.Where(b => b.ApplicableRatings.HasFlag(RatingCategoryFlags.Casual)); + break; + case RatingSearchOption.Planetwars: + q = q.Where(b => b.ApplicableRatings.HasFlag(RatingCategoryFlags.Planetwars)); + break; + case RatingSearchOption.None: + q = q.Where(b => b.ApplicableRatings == 0); + break; + default: + // The default case being no filtering should be safe enough. + break; + } + } + q = q.OrderByDescending(b => b.StartTime); if (model.offset.HasValue) q = q.Skip(model.offset.Value); diff --git a/Zero-K.info/Views/Battles/BattleDetail.cshtml b/Zero-K.info/Views/Battles/BattleDetail.cshtml index f82bf2af1..cf49b3cc2 100644 --- a/Zero-K.info/Views/Battles/BattleDetail.cshtml +++ b/Zero-K.info/Views/Battles/BattleDetail.cshtml @@ -100,9 +100,37 @@ @Model.IsMission + + + Rating: + + + @{ + if (Model.IsRatedMatch()) + { + switch (Model.GetRatingCategory()) + { + case RatingCategory.MatchMaking: + Competitive + break; + case RatingCategory.Casual: + Casual + break; + case RatingCategory.Planetwars: + Planetwars + break; + } + } + else + { + None + } + } + + @if (!string.IsNullOrEmpty(Model.ReplayFileName)) -{ + { Watch Replay Now @@ -112,7 +140,7 @@ Manual download
} -} + }
diff --git a/Zero-K.info/Views/Battles/BattleIndex.cshtml b/Zero-K.info/Views/Battles/BattleIndex.cshtml index 07fde4138..59c2238cc 100644 --- a/Zero-K.info/Views/Battles/BattleIndex.cshtml +++ b/Zero-K.info/Views/Battles/BattleIndex.cshtml @@ -6,18 +6,22 @@
- - + + + + - - - + + + @@ -30,6 +34,8 @@ Bots: @Html.EnumDropDownListFor(x => x.Bots) Rank: @Html.EnumDropDownListFor(x => x.Rank) Victory: @Html.EnumDropDownListFor(x => x.Victory) + MM: @Html.EnumDropDownListFor(x => x.Matchmaker) + Rating: @Html.EnumDropDownListFor(x => x.Rating)
Title: @Html.TextBoxFor(x => x.Title)Map: @Html.TextBoxFor(x => x.Map, new { data_autocomplete = Url.Action("Maps", "Autocomplete"), data_autocomplete_action = "submit" })Title: @Html.TextBoxFor(x => x.Title)Map: @Html.TextBoxFor(x => x.Map, new { data_autocomplete = Url.Action("Maps", "Autocomplete"), data_autocomplete_action = "submit" })
Players: - @using (var db = new ZkDataContext()) { @Html.MultiSelectFor(x => x.UserId, Url.Action("UsersNoLink", "Autocomplete"), x => Html.PrintAccount(db.Accounts.Find(x))); } + @using (var db = new ZkDataContext()) + {@Html.MultiSelectFor(x => x.UserId, Url.Action("UsersNoLink", "Autocomplete"), x => Html.PrintAccount(db.Accounts.Find(x))); + } Player count: @Html.TextBoxFor(x => x.PlayersFrom) - @Html.TextBoxFor(x => x.PlayersTo)
Player count: @Html.TextBoxFor(x => x.PlayersFrom) - @Html.TextBoxFor(x => x.PlayersTo)
Age: @Html.EnumDropDownListFor(x => x.Age)