ID:1289520
 
(See the best response by Nailez.)
Hello, my name is Kingleon250, and I am currently making a Yugioh BYOND game. I've been making good progress recently, but now have come to the biggest hill in the valley: The Duel System. I was wondering if someone could help me with the following in this order
*Choose Deck from List
*Draw cards from Deck and add into usr.contents

Here's what I have so far



Code:
obj
var
Name
Level = 1
Attribute = list("Light","Dark","Fire","Water","Earth","Wind","Divine")
Type = list("Aqua", "Beast", "Beast-Warrior", "Creator God", "Dinosaur", "Divine-Beast", "Dragon", "Fairy", "Fiend", "Fish", "Insect", "Machine", "Plant", "Psychic", "Pyro", "Reptile", "Rock", "Sea Serpent", "Spellcaster", "Thunder", "Warrior", "Winged Beast", "Zombie")
Monster_Type = list("Normal", "Effect", "Ritual", "Fusion", "Spell", "Trap", "Synchro", "XYZ", "Dark Synchro")
Spell_Type = list("Normal", "Continuous", "Field", "Equip", "Quick-Play", "Ritual", "Speed Spell")
Trap_Type = list("Normal", "Continuous", "Counter")
ATK = 0
DEF = 0
Pack = new/list()
Cards
LOB000
Name = "Tri-Horned Dragon"
Level = 8
Attribute = "Dark"
Type = "Dragon"
Monster_Type = "Normal"
ATK = 2850
DEF = 2350
Pack = "Legend of the Blue-Eyes White Dragon"
LOB001
Name = "Blue-Eyes White Dragon"
Level = 8
Attribute = "Light"
Type = "Dragon"
Monster_Type = "Normal"
ATK = 3000
DEF = 2500
Pack = "Legend of the Blue-Eyes White Dragon"
__________________________________________________
var/list/Decklist = list()


mob
proc
ChooseDeck()
usr = (input("Choose your deck",,) in list(Decklist))

Duel_Verbs
verb
Draw()
set category = "Duel Commands"
for(var/obj/Cards/C in world)
Decklist += C


I know it is not much, but I just can't seem to figure out the rest.

Best response
You are doing really well! :D

Instead of having the hand as the players contents (usr.contents) I made a new variable for the hand and I also made a variable for the main deck that the player is using.

mob
var
Main_Deck[0]
Hand[0]

And when the player draws I would remove the top most cards from the deck and add it to the hand. So my draw proc looks something like this.

mob
proc
Draw()
var/obj/Cards/Card = src.Main_Deck[src.Main_Deck.len]

src.Main_Deck.Remove(Card)
src.Hand.Add(Card)

This code takes the top most cards in the deck (the last one added to it) and removes it then adds it to the hand.

Now onto your other problem. To select a deck from the list it would be something like this.

mob
proc
Choose_Deck()
var/Selected_Deck = input(src, "Which deck would you like to duel with?", "Choose Deck") in Decklist)

//Depending on how you have set-up the decks you would make the main deck equal a copy of the selected deck.


What I have shown you is very basic and is in no way complete. For example the draw proc should check if there are no more cards left in the deck and end the duel.

Hopefully this starts you off, please post your progress and any other problems.

In response to Nailez
You made a rival, but helped him.

Typical Gai-Sensei *shed a tear*
=D
Hi, I'm back with a quick question. I have it so when you draw, you add the deck to your hand. How do I make the card actually appear in the "Hand" Statpanel though?
I will be on Skype soon we can talk there =D