<!doctype html>
<html>
<head>
<title>Pontoon or Draw Poker - RJM Programming - March, 2018</title>
<script type='text/javascript'>
var pots=[null];
var bids=[null];
var huh='', gnump=0, how='';
var carddealnum=location.search.split('carddealnum=')[1] ? eval(location.search.split('carddealnum=')[1].split('&')[0]) : 2;
var numplayers=location.search.split('numplayers=')[1] ? eval(location.search.split('numplayers=')[1].split('&')[0]) : 2;
var startwith=location.search.split('startwith=')[1] ? eval(location.search.split('startwith=')[1].split('&')[0]) : 0;
var theplayers=[], origtd='';
var ourpack, ourheap, anarray=[], aniarray=[];
var cardsinpack=['TwoOfHearts','TwoOfDiamonds','TwoOfSpades','TwoOfClubs','ThreeOfHearts','ThreeOfDiamonds','ThreeOfSpades','ThreeOfClubs','FourOfHearts','FourOfDiamonds','FourOfSpades','FourOfClubs','FiveOfHearts','FiveOfDiamonds','FiveOfSpades','FiveOfClubs','SixOfHearts','SixOfDiamonds','SixOfSpades','SixOfClubs','SevenOfHearts','SevenOfDiamonds','SevenOfSpades','SevenOfClubs','EightOfHearts','EightOfDiamonds','EightOfSpades','EightOfClubs','NineOfHearts','NineOfDiamonds','NineOfSpades','NineOfClubs','TenOfHearts','TenOfDiamonds','TenOfSpades','TenOfClubs','JackOfHearts','JackOfDiamonds','JackOfSpades','JackOfClubs','QueenOfHearts','QueenOfDiamonds','QueenOfSpades','QueenOfClubs','KingOfHearts','KingOfDiamonds','KingOfSpades','KingOfClubs','AceOfHearts','AceOfDiamonds','AceOfSpades','AceOfClubs'];
var mypictures = new Array("//www.rjmprogramming.com.au/images/02h.gif",
"//www.rjmprogramming.com.au/images/02d.gif",
"//www.rjmprogramming.com.au/images/02s.gif",
"//www.rjmprogramming.com.au/images/02c.gif",
"//www.rjmprogramming.com.au/images/03h.gif",
"//www.rjmprogramming.com.au/images/03d.gif",
"//www.rjmprogramming.com.au/images/03s.gif",
"//www.rjmprogramming.com.au/images/03c.gif",
"//www.rjmprogramming.com.au/images/04h.gif",
"//www.rjmprogramming.com.au/images/04d.gif",
"//www.rjmprogramming.com.au/images/04s.gif",
"//www.rjmprogramming.com.au/images/04c.gif",
"//www.rjmprogramming.com.au/images/05h.gif",
"//www.rjmprogramming.com.au/images/05d.gif",
"//www.rjmprogramming.com.au/images/05s.gif",
"//www.rjmprogramming.com.au/images/05c.gif",
"//www.rjmprogramming.com.au/images/06h.gif",
"//www.rjmprogramming.com.au/images/06d.gif",
"//www.rjmprogramming.com.au/images/06s.gif",
"//www.rjmprogramming.com.au/images/06c.gif",
"//www.rjmprogramming.com.au/images/07h.gif",
"//www.rjmprogramming.com.au/images/07d.gif",
"//www.rjmprogramming.com.au/images/07s.gif",
"//www.rjmprogramming.com.au/images/07c.gif",
"//www.rjmprogramming.com.au/images/08h.gif",
"//www.rjmprogramming.com.au/images/08d.gif",
"//www.rjmprogramming.com.au/images/08s.gif",
"//www.rjmprogramming.com.au/images/08c.gif",
"//www.rjmprogramming.com.au/images/09h.gif",
"//www.rjmprogramming.com.au/images/09d.gif",
"//www.rjmprogramming.com.au/images/09s.gif",
"//www.rjmprogramming.com.au/images/09c.gif",
"//www.rjmprogramming.com.au/images/10h.gif",
"//www.rjmprogramming.com.au/images/10d.gif",
"//www.rjmprogramming.com.au/images/10s.gif",
"//www.rjmprogramming.com.au/images/10c.gif",
"//www.rjmprogramming.com.au/images/11h.gif",
"//www.rjmprogramming.com.au/images/11d.gif",
"//www.rjmprogramming.com.au/images/11s.gif",
"//www.rjmprogramming.com.au/images/11c.gif",
"//www.rjmprogramming.com.au/images/12h.gif",
"//www.rjmprogramming.com.au/images/12d.gif",
"//www.rjmprogramming.com.au/images/12s.gif",
"//www.rjmprogramming.com.au/images/12c.gif",
"//www.rjmprogramming.com.au/images/13h.gif",
"//www.rjmprogramming.com.au/images/13d.gif",
"//www.rjmprogramming.com.au/images/13s.gif",
"//www.rjmprogramming.com.au/images/13c.gif",
"//www.rjmprogramming.com.au/images/01h.gif",
"//www.rjmprogramming.com.au/images/01d.gif",
"//www.rjmprogramming.com.au/images/01s.gif",
"//www.rjmprogramming.com.au/images/01c.gif"
);
function Pot(one) {
this.total=one;
this.GetTotal = function() {
return this.total;
};
this.SetTotal = function(towhat) {
this.total=towhat;
};
this.AddToTotal = function(what) {
this.total+=what;
};
}
function Bid(from, howmuch) {
this.howmuch = howmuch;
this.from = from;
this.CalculateTotal = function(thepot) {
var found=false, thetot=0;
if (thepot == null) {
if (bids[0] == null) {
return 0;
} else {
for (var iy=0; iy<bids.length; iy++) {
thetot+=bids[iy].GetBid();
}
return thetot;
}
} else {
return thepot.GetTotal();
}
thepot.SetTotal=tow;
};
this.GetBid = function() {
return this.howmuch;
};
this.SetPot = function(thepot, tow) {
var found=false;
if (thepot == null) {
try {
eval("found=(bids[0] instanceof Bid);");
} catch(eee) {
found=false;
}
if (!found) {
thepot=this.from;
}
}
thepot.SetTotal=tow;
};
this.AddToPot = function(thepot, wh) {
var found=false;
if (thepot == null) {
try {
eval("found=(bids[0] instanceof Bid);");
} catch(eee) {
found=false;
}
if (!found) {
thepot=this.from;
}
}
thepot.AddToTotal+=wh;
};
}
function Player(fullname) {
this.fullname = fullname;
this.num=theplayers.length;
this.score=0;
this.goes=0;
this.how='';
this.chosenottobid=false;
this.madebid=false;
this.cardtotal=0;
this.numtoreject=0;
this.cards = new Array();
this.Bid = function(thepot, what) {
var found=false;
if (thepot == null) {
try {
eval("found=(pots[0] instanceof Pot);");
} catch(eee) {
found=false;
}
if (!found) {
pots[0]=new Pot(what);
thepot=pots[0];
this.madebid=true;
}
} else {
this.madebid=true;
thepot.AddToTotal(what);
}
};
this.GetHow = function() {
return this.how;
};
this.SetAsNonBidder = function() {
this.chosenottobid = true;
};
this.SetAsBidder = function() {
this.madebid = true;
};
this.UnsetAsBidder = function() {
this.madebid = false;
this.chosenottobid = false;
};
this.AmBidder = function() {
return this.madebid;
};
this.AmNoBidder = function() {
return this.chosenottobid;
};
this.SetNoBidder = function() {
this.chosenottobid = true;
};
this.GetNumToReject = function() {
return this.numtoreject;
};
this.IncrementNumToReject = function() {
this.numtoreject++;
};
this.SetNumToReject = function(tor) {
this.numtoreject = tor;
};
this.SetTotal = function(theplayer, tow) {
var found=false;
if (thepot == null) {
try {
eval("found=(pots[0] instanceof Pot);");
} catch(eee) {
found=false;
}
if (!found) {
pots[0]=new Pot(tow);
thepot=pots[0];
}
} else {
thepot.SetTotal(tow);
}
};
this.SetFullname = function(fn) {
this.fullname = fn;
};
this.GetFullname = function() {
return this.fullname;
};
this.GetCardTotal = function() {
if (carddealnum == 5) { // Draw Poker
var five=[], fivec='', fived='', numdiff=0, pv=0;
//alert(document.getElementById('mydiv' + eval(1 + this.num)).innerHTML);
var isl=document.getElementById('mydiv' + eval(1 + this.num)).innerHTML.split('img ');
for (var jsl=1; jsl<isl.length; jsl++) {
if (isl[jsl].split('>')[0].indexOf('display:') == -1) {
five.push(isl[jsl].split('/images/')[1].split('.')[0]);
if (fived == '') {
numdiff++;
} else if (fivec.indexOf(isl[jsl].split('/images/')[1].split('.')[0].substring(0,2)) != -1) {
if (eval(fivec.indexOf(isl[jsl].split('/images/')[1].split('.')[0].substring(0,2).replace('01','14'))) > pv) pv=eval(fivec.indexOf(isl[jsl].split('/images/')[1].split('.')[0].substring(0,2).replace('01','14')));
} else {
numdiff++;
}
fivec+=fived + isl[jsl].split('/images/')[1].split('.')[0];
fived=',';
}
}
five.sort();
// Royal flush. A, K, Q, J, 10, all the same suit. ... 100000000
// Four of a kind. All four cards of the same rank. 10000000
// Full house. Three of a kind with a pair. 1000000
// Flush. Any five cards of the same suit, but not in a sequence. 100000
// Straight. ... 10000
// Three of a kind. ... 1000
// Two pair. ... 100
// Pair. 10
// Ace 1
this.cardtotal=0;
if (five.length == 5) {
var allthesamesuit=0, thoak=0, twoak=0, fh=0;
if ((',' + fivec + ',').split('h').length == 6) allthesamesuit=4;
if ((',' + fivec + ',').split('d').length == 6) allthesamesuit=3;
if ((',' + fivec + ',').split('c').length == 6) allthesamesuit=1;
if ((',' + fivec + ',').split('s').length == 6) allthesamesuit=2;
if (five[0].substring(0,2) == five[1].substring(0,2) && five[0].substring(0,2) == five[2].substring(0,2) && five[0].substring(0,2) != five[3].substring(0,2)) {
thoak=Math.floor(eval(eval(five[1].substring(0,2).replace('01','14')) / 1));
if (five[4].substring(0,2) == five[3].substring(0,2)) fh=Math.floor(eval(eval(five[1].substring(0,2)) / 2));
} else if (five[4].substring(0,2) != five[1].substring(0,2) && five[4].substring(0,2) == five[2].substring(0,2) && five[4].substring(0,2) == five[3].substring(0,2)) {
thoak=Math.floor(eval(eval(five[1].substring(0,2).replace('01','14')) / 1));
} else if (five[0].substring(0,2) != five[1].substring(0,2) && five[1].substring(0,2) == five[2].substring(0,2) && five[1].substring(0,2) == five[3].substring(0,2) && five[1].substring(0,2) != five[4].substring(0,2)) {
thoak=Math.floor(eval(eval(five[1].substring(0,2).replace('01','14')) / 1));
} else if (five[1].substring(0,2) != five[2].substring(0,2) && five[2].substring(0,2) == five[3].substring(0,2) && five[2].substring(0,2) == five[4].substring(0,2)) {
thoak=Math.floor(eval(eval(five[1].substring(0,2).replace('01','14')) / 1));
if (five[0].substring(0,2) == five[1].substring(0,2)) fh=Math.floor(eval(eval(five[3].substring(0,2)) / 2));
}
if (allthesamesuit != 0 && five[0].indexOf('01') != -1 && five[1].indexOf('10') != -1 && five[2].indexOf('11') != -1 && five[3].indexOf('12') != -1 && five[4].indexOf('13') != -1) {
this.cardtotal=eval(allthesamesuit * 100000000);
this.how=' for Royal Flush';
} else if (five[0].substring(0,2) == five[1].substring(0,2) && five[0].substring(0,2) == five[2].substring(0,2) && five[0].substring(0,2) == five[3].substring(0,2)) {
this.cardtotal=eval(1 * 10000000);
this.how=' for Four of a Kind';
} else if (five[4].substring(0,2) == five[1].substring(0,2) && five[4].substring(0,2) == five[2].substring(0,2) && five[4].substring(0,2) == five[3].substring(0,2)) {
this.cardtotal=eval(1 * 10000000);
this.how=' for Four of a Kind';
} else if (fh != 0) {
this.cardtotal=eval(fh * 1000000);
this.how=' for Full House';
} else if (allthesamesuit != 0) {
this.cardtotal=eval(allthesamesuit * 100000);
this.how=' for Flush';
} else if (numdiff == 5 && eval(eval(five[4].substring(0,2)) - eval(five[0].substring(0,2))) == 4) {
this.cardtotal=eval(Math.floor(eval(eval(five[4].substring(0,2)) / 2)) * 10000);
this.how=' for Straight';
} else if (numdiff == 5 && eval(eval(five[4].substring(0,2)) - eval(five[1].substring(0,2))) == 3 && eval(eval(five[4].substring(0,2)) - eval(five[0].substring(0,2))) == 12) {
this.cardtotal=eval(7 * 10000);
this.how=' for Straight';
} else if (thoak != 0) {
this.cardtotal=eval(thoak * 500);
this.how=' for Three of a Kind';
} else if (numdiff == 3) {
this.cardtotal=eval(Math.floor(eval(eval(five[4].substring(0,2)) / 2)) * 100);
this.how=' for Two Pairs';
} else if (numdiff == 4) {
this.cardtotal=eval(eval(pv) * 5);
this.how=' for Pair';
} else if (five[0].substring(0,2) == '01') {
this.cardtotal=7;
this.how='';
} else {
this.cardtotal=eval(Math.floor(eval(eval(five[4].substring(0,2)) / 2)) * 1);
this.how='';
}
}
} else {
this.how=' for ' + this.cardtotal;
}
return this.cardtotal;
};
this.SetScore = function(addthis) {
if (addthis != 0) {
var found=false;
if (pots[0] == null) {
try {
eval("found=(bids[0] instanceof Bid);");
} catch(eee) {
found=false;
}
if (found) {
addthis=bids[0].CalculateTotal(pots[0]);
}
} else {
addthis=pots[0].GetTotal();
}
}
this.score+=addthis;
};
this.SetGoes = function(addthis) {
this.goes+=addthis;
document.getElementById('score' + eval(1 + this.num)).innerHTML='Score: ' + this.score + '/' + this.goes;
};
this.SetCardTotal = function(addthis) {
//if (eval('' + addthis) == 0) alert(this.cardtotal);
this.cardtotal+=addthis;
};
this.Reset = function(aheap) {
for (var ju=0; ju<this.cards.length; ju++) {
aheap.Addone(this.cards[ju]);
}
pots=[null];
bids=[null];
this.how='';
this.cardtotal=0;
this.numtoreject=0;
this.cards = new Array();
document.getElementById('td' + eval(1 + this.num)).innerHTML=origtd.replace(/1/g,'' + eval(1 + this.num));
};
}
function Heap() {
this.cardat = 0;
this.cardpile = new Array();
this.Addone = function(onecard) {
this.cardpile.push(onecard);
};
this.Redeal = function(playerarr, numperplayer, apack) {
//for (var ju=0; ju<playerarr.length; ju++) {
// playerarr[ju].Reset(ourheap);
//}
var startat=0;
var howmany=this.cardpile.length;
if (numperplayer > 0) howmany=eval(this.cardat + playerarr.length * numperplayer);
for (var iu=this.cardat; iu<howmany; iu++) {
playerarr[startat].cards.push(this.cardpile[iu]);
playerarr[startat].SetCardTotal(playerarr[startat].cards[eval(-1 + playerarr[startat].cards.length)].ScorePontoon(playerarr[startat].GetCardTotal()));
if (carddealnum == 5) { // Draw Poker
document.getElementById('mydiv' + eval(1 + startat)).innerHTML+='<img onclick="this.style.border=' + "'" + '2px solid red' + "'; intr(" + eval(1 + startat) + ');" style=visibility:hidden; id=i_' + eval(1 + startat) + '_' + Math.floor(Math.random() * 123456) + ' src=' + apack.GetNameImageUrl(this.cardpile[iu].GetName()) + '></img>';
} else { // Pontoon
document.getElementById('mydiv' + eval(1 + startat)).innerHTML+='<img style=visibility:hidden; id=i_' + eval(1 + startat) + '_' + Math.floor(Math.random() * 123456) + ' src=' + apack.GetNameImageUrl(this.cardpile[iu].GetName()) + '></img>';
}
startat++;
if (startat >= playerarr.length) startat=0;
}
this.cardat=howmany;
};
this.Another = function(apack,playerarr,playernum) {
if (carddealnum == 5) { // Draw Poker
for (var it=0; it<playerarr[playernum].GetNumToReject(); it++) {
playerarr[playernum].cards.push(this.cardpile[this.cardat]);
//playerarr[playernum].SetCardTotal(playerarr[playernum].cards[eval(-1 + playerarr[playernum].cards.length)].ScorePontoon(playerarr[playernum].GetCardTotal()));
document.getElementById('mydiv' + eval(1 + playernum)).innerHTML+='<img id=i_' + eval(1 + playernum) + '_' + Math.floor(Math.random() * 123456) + ' src=' + apack.GetNameImageUrl(this.cardpile[this.cardat].GetName()) + '></img>';
this.cardat++;
}
} else { // Pontoon
playerarr[playernum].cards.push(this.cardpile[this.cardat]);
playerarr[playernum].SetCardTotal(playerarr[playernum].cards[eval(-1 + playerarr[playernum].cards.length)].ScorePontoon(playerarr[playernum].GetCardTotal()));
document.getElementById('mydiv' + eval(1 + playernum)).innerHTML+='<img id=i_' + eval(1 + playernum) + '_' + Math.floor(Math.random() * 123456) + ' src=' + apack.GetNameImageUrl(this.cardpile[this.cardat].GetName()) + '></img>';
this.cardat++;
}
};
}
function Pack(names, imageurls, shuffle, startwith) {
if (names.length == 0) {
if (shuffle) {
var sofar=',', ii;
var choice=Math.floor(Math.random() * cardsinpack.length);
var firstchoice=choice;
for (ii=0; ii<cardsinpack.length; ii++) {
while (sofar.indexOf(',' + cardsinpack[choice] + ',') != -1) {
choice=Math.floor(Math.random() * cardsinpack.length);
}
eval("names.push(new " + cardsinpack[choice] + "('" + cardsinpack[choice] + "'));");
imageurls.push(mypictures[choice]);
sofar+=(cardsinpack[choice] + ',');
choice=firstchoice;
}
} else {
for (ii=0; ii<cardsinpack.length; ii++) {
eval("names.push(new " + cardsinpack[ii] + "('" + cardsinpack[ii] + "'));");
imageurls.push(mypictures[ii]);
}
}
}
this.names = names;
this.imageurls = imageurls;
this.startwith = startwith;
this.GetNameImageUrl = function(acardname) {
for (var ip=0; ip<this.names.length; ip++) {
if (acardname == this.names[ip].GetName()) return this.imageurls[ip];
}
return '';
};
this.Deal = function(playerarr, numperplayer) {
var startat=0;
var howmany=this.names.length;
if (numperplayer > 0) howmany=eval(playerarr.length * numperplayer);
for (var iu=0; iu<howmany; iu++) {
playerarr[startat].cards.push(this.names[iu]);
playerarr[startat].SetCardTotal(playerarr[startat].cards[eval(-1 + playerarr[startat].cards.length)].ScorePontoon(playerarr[startat].GetCardTotal()));
if (carddealnum == 5) { // Draw Poker
document.getElementById('mydiv' + eval(1 + startat)).innerHTML+='<img onclick="this.style.border=' + "'" + '2px solid red' + "'; intr(" + eval(1 + startat) + ');" style=visibility:hidden; id=i_' + eval(1 + startat) + '_' + iu + ' src=' + this.imageurls[iu] + '></img>';
} else { // Pontoon
document.getElementById('mydiv' + eval(1 + startat)).innerHTML+='<img style=visibility:hidden; id=i_' + eval(1 + startat) + '_' + iu + ' src=' + this.imageurls[iu] + '></img>';
}
startat++;
if (startat >= playerarr.length) startat=0;
}
for (var iiu=howmany; iiu<this.names.length; iiu++) {
ourheap.Addone(this.names[iiu]);
}
};
}
function intr(uwho) {
theplayers[eval(-1 + uwho)].IncrementNumToReject();
document.getElementById('im' + uwho).style.visibility='visible';
}
function Card(name) {
this.name = name;
this.GetName = function() {
return this.name;
};
this.ScorePontoon = function(scoresofar) {
if (this.name.toLowerCase().indexOf('ace') != -1 && scoresofar > 10) {
return 1;
} else if (this.name.toLowerCase().indexOf('ace') != -1) {
return 11;
} else if (this.name.toLowerCase().indexOf('king') != -1) {
return 10;
} else if (this.name.toLowerCase().indexOf('queen') != -1) {
return 10;
} else if (this.name.toLowerCase().indexOf('jack') != -1) {
return 10;
} else if (this.name.toLowerCase().indexOf('ten') != -1) {
return 10;
} else if (this.name.toLowerCase().indexOf('nine') != -1) {
return 9;
} else if (this.name.toLowerCase().indexOf('eight') != -1) {
return 8;
} else if (this.name.toLowerCase().indexOf('seven') != -1) {
return 7;
} else if (this.name.toLowerCase().indexOf('six') != -1) {
return 6;
} else if (this.name.toLowerCase().indexOf('five') != -1) {
return 5;
} else if (this.name.toLowerCase().indexOf('four') != -1) {
return 4;
} else if (this.name.toLowerCase().indexOf('three') != -1) {
return 3;
} else if (this.name.toLowerCase().indexOf('two') != -1) {
return 2;
}
};
this.IsPicture = function() {
if (this.name.toLowerCase().indexOf('ace') != -1) {
return 4;
} else if (this.name.toLowerCase().indexOf('king') != -1) {
return 3;
} else if (this.name.toLowerCase().indexOf('queen') != -1) {
return 2;
} else if (this.name.toLowerCase().indexOf('jack') != -1) {
return 1;
}
return 0;
};
this.IsBlack = function() {
if (this.name.toLowerCase().replace('spades','clubs').indexOf('clubs') != -1) {
return true;
}
return false;
};
this.IsRed = function() {
if (this.name.toLowerCase().replace('hearts','diamonds').indexOf('diamonds') != -1) {
return true;
}
return false;
};
}
function TwoOfHearts(name) {
Card.call(this, name);
}
function TwoOfDiamonds(name) {
Card.call(this, name);
}
function TwoOfSpades(name) {
Card.call(this, name);
}
function TwoOfClubs(name) {
Card.call(this, name);
}
function ThreeOfHearts(name) {
Card.call(this, name);
}
function ThreeOfDiamonds(name) {
Card.call(this, name);
}
function ThreeOfSpades(name) {
Card.call(this, name);
}
function ThreeOfClubs(name) {
Card.call(this, name);
}
function FourOfHearts(name) {
Card.call(this, name);
}
function FourOfDiamonds(name) {
Card.call(this, name);
}
function FourOfSpades(name) {
Card.call(this, name);
}
function FourOfClubs(name) {
Card.call(this, name);
}
function FiveOfHearts(name) {
Card.call(this, name);
}
function FiveOfDiamonds(name) {
Card.call(this, name);
}
function FiveOfSpades(name) {
Card.call(this, name);
}
function FiveOfClubs(name) {
Card.call(this, name);
}
function SixOfHearts(name) {
Card.call(this, name);
}
function SixOfDiamonds(name) {
Card.call(this, name);
}
function SixOfSpades(name) {
Card.call(this, name);
}
function SixOfClubs(name) {
Card.call(this, name);
}
function SevenOfHearts(name) {
Card.call(this, name);
}
function SevenOfDiamonds(name) {
Card.call(this, name);
}
function SevenOfSpades(name) {
Card.call(this, name);
}
function SevenOfClubs(name) {
Card.call(this, name);
}
function EightOfHearts(name) {
Card.call(this, name);
}
function EightOfDiamonds(name) {
Card.call(this, name);
}
function EightOfSpades(name) {
Card.call(this, name);
}
function EightOfClubs(name) {
Card.call(this, name);
}
function NineOfHearts(name) {
Card.call(this, name);
}
function NineOfDiamonds(name) {
Card.call(this, name);
}
function NineOfSpades(name) {
Card.call(this, name);
}
function NineOfClubs(name) {
Card.call(this, name);
}
function TenOfHearts(name) {
Card.call(this, name);
}
function TenOfDiamonds(name) {
Card.call(this, name);
}
function TenOfSpades(name) {
Card.call(this, name);
}
function TenOfClubs(name) {
Card.call(this, name);
}
function JackOfHearts(name) {
Card.call(this, name);
}
function JackOfDiamonds(name) {
Card.call(this, name);
}
function JackOfSpades(name) {
Card.call(this, name);
}
function JackOfClubs(name) {
Card.call(this, name);
}
function QueenOfHearts(name) {
Card.call(this, name);
}
function QueenOfDiamonds(name) {
Card.call(this, name);
}
function QueenOfSpades(name) {
Card.call(this, name);
}
function QueenOfClubs(name) {
Card.call(this, name);
}
function KingOfHearts(name) {
Card.call(this, name);
}
function KingOfDiamonds(name) {
Card.call(this, name);
}
function KingOfSpades(name) {
Card.call(this, name);
}
function KingOfClubs(name) {
Card.call(this, name);
}
function AceOfHearts(name) {
Card.call(this, name);
}
function AceOfDiamonds(name) {
Card.call(this, name);
}
function AceOfSpades(name) {
Card.call(this, name);
}
function AceOfClubs(name) {
Card.call(this, name);
}
function ol() {
if (carddealnum == 5) {
document.getElementById('myh1').innerHTML=document.getElementById('myh1').innerHTML.replace('Pontoon','Draw Poker');
document.getElementById('mynums').value='-' + numplayers;
document.getElementById('div1').innerHTML=document.getElementById('div1').innerHTML.replace('Reveal Cards,','Reveal Cards (rejectable via click),');
document.getElementById('div2').innerHTML=document.getElementById('div2').innerHTML.replace('Reveal Cards,','Reveal Cards (rejectable via click),');
} else {
document.getElementById('mynums').value='' + numplayers;
}
var startat=0, found=true;
var origth=document.getElementById('th1').innerHTML;
origtd=document.getElementById('td1').innerHTML;
for (var iii=1; iii<=numplayers; iii++) {
if (iii > 2) {
document.getElementById('tr1').innerHTML+='<th style=display:inline-cell;>' + origth.replace(/1/g,'' + iii) + '</th>';
document.getElementById('tr2').innerHTML+='<td style=display:inline-cell; id=td' + iii + '>' + origtd.replace(/1/g,'' + iii) + '</td>';
}
theplayers.push(new Player('Player' + iii));
}
ourpack=new Pack(anarray,aniarray,true,startwith);
ourheap=new Heap();
ourpack.Deal(theplayers,carddealnum); // for pontoon vs 0);
for (var iiii=0; iiii<numplayers; iiii++) {
theplayers[iiii].SetCardTotal(0);
}
}
function bidfor(nump, islast) {
var hm=null,ca, iiii;
if (!islast) {
if (pots[0] == null) {
hm=prompt(theplayers[eval(0 + nump)].GetFullname() + ", what's your bid?", "1");
} else if ("we_like_verb_bid" == "we_like_verb_bid" || 1 == 1) {
if (theplayers[eval(0 + nump)].AmBidder() == false && theplayers[eval(0 + nump)].AmNoBidder() == false) {
ca=confirm(theplayers[eval(0 + nump)].GetFullname() + ", do you agree to see the earlier bid of " + eval(pots[0].GetTotal() / numplayers) + "?");
if (ca == true) {
theplayers[eval(0 + nump)].SetAsBidder();
} else {
theplayers[eval(0 + nump)].SetAsNonBidder();
}
}
}
} else if ("we_like_verb_bid" == "we_like_verb_bid" || 1 == 1) {
if (pots[0]) {
var ims=document.getElementsByTagName('img');
for (var ifw=0; ifw<ims.length; ifw++) {
ims[ifw].style.visibility='hidden';
}
for (iiii=0; iiii<numplayers; iiii++) {
if (theplayers[iiii].AmBidder() == false && theplayers[iiii].AmNoBidder() == false) {
ca=confirm(theplayers[iiii].GetFullname() + ", do you agree to see the earlier bid of " + eval(pots[0].GetTotal() / numplayers) + "?");
if (ca == true) {
theplayers[iiii].SetAsBidder();
} else {
theplayers[iiii].SetAsNonBidder();
}
}
}
}
}
if (hm != null) {
if ("we_like_verb_bid" == "we_like_verb_bid") { // Player "verb" bidding approach
theplayers[eval(0 + nump)].Bid(pots[0], eval(eval('' + hm) * numplayers));
theplayers[eval(0 + nump)].SetAsBidder();
//alert('' + nump + ' is ' + theplayers[nump].AmBidder());
} else { // Bid "noun" bidding approach
if (bids.length == 1) {
if (bids[0] == null) {
bids[0] = new Bid(theplayers[eval(0 + nump)].GetFullname(), eval('' + hm));
} else {
bids[0] = new Bid(theplayers[eval(0 + nump)].GetFullname(), eval('' + hm));
}
theplayers[eval(0 + nump)].SetAsBidder();
} else {
bids.push(new Bid(theplayers[eval(0 + nump)].GetFullname(), eval('' + hm)));
theplayers[eval(0 + nump)].SetAsBidder();
}
if (!pots[0]) pots[0] = new Pot(eval(eval('' + hm) * numplayers));
}
}
}
function lockedin(nump) {
gnump=nump;
if (document.getElementById('tinstructions').innerHTML.indexOf(theplayers[nump].GetFullname() + ' is locked in.') == -1) {
document.getElementById('tinstructions').innerHTML+=theplayers[nump].GetFullname() + ' is locked in.';
document.getElementById('mydiv' + eval(1 + nump)).style.display='none';
if (document.getElementById('tinstructions').innerHTML.split('<br>').length < numplayers) {
document.getElementById('tinstructions').innerHTML+='<br>';
} else {
var ims=document.getElementsByTagName('img');
for (ifw=0; ifw<ims.length; ifw++) {
ims[ifw].style.visibility='hidden';
}
setTimeout(postlockedin,500);
}
}
}
function postlockedin() {
var nump=gnump;
var ifw;
var ims=document.getElementsByTagName('img');
for (ifw=0; ifw<ims.length; ifw++) {
ims[ifw].style.visibility='hidden';
}
bidfor(nump,true);
for (ifw=0; ifw<ims.length; ifw++) {
ims[ifw].style.visibility='visible';
}
huh='No winners on this round.', huhd='';
var winner=-1, winningscore=-1;
for (var iiii=0; iiii<numplayers; iiii++) {
document.getElementById('mydiv' + eval(1 + iiii)).style.display='block';
if (theplayers[iiii].GetCardTotal() > 21) {
theplayers[iiii].SetCardTotal(-999);
}
}
for (var iii=0; iii<numplayers; iii++) {
if (theplayers[iii].GetCardTotal() >= winningscore) {
huh='Congratulations' + theplayers[iii].GetHow() + ' to';
winningscore=theplayers[iii].GetCardTotal();
}
}
for (var ii=0; ii<numplayers; ii++) {
if (theplayers[ii].GetCardTotal() == winningscore) {
if (theplayers[ii].AmBidder() == true || !pots[0]) {
huh+=huhd + ' ' + theplayers[ii].GetFullname();
huhd=',';
theplayers[ii].SetScore(1);
} else {
huh+=huhd + ' ' + theplayers[ii].GetFullname() + " (except that you did not join the bidding)";
huhd=',';
theplayers[ii].SetScore(0);
}
}
}
for (var i=0; i<numplayers; i++) {
theplayers[i].SetGoes(1);
}
if (1 == 1) {
setTimeout(andthen,2000);
} else {
alert(huh);
for (var i=0; i<numplayers; i++) {
theplayers[i].Reset(ourheap);
}
document.getElementById('tinstructions').innerHTML='';
ourheap.Redeal(theplayers,carddealnum,ourpack); // for pontoon vs 0);
}
}
function andprethen() {
var nump=gnump;
}
function andthen() {
var nump=gnump;
alert(huh);
for (var i=0; i<numplayers; i++) {
theplayers[i].Reset(ourheap);
theplayers[i].UnsetAsBidder();
}
document.getElementById('tinstructions').innerHTML='';
ourheap.Redeal(theplayers,carddealnum,ourpack); // for pontoon vs 0);
}
function reveal(iwhat) {
var cfw=iwhat.id.replace('ib','');
var ifw,fw='i_' + iwhat.id.replace('ib','') + '_';
var ims=document.getElementsByTagName('img');
if (iwhat.value.indexOf('Reveal') != -1) {
for (ifw=0; ifw<ims.length; ifw++) {
if (ims[ifw].id.indexOf(fw) != -1) ims[ifw].style.visibility='visible';
}
if (carddealnum == 5) { // Draw Poker
document.getElementById('div' + iwhat.id.replace('ib','')).innerHTML+='<input id=im' + iwhat.id.replace('ib','') + ' onclick="hidethese(' + iwhat.id.replace('ib','') + ',this); ourheap.Another(ourpack,theplayers,' + eval(-1 + eval(iwhat.id.replace('ib',''))) + ');" value=Minus type=button style=background-color:yellow;visibility:hidden;></input> <input onclick=bidfor(' + eval(-1 + eval(iwhat.id.replace('ib',''))) + ',false); value=Bid type=button style=background-color:yellow;></input> <input onclick=lockedin(' + eval(-1 + eval(iwhat.id.replace('ib',''))) + '); value=Finished type=button style=background-color:yellow;></input>';
} else { // Pontoon
document.getElementById('div' + iwhat.id.replace('ib','')).innerHTML+='<input onclick=ourheap.Another(ourpack,theplayers,' + eval(-1 + eval(iwhat.id.replace('ib',''))) + '); value=Add type=button style=background-color:yellow;></input> <input onclick=bidfor(' + eval(-1 + eval(iwhat.id.replace('ib',''))) + ',false); value=Bid type=button style=background-color:yellow;></input> <input onclick=lockedin(' + eval(-1 + eval(iwhat.id.replace('ib',''))) + '); value=Finished type=button style=background-color:yellow;></input>';
}
document.getElementById('ib' + cfw).value=document.getElementById('ib' + cfw).value.replace('Reveal','Hide');
//alert(document.getElementById('ib' + cfw).value);
} else {
for (ifw=0; ifw<ims.length; ifw++) {
if (ims[ifw].id.indexOf(fw) != -1) ims[ifw].style.visibility='hidden';
}
iwhat.value=iwhat.value.replace('Hide','Reveal');
}
}
function hidethese(ibv,ibo) {
document.getElementById('mydiv' + ibv).innerHTML=document.getElementById('mydiv' + ibv).innerHTML.replace(/border\:/g,'display:none;border:');
ibo.style.display='none';
}
function changen(od) {
var cfw=od.id.replace('dname','');
theplayers[eval(-1 + eval('' + cfw))].SetFullname(od.innerHTML);
}
</script>
</head>
<body onload="ol();">
<h1 id=myh1>Pontoon Card Game <select id=mynums onchange=" if (this.value < 0) { location.href=document.URL.split('#')[0].split('?')[0] + '?carddealnum=5&numplayers=' + this.value.replace('-',''); } else { location.href=document.URL.split('#')[0].split('?')[0] + '?carddealnum=2&numplayers=' + this.value; }"><option value=2>for 2 (Pontoon)</option><option value=-2>for 2 (Draw Poker)</option><option value=3>for 3 (Pontoon)</option><option value=-3>for 3 (Draw Poker)</option><option value=4>for 4 (Pontoon)</option><option value=-4>for 4 (Draw Poker)</option><option value=5>for 5 (Pontoon)</option><option value=-5>for 5 (Draw Poker)</option><option value=6>for 6 (Pontoon)</option><option value=-6>for 6 (Draw Poker)</option><option value=7>for 7 (Pontoon)</option><option value=-7>for 7 (Draw Poker)</option><option value=8>for 8 (Pontoon)</option><option value=-8>for 8 (Draw Poker)</option><option value=9>for 9 (Pontoon)</option><option value=-9>for 9 (Draw Poker)</option></select></h1>
<h3>RJM Programming - March, 2018</h3><br>
<table id=mytable style='width:100%' border=50>
<tbody id=mytbody>
<tr id=tr1><th id=th1><div onblur=changen(this); id=dname1 contenteditable=true>Player1</div> <div id=score1>Score: 0/0</div></th><th>Information</th><th><div onblur=changen(this); id=dname2 contenteditable=true>Player2</div> <div id=score2>Score: 0/0</div></th></tr>
<tr id=tr2><td id=td1>
<div id=div1><input type=button onclick=reveal(this); id=ib1 value='Reveal Cards, out of view' style=background-color:yellow;></input></div>
<div id='mydiv1' style='float:left;'></div>
</td><td id=tinstructions></td><td id=td2>
<div id=div2><input type=button onclick=reveal(this); id=ib2 value='Reveal Cards, out of view' style=background-color:yellow;></input></div>
<div id='mydiv2' style='float:left;'></div>
</td></tr>
</tbody>
</table>
</body>
</html>