")
return true
}
function msg(s)
{
document.msgbox.src = s
}
function errmsg(s)
{
document.errbox.src = s
}
function help()
{
window.open("smhelp.htm", "Instructions")
}
function musicon()
{
if (wantsmus)
{
musicwnd = window.open("smmusic.htm", "Music",
"location=no,top=5000,left=0,resizable=no,width=10,height=10,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no")
musicbox.src="musicoff.gif"
}
}
function musicoff()
{
if (musicwnd != 0)
{
musicwnd.close()
musicwnd = 0
musicbox.src="musicon.gif"
}
}
function toggle()
{
if (wantsmus = (musicwnd == 0))
musicon()
else
musicoff()
}
function putnum(n, t, u)
{
if (n < 10)
{
t.src = ns[n]
u.src = "blank.gif"
} else
{
t.src = ns[Math.floor(n/10)]
u.src = ns[n % 10]
}
}
function pts(n, b)
{
putnum(n, b[0], b[1])
}
function nextround()
{
if (paused)
if (round > 15)
if (mypts > opppts)
gameover("win1.gif", "win2.gif", "win3.gif")
else if (mypts < opppts)
gameover("lose1.gif", "lose2.gif", "lose3.gif")
else
gameover("draw1.gif", "draw2.gif", "draw3.gif")
else
{
putnum(round+1, mssnt, mssnu)
opp1.src = targets[rnd(targets.length)]
opp2.src = locs[rnd(locs.length)]
putnum(secrets[round], missiont, missionu)
mysel.src = oppsel.src = "blank.gif"
errmsg("blank.gif")
msg("selspy.gif")
paused = false
}
else
errmsg("nopause.gif")
}
function opp(n)
{
if (paused)
nextround()
else
if (oppnum >= 0)
errmsg("nopause.gif")
else
{
for (var i=0; i < 5; ++i)
oppbox[i].src = "blank.gif"
oppnum = n
myname.src = "name.gif"
namebox.src = oppname[n]
mssnbox.src = "mission.gif"
for (var i=0; i < 16; ++i)
hnum[i].src = anum[i].src = spy[i]
opp4.src = "rating.gif"
myscr.src = oppscr.src = "score.gif"
myt.src = oppt.src = ns[0]
paused = true
nextround()
}
}
function aimhi(t)
{
for (var i=t; i < 16; ++i)
if (oppspies[i]) return i
return -1
}
function aimlo(t)
{
for (var i=0; i < t; ++i)
if (oppspies[i]) return i
return 16
}
function aim(t)
{
if (t > 15) t = rnd(2)*15
if (oppspies[t])
return t
else
if (t > 6)
{
var x = aimhi(t)
return x > t ? x : aimlo(t)
} else
{
var y = aimlo(t)
return y < t ? y : aimhi(t)
}
}
function mx(l, h)
{
var r = -1
var m = l
if (h > 15) h = 15
for (var i=l; i <= h; ++i)
if (myspies[i])
m = i
for (var i=m; i <= h; ++i)
if (oppspies[i])
{
r = i
break
}
return r
}
function chuck()
{
for (var i=rnd(4)+1; i < 16; ++i)
if (oppspies[i])
return i
for (var i=1; i < 5; ++i)
if (oppspies[i])
return i
return 0
}
function pick(n)
{
if (paused)
nextround()
else
if (oppnum < 0)
errmsg("notopp.gif")
else
if (n < 0)
errmsg("nopick.gif")
else
if (myspies[n])
{
var e
var p = secrets[round]
myspies[n] = false
hnum[n].src = "blank.gif"
switch (oppnum)
{
case 0:
e = aim(rnd(16))
break
case 1:
e = aim(p+1+rnd(2))
break
case 2:
e = aim(p+1+rnd(4))
break
case 3:
e = aim(p+diff+1)
if (n >= p) diff = n-p
break
case 4:
if (p < 5)
{
e = mx(p, p+4)
if (e < 0) e = chuck()
} else
if (p < 9)
{
e = mx(p, p+3)
if (e < 0) e = aim(p+1+rnd(3))
} else
if (p < 13)
{
e = mx(p, p+2)
if (e < 0)
e = (oppspies[0] && rnd(2) == 0) ? 0 : aim(p+1+rnd(2))
} else
{
e = mx(13, 15)
if (e < 0)
e = (oppspies[0] && rnd(2) == 0) ? 0 : aim(p+rnd(17-p))
if (e > 13 && myspies[0] && rnd(2) == 0)
e = chuck()
else
if (e > 13 && rnd(3) == 0)
e = aim(5+rnd(3))
}
e = aim(p+diff+1)
if (n >= p) diff = n-p
break
}
myspies[n] = false
hnum[n].src = "blank.gif"
oppspies[e] = false
anum[e].src = "blank.gif"
errmsg("blank.gif")
mysel.src = spy[n]
oppsel.src = spy[e]
if (n == 0)
if (e == 0)
errmsg("draw.gif")
else
{
errmsg("success.gif")
mypts += e
pts(mypts, myscore)
}
else
if (e == 0)
{
errmsg("failure.gif")
opppts += n
pts(opppts, oppscore)
} else
if (n > e)
{
errmsg("success.gif")
mypts += p
pts(mypts, myscore)
} else
if (e > n)
{
errmsg("failure.gif")
opppts += p
pts(opppts, oppscore)
} else
errmsg("draw.gif")
paused = true
++round
msg("cont.gif")
} else
errmsg("used.gif")
}
// -->
