-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_loadouts-7510.scala
193 lines (179 loc) · 11.9 KB
/
generate_loadouts-7510.scala
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
val args = sc.getConf.get("spark.driver.args").split("\\s+")
val characterClass = args(0).toLowerCase.substring(0,1) match {
case "t" => "Titan"
case "h" => "Hunter"
case "w" => "Warlock"
}
val filterTier = args(1)
val classItemName = characterClass match {
case "Titan" => "Titan Mark"
case "Hunter" => "Hunter Cloak"
case "Warlock" => "Warlock Bond"
}
val df = spark.read.format("csv")
.option("header", "true")
.load("destinyArmor.csv")
df.cache()
val classArmor = df.filter($"Equippable" === characterClass)
.select("Name","Type","Id","Tier","Masterwork Type","Masterwork Tier","Mobility (Base)","Resilience (Base)","Recovery (Base)","Discipline (Base)","Intellect (Base)","Strength (Base)")
.withColumnRenamed("Masterwork Type", "Element")
.withColumn("Mobility", when($"Masterwork Tier" === 10, $"Mobility (Base)" + 2).otherwise($"Mobility (Base)"))
.withColumn("Resilience", when($"Masterwork Tier" === 10, $"Resilience (Base)" + 2).otherwise($"Resilience (Base)"))
.withColumn("Recovery", when($"Masterwork Tier" === 10, $"Recovery (Base)" + 2).otherwise($"Recovery (Base)"))
.withColumn("Discipline", when($"Masterwork Tier" === 10, $"Discipline (Base)" + 2).otherwise($"Discipline (Base)"))
.withColumn("Intellect", when($"Masterwork Tier" === 10, $"Intellect (Base)" + 2).otherwise($"Intellect (Base)"))
.withColumn("Strength", when($"Masterwork Tier" === 10, $"Strength (Base)" + 2).otherwise($"Strength (Base)"))
.drop("Mobility (Base)","Resilience (Base)","Recovery (Base)","Discipline (Base)","Intellect (Base)","Strength (Base)")
val helmets = classArmor.filter($"Type" === "Helmet")
.withColumnRenamed("Name", "Name_H")
// .filter($"Name_H" === "Wormhusk Crown")
.withColumnRenamed("Type", "Type_H")
.withColumnRenamed("Id", "Id_H")
.withColumn("Exotic_H", when($"Tier" === "Exotic", 1).otherwise(0))
.withColumn("Rare_H", when($"Tier" === "Rare", 1).otherwise(0))
.withColumnRenamed("Element", "Element_H")
.withColumnRenamed("Mobility", "Mobility_H")
.withColumnRenamed("Resilience", "Resilience_H")
.withColumnRenamed("Recovery", "Recovery_H")
.withColumnRenamed("Discipline", "Discipline_H")
.withColumnRenamed("Intellect", "Intellect_H")
.withColumnRenamed("Strength", "Strength_H")
.withColumn("Mobility_MW_H", when($"Masterwork Tier" === 10, $"Mobility_H").otherwise($"Mobility_H" + 2))
.withColumn("Resilience_MW_H", when($"Masterwork Tier" === 10, $"Resilience_H").otherwise($"Resilience_H" + 2))
.withColumn("Recovery_MW_H", when($"Masterwork Tier" === 10, $"Recovery_H").otherwise($"Recovery_H" + 2))
.withColumn("Discipline_MW_H", when($"Masterwork Tier" === 10, $"Discipline_H").otherwise($"Discipline_H" + 2))
.withColumn("Intellect_MW_H", when($"Masterwork Tier" === 10, $"Intellect_H").otherwise($"Intellect_H" + 2))
.withColumn("Strength_MW_H", when($"Masterwork Tier" === 10, $"Strength_H").otherwise($"Strength_H" + 2))
.drop("Masterwork Tier")
.drop("Tier")
val gauntlets = classArmor.filter($"Type" === "Gauntlets")
.withColumnRenamed("Name", "Name_G")
.withColumnRenamed("Type", "Type_G")
.withColumnRenamed("Id", "Id_G")
.withColumn("Exotic_G", when($"Tier" === "Exotic", 1).otherwise(0))
.withColumn("Rare_G", when($"Tier" === "Rare", 1).otherwise(0))
.withColumnRenamed("Element", "Element_G")
.withColumnRenamed("Mobility", "Mobility_G")
.withColumnRenamed("Resilience", "Resilience_G")
.withColumnRenamed("Recovery", "Recovery_G")
.withColumnRenamed("Discipline", "Discipline_G")
.withColumnRenamed("Intellect", "Intellect_G")
.withColumnRenamed("Strength", "Strength_G")
.withColumn("Mobility_MW_G", when($"Masterwork Tier" === 10, $"Mobility_G").otherwise($"Mobility_G" + 2))
.withColumn("Resilience_MW_G", when($"Masterwork Tier" === 10, $"Resilience_G").otherwise($"Resilience_G" + 2))
.withColumn("Recovery_MW_G", when($"Masterwork Tier" === 10, $"Recovery_G").otherwise($"Recovery_G" + 2))
.withColumn("Discipline_MW_G", when($"Masterwork Tier" === 10, $"Discipline_G").otherwise($"Discipline_G" + 2))
.withColumn("Intellect_MW_G", when($"Masterwork Tier" === 10, $"Intellect_G").otherwise($"Intellect_G" + 2))
.withColumn("Strength_MW_G", when($"Masterwork Tier" === 10, $"Strength_G").otherwise($"Strength_G" + 2))
.drop("Masterwork Tier")
.drop("Tier")
val chests = classArmor.filter($"Type" === "Chest Armor")
.withColumnRenamed("Name", "Name_C")
.withColumnRenamed("Type", "Type_C")
.withColumnRenamed("Id", "Id_C")
.withColumn("Exotic_C", when($"Tier" === "Exotic", 1).otherwise(0))
.withColumn("Rare_C", when($"Tier" === "Rare", 1).otherwise(0))
.withColumnRenamed("Element", "Element_C")
.withColumnRenamed("Mobility", "Mobility_C")
.withColumnRenamed("Resilience", "Resilience_C")
.withColumnRenamed("Recovery", "Recovery_C")
.withColumnRenamed("Discipline", "Discipline_C")
.withColumnRenamed("Intellect", "Intellect_C")
.withColumnRenamed("Strength", "Strength_C")
.withColumn("Mobility_MW_C", when($"Masterwork Tier" === 10, $"Mobility_C").otherwise($"Mobility_C" + 2))
.withColumn("Resilience_MW_C", when($"Masterwork Tier" === 10, $"Resilience_C").otherwise($"Resilience_C" + 2))
.withColumn("Recovery_MW_C", when($"Masterwork Tier" === 10, $"Recovery_C").otherwise($"Recovery_C" + 2))
.withColumn("Discipline_MW_C", when($"Masterwork Tier" === 10, $"Discipline_C").otherwise($"Discipline_C" + 2))
.withColumn("Intellect_MW_C", when($"Masterwork Tier" === 10, $"Intellect_C").otherwise($"Intellect_C" + 2))
.withColumn("Strength_MW_C", when($"Masterwork Tier" === 10, $"Strength_C").otherwise($"Strength_C" + 2))
.drop("Masterwork Tier")
.drop("Tier")
val legs = classArmor.filter($"Type" === "Leg Armor")
.withColumnRenamed("Name", "Name_L")
.withColumnRenamed("Type", "Type_L")
.withColumnRenamed("Id", "Id_L")
.withColumn("Exotic_L", when($"Tier" === "Exotic", 1).otherwise(0))
.withColumn("Rare_L", when($"Tier" === "Rare", 1).otherwise(0))
.withColumnRenamed("Element", "Element_L")
.withColumnRenamed("Mobility", "Mobility_L")
.withColumnRenamed("Resilience", "Resilience_L")
.withColumnRenamed("Recovery", "Recovery_L")
.withColumnRenamed("Discipline", "Discipline_L")
.withColumnRenamed("Intellect", "Intellect_L")
.withColumnRenamed("Strength", "Strength_L")
.withColumn("Mobility_MW_L", when($"Masterwork Tier" === 10, $"Mobility_L").otherwise($"Mobility_L" + 2))
.withColumn("Resilience_MW_L", when($"Masterwork Tier" === 10, $"Resilience_L").otherwise($"Resilience_L" + 2))
.withColumn("Recovery_MW_L", when($"Masterwork Tier" === 10, $"Recovery_L").otherwise($"Recovery_L" + 2))
.withColumn("Discipline_MW_L", when($"Masterwork Tier" === 10, $"Discipline_L").otherwise($"Discipline_L" + 2))
.withColumn("Intellect_MW_L", when($"Masterwork Tier" === 10, $"Intellect_L").otherwise($"Intellect_L" + 2))
.withColumn("Strength_MW_L", when($"Masterwork Tier" === 10, $"Strength_L").otherwise($"Strength_L" + 2))
.drop("Masterwork Tier")
.drop("Tier")
val classItems = classArmor.filter($"Type" === classItemName)
.limit(1)
.withColumnRenamed("Name", "Name_CL")
.withColumnRenamed("Type", "Type_CL")
.withColumnRenamed("Id", "Id_CL")
.withColumnRenamed("Element", "Element_CL")
.withColumnRenamed("Mobility", "Mobility_CL")
.withColumn("Mobility_CL", when($"Masterwork Tier" === 10, 2).otherwise(0))
.withColumnRenamed("Resilience", "Resilience_CL")
.withColumn("Resilience_CL", when($"Masterwork Tier" === 10, 2).otherwise(0))
.withColumnRenamed("Recovery", "Recovery_CL")
.withColumn("Recovery_CL", when($"Masterwork Tier" === 10, 2).otherwise(0))
.withColumnRenamed("Discipline", "Discipline_CL")
.withColumn("Discipline_CL", when($"Masterwork Tier" === 10, 2).otherwise(0))
.withColumnRenamed("Intellect", "Intellect_CL")
.withColumn("Intellect_CL", when($"Masterwork Tier" === 10, 2).otherwise(0))
.withColumnRenamed("Strength", "Strength_CL")
.withColumn("Strength_CL", when($"Masterwork Tier" === 10, 2).otherwise(0))
.withColumn("Mobility_MW_CL", lit(2))
.withColumn("Resilience_MW_CL", lit(2))
.withColumn("Recovery_MW_CL", lit(2))
.withColumn("Discipline_MW_CL", lit(2))
.withColumn("Intellect_MW_CL", lit(2))
.withColumn("Strength_MW_CL", lit(2))
.drop("Masterwork Tier")
.drop("Tier")
val joined = helmets
.crossJoin(gauntlets)
.crossJoin(chests)
.crossJoin(legs)
.crossJoin(classItems)
.withColumn("Exotics", $"Exotic_H" + $"Exotic_G" + $"Exotic_C" + $"Exotic_L")
.filter($"Exotics" === 1)
.drop("Exotics","Exotic_H","Exotic_G","Exotic_C","Exotic_L")
.withColumn("Rares", $"Rare_H" + $"Rare_G" + $"Rare_C" + $"Rare_L")
.drop("Rare_H","Rare_G","Rare_C","Rare_L")
.withColumn("Mobility", $"Mobility_H" + $"Mobility_G" + $"Mobility_C" + $"Mobility_L" + $"Mobility_CL")
.withColumn("Resilience", $"Resilience_H" + $"Resilience_G" + $"Resilience_C" + $"Resilience_L" + $"Resilience_CL")
.withColumn("Recovery", $"Recovery_H" + $"Recovery_G" + $"Recovery_C" + $"Recovery_L" + $"Recovery_CL")
.withColumn("Discipline", $"Discipline_H" + $"Discipline_G" + $"Discipline_C" + $"Discipline_L" + $"Discipline_CL")
.withColumn("Intellect", $"Intellect_H" + $"Intellect_G" + $"Intellect_C" + $"Intellect_L" + $"Intellect_CL")
.withColumn("Strength", $"Strength_H" + $"Strength_G" + $"Strength_C" + $"Strength_L" + $"Strength_CL")
.withColumn("Wasted", ($"Mobility" % 10) + ($"Resilience" % 10) + ($"Recovery" % 10) + ($"Discipline" % 10) + ($"Intellect" % 10) + ($"Strength" % 10))
.withColumn("Tiers", (($"Mobility" + $"Resilience" + $"Recovery" + $"Discipline" + $"Intellect" + $"Strength" - $"Wasted") / 10))
.withColumn("Tiers", format_number($"Tiers", 0))
.filter($"Tiers" >= filterTier)
.withColumn("Mobility_MW", $"Mobility_MW_H" + $"Mobility_MW_G" + $"Mobility_MW_C" + $"Mobility_MW_L" + $"Mobility_MW_CL")
.withColumn("Resilience_MW", $"Resilience_MW_H" + $"Resilience_MW_G" + $"Resilience_MW_C" + $"Resilience_MW_L" + $"Resilience_MW_CL")
.withColumn("Recovery_MW", $"Recovery_MW_H" + $"Recovery_MW_G" + $"Recovery_MW_C" + $"Recovery_MW_L" + $"Recovery_MW_CL")
.withColumn("Combo_MW", floor($"Mobility_MW" / 10) + floor($"Resilience_MW" / 10) + floor($"Recovery_MW" / 10))
.filter($"Combo_MW" >= 17 || (($"Combo_MW" === 16) && (($"Mobility_MW" % 10) >= 5) && ($"Mobility_MW" < 70)))
.withColumn("Discipline_MW", $"Discipline_MW_H" + $"Discipline_MW_G" + $"Discipline_MW_C" + $"Discipline_MW_L" + $"Discipline_MW_CL")
.withColumn("Intellect_MW", $"Intellect_MW_H" + $"Intellect_MW_G" + $"Intellect_MW_C" + $"Intellect_MW_L" + $"Intellect_MW_CL")
.withColumn("Strength_MW", $"Strength_MW_H" + $"Strength_MW_G" + $"Strength_MW_C" + $"Strength_MW_L" + $"Strength_MW_CL")
.drop("Mobility_MW_H","Mobility_MW_G","Mobility_MW_C","Mobility_MW_L","Mobility_MW_CL")
.drop("Resilience_MW_H","Resilience_MW_G","Resilience_MW_C","Resilience_MW_L","Resilience_MW_CL")
.drop("Recovery_MW_H","Recovery_MW_G","Recovery_MW_C","Recovery_MW_L","Recovery_MW_CL")
.drop("Discipline_MW_H","Discipline_MW_G","Discipline_MW_C","Discipline_MW_L","Discipline_MW_CL")
.drop("Intellect_MW_H","Intellect_MW_G","Intellect_MW_C","Intellect_MW_L","Intellect_MW_CL")
.drop("Strength_MW_H","Strength_MW_G","Strength_MW_C","Strength_MW_L","Strength_MW_CL")
.withColumn("Wasted_MW", ($"Mobility_MW" % 10) + ($"Resilience_MW" % 10) + ($"Recovery_MW" % 10) + ($"Discipline_MW" % 10) + ($"Intellect_MW" % 10) + ($"Strength_MW" % 10))
.withColumn("Tiers_MW", (($"Mobility_MW" + $"Resilience_MW" + $"Recovery_MW" + $"Discipline_MW" + $"Intellect_MW" + $"Strength_MW" - $"Wasted_MW") / 10))
.filter($"Mobility_MW" <= 79 && $"Resilience_MW" <= 59 && $"Recovery_MW" >= 50)
joined.write.format("csv").option("header", true).save(characterClass)
println()
println("Complete. Press any key to exit")
scala.io.StdIn.readLine()
sys.exit(0)