Fuck you and your persistence system

This commit is contained in:
SmArtKar
2021-02-03 16:43:05 +03:00
parent 76831f27fb
commit b0c63ea547
5 changed files with 90 additions and 0 deletions

View File

@@ -490,6 +490,27 @@ SUBSYSTEM_DEF(job)
job.after_spawn(H, M, joined_late) // note: this happens before the mob has a key! M will always have a client, H might not.
equip_loadout(N, H, TRUE)//CIT CHANGE - makes players spawn with in-backpack loadout items properly. A little hacky but it works
if(ishuman(H) && H.client && N)
if(H.client && H.client.prefs && length(H.client.prefs.tcg_cards))
var/obj/item/tcgcard_binder/binder = new(get_turf(H))
if(!H.equip_to_slot_if_possible(binder, SLOT_IN_BACKPACK, disable_warning = TRUE, bypass_equip_delay_self = TRUE))
qdel(binder)
else
for(var/card_type in H.client.prefs.tcg_cards)
var/obj/item/tcg_card/card = new(get_turf(H), card_type)
card.forceMove(binder)
binder.cards.Add(card)
else
if(H && N.client.prefs && length(N.client.prefs.tcg_cards))
var/obj/item/tcgcard_binder/binder = new(get_turf(H))
if(!H.equip_to_slot_if_possible(binder, SLOT_IN_BACKPACK, disable_warning = TRUE, bypass_equip_delay_self = TRUE))
qdel(binder)
else
for(var/card_type in N.client.prefs.tcg_cards)
var/obj/item/tcg_card/card = new(get_turf(H), card_type)
card.forceMove(binder)
binder.cards.Add(card)
return H
/*
/datum/controller/subsystem/job/proc/handle_auto_deadmin_roles(client/C, rank)

View File

@@ -88,6 +88,7 @@ SUBSYSTEM_DEF(persistence)
SavePhotoPersistence() //THIS IS PERSISTENCE, NOT THE LOGGING PORTION.
SavePaintings()
SaveScars()
SaveTCGCards()
/**
* Loads persistent data relevant to the current map: Objects, etc.
@@ -349,3 +350,24 @@ SUBSYSTEM_DEF(persistence)
if(!ending_human.client)
return
ending_human.client.prefs.save_character()
/datum/controller/subsystem/persistence/proc/SaveTCGCards()
for(var/i in GLOB.joined_player_list)
var/mob/living/carbon/human/ending_human = get_mob_by_ckey(i)
if(!istype(ending_human) || !ending_human.mind || !ending_human.client || !ending_human.client.prefs || !ending_human.client.prefs.tcg_cards)
continue
var/mob/living/carbon/human/original_human = ending_human.mind.original_character
if(!original_human || original_human.stat == DEAD || !(original_human == ending_human))
continue
var/obj/item/tcgcard_binder/binder = locate() in ending_human
if(!binder || !length(binder.cards))
continue
var/list/card_types = list()
for(var/obj/item/tcg_card/card in binder.cards)
card_types.Add(card.datum_type)
ending_human.client.prefs.tcg_cards = card_types
ending_human.client.prefs.save_character()

View File

@@ -218,6 +218,8 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/hide_ckey = FALSE //pref for hiding if your ckey shows round-end or not
var/list/tcg_cards = list()
/datum/preferences/New(client/C)
parent = C

View File

@@ -656,6 +656,14 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
modified_limbs = safe_json_decode(limbmodstr)
else
modified_limbs = list()
var/tcgcardstr
S["tcg_cards"] >> tcgcardstr
if(length(tcgcardstr))
tcg_cards = safe_json_decode(tcgcardstr)
else
tcg_cards = list()
S["chosen_limb_id"] >> chosen_limb_id
S["hide_ckey"] >> hide_ckey //saved per-character
@@ -1091,6 +1099,11 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
else
S["loadout"] << safe_json_encode(list())
if(length(tcg_cards))
S["tcg_cards"] << safe_json_encode(tcg_cards)
else
S["tcg_cards"] << safe_json_encode(list())
cit_character_pref_save(S)
return 1

View File

@@ -227,6 +227,8 @@
"Epic" = 9,
"Rare" = 30)
custom_price = PRICE_EXPENSIVE
/obj/item/cardpack/series_one
name = "Trading Card Pack: 2560 Core Set"
desc = "Contains six cards of varying rarity from the 2560 Core Set. Collect them all!"
@@ -454,5 +456,35 @@
user.put_in_hands(choice)
cards.Remove(choice)
update_icon()
if(length(cards) == 0)
qdel(src)
return
. = ..()
/obj/item/tcgcard_binder
name = "Trading Card Binder"
desc = "A TCG-branded card binder, specifically for your infinite collection of TCG cards!"
icon = 'icons/obj/tcg/misc.dmi'
icon_state = "binder"
var/list/cards = list()
/obj/item/tcgcard_binder/attackby(obj/item/I, mob/living/user, params)
if(istype(I, /obj/item/tcg_card))
var/obj/item/tcg_card/card = I
card.forceMove(src)
cards.Add(card)
. = ..()
/obj/item/tcgcard_binder/attack_hand(mob/living/carbon/user)
if(loc == user)
var/list/choices = list()
for(var/obj/item/tcg_card/card in cards)
choices[card] = image(icon = card.icon, icon_state = card.icon_state)
var/obj/item/tcg_card/choice = show_radial_menu(user, src, choices, require_near = TRUE, tooltips = TRUE)
if(choice)
choice.forceMove(get_turf(src))
user.put_in_hands(choice)
cards.Remove(choice)
return
. = ..()