Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

share xp between all adenture users evenly #374

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions adventure/adventure.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import random
import time
from abc import ABC
from collections import defaultdict
from datetime import datetime, timedelta
from types import SimpleNamespace
from typing import Literal, MutableMapping, Union
Expand Down Expand Up @@ -2504,7 +2505,8 @@ async def _reward(self, ctx: commands.Context, userlist, amount, modif, special)
daymult = self._daily_bonus.get(str(datetime.today().isoweekday()), 0)
xp = max(1, round(amount))
cp = max(1, round(amount))
newxp = 0
total_adventure_xp = 0
temp = defaultdict(dict)
newcp = 0
rewards_list = []
phrase = ""
Expand All @@ -2518,22 +2520,40 @@ async def _reward(self, ctx: commands.Context, userlist, amount, modif, special)
session_bonus = 0 if session.easy_mode else 1
else:
session_bonus = 0

async for user in AsyncIter(userlist, steps=100):
self._rewards[user.id] = {}
try:
c = await Character.from_json(ctx, self.config, user, self._daily_bonus)
except Exception as exc:
log.exception("Error with the new character sheet", exc_info=exc)
continue

userxp = int(xp + (xp * 0.5 * c.rebirths) + max((xp * 0.1 * min(250, c._int / 10)), 0))
usercp = int(cp + max((cp * 0.1 * min(1000, (c._luck + c._att) / 10)), 0))
userxp = int(userxp * (c.gear_set_bonus.get("xpmult", 1) + daymult + session_bonus))
usercp = int(usercp * (c.gear_set_bonus.get("cpmult", 1) + daymult))
newxp += userxp
newcp += usercp
roll = random.randint(1, 5)
total_adventure_xp += userxp
if c.heroclass.get("pet", {}).get("bonuses", {}).get("always", False):
roll = 5
else:
roll = random.randint(1, 5)
temp[user.id]["roll"] = roll
if roll == 5 and c.heroclass["name"] == "Ranger" and c.heroclass["pet"]:
petxp = int(userxp * c.heroclass["pet"]["bonus"])
total_adventure_xp += petxp
userxp += petxp
newxp = total_adventure_xp
per_participant_xp = total_adventure_xp / len(userlist)
async for user in AsyncIter(userlist, steps=100):
self._rewards[user.id] = {}
try:
c = await Character.from_json(ctx, self.config, user, self._daily_bonus)
except Exception as exc:
log.exception("Error with the new character sheet", exc_info=exc)
continue
usercp = int(cp + max((cp * 0.1 * min(1000, (c._luck + c._att) / 10)), 0))
usercp = int(usercp * (c.gear_set_bonus.get("cpmult", 1) + daymult))
newcp += usercp
roll = temp.get(user.id, {}).get("roll")
userxp = int(per_participant_xp)
if roll == 5 and c.heroclass["name"] == "Ranger" and c.heroclass["pet"]:
petxp = int(userxp * c.heroclass["pet"]["bonus"])
newxp += petxp
Expand Down