Skip to content

Commit

Permalink
Merge pull request #58 from moreal/avatar-dailyreward
Browse files Browse the repository at this point in the history
feat(api): include `dailyRewardReceivedIndex` in the `Models.Agent.Avatar` model
  • Loading branch information
moreal authored May 16, 2024
2 parents 859182e + 49e901b commit a44bf0c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Mimir.Worker/Scrapper/StateGetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public async Task<AvatarState> GetAvatarState(Address avatarAddress)
{
avatarState.actionPoint = actionPoint;
}

if (await GetStateWithLegacyAccount(avatarAddress, Addresses.DailyReward) is Integer dailyRewardReceivedIndex)
{
avatarState.dailyRewardReceivedIndex = dailyRewardReceivedIndex;
}

return avatarState;
}
Expand Down
2 changes: 1 addition & 1 deletion Mimir/Controllers/AgentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ IStateService stateService
}

return new AvatarsResponse(
avatars.Select(e => new Avatar(e.address.ToString(), e.name, e.level, e.actionPoint)).ToList()
avatars.Select(e => new Avatar(e.address.ToString(), e.name, e.level, e.actionPoint, e.dailyRewardReceivedIndex)).ToList()
);
}
}
3 changes: 2 additions & 1 deletion Mimir/Models/Agent/Avatar.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
namespace Mimir.Models.Agent;

public class Avatar(string avatarAddress, string avatarName, int level, int actionPoint)
public class Avatar(string avatarAddress, string avatarName, int level, int actionPoint, long dailyRewardReceivedIndex)
{
public string AvatarAddress { get; set; } = avatarAddress;
public string AvatarName { get; set; } = avatarName;
public int Level { get; set; } = level;
public int ActionPoint { get; private set; } = actionPoint;
public long DailyRewardReceivedIndex { get; private set; } = dailyRewardReceivedIndex;
}
3 changes: 2 additions & 1 deletion Mimir/Repositories/ArenaRankingRespository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ private async Task<ArenaRanking> BuildArenaRankingFromDocument(BsonDocument docu
document["Avatar"]["Avatar"]["address"].AsString,
document["Avatar"]["Avatar"]["name"].AsString,
document["Avatar"]["Avatar"]["level"].AsInt32,
document["Avatar"]["Avatar"]["actionPoint"].AsInt32
document["Avatar"]["Avatar"]["actionPoint"].AsInt32,
document["Avatar"]["Avatar"]["dailyRewardReceivedIndex"].AsInt64
);
arenaRanking.Avatar = avatar;

Expand Down
5 changes: 5 additions & 0 deletions Mimir/Util/StateGetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ await stateService.GetState(address, accountAddress) ??
{
avatarState.actionPoint = actionPoint;
}

if (await GetStateAsync(avatarAddress, Addresses.DailyReward) is Integer dailyRewardReceivedIndex)
{
avatarState.dailyRewardReceivedIndex = dailyRewardReceivedIndex;
}

return avatarState;
}
Expand Down

0 comments on commit a44bf0c

Please sign in to comment.