Skip to content

Commit

Permalink
feat: better hunt percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
Bluefissure committed Apr 25, 2022
1 parent 8f6b97f commit a311c34
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
8 changes: 4 additions & 4 deletions ffxivbot/handlers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"/about": "关于此项目",
"/donate": "援助作者",
"/random": "掷骰子",
"/chp": "彩虹屁",
# "/chp": "彩虹屁",
"/anime": '以图搜番("/anime 图片")',
"/gif": '生成沙雕图("/gif help")',
"/dice": 'DnD掷骰子("/dice 3d12")',
Expand All @@ -30,7 +30,7 @@
"/nuannuan": "本周金蝶暖暖作业",
#"/genshin": "原神圣遗物评分",
#"/hso": "好色哦",
"/hhsh": "好好说话",
# "/hhsh": "好好说话",
"/bot": "机器人相关功能",
"/ifttt": "IFTTT推送系统",
"/akhr": "罗德岛公开招募",
Expand Down Expand Up @@ -124,11 +124,11 @@
from .QQCommand_abv import QQCommand_abv
from .QQCommand_anime import QQCommand_anime
from .QQCommand_cat import QQCommand_cat
from .QQCommand_chp import QQCommand_chp
# from .QQCommand_chp import QQCommand_chp
from .QQCommand_dice import QQCommand_dice
from .QQCommand_duilian import QQCommand_duilian
from .QQCommand_gif import QQCommand_gif
from .QQCommand_hhsh import QQCommand_hhsh # be sure to come before /hh
# from .QQCommand_hhsh import QQCommand_hhsh # be sure to come before /hh
from .QQCommand_hh import QQCommand_hh # FFXIV Command
from .QQCommand_hso import QQCommand_hso
from .QQCommand_ifttt import QQCommand_ifttt
Expand Down
23 changes: 20 additions & 3 deletions ffxivbot/views/hunt.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import copy
import time
import json
import datetime
from django.contrib.auth.decorators import login_required
from django.db.models import Q, Max
from ffxivbot.models import Monster, Server, HuntLog, HuntGroup
from ffxivbot.models import Monster, HuntLog, HuntGroup
from .ren2res import ren2res
import traceback

def get_hms(seconds):
seconds = abs(int(seconds))
m, s = divmod(seconds, 60)
h, m = divmod(m, 60)
return h, m, s

def gen_hunts(user, sonar=False):
hunt_list = []
resource_groups = set()
Expand Down Expand Up @@ -44,8 +49,13 @@ def gen_hunts(user, sonar=False):
next_pop_time = kill_time + pop_cooldown
cd_schedulef = spawn_cooldown / pop_cooldown
schedulef = (time.time() - kill_time) / pop_cooldown
spawn_deltaf = (time.time() - next_spawn_time)
spawn_percentf = (time.time() - next_spawn_time) / (pop_cooldown - spawn_cooldown)
cd_schedule = "{:.2%}".format(cd_schedulef)
schedule = "{:.2%}".format(schedulef)
spawn_percent = "{:.2%}".format(spawn_percentf)
h, m, s = get_hms(spawn_deltaf)
spawn_delta = f'-{h:d}:{m:02d}:{s:02d}'
if schedulef >= cd_schedulef:
schedule_diff = schedulef - cd_schedulef
schedule_diff = "{:.2%}".format(schedule_diff)
Expand Down Expand Up @@ -74,8 +84,12 @@ def gen_hunts(user, sonar=False):
monster_info["schedule_diff"] = schedule_diff
monster_info["cd_schedulef"] = cd_schedulef
monster_info["cd_schedule"] = cd_schedule
monster_info["spawn_percentf"] = spawn_percentf
monster_info["spawn_percent"] = spawn_percent
monster_info["schedulef"] = schedulef
monster_info["schedule"] = schedule
monster_info["spawn_deltaf"] = spawn_deltaf
monster_info["spawn_delta"] = spawn_delta
monster_info["in_cd"] = in_cd
monster_info["kill_time"] = time.strftime(TIMEFORMAT_MDHMS, time.localtime(kill_time))
monster_info["next_spawn_time"] = time.strftime(TIMEFORMAT_MDHMS, time.localtime(next_spawn_time))
Expand Down Expand Up @@ -132,3 +146,6 @@ def hunt_sonar(req):
# What's the point???
def server2tag(server_name):
return NAME_TAG.get(server_name, "Unknown")


# Helper functions to calculate special conditions
6 changes: 3 additions & 3 deletions templates/hunt.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ <h3 class="card-title">数据来源:无</h3>
{% endif %}
{% if monster_info.schedulef > 1 %}
<td style="text-align: center; vertical-align: middle; width: 5%;"><span
class="badge bg-red">{{ monster_info.schedule }}</span></td>
class="badge bg-red">{{ monster_info.spawn_percent }}</span></td>
{% elif monster_info.schedulef < monster_info.cd_schedulef %}
<td style="text-align: center; vertical-align: middle; width: 5%;"><span
class="badge bg-gray">{{ monster_info.schedule }}</span></td>
class="badge bg-gray">{{ monster_info.spawn_delta }}</span></td>
{% else %}
<td style="text-align: center; vertical-align: middle; width: 5%;"><span
class="badge bg-green">{{ monster_info.schedule }}</span></td>
class="badge bg-green">{{ monster_info.spawn_percent }}</span></td>
{% endif %}
<td style="text-align: center; vertical-align: middle;">{{ monster_info.kill_time }}</td>
<td style="text-align: center; vertical-align: middle;">{{ monster_info.next_spawn_time }}</td>
Expand Down
12 changes: 12 additions & 0 deletions templates/tata.html
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,18 @@ <h3 class="card-title">其他獭窝</h3>
<!-- /.card-header -->
<div class="card-body">
<ul class="products-list product-list-in-card">
<li class="item">
<div class="product-img">
<img src="https://vip2.loli.io/2022/04/24/BfYuvVsx6tDmTaz.png" alt="喵窝">
</div>
<div class="product-info">
<a href="https://ffxiv-bot.yuyuko.com/" class="product-title" target="_blank">喵窝
<span class="badge bg-green float-right">自建</span></a>
<span class="product-description">
Nyanyanyanyanyanyanya!
</span>
</div>
</li>
<li class="item">
<div class="product-img">
<img src="https://vip2.loli.io/2022/04/21/6vRQkScZtGWXnrD.jpg" alt="冰音の鱼塘">
Expand Down

0 comments on commit a311c34

Please sign in to comment.