ID:149909
 
I keep getting a runtime error when I am trying to 'Deal card to each player.


proc name: Deal (/mob/proc/Deal)
source file: procs.dm,106
usr: the orange-bot (/mob/player)
src: the orange-bot (/mob/player)
call stack:
the orange-bot (/mob/player): Deal()
the orange-bot (/mob/player): deal()

Will try to build a short progressive picture.

mob/var/numcards = 0 //track the # of cards dealt to player


Created this list of cards there are actually 84:
mob/var/list/cards = list("1" = new /obj/card1, "2" = new /obj/card2, "3" = new /obj/card3)

Created this proc to deal the cards and add them to the user inventory

mob/proc/Deal()
while (usr.numcards <= 0)
var/cardnum = rand(1,84)
var/newtype = cards["[cardnum]"]
new newtype (src)
usr.numcards++

Anyone have any ideas??

mob/var/numcards = 0 //track the # of cards dealt to player
CHANGED the list of cards to be non associative, hence this :
Created this list of cards there are actually 84:
mob/var/list/cards = list("1" = new /obj/card1, "2" = new /obj/card2, "3" = new /obj/card3)
Became this :
mob/var/list/cards = list(/obj/card1,/obj/card2,/obj/card3)

Created a proc to deal the cards and add them to the user inventory
And I changed it to this:
Deal()
while (usr.numcards <= usr.hp +1)
var/newcard = pick(cards)
cards.Remove(newcard)
usr << "[newcard]"
usr.contents += new newcard
usr.numcards++
Instead of this:

mob/proc/Deal()
while (usr.numcards <= 10)
var/cardnum = rand(1,84)
var/newtype = cards["[cardnum]"]
new newtype (src)
usr.numcards++
And it worked great, now my players are getting cards, now I just have to let them do something with them.