Browse Source

任务的奖励增加一个公式计算的灵石奖励

master
秦汉 3 weeks ago
parent
commit
43e4d64179
  1. 18
      Build_God_Api/Build_God_Api/Services/DailyMissionService.cs
  2. 1
      Build_God_Game/src/api/dailyMission.ts
  3. 2
      Build_God_Game/src/assets/images/mission.svg
  4. 7
      Build_God_Game/src/views/DailyMissionView.vue

18
Build_God_Api/Build_God_Api/Services/DailyMissionService.cs

@ -47,6 +47,7 @@ namespace Build_God_Api.Services
public bool IsFromYesterday { get; set; }
public DateTime AssignedDate { get; set; }
public int ExpReward { get; set; }
public int MoneyReward { get; set; }
public int TodayClaimedCount { get; set; }
public int TodayTotalCount { get; set; }
public List<MissionRewardDto> Rewards { get; set; } = new();
@ -102,6 +103,18 @@ namespace Build_God_Api.Services
return coefficient * levelId * levelId * levelId;
}
private int CalculateMoneyReward(MissionDifficulty difficulty, int levelId)
{
var rate = difficulty switch
{
MissionDifficulty.Normal => 1,
MissionDifficulty.Hard => 2,
MissionDifficulty.Purgatory => 3,
_ => 1
};
return (int)(100 * rate * (1 + (levelId - 10) * 0.1m));
}
private DateTime GetBeijingTime()
{
return TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, BeijingTimeZone);
@ -158,6 +171,7 @@ namespace Build_God_Api.Services
IsFromYesterday = dm.IsFromYesterday,
AssignedDate = dm.AssignedDate,
ExpReward = CalculateExpReward(mission.Difficulty, character.LevelId),
MoneyReward = CalculateMoneyReward(mission.Difficulty, character.LevelId),
TodayClaimedCount = todayClaimedCount,
TodayTotalCount = todayTotalCount,
MissionType = mission.Type,
@ -258,6 +272,10 @@ namespace Build_God_Api.Services
character.CurrentExp += expReward;
_logger.LogInformation("角色 {CharacterId} 领取任务奖励:经验 +{ExpReward}", characterId, expReward);
var moneyReward = CalculateMoneyReward(mission.Difficulty, character.LevelId);
character.Money += moneyReward;
_logger.LogInformation("角色 {CharacterId} 领取任务奖励:灵石 +{MoneyReward}", characterId, moneyReward);
if (mission.Rewards != null)
{
foreach (var reward in mission.Rewards)

1
Build_God_Game/src/api/dailyMission.ts

@ -60,6 +60,7 @@ export interface DailyMission {
isFromYesterday: boolean
assignedDate: string
expReward: number
moneyReward: number
todayClaimedCount: number
todayTotalCount: number
rewards: MissionReward[]

2
Build_God_Game/src/assets/images/mission.svg

@ -1 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1774669383132" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="22425" xmlns:xlink="http://www.w3.org/1999/xlink" width="128" height="128"><path d="M962.56 502.784c-30.72-109.056-73.216-220.16-87.552-247.808-18.432-34.816-44.032-61.44-75.776-79.36-32.768-18.432-73.728-27.648-121.344-27.648h-327.68c-47.616 0-88.064 9.216-121.344 27.648-31.744 17.92-57.344 44.544-75.776 79.36-14.848 27.648-56.832 138.752-88.064 247.808-40.96 145.408-46.592 259.072-16.384 317.44 16.896 32.256 44.544 52.224 80.896 56.32 14.848 2.048 28.672 2.56 41.472 2.56 96.768 0 141.312-49.152 180.736-92.672 23.552-26.112 45.568-50.688 78.336-64h183.808c32.768 13.824 51.712 37.376 73.216 64.512 19.968 25.088 40.448 51.2 72.704 69.12 36.352 20.48 80.896 27.136 137.216 19.968 36.352-4.608 64-24.064 80.896-56.32 31.232-57.856 26.112-171.52-15.36-316.928z m-36.352 288.768c-8.192 16.384-19.968 24.576-38.4 26.624-12.288 1.536-24.064 2.048-34.304 2.048-68.096 0-93.184-31.744-123.904-70.144-24.064-30.208-51.2-64.512-100.352-82.944-3.072-1.024-6.144-1.536-9.728-1.536H426.496c-3.072 0-6.656 0.512-9.728 1.536-47.104 17.92-77.312 50.688-103.424 79.36-42.496 46.592-75.776 83.456-173.056 71.168-17.92-2.048-29.696-10.24-38.4-26.624-22.528-44.032-15.36-147.456 19.968-273.408C152.064 412.16 193.024 306.176 204.8 283.648c28.16-52.224 74.752-76.8 146.944-76.8H675.84c72.192 0 119.296 24.576 146.944 76.8 11.776 22.016 52.736 128 82.432 233.984 36.352 125.952 43.52 229.888 20.992 273.92z" p-id="22426" fill="#d81e06"></path><path d="M610.304 424.448c0 25.6 20.48 46.08 46.08 46.08s46.08-20.48 46.08-46.08-20.48-46.08-46.08-46.08-46.08 20.48-46.08 46.08zM712.704 527.872c0 25.6 20.48 46.08 46.08 46.08s46.08-20.48 46.08-46.08-20.48-46.08-46.08-46.08-46.08 20.992-46.08 46.08zM411.648 447.488H353.28V389.12c0-16.384-13.312-29.696-29.696-29.696s-29.696 13.312-29.696 29.696v58.368H235.52c-16.384 0-29.696 13.312-29.696 29.696S219.136 506.88 235.52 506.88h58.368v58.368c0 16.384 13.312 29.696 29.696 29.696s29.696-13.312 29.696-29.696V506.368h58.368c16.384 0 29.696-13.312 29.696-29.696s-13.312-29.184-29.696-29.184z" p-id="22427" fill="#d81e06"></path></svg>
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1777104274111" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="21236" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M468.114286 621.714286c7.314286 21.942857 21.942857 36.571429 43.885714 36.571428s36.571429-14.628571 43.885714-36.571428L585.142857 219.428571c0-43.885714-36.571429-73.142857-73.142857-73.142857-43.885714 0-73.142857 36.571429-73.142857 80.457143l29.257143 394.971429zM512 731.428571c-43.885714 0-73.142857 29.257143-73.142857 73.142858s29.257143 73.142857 73.142857 73.142857 73.142857-29.257143 73.142857-73.142857-29.257143-73.142857-73.142857-73.142858z" p-id="21237" data-spm-anchor-id="a313x.search_index.0.i3.2c923a81AKleVA" class="selected" fill="#d81e06"></path></svg>

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 912 B

7
Build_God_Game/src/views/DailyMissionView.vue

@ -197,6 +197,7 @@ const MissionCardContent = defineComponent({
: null,
h('div', { class: 'card-rewards' }, [
h('span', { class: 'reward-item exp-reward' }, `${props.mission.expReward}`),
h('span', { class: 'reward-item money-reward' }, `💰${props.mission.moneyReward}`),
...props.mission.rewards.slice(0, 2).map((reward: any) =>
h('span', { class: 'reward-item' }, `${getRewardIcon(reward.rewardType)}${reward.count}`)
),
@ -560,6 +561,12 @@ const MissionCardContent = defineComponent({
color: #ffd700;
}
.money-reward {
background: rgba(34, 197, 94, 0.1);
border-color: rgba(34, 197, 94, 0.3);
color: #22c55e;
}
.reward-more {
background: rgba(255, 255, 255, 0.1);
color: #888888;

Loading…
Cancel
Save