Skip to content

Commit

Permalink
feat: Invites now scale gexp based on join date.
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxgh committed Mar 20, 2024
1 parent 539093c commit ed5f43d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/utils/referral_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,27 @@ async def validate_invites(inviter_ign, invitee_ign):

async def check_invitation_validity(invitations: list):
guild_data = await get_guild_by_name(guild_handle)
members = []
members = {}
for member in guild_data["members"]:
members.append(member["uuid"])
members[member["uuid"]] = member["joined"]


weekly_valid_invites = []
for invitee_uuid in invitations:
if invitee_uuid not in members:
if invitee_uuid not in members.keys():
continue

_, weekly_gexp = await get_player_gexp(invitee_uuid, guild_data)

# Player earns more than double the member requirement
if weekly_gexp > (member_req * 2):
weekly_valid_invites.append(invitee_uuid)
continue

# Player has joined less than 7 days ago. Their gexp scaled up is double the member requirement.
days_since_join = (datetime.now() - datetime.fromtimestamp(members[invitee_uuid] / 1000.0)).days
if days_since_join <= 7 and ((weekly_gexp * 2) > ((member_req / 7) * days_since_join)):
weekly_valid_invites.append(invitee_uuid)

return weekly_valid_invites

Expand Down

0 comments on commit ed5f43d

Please sign in to comment.