-
Notifications
You must be signed in to change notification settings - Fork 0
/
refining_calculator.py
152 lines (107 loc) · 5.56 KB
/
refining_calculator.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
'''
Albion Online Refining Cost Calculation Module for WOOD, ORE, FIBER, HIDE
This module provides functions for calculating the refining cost of resources in Albion Online.
It provides functions for refining costs at T4, T5, T6, T7, and T8 tiers.
Each function takes a DataFrame containing resource data with 'item_id' and 'sell_price_max'
columns as input and returns the total refining cost based on the specified formula.
'''
from typing import List
import pandas as pd
def calculate_t4_refining_materials_price(data_frame: pd.DataFrame) -> int:
'''
Calculates the formula 2 * T4_raw_resource + T3_refined_resource using a DataFrame.
Args:
- data_frame |DataFrame| -- DataFrame with 'item_id' and 'sell_price_max' columns.
Returns:
- total_cost |float| -- Result of the formula.
'''
unique_item_id = data_frame["item_id"].unique()
t3_refined_resource_data = data_frame[data_frame['item_id'] == unique_item_id[0]]
t4_raw_resource_data = data_frame[data_frame['item_id'] == unique_item_id[1]]
min_t3_refined_resource = t3_refined_resource_data['sell_price_max'].min()
min_t4_raw_resource = t4_raw_resource_data['sell_price_max'].min()
t4_raw_resource_price = 2 * min_t4_raw_resource
total_cost = int(t4_raw_resource_price + min_t3_refined_resource)
return total_cost
def calculate_t5_refining_materials_price(data_frame: pd.DataFrame) -> int:
'''
Calculates the formula 3 * T5_raw_resource + T4_refined_resource using a DataFrame.
Args:
- data_frame (DataFrame): DataFrame with 'item_id' and 'sell_price_max' columns.
Returns:
- total_cost |float| -- Result of the formula.
'''
unique_item_id = data_frame["item_id"].unique()
t4_refined_resource_data = data_frame[data_frame['item_id'] == unique_item_id[0]]
t5_raw_resource_data = data_frame[data_frame['item_id'] == unique_item_id[1]]
min_t4_refined_resource = t4_refined_resource_data['sell_price_max'].min()
min_t5_raw_resource = t5_raw_resource_data['sell_price_max'].min()
total_cost = int(3 * min_t5_raw_resource + min_t4_refined_resource)
return total_cost
def calculate_t6_refining_materials_price(data_frame: pd.DataFrame) -> int:
'''
Calculates the formula 4 * T6_raw_resource + T5_refined_resource using a DataFrame.
Args:
- data_frame |DataFrame| -- DataFrame with 'item_id' and 'sell_price_max' columns.
Returns:
- total_cost |float| -- Result of the formula.
'''
unique_item_id = data_frame["item_id"].unique()
t5_refined_resource_data = data_frame[data_frame['item_id'] == unique_item_id[0]]
t6_raw_resource_data = data_frame[data_frame['item_id'] == unique_item_id[1]]
min_t5_refined_resource = t5_refined_resource_data['sell_price_max'].min()
min_t6_raw_resource = t6_raw_resource_data['sell_price_max'].min()
total_cost = int(4 * min_t6_raw_resource + min_t5_refined_resource)
return total_cost
def calculate_t7_refining_materials_price(data_frame: pd.DataFrame) -> int:
'''
Calculates the formula 5 * T7_raw_resource + T6_refined_resource using a DataFrame.
Args:
- data_frame |DataFrame| -- DataFrame with 'item_id' and 'sell_price_max' columns.
Returns:
- total_cost |float| -- Result of the formula.
'''
unique_item_id = data_frame["item_id"].unique()
t6_refined_resource_data = data_frame[data_frame['item_id'] == unique_item_id[0]]
t7_raw_resource_data = data_frame[data_frame['item_id'] == unique_item_id[1]]
min_t6_refined_resource = t6_refined_resource_data['sell_price_max'].min()
min_t7_raw_resource = t7_raw_resource_data['sell_price_max'].min()
total_cost = int(5 * min_t7_raw_resource + min_t6_refined_resource)
return total_cost
def calculate_t8_refining_materials_price(data_frame: pd.DataFrame) -> int:
'''
Calculates the formula 5 * T8_raw_resource + T7_refined_resource using a DataFrame.
Args:
- data_frame |DataFrame| -- DataFrame with 'item_id' and 'sell_price_max' columns.
Returns:
- total_cost |float| -- Result of the formula.
'''
unique_item_id = data_frame["item_id"].unique()
t7_refined_resource_data = data_frame[data_frame['item_id'] == unique_item_id[0]]
t8_raw_resource_data = data_frame[data_frame['item_id'] == unique_item_id[1]]
min_t7_refined_resource = t7_refined_resource_data['sell_price_max'].min()
min_t8_raw_resource = t8_raw_resource_data['sell_price_max'].min()
total_cost = int(5 * min_t8_raw_resource + min_t7_refined_resource)
return total_cost
def calculate__materials_price(variable_name: List[str], data_frame: pd.DataFrame) -> int:
'''
Calculates the refining materials price based on the provided variables and data frame.
Args:
- variable_name |List[str]| -- List of strings generated by generate_variable_name.
- data_frame |pd.DataFrame| -- DataFrame generated by show_best_price.
Returns:
- materials_price |int| -- The calculated refining materials price.
'''
extract_tier = variable_name[0].split('_')
tier = extract_tier[0]
if tier == 'T4':
materials_price = calculate_t4_refining_materials_price(data_frame)
elif tier == 'T5':
materials_price = calculate_t5_refining_materials_price(data_frame)
elif tier == 'T6':
materials_price = calculate_t6_refining_materials_price(data_frame)
elif tier == 'T7':
materials_price = calculate_t7_refining_materials_price(data_frame)
elif tier == 'T8':
materials_price = calculate_t8_refining_materials_price(data_frame)
return materials_price