ID:143209
 
Code:
mob
verb
draw()
if(!deckrand)
usr << "You need to shuffle a deck first."
return 0
if(deckrand.len==0)
usr << "Out of cards!"
deckrand = null
return 0
if(!hand)
hand = new()
var/c = deckrand[1]
deckrand.Remove(c)
hand += c
usr << "You draw a <b>[c]</b>."
//Error checking here
for(c in deckrand)
usr << c


-deckrand[] is the player's shuffled deck
-it can contain a variable number of obj/card

Problem description:
The problem I have is when a card is drawn and removed from deckrand[1], the next card in the list bearing the same name takes the [1] spot. Thus, if I have a deckrand ordered like this:

Goblin
Sage
Knight
Goblin
Sage
Sage

The first card I draw will obviously be a Goblin. The next card I draw should be a Sage, but it's a Goblin again. Now that the Goblins are gone, I can draw the Sage, but it will keep drwaing only Sages until they, too, are gone. Otherwise, it acts normally and truly depletes the objs from the list.
While it's performing undesirably, it's performing precisely as it should: Remove() is removing the LAST Goblin in the list, not the first. Instead, use deckrand.Cut(1,2) to remove the first element in the list.