ID:273571
 
I am currently making a Yu-Gi-Oh! game and I am stuck on a particular piece of code.

I have a shopkeeper code set up to sell Card Packs to the players, but what I want is when the players click on the pack that they bought in their Inventory, an html window pops up with a random set of 9 cards that belong in that pack.

Basically if anyone plays YGO IRL, a pack contains 9 cards and the set contains over 100 cards.

So, what I am asking is, how do I assign those 100 cards to that particular pack and when someone purchases that pack to see what they got, 9 random cards appear in a html window.

I'm not a very good explainer and I know I can ramble on but, any help on this would be much appreciated.

My email is [email protected] and my AIM is delatorrepaul (pretty easy to remember, no?).
First up you will need to grasp the html side of BYOND and there are a number of tutorials that will help you with that go run a search in resources for html or search some guides.

next up would most likely be where you define your cards with their variables and what not such as Stars, Attack, skills, w.e they use nowdays lol. add in an additional variable for deck kind its really as simple as that.

Just from what i know some basic variables if you didnt know them for a card would be.

Stars, Attack, Defence, Type, Pack ID/DeckID, Element, Rarity.

Rarity could be the most important out of them all for when your randoming your packs you dont want say a blue eyes white dragon in every pack
In response to Midgetbuster
I understand where you are coming from and it seems like you know a lot more about this than I do (I'm a novice so that's mostly why).

Would you maybe be able to give an example?
In response to Paul De La Torre
as it is now i dont really feel like typing any code.

If you run some searches im sure you will find some usefull things
In response to Midgetbuster
I ran through some html sources and guides but didn't really find what I was looking for.

What I really have trouble with is like the structure of the code. I don't understand how to set those variables to the card itself and then set those cards to the related packs.
Hmmm... What you could do... is this...

////////////////
// PLAYER MOB //
////////////////

mob
var
atom/card/current_deck[40]

list/atom
booster_pack/booster_packs = new/list()
card_pack/card_packs = new/list()
card/extra_cards = new/list()



/////////////////////////////
// OBJECT OF PACK OF CARDS //
/////////////////////////////

atom/card_pack

var
list/atom/card/cards = list()

proc

// previewing the cards
// (Can also be used to storing a card pack if necessary)
//----------------------


Preview(mob/A, obtain=FALSE as num)
var/list/atom/card/pack_cards = cards.Copy()
var/list/atom/card/preview_cards = new/list()

for (var/i = 1; i <= 9; i++)

if (length(pack_cards > 0))

var/l = length(pack_cards)
var/r = rand(1,l)

var/a = pack_cards[r]
pack_cards -= a
preview_cards += a
else
break

A << "Here is a preview of cards in this deck."
for (var/atom/card/C in preview_cards)
A << "[C.picture]"

if (obtain == TRUE)
var/atom/booster_pack/B = new
for (var/i = 1; i <= 9; i++)
B[i] = new preview_cards[i]

A.booster_packs += B
A << "Booster pack obtained!"





////////////////////////////
// OBJECT OF BOOSTER PACK //
////////////////////////////

atom/booster_pack

var
atom/card/cards[9]
origin_card_pack = null

/////////////////////
// OBJECT OF CARDS //
/////////////////////

atom/card

var/const
TYPE_NONE = 0
TYPE_MONSTER = 1
TYPE_MONSTEREFFECT = 2
TYPE_SPELL = 3
TYPE_TRAP = 4

var
card_type = TYPE_NONE
picture = null






//////////
// DATA //
//////////

// Example Card Pack
//-------------------

atom/card_pack/cardpack1

name = "Card Pack 1"
cards = list(\
new/atom/card/card1,\
new/atom/card/card2,\
new/atom/card/card3)

// Example Cards
//---------------


atom/card/card1
name = "Monster 1"
card_type = TYPE_MONSTER

atom/card/card2
name = "Spell 1"
card_type = TYPE_SPELL

atom/card/card3
name = "Trap 1"
card_type = TYPE_TRAP


It's not thoroughly tested, but it's something that may work in an HTML document. Basically, you could use html the way you use Output in a skin control.
In response to Makeii
One of my many questions will be: "What is the difference between the 'pack of cards' and the 'booster pack'?
In response to Makeii
//Alright so basically this is what I am stuck with.
//I have the card variables like so:


/////////////////////
// OBJECT OF CARDS //
/////////////////////
atom/card
var/const
TYPE_NONE = 0
TYPE_NORMALMONSTER = 1
TYPE_EFFECTMONSTER = 2
TYPE_FUSIONMONSTER = 3
TYPE_RITUALMONSTER = 4
TYPE_SYNCHROMONSTER = 5

TYPE_NORMALSPELL = 6
TYPE_QUICKPLAYSPELL = 7
TYPE_CONTINUOUSSPELL = 8
TYPE_EQUIPSPELL = 9
TYPE_RITUALSPELL = 10
TYPE_FIELDSPELL = 11

TYPE_NORMALTRAP = 12
TYPE_CONTINUOUSTRAP = 13
TYPE_COUNTERTRAP = 14

var
level = ""
flavour_text = ""
effect = ""
attack = ""
defense = ""
monster_type = ""
monster_sub_type = ""
attribute = ""
rarity = ""
set_name = ""

//(Stop me at anytime)
//Then I have the Booster Packs.
////////////////////////////
// OBJECT OF BOOSTER PACK //
////////////////////////////
obj
Packs
LOB
icon = 'Legend of the Blue Eyes.dmi'
price = 50
Click()
for(var/mob/M in world)
var/LOBPack = //HTML stuff
usr << browse(LOBPack,"window=pack")

MRD
icon = 'Metal Raiders.dmi'
price = 75
Click()
for(var/mob/M in world)
var/MRDPack = //More HTML Stuff
usr << browse(MRDPack,"window=Announce")

//*********************************//
//Now I have the shopkeeper's code.//
//********************************//
mob
YugisGrandpa
icon = 'Yugi.dmi'
density = 1
New()
for(var/NewItem in typesof(/obj/Packs)-/obj/Packs)
src.SellingItems += new NewItem
..()
mob
Topic(href,href_list[])
if(href_list["Item"])
var/ItemPath = "/obj/Packs/[href_list["Item"]]"
var/obj/Packs/NewItem = new ItemPath
if(src.money < NewItem.price)
src << "\white {Server}: \red You do not have enough money to purchase this item."
return
..()
src << "You bought a pack of \an [href_list["Item"]]"
src.contents += NewItem
src.money -= NewItem.price
//*******************************//
//Finally I have the Shop() verb.//
//*******************************//
mob/verb
Shop(mob/YugisGrandpa/M as mob in oview(1))
set category = "Commands"
set desc = "Buy Cards."
var/Display = {"
<table border = "3" cellspacing = "1" cellpadding = "1">
<Caption>Packs for sale</Caption>"}
for(var/obj/Packs/I in M.SellingItems)

Display +={"
<tr><td align = "center">[I.name]</td>
<td align = "center">Cost: $[I.price]</td>
<td align = "center">Buy</td>
</tr>"}

usr<< browse({"
[M.Welcome]



[Display]"},"window=shop")

//*****************************************************//
//*****************************************************//
So what I am asking is:
How would I go about making all of this into a successful Shopkeeping Code where it displays the packs in the shop via html. Then when you purchase said packs they are displayed in your inventory (Soon to be Trunk System also via html). THEN when you click on the packs another html pops up with 9 out of the 100 or so cards that belong to that set (Oh and would it be possible for the pack to disappear and leave only the cards in the Inventory 'Trunk' Panel after you click on it to open?)

I know I am asking a lot of questions pertaining to this piece of code but in my opinion, it is one of the most important codes in the game. I would really like if maybe someone could work with me on this if possible? If not, then I'll understand.
In response to Paul De La Torre
Sorry. What I meant was like a starter deck, which contains 40 cards, but I suppose in some examples could be 100. I suppose that there are many cards that belong to a particular set, so I suppose you could call them "deck affiliations" or something that let the user know which card belongs to which card set.