Coverage for src/utils/hive_blog.py: 0%
464 statements
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-03 19:06 +0000
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-03 19:06 +0000
1import pandas as pd
3from src.static import static_values_enum
4from src.static.static_values_enum import Leagues, sps_icon_url, dec_icon_url, coins_icon_url, glint_icon_url, \
5 voucher_icon_url, merit_icon_url, wild_league_icon_url, modern_league_icon_url
7image_hive_blog_20_url = 'https://images.hive.blog/20x0/'
8image_hive_blog_150_url = 'https://images.hive.blog/150x0/'
10credit_icon = image_hive_blog_20_url + coins_icon_url
11dec_icon = image_hive_blog_20_url + dec_icon_url
12sps_icon = image_hive_blog_20_url + sps_icon_url
13voucher_icon = image_hive_blog_20_url + voucher_icon_url
14glint_icon = image_hive_blog_20_url + glint_icon_url
15merits_icon = image_hive_blog_20_url + merit_icon_url
17intro_img = ('https://images.hive.blog/0x0/https://files.peakd.com/file/peakd-hive/beaker007/'
18 '23tvcWHTtW5SAv63Z2J86Zuyvn5Jk2BQQ5qBQrGBvv5hRm1DUaVKJN4Z8X9eFfSokovT1.png')
20earnings_divider = ('')
22market_divider = ('')
24tournament_divider = ('')
26closing_notes_divider = ('')
28season_overview_divider = ('')
30season_result_divider = ('')
33git_repo_link = '[git-repo](https://github.com/gamerbeaker007/splinterlands-statistics)'
34beneficiaries_img = ('https://images.hive.blog/0x0/https://files.peakd.com/file/peakd-hive/beaker007/'
35 '23tkhySrnBbRV3iV2aD2jH7uuYJuCsFJF5j8P8EVG1aarjqSR7cRLRmuTDhji5MnTVKSM.png')
37referral_link = '[beaker007](https://splinterlands.com?ref=beaker007)'
40def get_last_season_statistics_table(last_season_wild_battles, last_season_modern_battles):
41 if not last_season_wild_battles.empty and not last_season_wild_battles.rating.isna().values[0]:
42 last_season_wild_battles = last_season_wild_battles.iloc[0]
43 wild_league = last_season_wild_battles.league.astype(int)
44 wild_battles = int(last_season_wild_battles.battles)
45 wild_rank = int(last_season_wild_battles['rank'])
46 wild_rating = int(last_season_wild_battles.rating)
47 wild_league_name = Leagues(wild_league).name
48 wild_max_rating = int(last_season_wild_battles.max_rating)
49 wild_win = int(last_season_wild_battles.wins)
50 wild_win_pct = round((wild_win / wild_battles * 100), 2)
51 wild_longest_streak = int(last_season_wild_battles.longest_streak)
52 else:
53 wild_league = 0
54 wild_league_name = 'NA'
55 wild_battles = 'NA'
56 wild_rank = 'NA'
57 wild_rating = 'NA'
58 wild_max_rating = 'NA'
59 wild_win = 'NA'
60 wild_win_pct = 'NA'
61 wild_longest_streak = 'NA'
63 if not last_season_modern_battles.empty and not last_season_modern_battles.rating.isna().values[0]:
64 last_season_modern_battles = last_season_modern_battles.iloc[0]
65 modern_league = last_season_modern_battles.league.astype(int)
66 modern_battles = int(last_season_modern_battles.battles)
67 modern_rank = int(last_season_modern_battles['rank'])
68 modern_rating = int(last_season_modern_battles.rating)
69 modern_league_name = Leagues(modern_league).name
70 modern_max_rating = int(last_season_modern_battles.max_rating)
71 modern_win = int(last_season_modern_battles.wins)
72 modern_win_pct = round((modern_win / modern_battles * 100), 2)
73 modern_longest_streak = int(last_season_modern_battles.longest_streak)
74 else:
75 modern_league = 0
76 modern_league_name = 'NA'
77 modern_battles = 'NA'
78 modern_rank = 'NA'
79 modern_rating = 'NA'
80 modern_max_rating = 'NA'
81 modern_win = 'NA'
82 modern_win_pct = 'NA'
83 modern_longest_streak = 'NA'
85 wild_league_logo = 'https://images.hive.blog/75x0/' + wild_league_icon_url
86 wild_league_logo = wild_league_logo.replace('0.png', str(wild_league) + '.png')
87 modern_league_logo = 'https://images.hive.blog/75x0/' + modern_league_icon_url
88 modern_league_logo = modern_league_logo.replace('0.png', str(modern_league) + '.png')
90 extra_space = ' '
91 result = ('| Statistic | ' + wild_league_logo + '<br>' +
92 extra_space + 'Wild| ' + modern_league_logo + '<br>' +
93 extra_space + 'Modern | \n')
94 result += '| - | - | - |\n'
95 result += '| Battles | ' + str(wild_battles) + ' | '
96 result += str(modern_battles) + ' | \n'
97 result += '| Rank | ' + str(wild_rank) + ' | '
98 result += str(modern_rank) + ' | \n'
99 result += '| Rating | ' + str(wild_rating) + ' - ' + str(wild_league_name) + ' | '
100 result += str(modern_rating) + ' - ' + str(modern_league_name) + ' | \n'
101 result += '| Rating High | ' + str(wild_max_rating) + ' | '
102 result += str(modern_max_rating) + ' | \n'
103 result += '| Win PCT (Wins/battles * 100) | ' + str(wild_win_pct) + ' (' + str(wild_win) + '/' + str(
104 wild_battles) + ') |'
105 result += str(modern_win_pct) + ' (' + str(modern_win) + '/' + str(modern_battles) + ') |\n'
106 result += '| Longest Streak | ' + str(wild_longest_streak) + ' |'
107 result += str(modern_longest_streak) + ' |\n'
109 return result
112def get_last_season_costs_table(account, season_info_store, skip_zeros):
113 costs_rows = ''
114 dec_df = season_info_store['dec']
115 dec_df = dec_df.loc[(dec_df.player == account)].fillna(0)
116 if not dec_df.empty:
117 dec_df = dec_df.iloc[0]
118 if 'cost_rental_payment' in dec_df:
119 costs_rows += cost_earning_row('DEC rental payments', dec_icon, dec_df.cost_rental_payment, skip_zeros)
121 if 'rental_payment_fees' in dec_df:
122 costs_rows += cost_earning_row('DEC rental fees', dec_icon, dec_df.rental_payment_fees, skip_zeros)
123 if 'enter_tournament' in dec_df:
124 costs_rows += cost_earning_row('DEC tournament entry fees', dec_icon, dec_df.enter_tournament,
125 skip_zeros)
126 if 'market_rental' in dec_df:
127 costs_rows += cost_earning_row('DEC market rental', dec_icon, dec_df.market_rental, skip_zeros)
128 if 'purchased_energy' in dec_df:
129 costs_rows += cost_earning_row('DEC purchased energy', dec_icon,
130 dec_df.purchased_energy, skip_zeros)
131 if 'buy_market_purchase' in dec_df:
132 costs_rows += cost_earning_row('DEC market buy', dec_icon, dec_df.buy_market_purchase, skip_zeros)
133 if 'market_fees' in dec_df:
134 costs_rows += cost_earning_row('DEC market fees', dec_icon, dec_df.market_fees, skip_zeros)
135 if 'market_list_fee' in dec_df:
136 costs_rows += cost_earning_row('DEC market list fee', dec_icon, dec_df.market_list_fee, skip_zeros)
138 sps_df = season_info_store['sps']
139 sps_df = sps_df.loc[(sps_df.player == account)].fillna(0)
140 if not sps_df.empty:
141 sps_df = sps_df.iloc[0]
142 if 'enter_tournament' in sps_df:
143 costs_rows += cost_earning_row('SPS tournament entry fees', sps_icon, sps_df.enter_tournament,
144 skip_zeros)
145 if 'delegation_modern' in sps_df:
146 costs_rows += cost_earning_row('SPS ranked battle (modern) (fees)', sps_icon, sps_df.delegation_modern,
147 skip_zeros)
148 if 'delegation_wild' in sps_df:
149 costs_rows += cost_earning_row('SPS ranked battle (wild) (fees)', sps_icon, sps_df.delegation_wild,
150 skip_zeros)
151 if 'delegation_focus' in sps_df:
152 costs_rows += cost_earning_row('SPS daily focus (fees)', sps_icon, sps_df.delegation_focus, skip_zeros)
153 if 'delegation_season' in sps_df:
154 costs_rows += cost_earning_row('SPS season (fees)', sps_icon, sps_df.delegation_season, skip_zeros)
155 if 'delegation_land' in sps_df:
156 costs_rows += cost_earning_row('SPS land (fees)', sps_icon, sps_df.delegation_land, skip_zeros)
157 if 'delegation_nightmare' in sps_df:
158 costs_rows += cost_earning_row('SPS nightmare (TD) (fees)', sps_icon, sps_df.delegation_nightmare,
159 skip_zeros)
160 if 'delegation_brawl' in sps_df:
161 costs_rows += cost_earning_row('SPS brawl delegation', sps_icon, sps_df.delegation_brawl, skip_zeros)
163 glint_df = season_info_store['glint']
164 if not glint_df.empty:
165 glint_df = glint_df.loc[(glint_df.player == account)].fillna(0)
166 glint_df = glint_df.iloc[0]
167 if 'purchase_reward_draw' in glint_df:
168 costs_rows += cost_earning_row('GLINT rewards draws', glint_icon, glint_df.purchase_reward_draw,
169 skip_zeros)
171 result = 'None'
172 if costs_rows != '':
173 result = '| Costs | # |\n'
174 result += '| - | - |\n'
175 result += costs_rows
177 return result
180def cost_earning_row(title, icon, value, skip_zeros):
181 if skip_zeros and value == 0:
182 return ''
183 else:
184 return '| ' + str(title) + ' | ' + icon + ' ' + str(round(value, 3)) + ' |\n'
187def get_last_season_earnings_table(account, season_info_store, skip_zeros):
188 earning_rows = ''
189 dec_df = season_info_store['dec']
190 dec_df = dec_df.loc[(dec_df.player == account)].fillna(0)
191 if not dec_df.empty:
192 dec_df = dec_df.iloc[0]
193 if 'earn_rental_payment' in dec_df:
194 earning_rows += cost_earning_row('DEC rental payments', dec_icon, dec_df.earn_rental_payment, skip_zeros)
195 if 'sell_market_purchase' in dec_df:
196 earning_rows += cost_earning_row('DEC market sell', dec_icon, dec_df.sell_market_purchase, skip_zeros)
197 if 'tournament_prize' in dec_df:
198 earning_rows += cost_earning_row('DEC tournament rewards', dec_icon, dec_df.tournament_prize,
199 skip_zeros)
200 if 'modern_leaderboard_prizes' in dec_df:
201 earning_rows += cost_earning_row('DEC modern leaderboard rewards', dec_icon,
202 dec_df.modern_leaderboard_prizes, skip_zeros)
203 if 'leaderboard_prizes' in dec_df:
204 earning_rows += cost_earning_row('DEC wild leaderboard rewards', dec_icon,
205 dec_df.leaderboard_prizes, skip_zeros)
207 sps_df = season_info_store['sps']
208 sps_df = sps_df.loc[(sps_df.player == account)].fillna(0)
209 if not sps_df.empty:
210 sps_df = sps_df.iloc[0]
211 if 'tournament_prize' in sps_df:
212 earning_rows += cost_earning_row('SPS tournament rewards', sps_icon,
213 sps_df.tournament_prize,
214 skip_zeros)
215 if 'token_transfer_multi' in sps_df:
216 earning_rows += cost_earning_row('SPS tournament rewards (multi token)', sps_icon,
217 sps_df.token_transfer_multi,
218 skip_zeros)
219 if 'claim_staking_rewards' in sps_df:
220 earning_rows += cost_earning_row('SPS staking reward', sps_icon, sps_df.claim_staking_rewards,
221 skip_zeros)
222 if 'claim_staking_rewards_staking_rewards' in sps_df:
223 earning_rows += cost_earning_row('SPS staking reward',
224 sps_icon,
225 sps_df.claim_staking_rewards_staking_rewards,
226 skip_zeros)
227 if 'claim_staking_rewards_validator_rewards' in sps_df:
228 earning_rows += cost_earning_row('SPS validator reward',
229 sps_icon,
230 sps_df.claim_staking_rewards_validator_rewards,
231 skip_zeros)
232 if 'validate_block' in sps_df:
233 earning_rows += cost_earning_row('SPS validator block validation',
234 sps_icon,
235 sps_df.validate_block,
236 skip_zeros)
238 if 'token_award' in sps_df:
239 earning_rows += cost_earning_row('SPS token award (pools)', sps_icon, sps_df.token_award, skip_zeros)
241 unclaimed_sps_df = season_info_store['unclaimed_sps']
242 unclaimed_sps_df = unclaimed_sps_df.loc[(unclaimed_sps_df.player == account)].fillna(0)
243 if not unclaimed_sps_df.empty:
244 unclaimed_sps_df = unclaimed_sps_df.iloc[0]
245 if 'modern' in unclaimed_sps_df:
246 earning_rows += cost_earning_row('SPS ranked battle (modern)', sps_icon, unclaimed_sps_df.modern,
247 skip_zeros)
248 if 'wild' in unclaimed_sps_df:
249 earning_rows += cost_earning_row('SPS ranked battle (wild)', sps_icon, unclaimed_sps_df.wild, skip_zeros)
250 if 'survival' in unclaimed_sps_df:
251 earning_rows += cost_earning_row('SPS survival battle', sps_icon, unclaimed_sps_df.survival, skip_zeros)
252 if 'focus' in unclaimed_sps_df:
253 earning_rows += cost_earning_row('SPS daily focus', sps_icon, unclaimed_sps_df.focus, skip_zeros)
254 if 'season' in unclaimed_sps_df:
255 earning_rows += cost_earning_row('SPS season', sps_icon, unclaimed_sps_df.season, skip_zeros)
256 if 'land' in unclaimed_sps_df:
257 earning_rows += cost_earning_row('SPS land', sps_icon, unclaimed_sps_df.land, skip_zeros)
258 if 'nightmare' in unclaimed_sps_df:
259 earning_rows += cost_earning_row('SPS nightmare (TD) ', sps_icon, unclaimed_sps_df.nightmare, skip_zeros)
260 if 'brawl' in unclaimed_sps_df:
261 earning_rows += cost_earning_row('SPS brawl', sps_icon, unclaimed_sps_df.brawl, skip_zeros)
263 merits_df = season_info_store['merits']
264 merits_df = merits_df.loc[(merits_df.player == account)].fillna(0)
265 if not merits_df.empty:
266 merits_df = merits_df.iloc[0]
267 if 'quest_rewards' in merits_df:
268 earning_rows += cost_earning_row('MERITS quest reward', merits_icon, merits_df.quest_rewards, skip_zeros)
269 if 'season_rewards' in merits_df:
270 earning_rows += cost_earning_row('MERITS season rewards', merits_icon, merits_df.season_rewards, skip_zeros)
271 if 'brawl_prize' in merits_df:
272 earning_rows += cost_earning_row('MERITS brawl prizes', merits_icon, merits_df.brawl_prize, skip_zeros)
274 voucher_df = season_info_store['vouchers']
275 voucher_df = voucher_df.loc[(voucher_df.player == account)].fillna(0)
276 if not voucher_df.empty:
277 voucher_df = voucher_df.iloc[0]
278 if 'claim_staking_rewards' in voucher_df:
279 earning_rows += cost_earning_row('VOUCHER earned', voucher_icon, voucher_df.claim_staking_rewards,
280 skip_zeros)
281 glint_df = season_info_store['glint']
282 if not glint_df.empty:
283 glint_df = glint_df.loc[(glint_df.player == account)].fillna(0)
284 glint_df = glint_df.iloc[0]
285 if 'ranked_rewards' in glint_df:
286 earning_rows += cost_earning_row('GLINT ranked', glint_icon, glint_df.ranked_rewards,
287 skip_zeros)
288 if 'season_rewards' in glint_df:
289 earning_rows += cost_earning_row('GLINT season', glint_icon, glint_df.season_rewards,
290 skip_zeros)
292 result = 'None'
293 if earning_rows != '':
294 result = '| Earnings | # | \n'
295 result += '| - | - |\n'
296 result += earning_rows
298 return result
301def get_tournament_info(tournaments_info):
302 result = '|Tournament name | League | finish / entrants | wins/losses/draws | entry fee | prize | \n'
303 result += '|-|-|-|-|-|-| \n'
305 if not tournaments_info.empty:
306 for index, tournament in tournaments_info.iterrows():
307 if tournament.finish:
308 entry_fee = str(tournament.entry_fee) if tournament.entry_fee is not None else str(0)
310 result += '| ' + tournament['name']
311 result += '| ' + tournament.league
312 result += '| ' + str(int(tournament.finish)) + ' / ' + str(int(tournament.num_players))
313 result += '| ' + str(int(tournament.wins)) + ' / ' + str(int(tournament.losses)) + ' / ' + str(
314 int(tournament.draws))
315 result += '| ' + str(entry_fee)
316 result += '| ' + str(tournament.prize_qty) + ' ' + str(tournament.prize_type)
317 result += '| \n'
319 filters_sps_prizes = tournaments_info[tournaments_info.prize_type == 'SPS']
320 total_sps_earned = pd.to_numeric(filters_sps_prizes[['prize_qty']].sum(1), errors='coerce').sum()
322 filters_sps_entry_fee = tournaments_info[
323 tournaments_info.entry_fee.notna() &
324 tournaments_info.entry_fee.str.contains('SPS')
325 ].copy()
326 split = filters_sps_entry_fee.loc[:, 'entry_fee'].str.split(' ', expand=True)
327 total_sps_fee = 0
328 if not split.empty:
329 filters_sps_entry_fee.loc[:, 'fee_qty'] = split[0]
330 filters_sps_entry_fee.loc[:, 'fee_type'] = split[1]
331 total_sps_fee = pd.to_numeric(filters_sps_entry_fee[['fee_qty']].sum(1), errors='coerce').sum()
333 result += '|**Total SPS** | | | | **' + str(total_sps_fee) + '**|**' + str(total_sps_earned) + '**| \n'
335 return result
338def get_card_table(cards_df, print_count=False):
339 base_card_url = 'https://images.hive.blog/150x0/https://d36mxiodymuqjm.cloudfront.net/cards_by_level/'
341 if cards_df is not None and len(cards_df) > 0:
342 cards_df = cards_df.dropna(subset=['card_detail_id']).copy()
343 cards_df.loc[:, 'bcx_new'] = cards_df['bcx'].astype(float).astype(int)
344 cards_df = cards_df.drop(columns=['bcx'])
345 cards_df = cards_df.rename(columns={'bcx_new': 'bcx'})
347 unique_card_list = cards_df.card_name.unique()
348 temp = pd.DataFrame()
349 for card_name in unique_card_list:
350 temp = pd.concat([temp, pd.DataFrame({
351 'card_name': card_name,
352 'quantity_regular': len(cards_df[(cards_df['card_name'] == card_name) & (~cards_df['gold'])]),
353 'quantity_gold': len(cards_df[(cards_df['card_name'] == card_name) & (cards_df['gold'])]),
354 'edition_name': str(cards_df[(cards_df['card_name'] == card_name)].edition_name.values[0]),
355 'bcx': str(cards_df[(cards_df['card_name'] == card_name) & (~cards_df['gold'])].bcx.sum()),
356 'bcx_gold': str(cards_df[(cards_df['card_name'] == card_name) & (cards_df['gold'])].bcx.sum())
357 }, index=[0])], ignore_index=True)
359 if len(temp.index) > 5:
360 result = '| | | | | |\n'
361 result += '|-|-|-|-|-|\n'
362 else:
363 # print all in one row
364 table_row = '|'
365 for i in range(0, len(temp.index)):
366 table_row += ' |'
367 result = table_row + '\n' + table_row.replace(' ', '-') + '\n'
369 result += '|'
370 for index, card in temp.iterrows():
371 if index > 0 and index % 5 == 0:
372 result += '\n'
374 prefix = str(base_card_url) + str(card.edition_name) + '/' + str(card.card_name).replace(' ', '%20')
375 count_str = ''
376 gold_suffix = ''
377 bcx_str = ''
378 if card.quantity_regular > 0:
379 if card.quantity_gold == 0:
380 bcx_str = str('<br> bcx: ' + str(card.bcx))
381 else:
382 bcx_str = str('<br> regular bcx: ' + str(card.bcx))
384 if card.quantity_gold > 0:
385 gold_suffix = '_gold'
386 bcx_str += str('<br> gold bcx: ' + str(card.bcx_gold))
388 if print_count:
389 count_str = ' <br> ' + str(card.quantity_regular + card.quantity_gold) + 'x'
391 card_image_url = prefix + '_lv1' + gold_suffix + '.png'
392 result += '' + str(card_image_url) + count_str + bcx_str
393 result += ' |'
394 else:
395 result = 'None'
396 return result
399def get_introduction_chapter(account_names):
400 account_suffix = ''
401 if len(account_names) > 1:
402 account_suffix = ' (' + str(get_account_names_str(account_names)) + ')'
403 return intro_img + """
404<br><br><br>
405""" + season_overview_divider + """
406# <div class="phishy"><center>Season Summary""" + str(account_suffix) + """</center></div>
408"""
411def get_closure_chapter():
412 return """
413<br><br>
414""" + closing_notes_divider + """
415## <div class="phishy"><center>Closing notes</center></div>
416This report is generated with the splinterlands statistics tool from @beaker007 """ + git_repo_link + """.
417Any comment/remarks/errors pop me a message on peakd.
418If you like the content, consider adding @beaker007 as beneficiaries of your post created with the help of this tool.
419""" + beneficiaries_img + """
422If you are not playing splinterlands consider using my referral link """ + referral_link + """.
424Thx all for reading
426<center>https://d36mxiodymuqjm.cloudfront.net/website/splinterlands_logo.png</center>
427"""
430def get_plot_placeholder(account_name=None):
431 account_suffix = ""
432 if account_name:
433 account_suffix = " (" + str(account_name) + ")"
435 return """
436## <div class="phishy"><center>Season overall stats and history""" + str(account_suffix) + """</center></div>
438### Battles
440### Earnings
443"""
446def get_last_season_results(season_battles_wild, season_battles_modern, previous_season_id, account_name=None):
447 account_suffix = ''
448 if account_name:
449 account_suffix = ' (' + str(account_name) + ')'
450 return """
451<br><br>
452""" + season_result_divider + """
453# <div class="phishy"><center>Last Season results""" + str(account_suffix) + """</center></div>
454""" + str(get_last_season_statistics_table(season_battles_wild, season_battles_modern)) + """
456"""
459def get_tournament_results(tournaments_info, account_name=None):
460 account_suffix = ''
461 if account_name:
462 account_suffix = ' (' + str(account_name) + ')'
464 if not tournaments_info.empty:
465 return """
466<br><br>
467""" + tournament_divider + """
468## <div class="phishy"><center>Tournaments""" + str(account_suffix) + """</center></div>
469""" + str(get_tournament_info(tournaments_info)) + """
471"""
472 return ''
475def get_last_season_earning_costs(account, season_info_store, skip_zeros, account_name=None):
476 account_suffix = ''
477 if account_name:
478 account_suffix = ' (' + str(account_name) + ')'
480 return """
481<br><br>
482""" + earnings_divider + """
483## <div class="phishy"><center>Earnings and costs""" + str(account_suffix) + """</center></div>
484""" + str(get_last_season_earnings_table(account, season_info_store, skip_zeros)) + """
486## <div class="phishy"><center>Costs</center></div>
487""" + str(get_last_season_costs_table(account, season_info_store, skip_zeros)) + """
488 """
491def get_sub_type_sum(df, name):
492 if df.empty:
493 return 0
494 else:
495 return df.loc[df.sub_type == name].sub_type.count()
498def get_quantity_sum(df, reward_type):
499 if df.empty or df.loc[df.type == reward_type].empty:
500 return 0
501 else:
502 return df.loc[df.type == reward_type].quantity.sum()
505def get_quantity_potion_sum(df, reward_type, potion_type):
506 if df.empty or df.loc[df.type == reward_type].empty:
507 return 0
508 else:
509 return df.loc[(df.type == reward_type) & (df.potion_type == potion_type)].quantity.sum()
512def get_quantity_jackpot_sum(df, reward_type, prize_type):
513 if df.empty or df.loc[df.type == reward_type].empty:
514 return 0
515 else:
516 return df.loc[(df.type == reward_type) & (df.prize_type == prize_type)].quantity.sum()
519def get_reward_draws_table(df):
520 result = '|' + image_hive_blog_150_url + static_values_enum.reward_draw_common_icon_url
521 result += '|' + image_hive_blog_150_url + static_values_enum.reward_draw_rare_icon_url
522 result += '|' + image_hive_blog_150_url + static_values_enum.reward_draw_epic_icon_url
523 result += '|' + image_hive_blog_150_url + static_values_enum.reward_draw_legendary_icon_url
524 result += '|\n'
525 result += '|-|-|-|-|\n'
526 result += '| <center>Common: ' + str(get_sub_type_sum(df, 'common_draw')) + 'x</center>'
527 result += '| <center>Rare: ' + str(get_sub_type_sum(df, 'rare_draw')) + 'x</center>'
528 result += '| <center>Epic: ' + str(get_sub_type_sum(df, 'epic_draw')) + 'x</center>'
529 result += '| <center>Legendary: ' + str(get_sub_type_sum(df, 'legendary_draw')) + 'x</center>'
530 result += '|\n'
531 result += '|' + image_hive_blog_150_url + static_values_enum.reward_draw_common_gold_icon_url
532 result += '|' + image_hive_blog_150_url + static_values_enum.reward_draw_rare_gold_icon_url
533 result += '|' + image_hive_blog_150_url + static_values_enum.reward_draw_epic_gold_icon_url
534 result += '|' + image_hive_blog_150_url + static_values_enum.reward_draw_legendary_gold_icon_url
535 result += '|\n'
536 result += '| <center>GOLD Common: ' + str(get_sub_type_sum(df, 'gf_common_draw')) + 'x</center>'
537 result += '| <center>GOLD Rare: ' + str(get_sub_type_sum(df, 'gf_rare_draw')) + 'x</center>'
538 result += '| <center>GOLD Epic: ' + str(get_sub_type_sum(df, 'gf_epic_draw')) + 'x</center>'
539 result += '| <center>GOLD Legendary: ' + str(get_sub_type_sum(df, 'gf_legendary_gold_draw')) + 'x</center>'
540 result += '|\n'
541 result += '|' + image_hive_blog_150_url + static_values_enum.reward_draw_minor_icon_url
542 result += '|' + image_hive_blog_150_url + static_values_enum.reward_draw_major_icon_url
543 result += '|' + image_hive_blog_150_url + static_values_enum.reward_draw_ultimate_icon_url
544 result += '| '
545 result += '|\n'
546 result += '| <center>Minor chest: ' + str(get_sub_type_sum(df, 'minor_draw')) + 'x</center>'
547 result += '| <center>Medium chest: ' + str(get_sub_type_sum(df, 'major_draw')) + 'x</center>'
548 result += '| <center>Ultimate chest: ' + str(get_sub_type_sum(df, 'ultimate_draw')) + 'x</center>'
549 result += '| '
550 result += '|\n'
552 return result
555def get_rewards_draws_result_table(df):
556 if df.empty:
557 return 'None'
559 result = '| ' + image_hive_blog_150_url + static_values_enum.merit_icon_url
560 result += '| ' + image_hive_blog_150_url + static_values_enum.energy_icon_url
561 result += '| ' + image_hive_blog_150_url + static_values_enum.potion_gold_icon_url
562 result += '| ' + image_hive_blog_150_url + static_values_enum.potion_legendary_icon_url
563 result += '| ' + image_hive_blog_150_url + static_values_enum.beta_pack_icon
564 result += '| ' + image_hive_blog_150_url + static_values_enum.land_plot_icon_url
565 result += '|\n'
566 result += '|-|-|-|-|-|-|\n'
567 result += '| <center>' + str(get_quantity_sum(df, 'merits')) + '</center>'
568 result += '| <center>' + str(get_quantity_sum(df, 'energy')) + '</center>'
569 result += '| <center>' + str(get_quantity_potion_sum(df, 'potion', 'gold')) + '</center>'
570 result += '| <center>' + str(get_quantity_potion_sum(df, 'potion', 'legendary')) + '</center>'
571 result += '| <center>' + str(get_quantity_jackpot_sum(df, 'jackpot', 'BETA')) + '</center>'
572 result += '| <center>' + str(get_quantity_jackpot_sum(df, 'jackpot', 'PLOT')) + '</center>'
573 result += '|\n'
575 return result
578def get_season_league_rewards_table(df):
579 if df.empty:
580 return 'None'
582 wild_df = df[(df.format == 'wild')]
583 modern_df = df[(df.format == 'modern')]
584 wild_league_logo = 'https://images.hive.blog/50x0/' + wild_league_icon_url
585 modern_league_logo = 'https://images.hive.blog/50x0/' + modern_league_icon_url
586 suffix = ')'
588 result = '| <center>Format</center> '
589 result += '|' + image_hive_blog_150_url + static_values_enum.reward_draw_minor_icon_url
590 result += '|' + image_hive_blog_150_url + static_values_enum.reward_draw_major_icon_url
591 result += '|' + image_hive_blog_150_url + static_values_enum.reward_draw_ultimate_icon_url
592 result += '|\n'
593 result += '|-|-|-|-|\n'
595 result += '|'
596 for badge in modern_df.tier.unique().tolist():
597 prefix = ' + '.png') + suffix
599 result += '| <center>' + str(get_sub_type_sum(modern_df, 'minor')) + 'x</center>'
600 result += '| <center>' + str(get_sub_type_sum(modern_df, 'major')) + 'x</center>'
601 result += '| <center>' + str(get_sub_type_sum(modern_df, 'ultimate')) + 'x</center>'
602 result += '|\n'
604 result += '|'
605 for badge in wild_df.tier.unique().tolist():
606 prefix = ' + '.png') + suffix
608 result += '| <center>' + str(get_sub_type_sum(wild_df, 'minor')) + 'x</center>'
609 result += '| <center>' + str(get_sub_type_sum(wild_df, 'major')) + 'x</center>'
610 result += '| <center>' + str(get_sub_type_sum(wild_df, 'ultimate')) + 'x</center>'
611 result += '|\n'
613 return result
616def get_last_season_rewards(last_season_rewards, account_name=None):
617 account_suffix = ''
618 if account_name:
619 account_suffix = ' (' + str(account_name) + ')'
621 return """
622## <div class="phishy"><center>Reward draws purchased """ + str(account_suffix) + """</center></div>
623""" + str(get_reward_draws_table(last_season_rewards)) + """
625### <div class="phishy"><center>Special items earned""" + str(account_suffix) + """</center></div>
626""" + str(get_rewards_draws_result_table(last_season_rewards)) + """
628### <div class="phishy"><center>Cards earned""" + str(account_suffix) + """</center></div>
629""" + str(get_card_table(last_season_rewards)) + """
630 """
633def get_last_season_league_rewards(last_season_league_rewards, account_name=None):
634 account_suffix = ''
635 if account_name:
636 account_suffix = ' (' + str(account_name) + ')'
638 return """
639## <div class="phishy"><center>League rewards""" + str(account_suffix) + """</center></div>
640""" + str(get_season_league_rewards_table(last_season_league_rewards)) + """
642### <div class="phishy"><center>League rewards special items earned""" + str(account_suffix) + """</center></div>
643""" + str(get_rewards_draws_result_table(last_season_league_rewards)) + """
645### <div class="phishy"><center>League rewards cards earned""" + str(account_suffix) + """</center></div>
646""" + str(get_card_table(last_season_league_rewards)) + """
647 """
650def get_last_season_market_transactions(purchases_cards, sold_cards, account_name=None):
651 account_suffix = ''
652 if account_name:
653 account_suffix = ' (' + str(account_name) + ')'
655 return """
656<br><br>
657""" + market_divider + """
658## <div class="phishy"><center>Cards Purchased""" + str(account_suffix) + """</center></div>
659Note: Completed splex.gg and peakmonsters bids are not in this overview, those are purchased by other accounts.
661""" + str(get_card_table(purchases_cards, True)) + """
664## <div class="phishy"><center>Cards Sold""" + str(account_suffix) + """</center></div>
665Note: Only cards that are listed and sold in this season are displayed here.
666""" + str(get_card_table(sold_cards, True)) + """
668"""
671def get_account_introduction(account_names, previous_season_id):
672 result = 'Tracking my result for season ' + str(previous_season_id) + ' : ' \
673 + str(get_account_names_str(account_names)) + '\n\n'
674 return result
677def get_account_names_str(account_names):
678 result = ''
679 for account_name in account_names:
680 result += str(account_name)
681 if account_name != account_names[-1]:
682 result += ', '
683 return result
686def write_blog_post(account_names,
687 season_info_store,
688 last_season_rewards_dict,
689 last_season_league_rewards_dict,
690 tournaments_info_dict,
691 purchases_cards_dict,
692 sold_cards_dict,
693 previous_season_id,
694 skip_zeros=True):
695 single_account = (len(account_names) == 1)
696 post = get_account_introduction(account_names, previous_season_id)
697 post += get_introduction_chapter(account_names)
699 wild_battle_df = season_info_store['wild_battle']
700 modern_battle_df = season_info_store['modern_battle']
701 for account_name in account_names:
702 # If there is only one account so a single post do not use account name in post.
703 if single_account:
704 print_account_name = None
705 else:
706 print_account_name = account_name
708 post += get_plot_placeholder(account_name=print_account_name)
709 post += get_last_season_results(wild_battle_df.loc[wild_battle_df.player == account_name],
710 modern_battle_df.loc[modern_battle_df.player == account_name],
711 previous_season_id,
712 account_name=print_account_name)
713 post += get_tournament_results(tournaments_info_dict[account_name],
714 account_name=account_name)
715 post += get_last_season_earning_costs(account_name,
716 season_info_store,
717 skip_zeros,
718 account_name=print_account_name)
719 post += get_last_season_market_transactions(purchases_cards_dict[account_name],
720 sold_cards_dict[account_name],
721 account_name=print_account_name)
722 post += get_last_season_rewards(last_season_rewards_dict[account_name],
723 account_name=print_account_name)
724 post += get_last_season_league_rewards(last_season_league_rewards_dict[account_name],
725 account_name=print_account_name)
727 if single_account:
728 post += get_closure_chapter()
730 if not single_account:
731 post += get_closure_chapter()
732 return post