Skip to content

Commit

Permalink
修改任务和flash算法
Browse files Browse the repository at this point in the history
  • Loading branch information
heyunpeng committed Jul 31, 2015
1 parent 4437b9f commit 464b8bd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 33 deletions.
43 changes: 28 additions & 15 deletions app/views/flashview/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

<% content_for :script do %>
var nextgameid = "";
var nextseconds = 0;
$(document).ready(
function(){
setInterval(countdown, 1000);
Expand Down Expand Up @@ -80,7 +81,9 @@ $(document).ready(
setInterval(flash, 1000);
});
function flash(){
$.ajax({
if (nextseconds == 0 || nextseconds % 60 == 0 || nextseconds == 420
|| nextseconds == 580 || nextseconds == 570 || nextseconds == 560){
$.ajax({
url: 'jsondata',
type: 'GET',
dataType: 'json',
Expand All @@ -89,31 +92,41 @@ $(document).ready(
success: function(json) {

thisMovie('luck').countTime(json.seconds);

if (nextgameid == "")
{
nextgameid = json.nextnum;
thisMovie('luck').hisNum(json.curnum,json.curlog);
thisMovie('luck').nowNum(json.nextnum);
}

if (json.seconds == 420)
{
thisMovie('luck').reset();
thisMovie('luck').nowNum(json.nextnum);
}
else if (json.seconds == 0)
else
{
thisMovie('luck').startLuck();
}
else if (json.seconds == 580 && nextgameid == json.curnum)
{
thisMovie('luck').nowLuck(json.curlog);
nextgameid = json.nextnum;
if (nextseconds == 420)
{
thisMovie('luck').reset();
thisMovie('luck').nowNum(json.nextnum);
}
else if (nextseconds == 0)
{
thisMovie('luck').startLuck();
}
else if ((nextseconds == 580 || nextseconds == 570 || nextseconds == 560)
&& nextgameid == json.curnum)
{
thisMovie('luck').nowLuck(json.curlog);
nextgameid = json.nextnum;
}
}

nextseconds = parseInt(json.seconds);
}
}
)
}
else if (nextseconds > 0)
{
nextseconds -= 1;
}
};
<% end %>

Expand Down
32 changes: 14 additions & 18 deletions config/initializers/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ def processprize (userid, coin)
def cardnum(num)
if num%13 == 1
return 14
elsif num%13 == 0
return 13
else
return num%13
return num%14
end
end

Expand Down Expand Up @@ -90,34 +88,34 @@ def checkGrid (object)
small = cards.min
big = cards.max
if big-small == 2 and cards[0] != cards[1] and cards[1] != cards[2] and cards[0] != cards[2]
lsorder[lsorder.length] = i+1
lsorder[lsorder.length] = i+4
end
end

#all big && small
for i in 0..2
#if (object[i*3]%13 >= 12 or object[i*3]%13 == 1) and (object[i*3+1]%13 >= 12 or object[i*3+1] == 1) and (object[i*3+2]%13 >= 12 or object[i*3+2]%13 == 1)
if object[i*3]%14 + object[i*3+1]%14 + object[i*3+2]%14 > 34
cards = [cardnum(object[i*3]), cardnum(object[i*3+1]), cardnum(object[i*3+2])]

if cards[0] + cards[1] + cards[2] > 31
lsbig[lsbig.length] = i+1
#elsif object[i*3]%13 != 1 and object[i*3+1] != 1 and object[i*3+2] != 1 and object[i*3]%13 < 12 and object[i*3+1] < 12 and object[i+3+2] < 12
elsif object[i*3]%14 + object[i*3+1]%14 +object[i*3+2]%14 < 34
elsif cards[0] + cards[1] +cards[2] < 31
lssmall[lssmall.length] = i+1
end
#if (object[i]%13 >= 12 or object[i]%13 == 1) and (object[i+3]%13 >= 12 or object[i+3]%13 == 1) and (object[i+6]%13 >= 12 or object[i+6] == 1)
if object[i]%14 + object[i+3]%14 + object[i+6]%14 > 34

cards = [cardnum(object[i]), cardnum(object[i+3]), cardnum(object[i+6])]
if cards[0] + cards[1] + cards[2] > 31
lsbig[lsbig.length] = i+4
#elsif object[i]%13 != 1 and object[i+3]%13 != 1 and object[i+6]%13 != 1 and object[i]%13 < 12 and object[i+3] < 12 and object[i+6] < 13
elsif object[i]%14 + object[i+3]%14 + object[i+6]%14 < 34
elsif cards[0] + cards[1] + cards[2] < 31
lssmall[lssmall.length] = i+4
end
end

#all double
for i in 0..2
if object[i*3]%13 == object[i*3+1]%13 or object[i*3+1]%13 == object[i*3+2]%13 or object[i*3]%13 == object[i*3+2]%13 or object[i*3]%13 == object[i*3+2]%13
if object[i*3]%13 == object[i*3+1]%13 or object[i*3+1]%13 == object[i*3+2]%13 or object[i*3]%13 == object[i*3+2]%13
lsdouble[lsdouble.length] = i+1
end
if object[i]%13 == object[i+3]%13 or object[i+3]%13 == object[i+6]%13 or object[i]%13 == object[i+6]%13 or object[i]%13 == object[i+6]%13
if object[i]%13 == object[i+3]%13 or object[i+3]%13 == object[i+6]%13 or object[i]%13 == object[i+6]%13
lsdouble[lsdouble.length] = i+4
end
end
Expand All @@ -131,12 +129,10 @@ def checkGrid (object)
lscolor[lscolor.length] = i+4
end

if object[i*3] >= 14 and object[i*3] <= 26 and object[i*3+1] <= 14 and object[i*3+1] <= 26 and
object[i*3+2] >= 14 and object[i*3+2] <= 26
if object[i*3] >= 14 and object[i*3] <= 26 and object[i*3+1] <= 14 and object[i*3+1] <= 26 and object[i*3+2] >= 14 and object[i*3+2] <= 26
lscolor[lscolor.length] = i+1
end
if object[i] >= 14 and object[i] <= 26 and object[i+3] <= 14 and object[i+3] <= 26 and
object[i+6] >= 14 and object[i+6] <= 26
if object[i] >= 14 and object[i] <= 26 and object[i+3] <= 14 and object[i+3] <= 26 and object[i+6] >= 14 and object[i+6] <= 26
lscolor[lscolor.length] = i+4
end

Expand Down

0 comments on commit 464b8bd

Please sign in to comment.