|
1 |
| -using System.Collections.Immutable; |
| 1 | +using System; |
| 2 | +using System.Collections.Immutable; |
2 | 3 | using System.Linq;
|
3 | 4 | using System.Threading.Tasks;
|
4 | 5 | using Edelstein.Protocol.Gameplay.Entities.Inventories;
|
5 | 6 | using Edelstein.Protocol.Gameplay.Entities.Inventories.Templates;
|
| 7 | +using Edelstein.Protocol.Gameplay.Entities.Inventories.Templates.Options; |
6 | 8 | using Edelstein.Protocol.Gameplay.Game.Objects.Users.Stats;
|
7 | 9 | using Edelstein.Protocol.Utilities.Pipelines;
|
8 | 10 | using Edelstein.Protocol.Utilities.Templates;
|
9 | 11 |
|
10 | 12 | namespace Edelstein.Common.Gameplay.Game.Objects.Users.Stats.Calculations;
|
11 | 13 |
|
12 | 14 | public class FieldUserStatsCalculatorEquip(
|
13 |
| - ITemplateManager<IItemTemplate> items |
| 15 | + ITemplateManager<IItemTemplate> items, |
| 16 | + ITemplateManager<IItemOptionTemplate> options |
14 | 17 | ) : IFieldUserStatsCalculatorEntry
|
15 | 18 | {
|
16 | 19 | public int Priority => FieldUserStatsCalculatorSteps.Equip;
|
@@ -60,7 +63,65 @@ public async Task Handle(IPipelineContext ctx, IFieldUserStatsCalculatorContext
|
60 | 63 |
|
61 | 64 | stats.MaxHP.IncRate += template.IncMaxHPr;
|
62 | 65 | stats.MaxMP.IncRate += template.IncMaxMPr;
|
| 66 | + |
| 67 | + var grade = (ItemOptionGrade)(item.Grade & 0x3); |
| 68 | + if ((item.Grade & (int)ItemOptionGradeState.Released) > 0 && |
| 69 | + grade is |
| 70 | + ItemOptionGrade.Rare or |
| 71 | + ItemOptionGrade.Epic or |
| 72 | + ItemOptionGrade.Unique) |
| 73 | + { |
| 74 | + var level = (template.ReqLevel - 1) / 10; |
| 75 | + |
| 76 | + level = Math.Max(1, level); |
| 77 | + level = Math.Min(20, level); |
| 78 | + |
| 79 | + await ApplyItemOption(stats, item.Option1, level); |
| 80 | + await ApplyItemOption(stats, item.Option2, level); |
| 81 | + await ApplyItemOption(stats, item.Option3, level); |
| 82 | + } |
63 | 83 | }
|
64 | 84 | }
|
65 | 85 | }
|
| 86 | + |
| 87 | + private async Task ApplyItemOption(IFieldUserStatsCalculatorContext stats, int option, int level) |
| 88 | + { |
| 89 | + var template = await options.Retrieve(option); |
| 90 | + if (template == null) return; |
| 91 | + var templateLevel = await template.Levels.Retrieve(level); |
| 92 | + if (templateLevel == null) return; |
| 93 | + |
| 94 | + stats.STR.IncBase += templateLevel.IncSTR; |
| 95 | + stats.DEX.IncBase += templateLevel.IncDEX; |
| 96 | + stats.LUK.IncBase += templateLevel.IncLUK; |
| 97 | + stats.INT.IncBase += templateLevel.IncINT; |
| 98 | + |
| 99 | + stats.STR.IncRate += templateLevel.IncSTRr; |
| 100 | + stats.DEX.IncRate += templateLevel.IncDEXr; |
| 101 | + stats.LUK.IncRate += templateLevel.IncLUKr; |
| 102 | + stats.INT.IncRate += templateLevel.IncINTr; |
| 103 | + |
| 104 | + stats.MaxHP.IncBase += templateLevel.IncMaxHP; |
| 105 | + stats.MaxMP.IncBase += templateLevel.IncMaxMP; |
| 106 | + |
| 107 | + stats.MaxHP.IncRate += templateLevel.IncMaxHPr; |
| 108 | + stats.MaxMP.IncRate += templateLevel.IncMaxMPr; |
| 109 | + |
| 110 | + stats.PAD.IncBase += templateLevel.IncPAD; |
| 111 | + stats.PDD.IncBase += templateLevel.IncPDD; |
| 112 | + stats.MAD.IncBase += templateLevel.IncMAD; |
| 113 | + stats.MDD.IncBase += templateLevel.IncMDD; |
| 114 | + stats.ACC.IncBase += templateLevel.IncACC; |
| 115 | + stats.EVA.IncBase += templateLevel.IncEVA; |
| 116 | + |
| 117 | + stats.PAD.IncRate += templateLevel.IncPADr; |
| 118 | + stats.PDD.IncRate += templateLevel.IncPDDr; |
| 119 | + stats.MAD.IncRate += templateLevel.IncMADr; |
| 120 | + stats.MDD.IncRate += templateLevel.IncMDDr; |
| 121 | + stats.ACC.IncRate += templateLevel.IncACCr; |
| 122 | + stats.EVA.IncRate += templateLevel.IncEVAr; |
| 123 | + |
| 124 | + stats.Speed.IncBase += templateLevel.IncSpeed; |
| 125 | + stats.Jump.IncBase += templateLevel.IncJump; |
| 126 | + } |
66 | 127 | }
|
0 commit comments