Skip to content

Commit

Permalink
Straight Works fine now! Fixed other bugs with table ordering and wat…
Browse files Browse the repository at this point in the history
…ching game.
  • Loading branch information
Saheb committed Oct 4, 2015
1 parent f4b4815 commit 03618d9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
51 changes: 29 additions & 22 deletions public/challengeResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ var suit_map = {
"Hearts" : "h"
};


var cardArray = ["0","0","2", "3", "4", "5", "6", "7", "8", "9", "10","J","Q","K","A"];

var bet = store.getItem("previousBet")

function isFlush(cards, suitType){
Expand All @@ -39,33 +42,37 @@ function isStraight(cards,valueType){
var regex = '[id^=' + valueType + ']'
$(regex).css('opacity', '1.0')

if(cards.search(valueType) >= 0)
var value = card_score[valueType.toUpperCase()]
var left = 0; var right = 0;
for(var i=value;i<14;i++)
{
var value = card_score[valueType]
var left = 0; var right = 0;
for(var i=value;i<=14;i++)
var actualCard = cardArray[i+1].toLowerCase();
if(cards.search(actualCard) != -1)
{
if(cards.search(i+1) != -1)
{
var regex = '[id^=' + eval(i+1) + ']'
$(regex).css('opacity', '1.0')
right+=1
}
else
break;
var regex = '[id^=' + actualCard + ']'
$(regex).css('opacity', '1.0')
right+=1
}
for(var i=value;i>=2;i--)
else
break;
}
for(var i=value;i>2;i--)
{
var actualCard = cardArray[i-1].toLowerCase();
if(cards.search(actualCard) != -1)
{
if(cards.search(i-1) != -1)
{
var regex = '[id^=' + eval(i-1) + ']'
$(regex).css('opacity', '1.0')
left+=1
}
else
break;
var regex = '[id^=' + actualCard + ']'
$(regex).css('opacity', '1.0')
left+=1
}
if(right + left >= 4)
else
break;
}
if(right + left >= 4)
{
if(cards.search(valueType) < 0)
return false;
else
return true;
}
else
Expand Down
1 change: 1 addition & 0 deletions public/gamePlayEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function dealAndGetCards(){
$('#betPanel').remove();
$('#cards').remove();
$('#challengeBtn').remove();
$('#betBtn').remove();
$('#allHandsTable').fadeIn(1000);
$.ajax({
url : '/gamePlay/' + GAME_ID + '/' + nextRoundNumber + '/' + 'dealCards',
Expand Down
6 changes: 4 additions & 2 deletions public/html5Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function drawPlayers() {
var playerDist = canvas.height/2 - 2*radius*0.1;
var y = canvas.height/2 - 2*radius*0.1;
var x = 0;

for(num = myIndex; num < validPositions.length; num++){
ctx.beginPath();
ctx.fillStyle = 'red';
Expand All @@ -56,7 +57,7 @@ function drawPlayers() {
ctx.fillStyle = 'black';
var name = positionNameMap[validPositions[num]];
ctx.fillText(name,x,y+radius*0.15);
x = playerDist * Math.sin(angle);
x = playerDist * Math.sin(-1*angle);
y = playerDist * Math.cos(angle);
angle += angle;
}
Expand All @@ -70,7 +71,7 @@ function drawPlayers() {
ctx.fillStyle = 'black';
var name = positionNameMap[validPositions[num]];
ctx.fillText(name,x,y+radius*0.15);
x = playerDist * Math.sin(angle);
x = playerDist * Math.sin(-1*angle);
y = playerDist * Math.cos(angle);
angle += angle;
}
Expand All @@ -83,6 +84,7 @@ function watchPlayers(){
ctx.fillStyle = 'red';
ctx.textBaseline="middle";
ctx.textAlign="center";
ctx.save();
ctx.translate(canvas.width/2, canvas.height/2);
var num_of_players = Number(store.getItem("num_of_players"));
var angle = (2*Math.PI)/num_of_players;
Expand Down

0 comments on commit 03618d9

Please sign in to comment.