Uno (Card Game)/Julia: Difference between revisions

m
m (const globals)
Line 18:
 
""" The Uno card type. The first field is color, second field is number or command. """
const UnoCard = Pair{String, String}
color(c::UnoCard) = first(c)
type(c::UnoCard) = last(c)
Line 335:
"Green" => colorant"green", "Blue" => colorant"blue", "Wild" => colorant"black")
 
""" CSS style button for bold colored text """
function colorbutton(txt::String, clr::String)
button = GtkButton(txt)
Line 465 ⟶ 466:
hand = first(game.players).hand
isempty(hand) && return
nrow = (length(hand) + 15) ÷ 1615
for row in 1:nrow
cards = hand[(row - 1) * 1615 + 1 : min(length(hand), row * 1615 - 1)]
startx, starty = 40 + (1615 - length(cards)) * 20, 500 + 85 * (row - 1)
for (i, card) in enumerate(cards)
idx, x0 = (row - 1) * 1615 + i, startx + 50 * (i - 1)
cardpositions[idx] = [x0, starty, x0 + 40, starty + 80]
cairocard(ctx, card, x0, starty, 40, 80)
4,103

edits