ID:273576
 
Alright so this is what my cards look like right now.
obj
LOB
card
var
attribute
monster_type
monster_sub_type
level
flavour_text
effect
attack
defense
set_name
status
rarity
Normal_Monster
TriHornedDragon
name = "Tri-Horned Dragon"
attribute = "DARK"
level = "8 stars"
monster_type = "Dragon"
flavour_text = "An unworthy dragon with three sharp horns sprouting from its head."
attack = "2850"
defense = "2350"
set_name = "LOB-000"
status = "1st Edition"
rarity = "(ScR)"
BlueEyesWhiteDragon
name = "Blue-Eyes White Dragon"
attribute = "LIGHT"
level = "8 stars"
monster_type = "Dragon"
flavour_text = "This legendary dragon is a powerful engine of destruction. Virtually invincible, very few have faced this awesome creature and lived to tell the tale."
attack = "3000"
defense = "2500"
set_name = "LOB-001"
status = "1st Edition"
rarity = "(UR)"
Fusion_Monster
FlameSwordsman
name = "Flame Swordsman"
attribute = "FIRE"
level = "5 stars"
monster_type = "Warrior"
monster_sub_type = "Fusion"
flavour_text = "Flame Manipulator + Maskai the Legendary Swordsman"
attack = "1800"
defense = "1600"
set_name = "LOB-003"
status = "1st Edition"
rarity = "(SR)"
CharubinTheFireKnight
name = "Charubin The Fire Knight"
attribute = "FIRE"
level = "3 stars"
monster_type = "Pyro"
monster_sub_type = "Fusion"
flavour_text = "Monster Egg + Hinotoma Soul"
attack = "1100"
defense = "800"
set_name = "LOB-015"
status = "1st Edition"
rarity = "(R)"
Spell_Card
PotofGreed
name = "Pot of Greed"
card_type = "Normal Spell"
effect = "Draw 2 cards from your deck."
set_name = "LOB-???"
status = "1st Edition"
rarity = "(SR)"


All the cards follow that kind of structure...now for a Booster Pack that has all 100+ of these cards attached to it I guess like so?:
obj
Packs
LOB
for(var/obj/LOB/card/Normal_Monster/Effect_Monster/Fusion_Monster/Spell_Card)
icon = 'Legend of the Blue Eyes.dmi'
price = 50

I already defined the var known as price. Since I am but a novice coder/programmer and am still learning, my questions are:

-How would I be able to get 9 cards out of those 100+ cards to be randomly picked every time someone buys and opens these packs?

-I added the rarities but am not sure if I described them correctly enough to have them be apart of a probability system, so any help with that?

You shouldn't be using Text Strings (" ") for variables. You should either be using values, or the #define function if needed:

#define ATTACK 4
#define DEFENCE 6

mob/var/power

mob/verb/power()
switch(input("What kind of power?","",src) in list("Attack", "Defence")
if("Attack")
power = ATTACK
else
power = DEFENCE
src << "Your number is [power]"


If you are going to be having values which are all similar, such as different styles of card elements, you should do so by storing them in a list:

obj/var/card_element_list = list(Dark,Light,Fire,Water,Stone)

For probability, use the procedure prob. Ex.

mob/var/clan
mob/verb/Clan()
if prob(49)
clan = 10
else if prob(50)
clan = 7
else
clan = 3
In response to OrangeWeapons
Oh sorry, I'll make a note of that. Thanks so much for your input. Hopefully I can get some more answers though.
One possible way to go about this is to define a proc that picks random items in a list and returns the new list of picked items. It's similar to "pick()" except that it takes a list as an argument.

This proc I made, called "Pick_Items()" takes two arguments. The first one is the number of items you need to retrieve. The second argument is the list itself. The result is a new list containing the randomly picked items.

proc
/*
Pick()
Selects x items in a list randomly. This will return null if the
number of items asked for is greater than the list's length.
*/

Pick_Items(N=1 as num, list/L)

// exception handling
//--------------------
var/flag_list_notnull = FALSE
var/flag_list_length = FALSE
var/flag_n = FALSE
var/flag_num_list = FALSE

// check if L is not null
if (L != null)
flag_list_notnull = TRUE
else
return "LIST IS NULL"

// check length of L.
if (length(L) > 0)
flag_list_length = TRUE
else
return "LIST LENGTH IS NOT GREATER THAN 0"

// check if N is greater than 0.
if (N > 0)
flag_n = TRUE
else
return "N IS NOT GREATER THAN 0"

// check if N is equal or less than the length of the list.
if (N <= length(L))
flag_num_list = TRUE
else
return "NUMBER OF ITEMS NEEDED IS GREATER THAN LIST LENGTH"


// Picking the items
//-------------------

if (flag_list_notnull == TRUE && \
flag_list_length == TRUE && \
flag_n == TRUE && \
flag_num_list == TRUE)

var/list/new_items = list()
var/list/tmp_list = L.Copy()

for (var/i = 1; i <= N; i++)
var/d = rand(1,length(tmp_list))
var/e = tmp_list[d]
new_items += e
tmp_list -= e

return new_items


///////////
// DEBUG //
///////////


mob
Login()
var/list/L = list("1","2","3","4","5")
var/list/E = Pick_Items(3,L)

// check to see if E is an error message.
src << E


for (var/i in E)
src << i
In response to Makeii
I haven't incorporated rarities, though. I'm sorry. I don't know how to go about that.

Though, one possible solution (though it may be rather arcane) is to add copies of a particular card as it adds to the ratio. Or, when sending to Pick_Items(), you can run a loop through the list to create copies of the cards that are more common before sending the entire list to Pick_Items()
In response to Makeii
Probability. It's OK, I explained that in my post.