Skip to content

Commit

Permalink
Merge pull request #73 from Zalk0/dev
Browse files Browse the repository at this point in the history
- update readme
- update dependencies
- add overflow to ranking
- simplify hypixel_data.py
  • Loading branch information
Zalk0 authored Aug 17, 2024
2 parents ff2070b + 3eb5ddd commit 13c363c
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 185 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.7
rev: v0.6.1
hooks:
# Run the linter.
- id: ruff
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ChouetteBot-discord

![Python version 3.9+](https://img.shields.io/badge/Python-3.9+-blue)
[![Ruff status](https://github.com/Zalk0/ChouetteBot-discord/actions/workflows/ruff.yaml/badge.svg?branch=main)](https://github.com/Zalk0/ChouetteBot-discord/actions/workflows/ruff.yaml)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Zalk0/ChouetteBot-discord/main.svg)](https://results.pre-commit.ci/latest/github/Zalk0/ChouetteBot-discord/main)

Expand Down Expand Up @@ -55,13 +56,18 @@ You can also run ruff manually with the commands `ruff check` and `ruff format`.

[![Docker Image](https://github.com/Zalk0/ChouetteBot-discord/actions/workflows/docker-image.yaml/badge.svg?branch=main)](https://github.com/Zalk0/ChouetteBot-discord/actions/workflows/docker-image.yaml)

You can use a Docker image to deploy the bot. It's currently supporting amd64, armv6 and armv7
architectures. We provide deployment information on the [Docker Hub repository](https://hub.docker.com/r/gylfirst/chouettebot).
You can use a Docker image to deploy the bot.
It's currently supporting amd64, armv6, armv7 and arm64 architectures.
We provide deployment information on the
[Docker Hub repository](https://hub.docker.com/r/gylfirst/chouettebot).

You can build it from source with:

```bash
docker build .
# or
docker build --build-arg version=tag -t app:tag .
```
(see [Docker Build CLI Options](https://docs.docker.com/reference/cli/docker/image/build/#options) to get more info)

(see [Docker Build CLI Options](https://docs.docker.com/reference/cli/docker/image/build/#options)
to get more info)
316 changes: 159 additions & 157 deletions chouette/utils/hypixel_data.py
Original file line number Diff line number Diff line change
@@ -1,177 +1,177 @@
def experience_to_level(type_xp: str, xp_amount: float) -> float:
from typing import Optional


def experience_to_level(
type_xp: str, xp_amount: float, max_level: Optional[int] = None
) -> (float, float):
"""
Calcule le niveau correspondant à une quantité donnée d'expérience cumulative.
Args:
type_xp: Le type d'expérience pour lequel calculer le niveau (compétence, type de slayer, donjon).
Pour `slayer_type`, utilisez l'un des suivants: slayer_zombie, slayer_spider, slayer_web, slayer_vampire.
xp_amount: La quantité d'expérience cumulée.
max_level: Le niveau maximum
Returns:
level: Le niveau correspondant à la quantité donnée d'expérience cumulée.
"""
skill_xp_data: list[tuple[int, int]] = [
(0, 0),
(1, 50),
(2, 175),
(3, 375),
(4, 675),
(5, 1175),
(6, 1925),
(7, 2925),
(8, 4425),
(9, 6425),
(10, 9925),
(11, 14925),
(12, 22425),
(13, 32425),
(14, 47425),
(15, 67425),
(16, 97425),
(17, 147425),
(18, 222425),
(19, 322425),
(20, 522425),
(21, 822425),
(22, 1222425),
(23, 1722425),
(24, 2322425),
(25, 3022425),
(26, 3822425),
(27, 4722425),
(28, 5722425),
(29, 6822425),
(30, 8022425),
(31, 9322425),
(32, 10722425),
(33, 12222425),
(34, 13822425),
(35, 15522425),
(36, 17322425),
(37, 19222425),
(38, 21222425),
(39, 23322425),
(40, 25522425),
(41, 27822425),
(42, 30222425),
(43, 32722425),
(44, 35322425),
(45, 38072425),
(46, 40972425),
(47, 44072425),
(48, 47472425),
(49, 51172425),
(50, 55172425),
(51, 59472425),
(52, 64072425),
(53, 68972425),
(54, 74122425),
(55, 79672425),
(56, 85472425),
(57, 91572425),
(58, 97572425),
(59, 104672425),
(60, 111672425),
skill_xp_data: list[int] = [
0,
50,
175,
375,
675,
1175,
1925,
2925,
4425,
6425,
9925,
14925,
22425,
32425,
47425,
67425,
97425,
147425,
222425,
322425,
522425,
822425,
1222425,
1722425,
2322425,
3022425,
3822425,
4722425,
5722425,
6822425,
8022425,
9322425,
10722425,
12222425,
13822425,
15522425,
17322425,
19222425,
21222425,
23322425,
25522425,
27822425,
30222425,
32722425,
35322425,
38072425,
40972425,
44072425,
47472425,
51172425,
55172425,
59472425,
64072425,
68972425,
74172425,
79672425,
85472425,
91572425,
97972425,
104672425,
111672425,
]
dungeon_xp_data: list[tuple[int, int]] = [
(0, 0),
(1, 50),
(2, 125),
(3, 235),
(4, 395),
(5, 625),
(6, 955),
(7, 1425),
(8, 2095),
(9, 3045),
(10, 4385),
(11, 6275),
(12, 8940),
(13, 12700),
(14, 17960),
(15, 25340),
(16, 35640),
(17, 50040),
(18, 70040),
(19, 97640),
(20, 135640),
(21, 188140),
(22, 259640),
(23, 356640),
(24, 488640),
(25, 668640),
(26, 911640),
(27, 1239640),
(28, 1684640),
(29, 2284640),
(30, 3084640),
(31, 4149640),
(32, 5559640),
(33, 7459640),
(34, 9959640),
(35, 13259640),
(36, 17559640),
(37, 23159640),
(38, 30359640),
(39, 39559640),
(40, 51559640),
(41, 66559640),
(42, 85559640),
(43, 109559640),
(44, 139559640),
(45, 177559640),
(46, 225559640),
(47, 285559640),
(48, 360559640),
(49, 453559640),
(50, 569809640),
dungeon_xp_data: list[int] = [
0,
50,
125,
235,
395,
625,
955,
1425,
2095,
3045,
4385,
6275,
8940,
12700,
17960,
25340,
35640,
50040,
70040,
97640,
135640,
188140,
259640,
356640,
488640,
668640,
911640,
1239640,
1684640,
2284640,
3084640,
4149640,
5559640,
7459640,
9959640,
13259640,
17559640,
23159640,
30359640,
39559640,
51559640,
66559640,
85559640,
109559640,
139559640,
177559640,
225559640,
285559640,
360559640,
453559640,
569809640,
]
slayer_xp_data: list[list[tuple[int, int]]] = [
# Common part for the slayer levels
common_slayer_xp_data: list[int] = [
200,
1000,
5000,
20000,
100000,
400000,
1000000,
]
slayer_xp_data: tuple[list[int], list[int], list[int], list[int]] = (
[
(0, 0),
(1, 5),
(2, 15),
(3, 200),
(4, 1000),
(5, 5000),
(6, 20000),
(7, 100000),
(8, 400000),
(9, 1000000),
0,
5,
15,
*common_slayer_xp_data,
],
[
(0, 0),
(1, 5),
(2, 25),
(3, 200),
(4, 1000),
(5, 5000),
(6, 20000),
(7, 100000),
(8, 400000),
(9, 1000000),
0,
5,
25,
*common_slayer_xp_data,
],
[
(0, 0),
(1, 10),
(2, 30),
(3, 250),
(4, 1500),
(5, 5000),
(6, 20000),
(7, 100000),
(8, 400000),
(9, 1000000),
0,
10,
30,
250,
1500,
*common_slayer_xp_data[2:],
],
[
(0, 0),
(1, 20),
(2, 75),
(3, 240),
(4, 840),
(5, 2400),
0,
20,
75,
240,
840,
2400,
],
]
)

# Skill XP data
if type_xp == "skill":
Expand All @@ -195,8 +195,10 @@ def experience_to_level(type_xp: str, xp_amount: float) -> float:
else:
raise ValueError(f"Unknown type of XP: {type_xp}")

for i, (level, xp) in enumerate(xp_data):
for level, xp in enumerate(xp_data):
if max_level and level == max_level:
return max_level, xp_amount - xp
if xp_amount <= xp:
previous_xp = xp_data[i - 1][1]
return level - 1 + (xp_amount - previous_xp) / (xp - previous_xp)
return xp_data[-1][0]
previous_xp = xp_data[level - 1]
return level - 1 + (xp_amount - previous_xp) / (xp - previous_xp), None
return len(xp_data) - 1, xp_amount - xp_data[-1]
Loading

0 comments on commit 13c363c

Please sign in to comment.