forked from cmss13-devs/cmss13
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Xeno caste picks are now tracked in the DB (cmss13-devs#8261)
# About the pull request Tracks all evolved-into castes in the DB # Explain why it's good for the game Additional stat tracking is good, i'm cooking things # Testing Photographs and Procedure (T0/Hellhound/King no longer show up) ![image](https://github.com/user-attachments/assets/2a8d8758-66e0-4f3d-aaf6-131262801fc4)
- Loading branch information
1 parent
6c2f732
commit 27aaa87
Showing
5 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/datum/entity/round_caste_picks | ||
/// Round ID that we're storing data on | ||
var/round_id | ||
/// Dict of "castename" : amount picked | ||
var/list/castes_picked | ||
|
||
/datum/entity/round_caste_picks/New() | ||
. = ..() | ||
round_id = GLOB.round_id || -1 | ||
|
||
/datum/entity/round_caste_picks/assign_values(list/values, list/ignore = list()) | ||
for(var/field in metadata.field_types) | ||
if(ignore.Find(field)) | ||
continue | ||
if(field == "round_id") | ||
vars[field] = values[field] | ||
else | ||
castes_picked[field] = values[field] | ||
|
||
/datum/entity_meta/round_caste_picks | ||
entity_type = /datum/entity/round_caste_picks | ||
table_name = "round_caste_picks" | ||
field_types = list( | ||
"round_id" = DB_FIELDTYPE_INT, | ||
) | ||
|
||
/datum/entity_meta/round_caste_picks/New() | ||
. = ..() | ||
for(var/caste_name in (ALL_XENO_CASTES - XENO_T0_CASTES - XENO_CASTE_HELLHOUND - XENO_CASTE_KING)) | ||
field_types[lowertext(replacetext(caste_name, " ", "_"))] = DB_FIELDTYPE_INT | ||
|
||
/datum/entity_meta/round_caste_picks/map(datum/entity/round_caste_picks/entity, list/values) | ||
var/strid = "[values[DB_DEFAULT_ID_FIELD]]" | ||
entity.id = strid | ||
for(var/field in field_types) | ||
if(field == "round_id") | ||
entity.vars[field] = values[field] | ||
else | ||
entity.castes_picked[field] = values[field] | ||
|
||
/datum/entity_meta/round_caste_picks/unmap(datum/entity/round_caste_picks/entity, include_id = TRUE) | ||
var/list/values = list() | ||
if(include_id) | ||
values[DB_DEFAULT_ID_FIELD] = entity.id | ||
for(var/field in field_types) | ||
if(field == "round_id") | ||
values[field] = entity.vars[field] | ||
else | ||
values[field] = entity.castes_picked[field] | ||
|
||
return values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters