-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProficiency.sol
221 lines (201 loc) · 7.58 KB
/
Proficiency.sol
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
//SPDX-License-Identifier: MIT
pragma solidity 0.8.7;
import "./Rarity.sol";
import "./Feats.sol";
library Proficiency {
function is_proficient_with_armor(
uint256 summoner,
uint256 proficiency,
uint256 armor_type
) public view returns (bool) {
uint256 class = Rarity.class(summoner);
// Barbarian
if (class == 1) {
if (proficiency == 1 || proficiency == 2) {
return true;
} else if (
proficiency == 3 && Feats.armor_proficiency_heavy(summoner)
) {
return true;
} else if (proficiency == 4) {
if (armor_type == 18) {
return Feats.tower_shield_proficiency(summoner);
} else {
return true;
}
}
// Bard, Ranger
} else if (class == 2 || class == 8) {
if (proficiency == 1 || proficiency == 2) {
return true;
} else if (
(Feats.armor_proficiency_medium(summoner)) ||
(proficiency == 3 && Feats.armor_proficiency_heavy(summoner))
) {
return true;
} else if (proficiency == 4) {
if (armor_type == 18) {
return Feats.tower_shield_proficiency(summoner);
} else {
return true;
}
}
// Cleric, Paladin
} else if (class == 3 || class == 7) {
if (proficiency == 4 && armor_type == 18) {
return Feats.tower_shield_proficiency(summoner);
}
return true;
// Druid
} else if (class == 4) {
if (proficiency == 1 || proficiency == 2) {
return true;
} else if (
proficiency == 3 && Feats.armor_proficiency_heavy(summoner)
) {
return true;
} else if (proficiency == 4) {
if (armor_type == 18) {
return Feats.tower_shield_proficiency(summoner);
} else {
return true;
}
}
// Fighter
} else if (class == 5) {
return true;
// Rogue
} else if (class == 9) {
return
(proficiency == 1) ||
(proficiency == 2 &&
Feats.armor_proficiency_medium(summoner)) ||
(proficiency == 3 && Feats.armor_proficiency_heavy(summoner)) ||
(proficiency == 4 &&
armor_type == 18 &&
Feats.tower_shield_proficiency(summoner)) ||
(proficiency == 4 && Feats.shield_proficiency(summoner));
// Monk, Sorcerer, Wizard
} else if (class == 6 || class == 10 || class == 11) {
return
(proficiency == 1 && Feats.armor_proficiency_light(summoner)) ||
(proficiency == 2 &&
Feats.armor_proficiency_medium(summoner)) ||
(proficiency == 3 && Feats.armor_proficiency_heavy(summoner)) ||
(proficiency == 4 &&
armor_type == 18 &&
Feats.tower_shield_proficiency(summoner)) ||
(proficiency == 4 && Feats.shield_proficiency(summoner));
}
return false;
}
function is_proficient_with_weapon(
uint256 summoner,
uint256 proficiency,
uint256 weapon_type
) public view returns (bool) {
uint256 class = Rarity.class(summoner);
// Barbarian, Fighter, Paladin, Ranger
if (class == 1 || class == 5 || class == 7 || class == 8) {
if (proficiency == 1 || proficiency == 2) {
return true;
} else if (Feats.exotic_weapon_proficiency(summoner)) {
return true;
}
// Bard
} else if (class == 2) {
if (proficiency == 1) {
return true;
} else if (
(proficiency == 2 &&
Feats.martial_weapon_proficiency(summoner)) ||
(proficiency == 3 && Feats.exotic_weapon_proficiency(summoner))
) {
return true;
} else if (
weapon_type == 27 || // longsword
weapon_type == 29 || // rapier
weapon_type == 23 || // sap
weapon_type == 24 || // short sword
weapon_type == 46 // short bow
) {
return true;
}
// Cleric, Sorcerer
} else if (class == 3 || class == 10) {
if (proficiency == 1) {
return true;
} else if (
(proficiency == 2 &&
Feats.martial_weapon_proficiency(summoner)) ||
(proficiency == 3 && Feats.exotic_weapon_proficiency(summoner))
) {
return true;
}
// Druid, Monk, Wizard
} else if (class == 4 || class == 6 || class == 11) {
if (
(proficiency == 1 &&
Feats.simple_weapon_proficiency(summoner)) ||
(proficiency == 2 &&
Feats.martial_weapon_proficiency(summoner)) ||
(proficiency == 3 && Feats.exotic_weapon_proficiency(summoner))
) {
return true;
// Druid
} else if (
class == 4 &&
(weapon_type == 6 || // club
weapon_type == 2 || // dagger
weapon_type == 15 || // dart
weapon_type == 11 || // quarterstaff
weapon_type == 30 || // scimitar
weapon_type == 5 || // sickle
weapon_type == 9 || // shortspear
weapon_type == 17 || // sling
weapon_type == 12) // spear
) {
return true;
// Monk
} else if (
class == 6 &&
(weapon_type == 6 || // club
weapon_type == 14 || // light crossbow
weapon_type == 13 || // heavy crossbow
weapon_type == 2 || // dagger
weapon_type == 20 || // hand axe
weapon_type == 16 || // javelin
weapon_type == 48 || // kama
weapon_type == 49 || // nunchaku
weapon_type == 11 || // quarterstaff
weapon_type == 50 || // sia
weapon_type == 51 || // siangham
weapon_type == 17) // sling
) {
return true;
// Rogue
} else if (
class == 9 &&
(weapon_type <= 17 || // Simple weapons
weapon_type == 57 || // hand crossbow
weapon_type == 29 || // rapier
weapon_type == 23 || // sap
weapon_type == 46 || // shortbow
weapon_type == 24) // short sword
) {
return true;
// Wizard
} else if (
class == 11 &&
(weapon_type == 6 || // club
weapon_type == 2 || // dagger
weapon_type == 13 || // heavy crossbow
weapon_type == 14 || // light crossbow
weapon_type == 11) // quarterstaff
) {
return true;
}
}
return false;
}
}