1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
using FFXIVClientStructs.FFXIV.Client.Game.UI;
namespace Malmstone.Services
{
public class PvPService
{
public int CurrentFrontlineLosingBonus = -1;
public enum FrontlinePlacement
{
FirstPlace = 1, SecondPlace = 2, ThirdPlace = 3, Unknown=4
}
public struct PVPProfileFrontlineResults
{
public uint FirstPlace;
public uint SecondPlace;
public uint ThirdPlace;
}
public PVPProfileFrontlineResults CachedFrontlineResults;
public PvPSeriesInfo? GetPvPSeriesInfo()
{
unsafe
{
var pvpProfile = PvPProfile.Instance();
if (pvpProfile != null && pvpProfile->IsLoaded != 0)
{
return new PvPSeriesInfo
{
CurrentSeriesRank = pvpProfile->GetSeriesCurrentRank(),
ClaimedSeriesRank = pvpProfile->GetSeriesClaimedRank(),
SeriesExperience = pvpProfile->GetSeriesExperience()
};
}
return null;
}
}
public bool UpdateFrontlineResultCache()
{
unsafe
{
var pvpProfile = PvPProfile.Instance();
if (pvpProfile != null && pvpProfile->IsLoaded != 0)
{
CachedFrontlineResults = new PVPProfileFrontlineResults
{
FirstPlace = pvpProfile->FrontlineTotalFirstPlace,
SecondPlace = pvpProfile->FrontlineTotalSecondPlace,
ThirdPlace = pvpProfile->FrontlineTotalThirdPlace
};
return true;
}
return false;
}
}
public int GenerateFrontlineBonus(FrontlinePlacement FrontlineResult, int EarnedSeriesEXP)
{
// Calculates the current Frontline Bonus
// 1000 (no bonus), 1100, 1200, 1300, 1400, 1500 3rd
// 1250 (no bonus), 1375, 1500, 1625, 1750, 1875 2nd
// 1500 (no bonus), 1650, 1800, 1950, 2100, 2250 1st
if (FrontlineResult == FrontlinePlacement.ThirdPlace)
{
switch (EarnedSeriesEXP)
{
case 1000:
CurrentFrontlineLosingBonus = 0;
return 0;
case 1100:
CurrentFrontlineLosingBonus = 10;
return 10;
case 1200:
CurrentFrontlineLosingBonus = 20;
return 20;
case 1300:
CurrentFrontlineLosingBonus = 30;
return 30;
case 1400:
CurrentFrontlineLosingBonus = 40;
return 40;
case 1500:
CurrentFrontlineLosingBonus = 50;
return 50;
default:
return -1;
}
}
else if (FrontlineResult == FrontlinePlacement.SecondPlace)
{
switch (EarnedSeriesEXP)
{
case 1250:
CurrentFrontlineLosingBonus = 0;
return 0;
case 1375:
CurrentFrontlineLosingBonus = 10;
return 10;
case 1500:
CurrentFrontlineLosingBonus = 20;
return 20;
case 1625:
CurrentFrontlineLosingBonus = 30;
return 30;
case 2100:
CurrentFrontlineLosingBonus = 40;
return 40;
case 2250:
CurrentFrontlineLosingBonus = 50;
return 50;
default:
return -1;
}
}
else if (FrontlineResult == FrontlinePlacement.FirstPlace)
{
switch (EarnedSeriesEXP)
{
case 1500:
CurrentFrontlineLosingBonus = 0;
return 0;
case 1650:
CurrentFrontlineLosingBonus = 10;
return 10;
case 1800:
CurrentFrontlineLosingBonus = 20;
return 20;
case 1950:
CurrentFrontlineLosingBonus = 30;
return 30;
case 1750:
CurrentFrontlineLosingBonus = 40;
return 40;
case 1875:
CurrentFrontlineLosingBonus = 50;
return 50;
default:
return -1;
}
}
return -1;
}
public PVPProfileFrontlineResults GetPVPProfileFrontlineResults()
{
unsafe
{
var pvpProfile = PvPProfile.Instance();
if (pvpProfile != null && pvpProfile->IsLoaded != 0)
{
return new PVPProfileFrontlineResults
{
FirstPlace = pvpProfile->FrontlineTotalFirstPlace,
SecondPlace = pvpProfile->FrontlineTotalSecondPlace,
ThirdPlace = pvpProfile->FrontlineTotalThirdPlace,
};
}
}
return new PVPProfileFrontlineResults
{
FirstPlace = 0,
SecondPlace = 0,
ThirdPlace = 0,
};
}
}
public class PvPSeriesInfo
{
public byte CurrentSeriesRank { get; set; }
public byte ClaimedSeriesRank { get; set; }
public ushort SeriesExperience { get; set; }
}
}
|