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
|
inline int savingThrows (ClassSaveAs classSaveAs, int level, SavingThrowType savingThrowType) {
static const std::vector<std::vector<std::vector<int>>> savingThrowChart = {
{ // SaveAsFighter
{12, 13, 14, 15, 16},
{10, 11, 12, 13, 14},
{8, 9, 10, 10, 12},
{6, 7, 8, 8, 10},
{4, 5, 6, 5, 8}
},
{ // SaveAsMagicUser
{13, 14, 13, 16, 15},
{11, 12, 11, 14, 12},
{ 8, 9, 8, 11, 8}
},
{ // SaveAsCleric
{11, 12, 14, 16, 15},
{ 9, 10, 12, 14, 12},
{ 6, 7, 9, 11, 9},
{ 3, 5, 7, 8, 7}
},
{ // SaveAsNormalMan
{14, 15, 16, 17, 18}
},
{ // SaveAsThief
{13, 14, 13, 16, 15},
{12, 13, 11, 14, 13},
{10, 11, 9, 12, 10},
{ 8, 9, 7, 10, 8}
},
{ // SaveAsElf
{12, 13, 13, 15, 15},
{10, 11, 11, 13, 12},
{ 8, 9, 9, 10, 10},
{ 6, 7, 8, 8, 8}
},
{ // SaveAsDwarf
{ 8, 9, 10, 13, 12},
{ 6, 7, 8, 10, 10},
{ 4, 5, 6, 7, 8},
{ 2, 3, 4, 4, 6}
},
{ // SaveAsHalfling
{ 8, 9, 10, 13, 12},
{ 6, 7, 8, 10, 10},
{ 4, 5, 6, 7, 8}
}
};
const int levelCategory = [&classSaveAs, level]()->int {
switch (classSaveAs) {
case SaveAsFighter:
if (level <= 0) {classSaveAs = SaveAsNormalMan; return 0;}
return std::min ((level - 1) / 3, static_cast<int> (savingThrowChart[SaveAsFighter].size() - 1));
case SaveAsMagicUser: return std::min ((level - 1) / 5, static_cast<int> (savingThrowChart[SaveAsMagicUser].size() - 1));
case SaveAsCleric: return std::min ((level - 1) / 4, static_cast<int> (savingThrowChart[SaveAsCleric].size() - 1));
case SaveAsNormalMan: return 0;
case SaveAsThief: return std::min ((level - 1) / 4, static_cast<int> (savingThrowChart[SaveAsThief].size() - 1));
case SaveAsElf: return std::min ((level - 1) / 3, static_cast<int> (savingThrowChart[SaveAsElf].size() - 1));
case SaveAsDwarf: return std::min ((level - 1) / 3, static_cast<int> (savingThrowChart[SaveAsDwarf].size() - 1));
case SaveAsHalfling: return std::min ((level - 1) / 3, static_cast<int> (savingThrowChart[SaveAsHalfling].size() - 1));
}
}();
return savingThrowChart[classSaveAs][levelCategory][savingThrowType];
}
|