Last active
August 19, 2021 04:56
-
-
Save hsuRush/8afaccb2860ec51e629a60eb57f0937e to your computer and use it in GitHub Desktop.
WS bonus calculator (Python 3.x)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start at L:31 | 從31行開始 | |
import numpy as np | |
import random | |
def p2f(x): | |
return float(x.strip('%'))/100 | |
def text_to_num(text, bad_data_val = 0, ws_price=75000000): | |
#text = np.array([ list(word) for word in text ]) | |
d = { | |
'K': 1000, | |
'M': 1000000, | |
'B': 1000000000, | |
'WS': ws_price | |
} | |
if not isinstance(text, str): | |
# Non-strings are bad are missing data in poster's submission | |
return bad_data_val | |
elif text[-1].upper() in d : | |
# separate out the K, M, or B | |
num, magnitude = text[:-1], text[-1] | |
return int(float(num) * d[magnitude.upper()]) | |
elif text[-2:].upper() in d: | |
num, magnitude = text[:-2], text[-2:] | |
return int(float(num) * d[magnitude.upper()]) | |
else: | |
return float(text) | |
#------------------------------------------------ | |
# you can use K,M,B,WS in utils.text_to_num() | |
# 你可以使用 K,M,B,WS 作為單位 | |
# The the part that you can modify '74M', '0%', '25WS', '0,0833WS', '15%', 10000 (L:36 to L:43) | |
# 你可以更改的部分為 '74M', '0%', '25WS', '0,0833WS', '15%', 10000 (36行到43行) | |
ws_price = text_to_num('74M') # White Scroll price | 白捲價格 | |
current_ws_bonus = p2f('0%') # White Scroll bonus (0%, 1.5%, 3%, 4.5% etc) | 白捲失敗加成 | |
equip_price = text_to_num('25WS', ws_price=ws_price) # current equipment cost | 你現在裝備的價格 | |
equip_slot = 9 # scrolling slot (hammered) | 你裝備有幾次衝捲機會 | |
scroll_price = text_to_num('0.0833WS', ws_price=ws_price) # weapon att 15% 5/60 = 1/12 WS | 你要衝的捲軸的價格 | |
# 我用0.0833 因為武器att捲軸cost 5coin, 5/60= 1/12ws = 0.0833ws | |
scroll_percentage = p2f('15%') # the pass percentage for your scroll | 你衝捲的成功機率 | |
iterations = 10000 # larger is more accurate. | 跑幾次再去做平均 | |
#------------------------------------------------ | |
total_cost = 0 | |
for i in range(0,iterations): | |
cost = equip_price | |
cur_equip_slot = equip_slot | |
while (cur_equip_slot >= 0): | |
if random.random() < (scroll_percentage + current_ws_bonus): | |
# pass | |
cur_equip_slot -= 1 | |
cost = cost + ws_price + scroll_price | |
current_ws_bonus = 0. | |
else: | |
# fail | |
cost = cost + ws_price + scroll_price | |
current_ws_bonus += p2f('1.5%') | |
total_cost += cost | |
avr_cost = total_cost / iterations | |
print('Average cost(include equip cost):') | |
print(round(avr_cost / ws_price, 2), end=' ') | |
print('WS') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment