fixed triggers and regex handler
parent
2ebe4a6902
commit
cae918ff6d
|
@ -8,21 +8,22 @@ zci is_cached => 1;
|
|||
|
||||
name "2048";
|
||||
description "Javascript IA for online 2048";
|
||||
primary_example_queries "2048 game", "play 512";
|
||||
primary_example_queries "play 512";
|
||||
secondary_example_queries "play 4096";
|
||||
category "entertainment";
|
||||
topics "gaming";
|
||||
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Game2048.pm";
|
||||
attribution github => ["https://github.com/puskin94", "puskin"];
|
||||
|
||||
triggers any => "game", "play";
|
||||
my @game_modes = qw (128 256 512 1024 2048 4096 8192);
|
||||
my @triggers = map { "play $_" } @game_modes;
|
||||
triggers start => @triggers;
|
||||
|
||||
handle remainder => sub {
|
||||
handle query_lc => sub {
|
||||
|
||||
(my $inputNum, my $dimension) = split/ /;
|
||||
|
||||
# Play 128, 256, 512, 1024, 2048, 4096, 8192
|
||||
return unless $inputNum % 128 == 0 && $inputNum <= 8192;
|
||||
return unless $_ =~ qr#^play\s(?<inputNum>\d{3,4})\s*(?<dimension>\d{1,2})*$#;
|
||||
my $inputNum = $+{inputNum};
|
||||
my $dimension = $+{dimension};
|
||||
|
||||
if (!$dimension || $dimension > 10 || $dimension < 3) {
|
||||
$dimension = 4;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
box-shadow: 2px 2px 2px #999;
|
||||
}
|
||||
|
||||
.zci--game2048 .game2048__area td, tr {
|
||||
.zci--game2048 .game2048__area .boxtile {
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
border: 3px solid #776E65;
|
||||
|
|
|
@ -12,7 +12,7 @@ DDH.game2048.build = function(ops) {
|
|||
|
||||
|
||||
/* This function ( using 'transpose' and 'swapRows' )
|
||||
moves the numbers */
|
||||
moves and sums numbers */
|
||||
|
||||
function mov(dir) {
|
||||
var i,
|
||||
|
@ -102,7 +102,7 @@ DDH.game2048.build = function(ops) {
|
|||
var val;
|
||||
$("td").each(function(idx) {
|
||||
val = area[parseInt(idx / SIZE, 10)][idx % SIZE];
|
||||
$(this).html(val).attr("class","val-"+val);
|
||||
$(this).html(val).attr("class","boxtile val-"+val);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue