Minor card tweaks (#22568)

* cards

* Better handles cards

* update descriptions, limit visual size to 20

* Add alert so you don't dump your whole hand by mistake

* Update code/modules/games/cards.dm

Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>

* sirryan review

* Update code/modules/games/cards.dm

Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>

---------

Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>
This commit is contained in:
Luc
2023-10-12 10:21:56 -04:00
committed by GitHub
parent 9b44fc9b96
commit bcc68500ad
+46 -40
View File
@@ -58,20 +58,23 @@
/obj/item/deck/proc/build_deck()
return
/obj/item/deck/attackby(obj/O as obj, mob/user as mob)
if(istype(O,/obj/item/cardhand))
/obj/item/deck/attackby(obj/O, mob/user)
if(istype(O, /obj/item/cardhand))
var/obj/item/cardhand/H = O
if(H.parentdeck == src)
for(var/datum/playingcard/P in H.cards)
cards += P
qdel(H)
to_chat(user,"<span class='notice'>You place your cards on the bottom of [src].</span>")
update_icon(UPDATE_ICON_STATE)
return
else
if(H.parentdeck != src)
to_chat(user,"<span class='warning'>You can't mix cards from different decks!</span>")
return
if(length(H.cards) > 1)
var/confirm = alert("Are you sure you want to put your [length(H.cards)] cards back into the deck?", "Return Hand", "Yes", "No")
if(confirm == "No" || !Adjacent(user) || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED))
return
for(var/datum/playingcard/P in H.cards)
cards += P
qdel(H)
to_chat(user, "<span class='notice'>You place your cards on the bottom of [src].</span>")
update_icon(UPDATE_ICON_STATE)
return
..()
/obj/item/deck/examine(mob/user)
@@ -148,9 +151,6 @@
if(H && (H.parentdeck != src))
to_chat(user,"<span class='warning'>You can't mix cards from different decks!</span>")
return
if(H && length(H.cards) >= H.maxcardlen)
to_chat(user,"<span class = 'warning'>You can't hold that many cards in one hand!</span>")
return
if(!H)
H = new(get_turf(src))
@@ -311,7 +311,6 @@
icon = 'icons/obj/playing_cards.dmi'
icon_state = "empty"
w_class = WEIGHT_CLASS_TINY
var/maxcardlen = 20
actions_types = list(/datum/action/item_action/remove_card, /datum/action/item_action/discard)
var/concealed = FALSE
@@ -348,18 +347,14 @@
update_appearance(UPDATE_NAME|UPDATE_DESC|UPDATE_OVERLAYS)
else if(istype(O,/obj/item/cardhand))
var/obj/item/cardhand/H = O
if((length(H.cards) + length(cards)) > maxcardlen)
to_chat(user,"<span class='warning'>You can't hold that many cards in one hand!</span>")
return
if(H.parentdeck == parentdeck)
for(var/datum/playingcard/P in cards)
H.cards += P
H.concealed = concealed
qdel(src)
H.update_appearance(UPDATE_NAME|UPDATE_DESC|UPDATE_OVERLAYS)
cards.Add(H.cards)
qdel(H)
update_appearance(UPDATE_NAME|UPDATE_DESC|UPDATE_OVERLAYS)
return
else
to_chat(user,"<span class='notice'>You cannot mix cards from other deck!</span>")
to_chat(user, "<span class='notice'>You cannot mix cards from other decks!</span>")
return
..()
@@ -543,16 +538,20 @@
/obj/item/cardhand/update_name()
. = ..()
if(length(cards) > 1)
name = "hand of cards"
name = "hand of [length(cards)] cards"
else
name = "a playing card"
name = "playing card"
/obj/item/cardhand/update_desc()
. = ..()
if(length(cards) > 1)
desc = "Some playing cards."
else
desc = "A playing card."
if(concealed)
desc = "A playing card. You can only see the back."
else
var/datum/playingcard/card = cards[1]
desc = "\A [card.name]."
/obj/item/cardhand/update_icon_state()
return
@@ -583,23 +582,30 @@
return
var/offset = FLOOR(20/length(cards) + 1, 1)
var/i = 0
for(var/datum/playingcard/P in cards)
var/image/I = new(icon, (concealed ? "[P.back_icon]" : "[P.card_icon]") )
//I.pixel_x = origin+(offset*i)
switch(direction)
if(SOUTH)
I.pixel_x = 8-(offset*i)
if(WEST)
I.pixel_y = -6+(offset*i)
if(EAST)
I.pixel_y = 8-(offset*i)
else
I.pixel_x = -7+(offset*i)
I.transform = M
. += I
// var/i = 0
for(var/i in 1 to length(cards))
var/datum/playingcard/P = cards[i]
if(i >= 20)
// skip the rest and just draw the last one on top
. += render_card(cards[length(cards)], M, i, offset)
break
. += render_card(P, M, i, offset)
i++
/obj/item/cardhand/proc/render_card(datum/playingcard/card, matrix/mat, index, offset)
var/image/I = new(icon, (concealed ? "[card.back_icon]" : "[card.card_icon]") )
switch(direction)
if(SOUTH)
I.pixel_x = 8 - (offset * index)
if(WEST)
I.pixel_y = -6 + (offset * index)
if(EAST)
I.pixel_y = 8 - (offset * index)
else
I.pixel_x = -7 + (offset * index)
I.transform = mat
return I
/obj/item/cardhand/dropped(mob/user)
..()
if(user)