Card Dealer
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BarefootJoey
//
// ██████████████████████████████████████████████████████████████████████
// █▄─▄─▀██▀▄─██▄─▄▄▀█▄─▄▄─█▄─▄▄─█─▄▄─█─▄▄─█─▄─▄─███▄─▄█─▄▄─█▄─▄▄─█▄─█─▄█
// ██─▄─▀██─▀─███─▄─▄██─▄█▀██─▄███─██─█─██─███─███─▄█─██─██─██─▄█▀██▄─▄██
// █▄▄▄▄██▄▄█▄▄█▄▄█▄▄█▄▄▄▄▄█▄▄▄███▄▄▄▄█▄▄▄▄██▄▄▄██▄▄▄███▄▄▄▄█▄▄▄▄▄██▄▄▄██
//
//@version=5
indicator("Card Dealer", overlay=true)

// Input
position = input.string(position.top_right, "Location", [position.top_center, position.top_right, position.middle_right, position.bottom_right, position.bottom_center, position.bottom_left, position.middle_left, position.top_left])
size = input.string(size.huge, "Size", [size.tiny, size.small, size.normal, size.large, size.huge])
transp = input.int(0, "Transparency", minval=0, maxval=100)

// List of Numbers
q1 = 'A'
q2 = '2'
q3 = '3'
q4 = '4'
q5 = '5'
q6 = '6'
q7 = '7'
q8 = '8'
q9 = '9'
q10 = '10'
q11 = 'J'
q12 = 'Q'
q13 = 'K'

// List of Suits
s1 = '♠'
s2 = '♣'
s3 = '♥'
s4 = '♦'

// Card Randomizing Logic 
r = math.round(math.random(1, 13))
numout = 
  r == 1 ? q1 : r == 2 ? q2 : r == 3 ? q3 : r == 4 ? q4 : r == 5 ? q5 : r == 6 ? q6 : r == 7 ? q7 : r == 8 ? q8 : r == 9 ? q9 :
  r == 10 ? q10 : r == 11 ? q11 : r == 12 ? q12 : r == 13 ? q13 : 
  na

s = math.round(math.random(1, 4))
suitout = 
  s == 1 ? s1 : s == 2 ? s2 : s == 3 ? s3 : s == 4 ? s4 : 
  na
colout = 
  s == 1 ? color.black : s == 2 ? color.black : s == 3 ? color.red : s == 4 ? color.red : 
  na

// Table Output
var table quote = table.new(position, 1, 1, color.new(color.white, transp))
if barstate.isconfirmed
    table.cell(quote, 0, 0, str.tostring(numout) + str.tostring(suitout), text_size = size, text_color = color.new(colout, transp), tooltip="🃏 Double click to access settings")
    
// EoS made w/ ❤ by @BarefootJoey ✌💗📈
