Skip to content

Commit

Permalink
Allow searching by is-MM and rating type.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aquanim committed Jan 26, 2021
1 parent 2959b27 commit 8312446
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
40 changes: 40 additions & 0 deletions Zero-K.info/Controllers/BattlesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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 RatingOption Rating { get; set; }
public RankSelector Rank { get; set; } = RankSelector.Undefined;
public int? offset { get; set; }
public List<BattleQuickInfo> Data;
Expand All @@ -68,6 +70,15 @@ public enum AgeOption
ThisMonth = 3
}

public enum RatingOption
{
Any = 0,
Casual = 1,
Competitive = 2,
Planetwars = 3,
None = 4
}

/// <summary>
/// Returns the main battle replay list; params filter
/// </summary>
Expand Down Expand Up @@ -138,6 +149,35 @@ 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 != RatingOption.Any)
{
switch (model.Rating)
{
case RatingOption.Competitive:
//q = q.Where(b => b.IsRatedMatch() && b.GetRatingCategory() == RatingCategory.MatchMaking);
q = q.Where(b => b.ApplicableRatings.HasFlag(RatingCategoryFlags.MatchMaking));
break;
case RatingOption.Casual:
//q = q.Where(b => b.IsRatedMatch() && b.GetRatingCategory() == RatingCategory.Casual);
q = q.Where(b => b.ApplicableRatings.HasFlag(RatingCategoryFlags.Casual));
break;
case RatingOption.Planetwars:
//q = q.Where(b => b.IsRatedMatch() && b.GetRatingCategory() == RatingCategory.Planetwars);
q = q.Where(b => b.ApplicableRatings.HasFlag(RatingCategoryFlags.Planetwars));
break;
case RatingOption.None:
//q = q.Where(b => !b.IsRatedMatch());
q = q.Where(b => b.ApplicableRatings == 0);
break;
}
}

q = q.OrderByDescending(b => b.StartTime);

if (model.offset.HasValue) q = q.Skip(model.offset.Value);
Expand Down
18 changes: 12 additions & 6 deletions Zero-K.info/Views/Battles/BattleIndex.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@
<form action="@Url.Action("Index")" id="ajaxScrollForm" method="post">
<table class="inputTable">
<tr>
<td>Title: </td><td>@Html.TextBoxFor(x => x.Title)</td>
<td>Map: </td><td>@Html.TextBoxFor(x => x.Map, new { data_autocomplete = Url.Action("Maps", "Autocomplete"), data_autocomplete_action = "submit" })</td>
<td>Title: </td>
<td>@Html.TextBoxFor(x => x.Title)</td>
<td>Map: </td>
<td>@Html.TextBoxFor(x => x.Map, new { data_autocomplete = Url.Action("Maps", "Autocomplete"), data_autocomplete_action = "submit" })</td>
</tr>
<tr>
<td>Players: </td>
<td>
@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)));
}
</td>
<td>Player count: </td><td> @Html.TextBoxFor(x => x.PlayersFrom) - @Html.TextBoxFor(x => x.PlayersTo)</td>
</tr>
<tr>
<td>Player count: </td>
<td> @Html.TextBoxFor(x => x.PlayersFrom) - @Html.TextBoxFor(x => x.PlayersTo)</td>
</tr>
<tr></tr>
<tr>
<td colspan="4">
Age: @Html.EnumDropDownListFor(x => x.Age)
Mission: @Html.EnumDropDownListFor(x => x.Mission)
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)
<input name="sa" value="Search" alt="Search" type="image" src="/img/search_img.png" style="border: none; vertical-align: middle;" />
</td>
</tr>
Expand Down

0 comments on commit 8312446

Please sign in to comment.