mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 21:18:37 +01:00
[MIRROR] You can now tap TCG cards. (#707)
* You can now tap TCG cards. (#53459) Basically the last groundwork TCG PR we need before we can sew the rules into the game, you can now use TCG cards on the ground with a new radial with an empty hand to either tap, flip, or pick up individual cards. This will also mean that using a deck on a set of individual cards on the ground is now the fastest and most efficient way to pick up cards now. Author's note: Opponent's card was not "deleted for effect", it was sent to the Shadow Realm, for all eternity. * You can now tap TCG cards. Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,8 @@ GLOBAL_LIST_EMPTY(cached_cards)
|
||||
|
||||
#define DEFAULT_TCG_DMI_ICON 'icons/runtime/tcg/default.dmi'
|
||||
#define DEFAULT_TCG_DMI "icons/runtime/tcg/default.dmi"
|
||||
#define TAPPED_ANGLE 90
|
||||
#define UNTAPPED_ANGLE 0
|
||||
|
||||
/obj/item/tcgcard
|
||||
name = "Coder"
|
||||
@@ -19,6 +21,8 @@ GLOBAL_LIST_EMPTY(cached_cards)
|
||||
var/series = "coderbus"
|
||||
///Is the card flipped?
|
||||
var/flipped = FALSE
|
||||
///Has this card been "tapped"? AKA, is it horizontal?
|
||||
var/tapped = FALSE
|
||||
|
||||
/obj/item/tcgcard/Initialize(mapload, datum_series, datum_id)
|
||||
. = ..()
|
||||
@@ -43,19 +47,34 @@ GLOBAL_LIST_EMPTY(cached_cards)
|
||||
id = temp.id
|
||||
series = temp.series
|
||||
|
||||
GLOBAL_LIST_EMPTY(tcgcard_radial_choices)
|
||||
|
||||
/obj/item/tcgcard/attack_hand(mob/user)
|
||||
if(!isturf(loc))
|
||||
return ..()
|
||||
var/list/choices = GLOB.tcgcard_radial_choices
|
||||
if(!length(choices))
|
||||
choices = GLOB.tcgcard_radial_choices = list(
|
||||
"Pickup" = image(icon = 'icons/mob/radial.dmi', icon_state = "radial_pickup"),
|
||||
"Tap" = image(icon = 'icons/mob/radial.dmi', icon_state = "radial_tap"),
|
||||
"Flip" = image(icon = 'icons/mob/radial.dmi', icon_state = "radial_flip"),
|
||||
)
|
||||
var/choice = show_radial_menu(user, src, choices, custom_check = CALLBACK(src, .proc/check_menu, user), require_near = TRUE, tooltips = TRUE)
|
||||
if(!check_menu(user))
|
||||
return
|
||||
switch(choice)
|
||||
if("Tap")
|
||||
tap_card(user)
|
||||
if("Pickup")
|
||||
user.put_in_hands(src)
|
||||
if("Flip")
|
||||
flip_card(user)
|
||||
if(null)
|
||||
return
|
||||
|
||||
/obj/item/tcgcard/attack_self(mob/user)
|
||||
. = ..()
|
||||
to_chat(user, "<span_class='notice'>You turn the card over.</span>")
|
||||
if(!flipped)
|
||||
name = "Trading Card"
|
||||
desc = "It's the back of a trading card... no peeking!"
|
||||
icon_state = "cardback"
|
||||
else
|
||||
var/datum/card/template = GLOB.cached_cards[series]["ALL"][id]
|
||||
name = template.name
|
||||
desc = template.desc
|
||||
icon_state = template.icon_state
|
||||
flipped = !flipped
|
||||
flip_card(user)
|
||||
|
||||
/obj/item/tcgcard/equipped(mob/user, slot, initial)
|
||||
. = ..()
|
||||
@@ -65,18 +84,6 @@ GLOBAL_LIST_EMPTY(cached_cards)
|
||||
. = ..()
|
||||
zoom_out()
|
||||
|
||||
/**
|
||||
* Transforms the card's sprite to look like a small, paper card. Use when outside of inventory
|
||||
*/
|
||||
/obj/item/tcgcard/proc/zoom_in()
|
||||
transform = matrix()
|
||||
|
||||
/**
|
||||
* Transforms the card's sprite to look like a large, detailed, illustrated paper card. Use when inside of inventory/storage.
|
||||
*/
|
||||
/obj/item/tcgcard/proc/zoom_out()
|
||||
transform = matrix(0.3,0,0,0,0.3,0)
|
||||
|
||||
/obj/item/tcgcard/update_icon_state()
|
||||
. = ..()
|
||||
if(!flipped)
|
||||
@@ -103,11 +110,56 @@ GLOBAL_LIST_EMPTY(cached_cards)
|
||||
user.put_in_hands(new_deck)
|
||||
if(istype(I, /obj/item/tcgcard_deck))
|
||||
var/obj/item/tcgcard_deck/old_deck = I
|
||||
flipped = old_deck.flipped
|
||||
if(length(old_deck.contents) >= 30)
|
||||
to_chat(user, "<span class='notice'>This pile has too many cards for a regular deck!</span>")
|
||||
return
|
||||
user.transferItemToLoc(src, old_deck)
|
||||
flipped = old_deck.flipped
|
||||
zoom_in()
|
||||
old_deck.update_icon()
|
||||
update_icon()
|
||||
return ..()
|
||||
|
||||
/obj/item/tcgcard/proc/check_menu(mob/living/user)
|
||||
if(!istype(user))
|
||||
return FALSE
|
||||
if(user.incapacitated() || !user.Adjacent(src))
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/obj/item/tcgcard/proc/tap_card(mob/user)
|
||||
var/matrix/ntransform = matrix(transform)
|
||||
if(tapped)
|
||||
ntransform.TurnTo(TAPPED_ANGLE , UNTAPPED_ANGLE)
|
||||
else
|
||||
ntransform.TurnTo(UNTAPPED_ANGLE , TAPPED_ANGLE)
|
||||
tapped = !tapped
|
||||
animate(src, transform = ntransform, time = 2, easing = (EASE_IN|EASE_OUT))
|
||||
|
||||
/**
|
||||
* Transforms the card's sprite to look like a small, paper card. Use when outside of inventory
|
||||
*/
|
||||
/obj/item/tcgcard/proc/zoom_in()
|
||||
transform = matrix()
|
||||
|
||||
/**
|
||||
* Transforms the card's sprite to look like a large, detailed, illustrated paper card. Use when inside of inventory/storage.
|
||||
*/
|
||||
/obj/item/tcgcard/proc/zoom_out()
|
||||
transform = matrix(0.3,0,0,0,0.3,0)
|
||||
|
||||
/obj/item/tcgcard/proc/flip_card(mob/user)
|
||||
to_chat(user, "<span_class='notice'>You turn the card over.</span>")
|
||||
if(!flipped)
|
||||
name = "Trading Card"
|
||||
desc = "It's the back of a trading card... no peeking!"
|
||||
icon_state = "cardback"
|
||||
else
|
||||
var/datum/card/template = GLOB.cached_cards[series]["ALL"][id]
|
||||
name = template.name
|
||||
desc = template.desc
|
||||
icon_state = template.icon_state
|
||||
flipped = !flipped
|
||||
/**
|
||||
* A stack item that's not actually a stack because ORDER MATTERS with a deck of cards!
|
||||
* The "top" card of the deck will always be the bottom card in the stack for our purposes.
|
||||
@@ -173,7 +225,6 @@ GLOBAL_LIST_EMPTY(cached_cards)
|
||||
stored_card.zoom_out()
|
||||
. = ..()
|
||||
|
||||
|
||||
/obj/item/tcgcard_deck/proc/check_menu(mob/living/user)
|
||||
if(!istype(user))
|
||||
return FALSE
|
||||
@@ -192,6 +243,7 @@ GLOBAL_LIST_EMPTY(cached_cards)
|
||||
new_card.forceMove(src)
|
||||
new_card.zoom_in()
|
||||
|
||||
|
||||
/obj/item/tcgcard_deck/attack_self(mob/living/carbon/user)
|
||||
shuffle_deck(user)
|
||||
return ..()
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 22 KiB |
Reference in New Issue
Block a user