Modif calcul et affichage mercy

This commit is contained in:
ArcElewyn 2025-08-25 18:21:50 +02:00
parent c2f23a7e73
commit d1540c816d
3 changed files with 25 additions and 20 deletions

View file

@ -2,6 +2,7 @@ import discord
from discord.ext import commands from discord.ext import commands
from config import AUTHORIZED_CHANNEL_ID from config import AUTHORIZED_CHANNEL_ID
from utils.MercyManager_class import MercyManager from utils.MercyManager_class import MercyManager
from utils.helpers import calc_chance_and_guarantee
VALID_SHARDS = ["ancient", "void", "sacred", "primal", "remnant"] VALID_SHARDS = ["ancient", "void", "sacred", "primal", "remnant"]
@ -10,23 +11,6 @@ class Mercy(commands.Cog):
self.bot = bot self.bot = bot
self.mercy_manager = MercyManager() self.mercy_manager = MercyManager()
def calc_chance_and_guarantee(self, shard_type, pulls):
"""Calcule la chance actuelle et le pull garanti"""
rules = {
"ancient": {"start": 200, "increment": 5, "base": 0.5},
"void": {"start": 200, "increment": 5, "base": 0.5},
"sacred": {"start": 12, "increment": 2, "base": 6},
"primal_legendary": {"start": 75, "increment": 1, "base": 1},
"primal_mythical": {"start": 200, "increment": 10, "base": 0.5},
"remnant": {"start": 24, "increment": 1, "base": 0},
}
rule = rules[shard_type]
chance = rule["base"] if pulls < rule["start"] else rule["base"] + (pulls - rule["start"]) * rule["increment"]
guaranteed_at = None
if chance >= 100:
guaranteed_at = rule["start"] + (100 - rule["base"]) / rule["increment"]
return chance, guaranteed_at
@commands.command(name="mercy") @commands.command(name="mercy")
async def mercy(self, ctx, action: str = None, arg1: str = None, arg2: str = None): async def mercy(self, ctx, action: str = None, arg1: str = None, arg2: str = None):
if ctx.channel.id != AUTHORIZED_CHANNEL_ID: if ctx.channel.id != AUTHORIZED_CHANNEL_ID:

View file

@ -88,8 +88,8 @@ class MercyManager:
return rule["base"] return rule["base"]
return rule["base"] + (pulls - rule["threshold"]) * rule["increment"] return rule["base"] + (pulls - rule["threshold"]) * rule["increment"]
def get_guaranteed_pull(self, shard_type): def pulls_until_guaranteed(self, shard_type, pulls):
"""Retourne le pull où la loot est garanti à 100%""" """Retourne combien de pulls restent avant un loot garanti"""
rules = { rules = {
"ancient": {"start": 200, "increment": 5, "base": 0.5}, "ancient": {"start": 200, "increment": 5, "base": 0.5},
"void": {"start": 200, "increment": 5, "base": 0.5}, "void": {"start": 200, "increment": 5, "base": 0.5},
@ -101,4 +101,6 @@ class MercyManager:
if shard_type not in rules: if shard_type not in rules:
return None return None
rule = rules[shard_type] rule = rules[shard_type]
return int(rule["start"] + (100 - rule["base"]) / rule["increment"]) guaranteed_pull = int(rule["start"] + (100 - rule["base"]) / rule["increment"])
remaining = guaranteed_pull - pulls
return remaining if remaining > 0 else 0

View file

@ -99,3 +99,22 @@ def get_difficulty_display_name(difficulty):
def is_authorized_channel(ctx): def is_authorized_channel(ctx):
return ctx.channel.id == AUTHORIZED_CHANNEL_ID return ctx.channel.id == AUTHORIZED_CHANNEL_ID
MERCY_RULES = {
"ancient": {"start": 200, "increment": 5, "base": 0.5},
"void": {"start": 200, "increment": 5, "base": 0.5},
"sacred": {"start": 12, "increment": 2, "base": 6},
"primal_legendary": {"start": 75, "increment": 1, "base": 1},
"primal_mythical": {"start": 200, "increment": 10, "base": 0.5},
"remnant": {"start": 24, "increment": 1, "base": 0},
}
def calc_chance_and_guarantee(shard_type, pulls):
"""Retourne chance, pull garanti et pulls restants"""
if shard_type not in MERCY_RULES:
return 0, None, None
rule = MERCY_RULES[shard_type]
chance = rule["base"] if pulls < rule["start"] else rule["base"] + (pulls - rule["start"]) * rule["increment"]
guaranteed_at = int(rule["start"] + (100 - rule["base"]) / rule["increment"])
remaining = max(0, guaranteed_at - pulls)
return chance, guaranteed_at, remaining