/
cards.dm
56 lines (50 loc) · 1.6 KB
/
cards.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
*A storage component to be used on card piles, for use as hands/decks/discard piles. Don't use on something that's not a card pile!
*/
/datum/storage/tcg
max_specific_storage = WEIGHT_CLASS_TINY
max_slots = 30
max_total_storage = WEIGHT_CLASS_TINY * 30
/datum/storage/tcg/New(
atom/parent,
max_slots,
max_specific_storage,
max_total_storage,
)
. = ..()
set_holdable(/obj/item/tcgcard)
/datum/storage/tcg/attempt_remove(obj/item/thing, atom/remove_to_loc, silent = FALSE)
. = ..()
if(!.)
return
var/obj/item/tcgcard_deck/deck = parent
var/obj/item/tcgcard/card = thing
card.flipped = deck.flipped
card.update_appearance(UPDATE_ICON_STATE)
if(length(real_location.contents) == 0)
qdel(parent)
/datum/storage/tcg/show_contents(mob/to_show)
// sometimes, show contents is called when the mob is already seeing the contents of the deck, to refresh the view.
// to avoid spam, we only show the message if they weren't already seeing the contents.
var/was_already_seeing = to_show.active_storage == src
. = ..()
if(!.)
return .
if(!was_already_seeing)
to_show.visible_message(
span_notice("[to_show] starts to look through the contents of [parent]!"),
span_notice("You begin looking into the contents of [parent]."),
)
return .
/datum/storage/tcg/hide_contents(mob/to_hide)
// see above
var/was_actually_seeing = to_hide.active_storage == src
. = ..()
if(!.)
return .
if(QDELING(src))
return .
if(was_actually_seeing)
real_location.visible_message(span_notice("[parent] is shuffled after looking through it."))
real_location.contents = shuffle(real_location.contents)
return .