Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes playing cards #5337

Merged
merged 4 commits into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions code/game/objects/items/toys/cards.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
. = ..()
populate_deck()

/obj/item/toy/deck/Destroy(force)
. = ..()
QDEL_NULL_LIST(cards)

/obj/item/toy/deck/get_examine_text(mob/user)
. = ..()
. += SPAN_NOTICE("There are <b>[length(cards)]</b> cards remaining in the deck.")
Expand Down Expand Up @@ -75,6 +79,7 @@
var/obj/item/toy/handcard/H = O
for(var/datum/playing_card/P as anything in H.cards)
cards += P
H.cards -= P
update_icon()
qdel(O)
user.visible_message(SPAN_NOTICE("<b>[user]</b> places their cards on the bottom of \the [src]."), SPAN_NOTICE("You place your cards on the bottom of the deck."))
Expand Down Expand Up @@ -271,6 +276,10 @@
if(!concealed)
. += " ([length(cards)] card\s)"

/obj/item/toy/handcard/Destroy(force)
. = ..()
QDEL_NULL_LIST(cards)

/obj/item/toy/handcard/aceofspades
icon_state = "spades_ace"
desc = "An Ace of Spades"
Expand Down Expand Up @@ -315,6 +324,9 @@

//fuck any qsorts and merge sorts. This needs to be brutally easy
var/cards_length = length(cards)
if(cards_length >= 200)
to_chat(usr, SPAN_WARNING("Your hand is too big to sort. Remove some cards."))
return
for(var/i = 1 to cards_length)
for(var/k = 2 to cards_length)
if(cards[i].sort_index > cards[k].sort_index)
Expand All @@ -331,6 +343,7 @@
var/cards_length = length(H.cards)
for(var/datum/playing_card/P in H.cards)
cards += P
H.cards -= P
qdel(O)
if(pile_state)
if(concealed)
Expand Down Expand Up @@ -390,6 +403,8 @@
/obj/item/toy/handcard/MouseDrop(atom/over)
if(usr != over || !Adjacent(usr))
return
if(ismob(loc))
return
usr.put_in_hands(src)

/obj/item/toy/handcard/get_examine_text(mob/user)
Expand Down Expand Up @@ -423,6 +438,12 @@
name = "a playing card"
desc = "A playing card."

if(length(cards) >= 200)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(length(cards) >= 200)
if(cards_length >= 200)

// BYOND will flat out choke when using thousands of cards for some unknown reason,
// possibly due to the transformed overlay stacking below. Nobody's gonna see the
// difference past 40 or so anyway.
return

overlays.Cut()

if(!cards_length)
Expand Down
Loading