Reworked random raids to be randomizable multiple times
This commit is contained in:
parent
dd79b0e333
commit
6e4dce5b1f
9 changed files with 249 additions and 83 deletions
|
@ -49,7 +49,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
<RaidRolesPlanned _raid=@_raid _user=@_user/>
|
||||
<RaidRolesRandom _raid=@_raid _user=@_user/>
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -65,7 +65,7 @@
|
|||
<span class="oi oi-plus" aria-hidden="true"></span> Edit
|
||||
</NavLink>
|
||||
</div>
|
||||
@if(_raid.RaidType != RaidType.Planned && !_raid.IsRandomized)
|
||||
@if(_raid.RaidType != RaidType.Planned)
|
||||
{
|
||||
<button type=button @onclick="() => RandomizeClicked()">Randomize</button>
|
||||
}
|
||||
|
|
|
@ -209,12 +209,16 @@
|
|||
{
|
||||
if(_raid.RaidType != RaidType.Planned)
|
||||
{
|
||||
PlannedRaidRole role = _raid.Roles.FirstOrDefault(r => r.IsRandomSignUpRole);
|
||||
int randomRoleId = role != null ? role.PlannedRaidRoleId : 0;
|
||||
_raid.Roles.Clear();
|
||||
_raid.Roles.Add(new PlannedRaidRole()
|
||||
{
|
||||
Spots = 10,
|
||||
Name = "Random",
|
||||
Description = _raid.RaidType.ToString()
|
||||
Description = _raid.RaidType.ToString(),
|
||||
IsRandomSignUpRole = true,
|
||||
PlannedRaidRoleId = randomRoleId
|
||||
});
|
||||
}
|
||||
|
||||
|
|
115
Lieb/Pages/Raids/RaidRolesRandom.razor
Normal file
115
Lieb/Pages/Raids/RaidRolesRandom.razor
Normal file
|
@ -0,0 +1,115 @@
|
|||
@using Lieb.Data
|
||||
@using Lieb.Models
|
||||
@using Lieb.Models.GuildWars2
|
||||
@using Lieb.Models.GuildWars2.Raid
|
||||
@inject RaidService RaidService
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
@{
|
||||
RaidSignUp userRole = _raid.SignUps.Where(s => s.LiebUserId == _user.LiebUserId).FirstOrDefault();
|
||||
bool isSignedUp = userRole != null;
|
||||
}
|
||||
@foreach (PlannedRaidRole role in _raid.Roles)
|
||||
{
|
||||
RaidSignUp[] signUps = _raid.SignUps.Where(s => s.PlannedRaidRoleId == role.PlannedRaidRoleId).ToArray();
|
||||
int usedSpots = signUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count();
|
||||
|
||||
<tr>
|
||||
@if (role.IsRandomSignUpRole && _raid.SignUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count() < 10)
|
||||
{
|
||||
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.SignedUp)">Sign Up</button></td>
|
||||
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Maybe)">Maybe</button></td>
|
||||
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Backup)">Backup</button></td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
}
|
||||
<td><h5>@role.Name: @role.Description (@usedSpots /@role.Spots)</h5></td>
|
||||
</tr>
|
||||
|
||||
@foreach (var signUp in signUps)
|
||||
{
|
||||
@if(signUp.SignUpType != SignUpType.SignedOff)
|
||||
{
|
||||
<tr>
|
||||
@{bool isUser = isSignedUp && userRole.PlannedRaidRole.PlannedRaidRoleId == role.PlannedRaidRoleId && signUp.LiebUserId == _user.LiebUserId;}
|
||||
<td></td>
|
||||
<td></td>
|
||||
@if(isUser)
|
||||
{
|
||||
<td><button @onclick="() => SignOffClicked(role, _user)">Sign Off</button></td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td></td>
|
||||
}
|
||||
@{string signUpStatus = string.Empty;}
|
||||
@if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}";
|
||||
|
||||
@if (isUser && _usableAccounts.Count > 1)
|
||||
{
|
||||
<td>@signUp.LiebUser.Name
|
||||
<select value=@signUp.GuildWars2AccountId @onchange="args => ChangeAccount(_user, args)">
|
||||
@foreach (var account in _usableAccounts)
|
||||
{
|
||||
<option value=@account.GuildWars2AccountId>@account.AccountName</option>
|
||||
}
|
||||
</select> @signUpStatus </td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>@signUp.LiebUser.Name (@signUp.GuildWars2Account.AccountName) @signUpStatus</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public Raid _raid { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public LiebUser _user { get; set; }
|
||||
|
||||
private List<GuildWars2Account> _usableAccounts;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
_usableAccounts = _user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Count > 0).ToList();
|
||||
}
|
||||
|
||||
async Task SignUpClicked(PlannedRaidRole role, LiebUser liebUser, bool isSignedUp, SignUpType signUpType)
|
||||
{
|
||||
if(isSignedUp)
|
||||
{
|
||||
await RaidService.ChangeSignUpType(_raid.RaidId, liebUser.LiebUserId, role.PlannedRaidRoleId, signUpType);
|
||||
}
|
||||
else
|
||||
{
|
||||
await RaidService.SignUp(_raid.RaidId, liebUser.LiebUserId, _usableAccounts.FirstOrDefault().GuildWars2AccountId, role.PlannedRaidRoleId, signUpType);
|
||||
}
|
||||
_raid = RaidService.GetRaid(_raid.RaidId);
|
||||
}
|
||||
|
||||
async Task SignOffClicked(PlannedRaidRole role, LiebUser liebUser)
|
||||
{
|
||||
await RaidService.SignOff(_raid.RaidId, liebUser.LiebUserId, role.PlannedRaidRoleId);
|
||||
_raid = RaidService.GetRaid(_raid.RaidId);
|
||||
}
|
||||
|
||||
async Task ChangeAccount(LiebUser liebUser, ChangeEventArgs e)
|
||||
{
|
||||
int accountId = int.Parse(e.Value.ToString());
|
||||
await RaidService.ChangeAccount(_raid.RaidId, liebUser.LiebUserId, accountId);
|
||||
_raid = RaidService.GetRaid(_raid.RaidId);
|
||||
}
|
||||
}
|
9
Lieb/Pages/Raids/RaidRolesRandom.razor.css
Normal file
9
Lieb/Pages/Raids/RaidRolesRandom.razor.css
Normal file
|
@ -0,0 +1,9 @@
|
|||
h5 {
|
||||
color: lightgrey;
|
||||
}
|
||||
|
||||
table {
|
||||
column-width: auto;
|
||||
color: lightgray;
|
||||
width: max-content;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue