Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added pull a card goodie #152

Closed
wants to merge 7 commits into from

5 participants

@mattlehning

No description provided.

@nospampleasemam

Looks good :-)

One thing I think needs to be added is some kind of delimiter when you return multiple cards. A comma would probably be perfect?

Also, how about using [unicode](https://en.wikipedia.org/wiki/Playing_Cards_(Unicode_block\)) for the HTML version? I think that it'd be very cool. You can actually include unicode characters directly inside your source file if you use utf8.

Tell me what you think!

@zekiel
Owner

@nospampleasemam can you please look at this and add to staging if we can continue with it?

@jagtalon
Owner

@mattlehning it looks good on Windows, but all I see are boxes on both OS X and iOS:

screen shot 2013-10-29 at 11 12 43 am

screen shot 2013-10-29 at 11 14 20 am

@nospampleasemam does it look okay on your system?

@djinn

@jagtalon I can confirm being able see correct symbol on gnome-terminal on Ubuntu Linux 12.04.
cardgoodie
@mattlehning Could you include primary example in the module for reference?

@jagtalon
Owner

@djinn it doesn't work on the browser, though. :(

It would be nice if someone could continue working on this plugin. Closing this PR.

@jagtalon jagtalon closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 31, 2013
  1. @mattlehning

    Pull a card goodie

    mattlehning authored
  2. @mattlehning

    cleaned up code

    mattlehning authored
Commits on Feb 2, 2013
  1. @mattlehning
Commits on Feb 9, 2013
  1. @mattlehning
Commits on Feb 14, 2013
  1. @mattlehning

    Added unicode

    mattlehning authored
  2. @mattlehning
  3. @mattlehning

    Fixed test file

    mattlehning authored
This page is out of date. Refresh to see the latest.
Showing with 59 additions and 0 deletions.
  1. +31 −0 lib/DDG/Goodie/Card.pm
  2. +28 −0 t/Card.t
View
31 lib/DDG/Goodie/Card.pm
@@ -0,0 +1,31 @@
+package DDG::Goodie::Card;
+
+use DDG::Goodie;
+use utf8;
+
+triggers start => 'choose', 'pick', 'card', 'pull';
+
+handle query_lc => sub {
+ return unless my ($a, $n) = $_ =~ /^((?:choose|pick|pull)\s+a\s+card|(?:pick|choose|pull)\s+(\d{0,2})\s+cards?)$/;
+ my @output;
+ my @choices = ("ace of spades 🂡", "2 of spades 🂢", "3 of spades 🂣", "4 of spades 🂤", "5 of spades 🂥", "6 of spades 🂦", "7 of spades 🂧", "8 of spades 🂨", "9 of spades 🂩", "10 of spades 🂪", "jack of spades 🂫", "queen of spades 🂭", "king of spades 🂮", "ace of diamonds 🃁", "2 of diamonds 🃂", "3 of diamonds 🃃", "4 of diamonds 🃄", "5 of diamonds 🃅", "6 of diamonds 🃆", "7 of diamonds 🃇", "8 of diamonds 🃈", "9 of diamonds 🃉", "10 of diamonds 🃊", "jack of diamonds 🃋", "queen of diamonds 🃍", "king of diamonds 🃎", "ace of hearts 🂱", "2 of hearts 🂲", "3 of hearts 🂳", "4 of hearts 🂴", "5 of hearts 🂵", "6 of hearts 🂶", "7 of hearts 🂷", "8 of hearts 🂸", "9 of hearts 🂹", "10 of hearts 🂺", "jack of hearts 🂻", "queen of hearts 🂽", "king of hearts 🂾", "ace of clubs 🂾", "2 of clubs 🃒", "3 of clubs 🃓", "4 of clubs 🃔", "5 of clubs 🃕", "6 of clubs 🃖", "7 of clubs 🃗", "8 of clubs 🃘", "9 of clubs 🃙", "10 of clubs 🃚", "jack of clubs 🃛", "queen of clubs 🃝", "king of clubs 🃞");
+
+ my $cards = 1;
+ my $card;
+ my $b = "pick a card";
+ my $c = "choose a card";
+ my $d = "pull a card";
+ my $count;
+
+ $n = 1 if($a eq $b||$a eq $c||$a eq $d);
+
+ if($n >= 1) {
+ for ($count = 1; $count <= $n; $count++) {
+ $card = $choices[int rand @choices];
+ push @output, $card;
+ }
+ }
+ return join(', ', @output) . ' (random)' if @output;
+};
+
+1;
View
28 t/Card.t
@@ -0,0 +1,28 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More;
+use DDG::Test::Goodie;
+use utf8;
+
+zci answer_type => 'card';
+zci is_cached => 0;
+
+ddg_goodie_test(
+ [qw(
+ DDG::Goodie::Card
+ )],
+ 'pick a card' => test_zci(qr/(\d|ace|jack|queen|king) of (clubs|spades|diamonds|hearts) [🂡-🃞] \(random\)/),
+ 'pick 1 card' => test_zci(qr/(\d|ace|jack|queen|king) of (clubs|spades|diamonds|hearts) [🂡-🃞] \(random\)/),
+ 'pick 2 cards' => test_zci(qr/(\d|ace|jack|queen|king) of (clubs|spades|diamonds|hearts) [🂡-🃞], (\d|ace|jack|queen|king) of (clubs|spades|diamonds|hearts) [🂡-🃞] \(random\)/),
+ 'choose a card' => test_zci(qr/(\d|ace|jack|queen|king) of (clubs|spades|diamonds|hearts) [🂡-🃞] \(random\)/),
+ 'choose 1 card' => test_zci(qr/(\d|ace|jack|queen|king) of (clubs|spades|diamonds|hearts) [🂡-🃞] \(random\)/),
+ 'choose 2 cards' => test_zci(qr/(\d|ace|jack|queen|king) of (clubs|spades|diamonds|hearts) [🂡-🃞], (\d|ace|jack|queen|king) of (clubs|spades|diamonds|hearts) [🂡-🃞] \(random\)/),
+ 'pull a card' => test_zci(qr/(\d|ace|jack|queen|king) of (clubs|spades|diamonds|hearts) [🂡-🃞] \(random\)/),
+ 'pull 1 card' => test_zci(qr/(\d|ace|jack|queen|king) of (clubs|spades|diamonds|hearts) [🂡-🃞] \(random\)/),
+ 'pull 2 cards' => test_zci(qr/(\d|ace|jack|queen|king) of (clubs|spades|diamonds|hearts) [🂡-🃞], (\d|ace|jack|queen|king) of (clubs|spades|diamonds|hearts) [🂡-🃞] \(random\)/),
+
+);
+
+done_testing;
Something went wrong with that request. Please try again.