Add unit-tests for card decks (#24791)

* Add unit-tests for card decks

* Fix linter CI comments

* Rename unit-test file due to duplicate filename

* Fix review comments

* Fix unit-test broken after review comment fixing

* Remove blank unit-tests for card-decks

* Use TRUE instead of magic-value 1 in cardshuffle sound call

Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>

---------

Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
This commit is contained in:
Zantox
2024-04-14 11:35:48 +00:00
committed by GitHub
co-authored by Burzah
parent c73443bc47
commit cb03f174a0
3 changed files with 42 additions and 3 deletions
+11 -3
View File
@@ -50,10 +50,16 @@
/obj/item/deck/Initialize(mapload)
. = ..()
build_decks()
update_icon(UPDATE_ICON_STATE)
/obj/item/deck/proc/build_decks()
if(length(cards))
// prevent building decks more than once
return
for(var/deck in 1 to deck_size)
build_deck()
deck_total = length(cards)
update_icon(UPDATE_ICON_STATE)
/obj/item/deck/proc/build_deck()
return
@@ -227,8 +233,10 @@
var/mob/living/user = usr
if(cooldown < world.time - 1 SECONDS)
cards = shuffle(cards)
user.visible_message("<span class='notice'>[user] shuffles [src].</span>")
playsound(user, 'sound/items/cardshuffle.ogg', 50, 1)
if(user)
user.visible_message("<span class='notice'>[user] shuffles [src].</span>")
playsound(user, 'sound/items/cardshuffle.ogg', 50, TRUE)
cooldown = world.time