Skip to content

Commit

Permalink
auto receive achieve ranking reward
Browse files Browse the repository at this point in the history
  • Loading branch information
moonheart committed Dec 31, 2023
1 parent cfa0cb1 commit 78303d1
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 1 deletion.
1 change: 1 addition & 0 deletions MementoMori.BlazorShared/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@
<MudButton Size="Size.Small" Variant="Variant.Filled" Disabled="@Funcs.IsQuickActionExecuting" @onclick="@Funcs.AutoUseItems">@ResourceStrings.UseNormalItems</MudButton>
<MudButton Size="Size.Small" Variant="Variant.Filled" Disabled="@Funcs.IsQuickActionExecuting" @onclick="@Funcs.AutoRankUpCharacter">@TextResourceTable.Get("[CharacterRankUpBulkButton]")</MudButton>
<MudButton Size="Size.Small" Variant="Variant.Filled" Disabled="@Funcs.IsQuickActionExecuting" @onclick="@Funcs.ReadAllMemories">@TextResourceTable.Get("[CharacterDetailMemory]")</MudButton>
<MudButton Size="Size.Small" Variant="Variant.Filled" Disabled="@Funcs.IsQuickActionExecuting" @onclick="@Funcs.ReceiveAchievementReward">@TextResourceTable.Get("[AchieveRankingAchievementTargetLabel]")</MudButton>
@* <MudButton Size="Size.Small" Variant="Variant.Filled" Disabled="@Funcs.IsQuickActionExecuting" @onclick="@Funcs.UseFriendCode">邀请码</MudButton> *@
</MudPaper>
</MudTabPanel>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using MessagePack;

namespace MementoMori.Ortega.Share.Data.ApiInterface.Ranking
{
[MessagePackObject(true)]
[OrtegaApi("ranking/getPlayerRanking", true, false)]
public class GetPlayerRankingRequest : ApiRequestBase
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Runtime.CompilerServices;
using MementoMori.Ortega.Share.Data.Player;
using MessagePack;

namespace MementoMori.Ortega.Share.Data.ApiInterface.Ranking
{
[MessagePackObject(true)]
public class GetPlayerRankingResponse : ApiResponseBase, IUserSyncApiResponse
{
public long AutoRanking { get; set; }

public List<PlayerInfo> AutoRankingPlayerList { get; set; }

public long AutoRankingToday { get; set; }

public long BattlePower { get; set; }

public long BattlePowerRanking { get; set; }

public List<PlayerInfo> BattlePowerRankingPlayerList { get; set; }

public long BattlePowerRankingToday { get; set; }

public long PlayerRankRanking { get; set; }

public List<PlayerInfo> PlayerRankRankingPlayerList { get; set; }

public long PlayerRankRankingToday { get; set; }

public long TowerBattleRanking { get; set; }

public List<PlayerInfo> TowerBattleRankingPlayerList { get; set; }

public long TowerBattleRankingToday { get; set; }

public UserSyncData UserSyncData { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using MessagePack;

namespace MementoMori.Ortega.Share.Data.ApiInterface.Ranking
{
[MessagePackObject(true)]
[OrtegaApi("ranking/receiveAchieveRankingReward", true, false)]
public class ReceiveAchieveRankingRewardRequest : ApiRequestBase
{
public long AchieveRankingRewardMBId { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Runtime.CompilerServices;
using MementoMori.Ortega.Share.Data.Item;
using MessagePack;

namespace MementoMori.Ortega.Share.Data.ApiInterface.Ranking
{
[MessagePackObject(true)]
public class ReceiveAchieveRankingRewardResponse : ApiResponseBase, IUserSyncApiResponse
{
public List<UserItem> RewardItemList { get; set; }

public UserSyncData UserSyncData { get; set; }
}
}
2 changes: 1 addition & 1 deletion MementoMori.Ortega/Share/Data/UserSyncData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void UserItemEditorMergeUserSyncData(UserSyncData userSyncData)
if (userSyncData.PresentCount != null) PresentCount = userSyncData.PresentCount;
if (userSyncData.PrivacySettingsType != null) PrivacySettingsType = userSyncData.PrivacySettingsType;
if (userSyncData.ReceivableAchieveRankingRewardIdMap.IsNotNullOrEmpty())
ReceivableAchieveRankingRewardIdMap = ReceivableAchieveRankingRewardIdMap.Merge(userSyncData.ReceivableAchieveRankingRewardIdMap);
ReceivableAchieveRankingRewardIdMap = userSyncData.ReceivableAchieveRankingRewardIdMap;
if (userSyncData.ReceivedAchieveRankingRewardIdList.IsNotNullOrEmpty())
ReceivedAchieveRankingRewardIdList = userSyncData.ReceivedAchieveRankingRewardIdList;
if (userSyncData.ReceivedAutoBattleRewardLastTime != null) ReceivedAutoBattleRewardLastTime = userSyncData.ReceivedAutoBattleRewardLastTime;
Expand Down
23 changes: 23 additions & 0 deletions MementoMori/MementoMoriFuncs.Ops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
using MementoMori.Ortega.Share.Data.TradeShop;
using static MementoMori.Ortega.Share.Masters;
using DynamicData;
using MementoMori.Ortega.Share.Data.ApiInterface.Ranking;
using MementoMori.Ortega.Share.Data.Battle;

namespace MementoMori;
Expand Down Expand Up @@ -2266,6 +2267,27 @@ double GetMaxItemCount(IUserItem userItem)
});
}

public async Task ReceiveAchievementReward()
{
await ExecuteQuickAction(async (log, token) =>
{
await GetResponse<GetPlayerRankingRequest, GetPlayerRankingResponse>(new GetPlayerRankingRequest());
foreach (var (rankingDataType, mbId) in UserSyncData.ReceivableAchieveRankingRewardIdMap)
{
foreach (var mb in AchieveRankingRewardTable.GetByRankingDataType(rankingDataType))
{
if (mb.Id >= mbId || UserSyncData.ReceivedAchieveRankingRewardIdList.Contains(mb.Id))
{
continue;
}
var response = await GetResponse<ReceiveAchieveRankingRewardRequest, ReceiveAchieveRankingRewardResponse>(new ReceiveAchieveRankingRewardRequest() { AchieveRankingRewardMBId = mb.Id });
log($"{TextResourceTable.Get(mb.AchieveTargetDescriptionKey)}");
response.RewardItemList.PrintUserItems(log);
}
}
});
}


public async Task ExecuteAllQuickAction()
{
Expand All @@ -2282,6 +2304,7 @@ public async Task ExecuteAllQuickAction()
await ReceiveGvgReward();
await GuildCheckin();
await GuildRaid();
await ReceiveAchievementReward();
await BountyQuestRewardAuto();
await BountyQuestStartAuto();
if (GameConfig.AutoJob.AutoDungeonBattle) await AutoDungeonBattle();
Expand Down

0 comments on commit 78303d1

Please sign in to comment.