Closed MRSKnshnn closed 1 year ago
possible coding solution for this!! wrote this lazy pseudo-code in what wants to so badly be lua
repeat
local tierVal = math.random(1,136)
if tierVal == 1 then
function(checkIfTier1HasAnyCards)
if tier1Cards == true then
## loop break idk lol
end
else if tierVal == ## range 2 to 3
## continue this process until all tiers’ values are accounted for
until ## loop break idk
after the loop then select random card with the rarity tier that got selected in the loop and give that card
here's a table of the value ranges for each rarity: 0 = no value range, card can't be randomly drawn 1 = 1 2 = 2-3 3 = 4-6 4 = 7-10 5 = 11-15 6 = 16-21 7 = 22-28 8 = 29-36 9 = 37-45 10 = 46-55 11 = 56-66 12 = 67-78 13 = 79-91 14 = 92-105 15 = 106-120 16 = 121-136
not sure if the bot would be doing too much with this process though, like if it would end up overworking. just a matter of knowing how to code this ig
the rarity value is selected from the cards table in the SQL query. Then, the total_rarity variable is set to the sum of the rarities of all cards with rarity greater than 0. A random integer between 0 and total_rarity-1 is generated using the random module. Then, we iterate over the results from the SELECT query and add the rarity of each card to a cumulative_rarity variable until rand_int is less than cumulative_rarity. At this point, we break out of the loop and assign the values of name, card_id, image_url, color_hex, and rarity to variables. Finally, we use these variables to create the embed and insert the card into the user's collection with is_top_card set to 1.
for card rarity, this would be specified when creating the card as a number value property. setting the rarity to 0 would make the card impossible to draw, only able to be given via the specific-user-adding commands mentioned in another post. 1 would be still possible to draw, but at the rarest level. 16 levels of rarity is ideal (scale from 0-16), though with my coding inexperience, i'm unsure how the probability math would be played out with that. something something level 16 would make the card 16 times more likely to be drawn, so maybe with the draw command, it could place 16 of a level 16 card into the random selection? though i'm not sure if that would end up overloading the bot given how many cards there will be in the first place (probably 200+ <///3). i'll try and do some research into probability math and such just to save time on your end; i have very limited experience with maths coding in lua, so i figure i might be able to work my way around figuring out maths stuff for python