proc/Check_Objs(mob/M,deck,name)
var/list/tmpdeck[]=new()
var/kill = 0
var/list/kill_cards = list()
for(var/A in deck)
if(A in typesof(/obj/cards))
var/obj/cards/C = new A
tmpdeck += A
del C
else
kill ++
kill_cards += A
if(kill)
M<<{"<font color=#670000><b>Please check the Deck '[name]' for the folowing [kill] missing card\s.</b></font>"}
M<<"DEBUG: Bad Card Pile Size - [kill_cards.len]"
var/kill_count = 0
while(kill_count < kill_cards.len)
kill_count++
var/card_type_path = "[kill_cards[kill_count]]"
M<<"DEBUG: Card Type Path - [card_type_path]"
card_type_path = dd_replacetextUD(card_type_path,"obj/cards","")
card_type_path = dd_replacetextUD(card_type_path,"/monster/","<b>Monster Card - Set: </b>")
card_type_path = dd_replacetextUD(card_type_path,"/spell/","<b>Spell Card - Set: </b>")
card_type_path = dd_replacetextUD(card_type_path,"/trap/","<b>Trap Card - Set: </b>")
card_type_path = dd_replacetextUD(card_type_path,"/"," <b>- Card ID:</b> ")
M<<{"<font color=#ceafaf>[card_type_path]</font>"}
return tmpdeck
Problem description:
So I won't really go too much in to detail about why this is needed, but the short story is that I occasionally have to remove an obj from the game or change its obj path.
The players have decks of cards in their save file. These decks are lists and the cards are objects. When I remove a card from the game, or have to change its path, the deck has to be updated since the game checks deck's card counts and loads objects from the list, so it's important that there's no bad objects in a player's deck before they try to play or it will cause major issues later in the game.
This proc here receives each deck on login, creates a second list, goes through each card in the initial deck, and if it's a valid card, adds it to the new deck. At the end, that corrected deck replaces the user's original deck so that the removed cards are no longer a part of it.
The issue is that sometimes players can't remember every card they have in their deck and cant figure out which card is missing without asking. I do provide update notes and make sure to include this information any time this happens, but occasionally I have to change multiple cards at once which makes it more difficult.
What I'm TRYING to do with this code here is to get the bad card's obj path as a string, and then manipulate it in to an output to try and help the users a bit.
A typical obj path for a card in my game would look like...
obj/cards/monster/HA07/EN020
in the code im using a proc... dd_replacetextUD()
which is a case sensitive text replacement proc...
dd_replacetextUD(STRING,Term to look for,Replacement Term)
I'm trying to do with this code is take that line, turn it into a string...
"obj/cards/monster/HA07/EN020"
replace the "obj/cards" portion with nothing, ""
"/monster/HA07/EN020"
replace the "/monster/" or "/spell/" or "/trap/" portion with "Monster Card - Set: "
"Monster Card - Set: HA07/EN020"
replace the final "/" with " - Card ID: "
"Monster Card - Set: HA07 - Card ID: EN020"
Which is the best I can do but it should be enough for the players.
However I can't seem to retrieve the path of the bad obj. It's obviously readable since I get errors off the proc on login.
Warning: type read from file (/obj/cards/monster/HA07/EN020) is not defined
I've tried a few different ways of getting the output but I cant seem to figure it out.