-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
209 additions
and
30 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
MementoMori.BlazorShared/Components/Settings/GachaSettings.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
@inject ISnackbar Snackbar | ||
@inject IWritableOptions<PlayersOption> PlayersOptions | ||
@using MementoMori.Option | ||
@using MementoMori.Ortega.Common.Utils | ||
@using MementoMori.Ortega.Share | ||
@using MementoMori.Ortega.Share.Data.Item | ||
@using MementoMori.Common.Localization | ||
@using MementoMori.Ortega.Share.Enums | ||
@inherits MementoMori.WebUI.Models.AccountComponent | ||
@inject IWritableOptions<GameConfig> WritableGameConfig | ||
|
||
<MudCard> | ||
<MudCardHeader> | ||
<CardHeaderContent> | ||
<MudText>@Masters.TextResourceTable.Get("[CommonFooterGachaButtonLabel]") (Global)</MudText> | ||
</CardHeaderContent> | ||
</MudCardHeader> | ||
<MudCardContent> | ||
<MudField Label="@ResourceStrings.AutoGachaConsumeItems" Variant="Variant.Outlined"> | ||
<MudSelect T="UserItem" Label="" MultiSelection="true" Dense="true" Comparer="@(new UserItemComparer())" | ||
@bind-SelectedValues="GachaConfigAutoGachaConsumeUserItems" MultiSelectionTextFunc="list => string.Format(ResourceStrings.SelectedXItems, list.Count)"> | ||
@foreach (var item in _gachaConsumeItems) | ||
{ | ||
<MudSelectItem T="UserItem" Value="@item">@ItemUtil.GetItemName(item)</MudSelectItem> | ||
} | ||
</MudSelect> | ||
</MudField> | ||
<MudField Label="@Tr("[TradeShopTabName11]")" Variant="Variant.Outlined"> | ||
<MudSelect T="GachaRelicType" Label="@Tr("[GachaRelicChangeTitle]")" @bind-Value="_targetRelicType" Dense="true"> | ||
<MudSelectItem T="GachaRelicType" Value="GachaRelicType.None">None</MudSelectItem> | ||
<MudSelectItem T="GachaRelicType" Value="GachaRelicType.ChaliceOfHeavenly">@Tr("[ItemName45]")</MudSelectItem> | ||
<MudSelectItem T="GachaRelicType" Value="GachaRelicType.SilverOrderOfTheBlueSky">@Tr("[ItemName46]")</MudSelectItem> | ||
<MudSelectItem T="GachaRelicType" Value="GachaRelicType.DivineWingsOfDesire">@Tr("[ItemName47]")</MudSelectItem> | ||
<MudSelectItem T="GachaRelicType" Value="GachaRelicType.FruitOfTheGarden">@Tr("[ItemName48]")</MudSelectItem> | ||
</MudSelect> | ||
<MudSwitch Label="Auto Buy 3 times" @bind-Checked="_isAutoGacha"></MudSwitch> | ||
</MudField> | ||
</MudCardContent> | ||
</MudCard> | ||
|
||
@code { | ||
IEnumerable<UserItem> GachaConfigAutoGachaConsumeUserItems | ||
{ | ||
get => WritableGameConfig.Value.GachaConfig.AutoGachaConsumeUserItems; | ||
set => WritableGameConfig.Update(x => x.GachaConfig.AutoGachaConsumeUserItems = value.ToList()); | ||
} | ||
|
||
List<UserItem> _gachaConsumeItems = new(); | ||
|
||
GachaRelicType _targetRelicType = GachaRelicType.None; | ||
|
||
bool _isAutoGacha; | ||
|
||
protected override Task AccountChanged() | ||
{ | ||
_gachaConsumeItems = Masters.ItemTable.GetArray() | ||
.Where(d => d.ItemType == ItemType.GachaTicket || d.ItemType == ItemType.FriendPoint || d.ItemType == ItemType.Gold) | ||
.Select(d => new UserItem() {ItemId = d.ItemId, ItemType = d.ItemType}).ToList(); | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
private class UserItemComparer : IEqualityComparer<UserItem> | ||
{ | ||
public bool Equals(UserItem x, UserItem y) | ||
{ | ||
if (ReferenceEquals(x, y)) return true; | ||
if (ReferenceEquals(x, null)) return false; | ||
if (ReferenceEquals(y, null)) return false; | ||
if (x.GetType() != y.GetType()) return false; | ||
return x.ItemId == y.ItemId && x.ItemType == y.ItemType; | ||
} | ||
|
||
public int GetHashCode(UserItem obj) | ||
{ | ||
return HashCode.Combine(obj.ItemId, (int) obj.ItemType); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
MementoMori.Ortega/Share/Data/ApiInterface/Gacha/ChangeGachaRelicRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using MementoMori.Ortega.Share.Enums; | ||
using MessagePack; | ||
|
||
namespace MementoMori.Ortega.Share.Data.ApiInterface.Gacha | ||
{ | ||
[MessagePackObject(true)] | ||
[OrtegaApi("gacha/changeGachaRelic", true, false)] | ||
public class ChangeGachaRelicRequest : ApiRequestBase | ||
{ | ||
public GachaRelicType GachaRelicType { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
MementoMori.Ortega/Share/Data/ApiInterface/Gacha/ChangeGachaRelicResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Runtime.CompilerServices; | ||
using MementoMori.Ortega.Share.Data.Gacha; | ||
using MessagePack; | ||
|
||
namespace MementoMori.Ortega.Share.Data.ApiInterface.Gacha | ||
{ | ||
[MessagePackObject(true)] | ||
public class ChangeGachaRelicResponse : ApiResponseBase, IUserSyncApiResponse | ||
{ | ||
public List<GachaCaseInfo> GachaCaseInfoList { get; set; } | ||
|
||
public UserSyncData UserSyncData { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using MementoMori.Option; | ||
using Quartz; | ||
|
||
namespace MementoMori.Jobs; | ||
|
||
internal class AutoChangeGachaRelicJob : IJob | ||
{ | ||
private AccountManager _accountManager; | ||
|
||
public AutoChangeGachaRelicJob(AccountManager accountManager) | ||
{ | ||
_accountManager = accountManager; | ||
} | ||
|
||
public async Task Execute(IJobExecutionContext context) | ||
{ | ||
var userId = context.MergedJobDataMap.GetLongValue("userId"); | ||
if (userId <= 0) return; | ||
var account = _accountManager.Get(userId); | ||
if (!account.Funcs.IsQuickActionExecuting) await account.Funcs.Login(); | ||
await account.Funcs.AutoSetGachaRelic(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters