Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
Doubleumc committed Aug 10, 2024
1 parent 2ad5e45 commit 7cc20bb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions code/__DEFINES/stats.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
#define FACEHUG_TIER_3 100
#define FACEHUG_TIER_4 1000

/// Consecutive rounds this player has readied up and failed to get a slot.
#define PLAYER_STAT_UNASSIGNED_ROUND_STREAK "unassigned_round_streak"

// Stat Categories
#define STAT_CATEGORY_MARINE "marine"
#define STAT_CATEGORY_XENO "xeno"
#define STAT_CATEGORY_YAUTJA "yautja"
#define STAT_CATEGORY_MISC "misc"
23 changes: 21 additions & 2 deletions code/game/jobs/role_authority.dm
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,26 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou
if(!length(roles_to_assign) || !length(unassigned_players))
return

log_debug("ASSIGNMENT: Building weighted_players list.")
var/list/weighted_players = list()
for(var/mob/new_player/cycled_unassigned in unassigned_players)
//1 base weight + 1 for new players + 1/per missed round
var/weight = 1 + (cycled_unassigned.client.get_total_human_playtime() < 5 HOURS) + get_client_stat(cycled_unassigned.client, PLAYER_STAT_UNASSIGNED_ROUND_STREAK)
weighted_players[cycled_unassigned] = weight

log_debug("ASSIGNMENT: Weighted shuffling unassigned_players list.")
unassigned_players.Cut()
while(length(weighted_players))
var/mob/new_player/weighted_pick = pick_weight(weighted_players)
unassigned_players += weighted_pick
weighted_players -= weighted_pick

log_debug("ASSIGNMENT: Starting prime priority assignments.")
for(var/mob/new_player/cycled_unassigned in shuffle(unassigned_players))
for(var/mob/new_player/cycled_unassigned in unassigned_players)
assign_role_to_player_by_priority(cycled_unassigned, roles_to_assign, unassigned_players, PRIME_PRIORITY)

log_debug("ASSIGNMENT: Starting regular priority assignments.")
for(var/mob/new_player/cycled_unassigned in shuffle(unassigned_players))
for(var/mob/new_player/cycled_unassigned in unassigned_players)
var/player_assigned_job = FALSE

for(var/priority in HIGH_PRIORITY to LOW_PRIORITY)
Expand All @@ -278,6 +292,7 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou

if(assign_role(cycled_unassigned, random_job))
log_debug("ASSIGNMENT: We have randomly assigned [random_job_name] to [cycled_unassigned]")
cycled_unassigned.client.player_data?.adjust_stat(PLAYER_STAT_UNASSIGNED_ROUND_STREAK, STAT_CATEGORY_MISC, 0, TRUE)
unassigned_players -= cycled_unassigned

if(random_job.spawn_positions != -1 && random_job.current_positions >= random_job.spawn_positions)
Expand All @@ -292,6 +307,7 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou
var/datum/job/marine_job = GET_MAPPED_ROLE(JOB_SQUAD_MARINE)
if(assign_role(cycled_unassigned, marine_job))
log_debug("ASSIGNMENT: We have assigned [marine_job.title] to [cycled_unassigned] via alternate option.")
cycled_unassigned.client.player_data?.adjust_stat(PLAYER_STAT_UNASSIGNED_ROUND_STREAK, STAT_CATEGORY_MISC, 0, TRUE)
unassigned_players -= cycled_unassigned

if(marine_job.spawn_positions != -1 && marine_job.current_positions >= marine_job.spawn_positions)
Expand All @@ -305,6 +321,8 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou
cycled_unassigned.ready = 0

log_debug("ASSIGNMENT: Assignment complete. Players unassigned: [length(unassigned_players)] Jobs unassigned: [length(roles_to_assign)]")
for(var/mob/new_player/cycled_unassigned in unassigned_players)
cycled_unassigned.client.player_data?.adjust_stat(PLAYER_STAT_UNASSIGNED_ROUND_STREAK, STAT_CATEGORY_MISC, 1)

return roles_to_assign

Expand All @@ -321,6 +339,7 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou

if(assign_role(cycled_unassigned, actual_job))
log_debug("ASSIGNMENT: We have assigned [job_name] to [cycled_unassigned].")
cycled_unassigned.client.player_data?.adjust_stat(PLAYER_STAT_UNASSIGNED_ROUND_STREAK, STAT_CATEGORY_MISC, 0, TRUE)
unassigned_players -= cycled_unassigned

if(actual_job.spawn_positions != -1 && actual_job.current_positions >= actual_job.spawn_positions)
Expand Down

0 comments on commit 7cc20bb

Please sign in to comment.