diff --git a/cpp/spinner.cpp b/cpp/spinner.cpp new file mode 100755 index 0000000..3689758 --- /dev/null +++ b/cpp/spinner.cpp @@ -0,0 +1,43 @@ +#include +#include +#include +#include + +constexpr auto num_points = 10; +constexpr auto sleep_msec = 1; +constexpr auto radius = 100.0f; + +int main() { + const auto window_handle = FindWindow(nullptr, "osu!"); + if (!window_handle) { + printf("FATAL: Could not find osu!. (0x%X)\n", GetLastError()); + return -1; + } + + auto get_desired_pos = [&]() -> std::tuple { + static auto counter = 0; + counter++; + + RECT rect; + GetWindowRect(window_handle, &rect); + + const auto center_x = rect.left + (rect.right - rect.left) / 2; + const auto center_y = rect.top + (rect.bottom - rect.top) / 2; + + const auto angle = 3.1415926f * 2.0f * (float)counter / (float)num_points; + + if (counter > num_points) { + counter = 0; + } + + return { center_x + radius * sin(angle), center_y + radius * cos(angle) }; + }; + + while (!GetAsyncKeyState(VK_DELETE)) { + if (GetAsyncKeyState('P')) { + std::apply(SetCursorPos, get_desired_pos()); + } + + Sleep(sleep_msec); + } +} diff --git a/python/web/get_7k_pp.py b/python/web/get_7k_pp.py new file mode 100755 index 0000000..e744592 --- /dev/null +++ b/python/web/get_7k_pp.py @@ -0,0 +1,47 @@ +import requests +import json +import sys + +if len(sys.argv) < 3: + print("usage: python get_7k_pp.py [api key] [username]") + exit(0) + +api_key = sys.argv[1] +usernames = sys.argv[2:] + +def get_json(url): + page = requests.get(url) + + try: + page.raise_for_status() + except: + print("Could not get '{}'".format(url)) + return [] + + return json.loads(page.text) + +def get_user_best(api_key, username): + return get_json("https://osu.ppy.sh/api/get_user_best?k={}&limit=100&m=3&u={}".format(api_key, username)) + +def get_beatmap(api_key, id): + return get_json("https://osu.ppy.sh/api/get_beatmaps?k={}&b={}".format(api_key, id)) + +for username in usernames: + scores_7k = [] + pp_7k = 0.0 + for score in get_user_best(api_key, username): + info = get_beatmap(api_key, score["beatmap_id"])[0] + if info["diff_size"] == '7': + # theres probably a prettier solution for this + percentage = 100.0 + for num in range(len(scores_7k)): + percentage *= 0.95 + + pp_7k += float(score["pp"]) / 100.0 * percentage + scores_7k.append("[{:.2f}+ ({:.2f}%)] {:.2f} {} [{}] {}k".format(pp_7k, percentage, float(score["pp"]), info["title"], info["version"], score["score"][:3])) + + print("7k pp for '{}'".format(username)) + print("Total = {}".format(pp_7k)) + + for score_7k in scores_7k: + print(score_7k) diff --git a/python/get_beatmaps.py b/python/web/get_beatmaps.py similarity index 100% rename from python/get_beatmaps.py rename to python/web/get_beatmaps.py