Modif calcul et affichage mercy
This commit is contained in:
parent
c2f23a7e73
commit
d1540c816d
3 changed files with 25 additions and 20 deletions
|
|
@ -2,6 +2,7 @@ import discord
|
|||
from discord.ext import commands
|
||||
from config import AUTHORIZED_CHANNEL_ID
|
||||
from utils.MercyManager_class import MercyManager
|
||||
from utils.helpers import calc_chance_and_guarantee
|
||||
|
||||
VALID_SHARDS = ["ancient", "void", "sacred", "primal", "remnant"]
|
||||
|
||||
|
|
@ -10,23 +11,6 @@ class Mercy(commands.Cog):
|
|||
self.bot = bot
|
||||
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")
|
||||
async def mercy(self, ctx, action: str = None, arg1: str = None, arg2: str = None):
|
||||
if ctx.channel.id != AUTHORIZED_CHANNEL_ID:
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ class MercyManager:
|
|||
return rule["base"]
|
||||
return rule["base"] + (pulls - rule["threshold"]) * rule["increment"]
|
||||
|
||||
def get_guaranteed_pull(self, shard_type):
|
||||
"""Retourne le pull où la loot est garanti à 100%"""
|
||||
def pulls_until_guaranteed(self, shard_type, pulls):
|
||||
"""Retourne combien de pulls restent avant un loot garanti"""
|
||||
rules = {
|
||||
"ancient": {"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:
|
||||
return None
|
||||
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
|
||||
|
|
|
|||
|
|
@ -99,3 +99,22 @@ def get_difficulty_display_name(difficulty):
|
|||
def is_authorized_channel(ctx):
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue