r/webdev • u/[deleted] • Sep 03 '15
HTML5 Deck of Cards
http://pakastin.github.io/deck-of-cards/1
u/pkstn Sep 03 '15
Thanks scotchio for adding this here as well 👍
3
Sep 03 '15
Saw this on HN earlier. Loved it! Great stuff. Thanks for sharing
2
1
u/pkstn Sep 04 '15
No worries! It has already inspired people to make their own card games/tests, so mission accomplished! :)
2
2
u/cbleslie Sep 03 '15
Neat. The only real improvement you could have passed suit as a class to the card.
1
u/pkstn Sep 04 '15
I could do that of course, but I don't see the point..?
1
u/cbleslie Sep 06 '15
What's the point of describing a card as red, or black? Why not just describe the suit and let it pass its symbol as part of its identity. Jokers are neither red nor black. So why not just accept stronger more semantic way of passing your classes. Black is just a property. Why not just describe identity of the card, like: This is a "card" let it inherit the identity of a "spade". JS shouldn't care about colors, or symbols. It should just care about value and suit. Let css present what that should look like.
I hope that's clear enough?
1
u/pkstn Sep 06 '15 edited Sep 06 '15
That's a great idea! I will do that. The reason I used .card and .card.red was that the suit is showed in HTML as a text and at current there's no need for suit to have their own style apart from the color, but you proved your point about the semantics.
Also makes JS even simplier.
Thanks!
1
u/pkstn Sep 06 '15
You'd also need them if you'll use some premade graphic files with kings, queens, jacks.. makes totally sense!
1
1
u/pkstn Sep 08 '15
Added better graphics and a couple of easter eggs..see if you can find them :) https://deck-of-cards.js.org
3
u/stark0788 Sep 03 '15
Very cool - but there should be a feature to flip the card over - would allow you to play a plethora of card games.