JavaScript Solitaire Game Type 2 ');
aboutWin.document.write('Version 1.1 ');
aboutWin.document.write('Written by Paul Schaper ');
aboutWin.document.write('July/Oct, 1998   ');
aboutWin.document.write('Home Page: http://ourworld.compuserve.com/homepages/schaper ');
aboutWin.document.write('Email: mailto:schaper@compuserve.com ');
aboutWin.document.write('
');
aboutWin.document.write('');
aboutWin.document.write('* Please let the entire card face load before you click again. ');
aboutWin.document.write('* To move a card to home, click the home pile and the first legal card will advance. ');
aboutWin.document.write('* Short cut: click empty column to fill. ');
aboutWin.document.write(
');
}
function popupCalc() {
var aboutWin = window.open('bcalc1.htm', 'popupCalc', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=389,height=257');
}
//
// Menu row
//
function menuItem(x) {
if (x==0) { transpose = (transpose + 1) % 52; shuffle(); return}
// if (x==0) { location.href = 'http://ourworld.compuserve.com/homepages/schaper/index.htm' }
if (x==1) { redraw = 1; return }
if (x==2) { aboutGame(); return }
if (x==3) { drawBoard(); return }
if (x==4) { ngame = 0; shuffle(); return }
if (x==5) { return }
if (x==6) { history.go(-1) }
}
//
// Main
//
function click(x,y) {
var i; var j; var k
//
// selected the draw pile
//
if (x < 4 && y < 1) { // draw a card
if (drawPile[0] == 0 && upPile[0] == 0) return // no cards left
removeArrow()
if (drawPile[0] == 0) //{ drawBoard() } // if draw pile empty...
if (redraw == 1){
while (upPile[0] > 0) // while cards left in up pile...
drawPile[++drawPile[0]] = upPile[upPile[0]--]//restart pile? yes but error
}
upPile[++upPile[0]] = drawPile[drawPile[0]--] // flip one or two cards
if (drawPile[0] > 0 && (upPile[0] % 2) == 1)
upPile[++upPile[0]] = drawPile[drawPile[0]--]
if ((upPile[0]%2) == 0)
cardDraw(topOf(upPile), 0, 2)
else
cardDraw(-1, 1, 2)
if (upPile[0] == 2) imageDraw(4,2,"cardbk3.gif")
if (drawPile[0] == 0) cardDraw(-3, 0, 0)
return
}
//
// selected the up card
//
if (x < 5 && y == 2) {
if (upPile[0] == 0) return
removeArrow()
addArrow(1,2)
return
}
//
// selected a home pile
//
if (x < 4 && y > 5) {
k = (y - 6) / 2 // k = homePile[]
if (arrow.z == 17) {
if (( (card.value[topOf(upPile)] == 1 && homePile[k] == 0) ||
(topOf(upPile) == homePile[k]+1) ) || (topOf(upPile) == homePile[k]+2) ) {
homePile[k] = upPile[upPile[0]--]
if ((upPile[0]%2) == 0) {
cardDraw(topOf(upPile), 0, 2)
if (upPile[0] == 0) imageDraw(4,2,"cardnull.gif") }
else {
if (upPile[0] == 1)
imageDraw(0,2,"cardnull.gif")
else {
j = upPile[upPile[0]-1]
imageDraw(0,2,"card"+card.value[j]+card.type[j]+"0.gif")
}
cardDraw(-1, 1, 2)
}
cardDraw(homePile[k], 0, y)
removeArrow()
return
}
}
if (arrow.z > 17) {
if ( (card.value[topOf(stack[arrow.y])] == 1 && homePile[k] == 0) ||
(topOf(stack[arrow.y]) == homePile[k]+1) ) {
homePile[k] = stack[arrow.y][stack[arrow.y][0]--]
if (stack[arrow.y][0] > 0)
cardDraw(topOf(stack[arrow.y]), stack[arrow.y][0]+5, arrow.y*2)
else
cardDraw(0, 5, arrow.y*2)
imageDraw(stack[arrow.y][0]+9, arrow.y*2, "cardnull.gif")
cardDraw(homePile[k], 0, y)
removeArrow()
return
}
}
if (( (card.value[topOf(upPile)] == 1 && homePile[k] == 0) ||
(topOf(upPile) == homePile[k]+1) ) && ((upPile[0]%2) == 0) ) {
homePile[k] = upPile[upPile[0]--]
if ((upPile[0]%2) == 0) {
cardDraw(topOf(upPile), 0, 2)
if (upPile[0] == 0) imageDraw(4,2,"cardnull.gif") }
else {
if (upPile[0] == 1)
imageDraw(0,2,"cardnull.gif")
else {
j = upPile[upPile[0]-1]
imageDraw(0,2,"card"+card.value[j]+card.type[j]+"0.gif")
}
cardDraw(-1, 1, 2)
}
cardDraw(homePile[k], 0, y)
removeArrow()
return
}
for (i=0;i<7;i++) {
if ( (card.value[topOf(stack[i])] == 1 && homePile[k] == 0) ||
(topOf(stack[i]) == homePile[k]+1) ) {
homePile[k] = stack[i][stack[i][0]--]
if (stack[i][0] > 0)
cardDraw(topOf(stack[i]), stack[i][0]+5, i*2)
else
if (buried[i][0] > 0)
cardDraw(-1, 5, i*2)
else
cardDraw(0, 5, i*2)
//insert
imageDraw(stack[i][0]+9, i*2, "cardnull.gif")
cardDraw(homePile[k], 0, y)
break
}
}
removeArrow()
return
}
//
// selected a gap
//
if (x < 5) return // no gaps allowed
//
// selected a stack
//
k = y / 2
//
// Attemt moving card from the upPile to a stack
//
if (arrow.z == 17) {
i = card.value[topOf(upPile)]
j = card.color[topOf(upPile)]
if ( (stack[k][0] == 0) ||
(i == card.value[topOf(stack[k])]-1 && j != card.color[topOf(stack[k])] && ((upPile[0]%2) == 0)) ) {
stack[k][++stack[k][0]] = upPile[upPile[0]--]
cardDraw(topOf(stack[k]), stack[k][0]+5, y)
if ((upPile[0]%2) == 0) {
cardDraw(topOf(upPile), 0, 2)
if (upPile[0] == 0) imageDraw(4,2,"cardnull.gif") }
else {
if (upPile[0] == 1)
imageDraw(0,2,"cardnull.gif")
else {
j = upPile[upPile[0]-1]
imageDraw(0,2,"card"+card.value[j]+card.type[j]+"0.gif")
}
cardDraw(-1, 1, 2)
}
removeArrow()
return
}
}
//
// Attemt moving one stack to another
//
if (arrow.z > 17) {
i = card.value[stack[arrow.y][1]]
j = card.color[stack[arrow.y][1]]
if ( (stack[k][0] == 0) ||
(i == card.value[topOf(stack[k])]-1 && j != card.color[topOf(stack[k])]) ) {
for (i=0;i
Holomind from Many Viewpoints
You can keep the same internal structure or holographic code, but transposes the cards up one. This emulates the holomind from a different viewpoint, Some views solve problems and others do not!
Transpose keeps the same shuffle, but transposes the cards up one. This emulates the holomind from a different viewpoint, Some views solve problems and others do not!
With Netscape 3, if Netscape ever resizes the screen, Netscape will clear all the cards off the board.
I added the redraw board button so that you can continue the game, but Netscape operates slowly.
When you finish the game, clicking Netscape's Reload button will start a new game and speed things up again.