-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperations.py
399 lines (341 loc) · 11.6 KB
/
operations.py
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
import options
import utils
import json
from collections import defaultdict
import glob
import csv
class Operation:
def __init__(self, cost, profit, inputs, outputs, limit, description, limiter, chunk_size, output_hint):
self.cost = cost
self.profit = profit
self.inputs = inputs
self.outputs = outputs
self.limit = min(limit, options.budget // cost if cost else options.sanity)
self.description = description
self.limiter = limiter
self.chunk_size = chunk_size
self.output_hint = output_hint
self.lpvariable = None
self.value = None
self.indicator = None
def FlipBuy(items):
results = []
for item in items:
# Sanity
if 'buy_price' not in item or item['buy_price'] == 0 or ('vendor_value' in item and item['buy_price'] < item['vendor_value']):
continue
# Reduce variance a bit
if item['adjusted_buy'] < options.min_velocity:
continue
results.append(Operation(
(item['buy_price'] + 1),
0,
{},
{item['id']: 1},
min(options.sanity, item['adjusted_buy']),
f'Buy {item["name"]} ({item["id"]}) @ {utils.coins(item["buy_price"] + 1)}',
True,
250 * options.click_weight,
item['id']
))
return results
def FlipSell(items):
results = []
for item in items:
# Sanity
if 'sell_price' not in item:
continue
# Reduce variance a bit
if item['adjusted_sell'] < options.min_velocity:
continue
# save some computation speed
if item['adjusted_sell'] * item['sell_price'] < options.min_move_per_day:
continue
results.append(Operation(
0,
int((item['sell_price'] - 1)*0.85*options.safetyprice),
{item['id']: 1},
{},
min(options.sanity, item['adjusted_sell']),
f'Sell {item["name"]} ({item["id"]}) @ {utils.coins(item["sell_price"] - 1)}',
False,
250 * options.click_weight,
item['id']
))
return results
def SpecialCrafting(recipes, names):
daily = ['-260']
results = []
for recipe in recipes:
# Remove Amalgamated Spam
if recipe['name'] == "Amalgamated Gemstone":
continue
op = Operation(
0,
0,
{i['item_id']: i['count'] for i in recipe['ingredients']},
{recipe['output_item_id']: recipe['output_item_count']},
1 if recipe['id'] in daily else options.sanity,
f'Craft {recipe["name"]} from {", ".join(names.get(i["item_id"], "???") for i in recipe["ingredients"])} ({recipe["id"]})',
False,
1000 * options.click_weight,
recipe['output_item_id']
)
# Gold is handled as id -1
if -1 in op.inputs:
op.cost = op.inputs[-1]
op.description = f'Buy {recipe["name"]} from vendor ({recipe["id"]})'
op.chunk_size = options.sanity
op.limiter = False
del op.inputs[-1]
results.append(op)
return results
def Crafting(recipes, names, account_recipes):
daily = [66913, 79795, 66993, 66917, 66923, 67377, 79726,
79817, 79790, 46744, 79763, 46742, 46740, 46745, 67015]
account_recipes = set(account_recipes)
results = []
for recipe in recipes:
# skip duplicate mithrilium recipe
if recipe['id'] == 12053:
continue
# skip unlearned recipes
if recipe['id'] not in account_recipes and "LearnedFromItem" in recipe['flags']:
continue
results.append(Operation(
0,
0,
{i['item_id']: i['count'] for i in recipe['ingredients']},
{recipe['output_item_id']: recipe['output_item_count']},
1 if recipe['output_item_id'] in daily else options.sanity,
f'Craft {names.get(recipe["output_item_id"], "???")} from {", ".join(names.get(i["item_id"], "???") for i in recipe["ingredients"])} ({recipe["id"]})',
recipe['type'] != 'Refinement',
1000 * options.click_weight,
recipe['output_item_id']
))
return results
def EctoSalvage():
return [Operation(
60,
0,
{19721: 1},
{24277: 1.85},
options.sanity,
f'Salvage Ecto',
False,
options.sanity,
19721
)]
def Gemstones(names):
stones = [24773, 24502, 24884, 24516, 24508, 24522, 72504, 70957, 72315, 76179, 74988,
24515, 75654, 24510, 24512, 76491, 24520, 42010, 72436, 24524, 24533, 24532, 24518, 24514]
return [Operation(
0,
0,
{19721: 5, stone: 75},
{68063: 11.5},
options.sanity,
f'Make gemstones from ecto and {names[stone]}',
False,
5*options.click_weight,
stone
) for stone in stones] + [
Operation(
0,
0,
{24325: 10,
24340: 10,
24330: 10,
70842: 10},
{92687: 1},
options.sanity,
f'Make draconic lodestones from lodestones (Mordrem Lodestone)',
False,
25*options.click_weight,
92687)
] + [
Operation(
0,
0,
{24325: 10,
24340: 10,
24330: 10,
24335: 10},
{92687: 1},
options.sanity,
f'Make draconic lodestones from lodestones (Pile of Putrid Essence)',
False,
25*options.click_weight,
92687)
]
def Data(lookup):
files = glob.glob("Data/*.json")
results = []
for datafile in files:
with open(datafile, 'r') as jsonfile:
data = json.load(jsonfile)
divisor = data['Input']['Quantity']
outputs = defaultdict(int)
for o in data['Outputs']:
outputs[o['ID']] += o['Quantity']
item = lookup[data['Input']['ID']]
# Debug Info
cost = (lookup[data['Input']['ID']]["buy_price"] +
1 + data['Cost']) * data['Input']['Quantity']
profit_buy = sum((lookup[k]["buy_price"] + 1) * v for k, v in outputs.items(
) if k in lookup) + data['Profit'] * data['Input']['Quantity']
profit_sell = sum((lookup[k]["sell_price"] + 1)*0.85 * v for k, v in outputs.items(
) if k in lookup) + data['Profit'] * data['Input']['Quantity']
print(lookup[data['Input']['ID']]["name"], 100 *
(profit_buy-cost)/cost, 100*(profit_sell-cost)/cost)
results.append(Operation(
data['Cost'],
data['Profit'],
{data['Input']['ID']: 1},
{k: v/divisor for k, v in outputs.items()},
options.sanity,
f'{data["Verb"]} {data["Input"]["Name"]}',
False,
options.sanity,
data['Input']['ID']
))
return results
def Fractal():
t5 = [24276, 24299, 24282, 24341, 24294, 24356, 24350, 24288]
outputs = {
49424: 2.25, # infusion
74268: 0.015, # mew
46735: 1, # t7
46731: 1, # t7
46733: 1 # t7
}
outputs.update({i: 0.348 for i in t5})
return [
Operation(
0,
43*utils.silver,
{
75919: 1, # encryption
73248: 0.9 # matrix
},
outputs,
options.sanity,
"Crack fractal Encryptions",
False,
250 * options.click_weight,
75919
)
]
def Dump():
with open("inventory.csv", 'r') as csvfile:
data = csv.DictReader(csvfile)
return [Operation(
0,
0,
{},
{
int(d['ID']):int(d['Total'])
},
1,
f'Use {d["Name"]} ({d["ID"]})',
False,
options.sanity,
int(d['ID'])
)
for d in data]
def Dyes(dyes, lookup):
results = []
hues = {
'Brown': [74982],
'White': [75862],
'Blue': [75694],
'Black': [70426],
'Gray': [75862, 70426],
'Red': [71692],
'Orange': [75270],
'Purple': [77112],
'Yellow': [71952],
'Green': [76799]
}
rarities = {
'Fine': 3,
'Masterwork': 6.5,
'Rare': 10.4
}
for dye in dyes:
if 'item' not in dye or dye['hue'] not in hues or dye['item'] not in lookup:
continue
item = lookup[dye['item']]
if item['rarity'] not in rarities:
continue
results.append(
Operation(
3,
0,
{
item['id']: 0.01
},
{
hue: rarities[item['rarity']]/len(hues[dye['hue']]) for hue in hues[dye['hue']]
},
options.sanity,
f'Salvage {item["name"]}',
False,
options.sanity,
item['id']
)
)
return results
def Salvaging(items, tplookup, lookup):
results = []
champ_items = (44978, 44980, 44983, 72191, 44982, 44960, 44977, 44991, 44984, 44985, 44967, 44964, 44974, 44965, 44971, 44976, 44962,
44961, 44986, 44973, 44969, 44988, 44992, 44968, 44987, 44963, 44990, 44966, 44972, 44975, 44989, 44979, 44981, 44999, 44970)
stats = ("Solder's", "Rabid", "Dire", "Cavalier's", "Shaman's")
insignias = {lookup[i]['name'].split()[0]: i for i in (
46712, 46710, 49522, 46709, 46708)}
inscriptions = {lookup[i]['name'].split()[0]: i for i in (
46688, 46686, 46690, 46685, 46684)}
for item in items:
if item['id'] not in lookup or "NoSalvage" in lookup[item['id']]['flags']:
continue
if item['rarity'] == 'Rare' and \
item['type'] in ['Armor', 'Weapon', 'Trinket'] and \
item['level'] >= 68:
operation = Operation(
60,
0,
{item['id']: 1},
{19721: 0.875},
options.sanity,
f'Extract and salvage {item["name"]} ({item["id"]})',
False,
options.sanity,
item['id']
)
if 'upgrade1' in item:
operation.outputs[item['upgrade1']] = 1
results.append(operation)
if item['rarity'] == 'Exotic' and \
item['type'] in ['Armor', 'Weapon', 'Trinket'] and \
item['level'] >= 68:
operation = Operation(
60,
0,
{item['id']: 1},
{19721: 1.2, 46681:0.5},
options.sanity,
f'Extract and salvage {item["name"]} ({item["id"]})',
False,
options.sanity,
item['id']
)
if 'upgrade1' in item:
operation.outputs[item['upgrade1']] = 1
# We keep this in here for now to avoid craftables
if item['id'] not in champ_items and 'statName' in item and item['statName'] in stats:
if item['type'] == 'Weapon':
operation.outputs[inscriptions[item['statName']]] = 0.4
elif item['type'] == 'Armor':
operation.outputs[insignias[item['statName']]] = 0.4
results.append(operation)
return results