/* -- Hospital Millions -------------------------------------------- A board game devised by John Lister for publication in Health Emergency the newspaper of London Health Emergency http://www.healthemergency.org.uk Developed for interactive application by Paul Lister, January 2013 For free distribution only (c) 2013 London Health Emergency & Paul Lister Any errors are mistakes ------------------------------------------------------------------ */ var want_sounds=false; var iterations=30; var steps=30; var msteps=0; var n_players=4; var cleartm=0; var dietm=0; var delay=0; var whothrew=''; ordered=1; var boingsound; var clicksound; var rollsound; var fsound; var fshortsound; var popsound; var plopsound; var ohsound; var oohsound; var gunshot; var ding; var usercolour=['Red','Green','Cyan','Magenta']; var on_player=0; var player= [ {colour:'Red', username:'Fred', tileid:'tile1', on_square:0, balance:1500, aecount:0, threw:0}, {colour:'Green', username:'Bert', tileid:'tile2', on_square:0, balance:1500, aecount:0, threw:0}, {colour:'Cyan', username:'Mavis', tileid:'tile3', on_square:0, balance:1500, aecount:0, threw:0}, {colour:'Magenta', username:'Edna', tileid:'tile4', on_square:0, balance:1500, aecount:0, threw:0} ]; // width,height,x,y,direction,opcode,cost,fee,throws,contract owner,contracts,function,name var squares=[ {w:272, h:260, x:201, y: 1, dir:"R", opcode:"n", cost: 0, fee: 0, throws:0, owner:-1, contracts:0, func:'collect', name:'New Financial Year'}, {w:210, h:260, x:338, y: 1, dir:"r", opcode:"c", cost: 500, fee:100, throws:1, owner:-1, contracts:0, func:'priceythrow', name:'Pricey Water Closet'}, {w:142, h:260, x:444, y: 1, dir:"r", opcode:"c", cost: 200, fee: 40, throws:0, owner:-1, contracts:0, func:'', name:'Pathology Services'}, {w:144, h:260, x:516, y: 1, dir:"r", opcode:"c", cost: 200, fee: 40, throws:0, owner:-1, contracts:0, func:'', name:'Back Office and Call Centres'}, {w:176, h:260, x:589, y: 1, dir:"r", opcode:"p", cost:1000, fee:200, throws:2, owner:-1, contracts:0, func:'PFIthrow', name:'PFI (1)'}, {w:144, h:260, x:678, y: 1, dir:"r", opcode:"c", cost: 200, fee: 60, throws:0, owner:-1, contracts:0, func:'', name:'Cleaning Services'}, {w:144, h:260, x:751, y: 1, dir:"r", opcode:"c", cost: 500, fee:100, throws:0, owner:-1, contracts:0, func:'', name:'Community Health Services'}, {w:142, h:260, x:824, y: 1, dir:"r", opcode:"t", cost: 0, fee: 0, throws:1, owner:-1, contracts:0, func:'do_triage', name:'Triage (1)'}, {w:144, h:260, x:896, y: 1, dir:"r", opcode:"c", cost: 100, fee: 10, throws:0, owner:-1, contracts:0, func:'', name:'GP Out of Hours Services'}, {w:272, h:260, x:969, y: 1, dir:"D", opcode:"s", cost: 0, fee: 0, throws:1, owner:-1, contracts:0, func:'monitorthrow', name:'Monitor'}, {w:272, h:150, x:969, y:132, dir:"d", opcode:"c", cost: 250, fee: 50, throws:0, owner:-1, contracts:0, func:'', name:'Private Clinic'}, {w:272, h:150, x:969, y:208, dir:"d", opcode:"C", cost: 0, fee: 0, throws:1, owner:-1, contracts:0, func:'do_community', name:'Community Care (1)'}, {w:272, h:170, x:969, y:284, dir:"d", opcode:"p", cost:1000, fee:200, throws:2, owner:-1, contracts:0, func:'PFIthrow', name:'PFI (2)'}, {w:272, h:150, x:969, y:370, dir:"d", opcode:"c", cost: 150, fee: 30, throws:0, owner:-1, contracts:0, func:'', name:'Commissioning Support Services'}, {w:272, h:150, x:969, y:446, dir:"d", opcode:"c", cost: 200, fee: 40, throws:0, owner:-1, contracts:0, func:'', name:'Physiotherapy Services'}, {w:272, h:260, x:969, y:522, dir:"L", opcode:"d", cost: 0, fee: 0, throws:2, owner:-1, contracts:0, func:'', name:'A & E'}, {w:144, h:260, x:896, y:522, dir:"l", opcode:"c", cost: 300, fee: 60, throws:0, owner:-1, contracts:0, func:'', name:'Primary Care'}, {w:142, h:260, x:824, y:522, dir:"l", opcode:"t", cost: 0, fee: 0, throws:1, owner:-1, contracts:0, func:'do_triage', name:'Triage (2)'}, {w:148, h:260, x:749, y:522, dir:"l", opcode:"c", cost: 400, fee: 80, throws:0, owner:-1, contracts:0, func:'', name:'Independent Sector Treatment Centre'}, {w:142, h:260, x:677, y:522, dir:"l", opcode:"c", cost: 750, fee:150, throws:0, owner:-1, contracts:0, func:'', name:'Cosmetic Surgery'}, {w:176, h:260, x:588, y:522, dir:"l", opcode:"p", cost:1000, fee:200, throws:2, owner:-1, contracts:0, func:'PFIthrow', name:'PFI (3)'}, {w:144, h:260, x:515, y:522, dir:"l", opcode:"c", cost: 800, fee:100, throws:0, owner:-1, contracts:0, func:'', name:'Surgical Implants and Prostheses'}, {w:144, h:260, x:442, y:522, dir:"l", opcode:"c", cost: 150, fee: 30, throws:0, owner:-1, contracts:0, func:'', name:'Private Wing'}, {w:206, h:260, x:338, y:522, dir:"l", opcode:"c", cost:1000, fee:300, throws:1, owner:-1, contracts:0, func:'McImousethrow',name:'McImouse Management Consultancy'}, {w:272, h:260, x:201, y:522, dir:"U", opcode:"g", cost: 0, fee: 0, throws:0, owner:-1, contracts:0, func:'', name:'Hedge Fund'}, {w:272, h:150, x:201, y:446, dir:"u", opcode:"c", cost: 100, fee: 20, throws:0, owner:-1, contracts:0, func:'', name:'Secretarial Services'}, {w:272, h:150, x:201, y:370, dir:"u", opcode:"C", cost: 0, fee: 0, throws:1, owner:-1, contracts:0, func:'do_community', name:'Community Care (2)'}, {w:272, h:170, x:201, y:284, dir:"u", opcode:"p", cost:1000, fee:200, throws:2, owner:-1, contracts:0, func:'PFIthrow', name:'PFI (4)'}, {w:272, h:150, x:201, y:208, dir:"u", opcode:"c", cost: 400, fee: 80, throws:0, owner:-1, contracts:0, func:'', name:'Medium Secure Mental Health'}, {w:272, h:150, x:201, y:132, dir:"u", opcode:"c", cost: 800, fee:100, throws:2, owner:-1, contracts:0, func:'kingsthrow', name:'King\'s Fund Consultancy'} ]; var communitychest= [ "You've won an award for your privatisation efforts. Collect £100,000 x throw of a die", "Land a monster IT contract. Collect £1m x throw of two dice", "An investment collapses as funding is pulled by hedge fund. Pay Banker £2m", "Your tax avoidance is publicised by a campaign. Pay £200,000 to take HMRC inspectors to lunch", "Shareholders revolt. Pay Banker a dividend of £1 million", "You win a contract for imaging services: collect £100,000 x throw of a die - less £200,000 for new equipment" ]; var triagecard= [ "Your Think Tank wins hedge fund backing. Collect £500,000 and advance to King's Fund", "Rebrand an old drug as a new product. Collect £2 million", "Your cheap cosmetic prostheses are found to be faulty. Collapse your company and relaunch under a similar name to dodge payout. Pay Banker £500,000", "Cash in on a flu epidemic, taking the chance to market your ineffective medicine. Collect £3 million", "Rush to A&E. Do not collect any fees until discharged", "Unexpected Quality inspection reveals your poor standards. Pay Banker £1 million to continue regardless" ]; function initialise() { var i,img,fn; ordered=1; want_sounds=true; document.getElementById('cbsound').checked=true; boingsound=createsoundbite(1,"boing_spring"); clicksound=createsoundbite(2,"click8"); rollsound=createsoundbite(3,"roll"); fsound=createsoundbite(4,"fquick"); fshortsound=createsoundbite(5,"fshort"); oohsound=createsoundbite(6,"ooh"); plopsound=createsoundbite(7,"plop"); ohsound=createsoundbite(8,"oh"); popsound=createsoundbite(9,"pop"); roll2sound=createsoundbite(10,"roll2"); gunshot=createsoundbite(11,"gunshot"); ding=createsoundbite(12,"ding"); if (!want_sounds) document.getElementById('soundcheck').style.visibility='hidden'; for (i=1; i<31; i++) { w=squares[i-1].w/2; h=squares[i-1].h/2; x=squares[i-1].x; y=squares[i-1].y; if (i<10) fn='images/square0'+i+'.gif'; else fn='images/square'+i+'.gif'; img=new Image(); img.src=fn; img.style.position='absolute'; img.style.width=w+'px'; img.style.height=h+'px'; img.style.left=x+'px'; img.style.top=y+'px'; document.body.appendChild(img); } for (i=1; i<5; i++) document.getElementById('input'+i).value=''; InitDragDrop(); // -- Just for now document.getElementById('input1').value='Eric'; document.getElementById('input2').value='Mavis'; } function startup() { var ob,t,i,dy,n=0; n_players=0; for (i=0; i<4; i++) player[i].username=''; for (i=0; i<4; i++) { nm=document.getElementById('input'+(i+1)).value; if (nm.length>0) { t=nm.charAt(0); nm=t.toUpperCase()+nm.substr(1,nm.length-1); player[n_players].username=nm; player[n_players].colour=usercolour[i]; player[n_players].tileid='tile'+(i+1); n_players++; } } if (n_players>0) { document.getElementById('setup').style.visibility='hidden'; document.getElementById('startbut').style.visibility='hidden'; document.getElementById('blurb').style.left='370px'; document.getElementById('blurb').style.top='160px'; document.getElementById('diepic').style.visibility='visible'; for (i=0; i<4; i++) document.getElementById('tilename'+(i+1)).style.visibility='hidden'; if (want_sounds) { want_sounds=(document.getElementById('cbsound').checked); document.getElementById('soundcheck').style.visibility='hidden'; } } ob=document.getElementById('threwn'); ob.innerHTML='Roll to choose
who goes first'; ob.style.visibility='visible'; ob.style.zIndex=10; ob=document.getElementById('thrown'); ob.innerHTML=player[on_player].username+' to throw'; ob.style.visibility='visible'; ob.style.zIndex=10; } function reveal_panels() { var i,tid,dy; dy=40; for (i=1; i<=n_players; i++) { document.getElementById('panel'+i).style.visibility='visible'; document.getElementById('panel'+i).style.left='1px'; document.getElementById('panel'+i).style.top=dy+'px'; tid=player[i-1].tileid; document.getElementById(tid).style.left='142px'; document.getElementById(tid).style.top=(dy+5)+'px'; document.getElementById(tid).style.visibility='visible'; document.getElementById('playername'+i).innerHTML=player[i-1].username; document.getElementById('playertile'+i).src=document.getElementById(tid).src; dy+=104; showbalance(i-1); } } function clear_message() { if (cleartm==0) document.getElementById('message').style.visibility='hidden'; else { cleartm--; window.setTimeout(function(){clear_message();},2000); } } function wait(t) { delay=t; waitforit(); } function waitfor_die() { if (dietm==0) { hide_square(); document.getElementById('diepic').style.visibility='visible'; var tt=player[on_player].username+' to throw'; if ((player[on_player].on_square==15) && (player[on_player].balance>=200)) // A & E and can afford to jump queue tt+=', or

' document.getElementById('thrown').innerHTML=tt; } else { dietm--; window.setTimeout(function(){waitfor_die();},2000); } } function show_die(t) { dietm=t; waitfor_die(); } function leaveAandE() { var sq=player[on_player].on_square; var msg=document.getElementById('message'); player[on_player].on_square=22; // Go to private wing player[on_player].balance-=200; msg.innerHTML=player[on_player].username+' has jumped the queue'; msg.style.visibility='visible'; cleartm=1; window.setTimeout(function(){clear_message();},4000); showbalance(on_player); migrate(sq,22); document.getElementById('diepic').style.visibility='hidden'; document.getElementById('thrown').innerHTML=''; } function collect() { player[on_player].balance+=500; showbalance(on_player); } function nformat(n) { n+=','; while (n.length<4) n='0'+n; return (','+n.substr(0,3)); } function numformat(d) { var thousands,millions,billions=0; var n=''; thousands=d; var negative=(thousands<0); if (negative) thousands=Math.abs(thousands); millions=Math.floor(thousands / 1000); thousands-=millions*1000; billions=Math.floor(millions / 1000); millions-=billions*1000; if (billions>0) n+=billions+nformat(millions)+nformat(thousands); else if (millions>0) n+=millions+nformat(thousands); else n+=thousands; if (negative) n='-'+n; return(n); } function showbalance(p) { var n=numformat(player[p].balance*1000); document.getElementById('balance'+p).innerHTML="Bank balance
£"+n; } function throw_die() { hide_square(); r=1+Math.floor(Math.random()*6); document.getElementById('thrown').innerHTML=player[on_player].username+" threw "+r; return r; } function throw_dice() { hide_square(); r1=1+Math.floor(Math.random()*6); r2=1+Math.floor(Math.random()*6); tot=r1+r2; document.getElementById('thrown').innerHTML=player[on_player].username+" threw "+r1+" and "+r2+" ="+tot; return tot; } function do_community() { var ob=document.getElementById('community'); var obtxt=document.getElementById('ctext'); var n=throw_die(); if (want_sounds) { if ((n==1) || (n==2) || (n==6)) oohsound.playclip(); else ohsound.playclip(); } ob.style.visibility='visible'; obtxt.innerHTML=communitychest[n-1]+'

'; obtxt.style.visibility='visible'; } function hide_community(n) { document.getElementById('community').style.visibility='hidden';; document.getElementById('ctext').style.visibility='hidden';; switch (n) { case 1: player[on_player].balance+=throw_die()*100; break; case 2: player[on_player].balance+=throw_dice()*1000; break; case 3: player[on_player].balance-=2000; break; case 4: player[on_player].balance-=200; break; case 5: player[on_player].balance-=1000; break; case 6: player[on_player].balance+= throw_die()*100 - 200; break; } showbalance(on_player); on_player=(on_player+1) % n_players; show_die(0); } function do_triage() { var ob=document.getElementById('triage'); var obtxt=document.getElementById('ctext'); var n=throw_die(); if (want_sounds) { if ((n==1) || (n==2) || (n==4)) // Good oohsound.playclip(); else ohsound.playclip(); } ob.style.visibility='visible'; obtxt.innerHTML=triagecard[n-1]+'

'; obtxt.style.visibility='visible'; } function hide_triage(n) { var x; var osq=player[on_player].on_square; document.getElementById('triage').style.visibility='hidden';; document.getElementById('ctext').style.visibility='hidden';; switch (n) { case 1: player[on_player].balance+=500; player[on_player].on_square=29; migrate(osq,29); break; case 2: player[on_player].balance+=2000; break; case 3: player[on_player].balance-=500; break; case 4: player[on_player].balance+=3000; break; case 5: player[on_player].on_square=15; // A&E migrate(osq,15); break; case 6: player[on_player].balance-=1000; break; } showbalance(on_player); if ((n!=1) && (n!=5)) { on_player=(on_player+1) % n_players; show_die(0); } } function buycontract(n) { var w=squares[n].w/2; var h=squares[n].h/2; var x=squares[n].x; var y=squares[n].y; var dir=squares[n].dir; var opcode=squares[n].opcode; var cost=squares[n].cost; var contracts=squares[n].contracts; player[on_player].balance-=cost; squares[n].owner=on_player; squares[n].contracts++; // Add contract blob var img=new Image(); img.style.position='absolute'; switch (dir) { case 'l': case 'r': img.src='images/contract'+player[on_player].colour+'V.gif'; if (dir=='r') y+=(h+2); else y-=19; if ((n==1) || (n==23)) x=x+w-(10*contracts)-11; else x+=10*contracts; break; case 'd': case 'u': img.src='images/contract'+player[on_player].colour+'H.gif'; if (dir=='d') x-=18; else x+=w+2; if ((n==10) || (n==29)) y=y+h-(10*contracts)-11; else y+=2+(10*contracts); break; } img.style.left=x+'px'; img.style.top=y+'px'; document.body.appendChild(img); if (want_sounds) popsound.playclip(); showbalance(on_player); on_player=(on_player+1) % n_players; hide_square(); show_die(0); } function stick() { hide_square(); on_player=(on_player+1) % n_players; show_die(0); } function goto_square(n) { var osq=player[on_player].on_square; hide_square(); player[on_player].on_square=n; migrate(osq,n); } function go_start() { var osq=player[on_player].on_square; hide_square(); player[on_player].on_square=0; migrate(osq,0); } function show_square(n) { var ns=(n<9) ? '0'+(n+1):(n+1); var ob=document.getElementById('msquare'); var msg=document.getElementById('message'); var obtxt=document.getElementById('mtext'); ob.src='images/square'+ns+'.gif'; var w=squares[n].w; var h=squares[n].h; var x=squares[n].x; var y=squares[n].y; var dir=squares[n].dir; var opcode=squares[n].opcode; var throws=squares[n].throws; var owner=squares[n].owner; var cost=squares[n].cost; var fee=squares[n].fee; var contracts=squares[n].contracts; var fn=squares[n].func; switch (dir) { case 'D': case 'd': x-=w/2; break; case 'L': x-=w/2; y-=h/2; break; case 'U': case 'l': y-=h/2; break; } ob.style.left=x+'px'; ob.style.top=y+'px'; ob.style.visibility='visible'; if (dir=='U') { obtxt.innerHTML=''; obtxt.style.left=x+4+'px'; obtxt.style.top=(y+h-18)+'px'; obtxt.style.visibility='visible'; obtxt.style.zIndex=11; if (want_sounds) boingsound.playclip(); } else if (( (owner == -1) && ((opcode == 'c') || (opcode=='p')) ) || (owner==on_player)) { if (cost<=player[on_player].balance) obtxt.innerHTML=' '; else { if (want_sounds) fshortsound.playclip(); obtxt.innerHTML=''; } obtxt.style.left=x+4+'px'; obtxt.style.top=(y+h-18)+'px'; obtxt.style.visibility='visible'; obtxt.style.zIndex=11; } else if ((owner!=on_player) && (throws>0)) { tt=(throws>1) ? "Throw twice":"Throw"; obtxt.innerHTML=''; obtxt.style.left=x+4+'px'; obtxt.style.top=(y+h-18)+'px'; obtxt.style.visibility='visible'; obtxt.style.zIndex=11; } else if ((owner>=0) && (owner!=on_player) && (fee * contracts>0)) { player[on_player].balance -= fee*contracts; player[owner].balance += fee*contracts; if (player[on_player].balance<0) { tt=player[on_player].username+' is BANKRUPT'; if (want_sounds) ohsound.playclip(); } else { n=numformat(fee*contracts*1000); tt=player[on_player].username+' pays '+player[owner].username+' £'+n; if (want_sounds) plopsound.playclip(); } msg.innerHTML=tt; msg.style.visibility='visible'; showbalance(on_player); showbalance(owner); on_player=(on_player+1) % n_players; cleartm=1; window.setTimeout(function(){clear_message();},4000); show_die(1); } else { obtxt.style.visibility='hidden'; on_player=(on_player+1) % n_players; showbalance(on_player); show_die(1); } ob.style.zIndex=10; } function priceythrow() { var owner=squares[1].owner; var contracts=squares[1].contracts; var msg=document.getElementById('message'); var r=throw_die()*contracts*squares[1].fee; player[on_player].balance-=r; player[owner].balance+=r; if (want_sounds) plopsound.playclip(); if (player[on_player].balance<0) tt=player[on_player].username+' is BANKRUPT'; else { n=numformat(r*1000); tt=player[on_player].username+' pays '+player[owner].username+' £'+n; } msg.innerHTML=tt; msg.style.visibility='visible'; showbalance(on_player); showbalance(owner); on_player=(on_player+1) % n_players; hide_square(); cleartm=1; window.setTimeout(function(){clear_message();},4000); show_die(1); } function McImousethrow() { var owner=squares[23].owner; var contracts=squares[23].contracts; var msg=document.getElementById('message'); var r=throw_die()*contracts*squares[23].fee; player[on_player].balance-=r; player[owner].balance+=r; if (want_sounds) plopsound.playclip(); if (player[on_player].balance<0) tt=player[on_player].username+' is BANKRUPT'; else { var n=numformat(r*1000); tt=player[on_player].username+' pays '+player[owner].username+' £'+n; } msg.innerHTML=tt; msg.style.visibility='visible'; showbalance(on_player); showbalance(owner); on_player=(on_player+1) % n_players; hide_square(); cleartm=1; window.setTimeout(function(){clear_message();},4000); show_die(1); } // King's Fund function kingsthrow() { var owner=squares[29].owner; var contracts=squares[29].contracts; var msg=document.getElementById('message'); var r=throw_dice()*contracts*squares[29].fee; player[on_player].balance-=r; player[owner].balance+=r; if (want_sounds) ding.playclip(); if (player[on_player].balance<0) tt=player[on_player].username+' is BANKRUPT'; else { n=numformat(r*1000); tt=player[on_player].username+' pays '+player[owner].username+' £'+n; } msg.innerHTML=tt; msg.style.visibility='visible'; showbalance(on_player); showbalance(owner); on_player=(on_player+1) % n_players; hide_square(); cleartm=1; window.setTimeout(function(){clear_message();},4000); show_die(1); } function PFIthrow() { var osq=player[on_player].on_square; var owner=squares[osq].owner; var msg=document.getElementById('message'); var contracts=squares[osq].contracts; var r=throw_dice()*contracts*squares[osq].fee; // Does owner have all four PFIs? var all_PFIs=((squares[4].owner==owner) && (squares[12].owner==owner) && (squares[20].owner==owner) && (squares[27].owner==owner)); if (all_PFIs) r*=2; player[on_player].balance-=r; player[owner].balance+=r; if (want_sounds) fsound.playclip(); if (player[on_player].balance<0) tt=player[on_player].username+' is BANKRUPT'; else { var n=numformat(r*1000); tt=player[on_player].username+' pays '+player[owner].username+' £'+n; } msg.innerHTML=tt; msg.style.visibility='visible'; showbalance(on_player); showbalance(owner); on_player=(on_player+1) % n_players; hide_square(); cleartm=1; window.setTimeout(function(){clear_message();},4000); show_die(1); } function hide_square() { document.getElementById('msquare').style.visibility='hidden'; document.getElementById('mtext').style.visibility='hidden'; } function progress() { document.getElementById('diepic').style.visibility='hidden'; hide_square(); if (want_sounds) { var n=1+Math.floor(Math.random()*6); if (n % 2) rollsound.playclip(); else roll2sound.playclip(); delay=2; } else delay=0; do_progress(); } function do_progress() { var tt,bootedout; if (delay>0) { delay--; window.setTimeout(function(){do_progress();},1000); return; } var r=1+Math.floor(Math.random()*6); if (ordered <= n_players) { var threw=document.getElementById('threwn'); player[on_player].threw=r; whothrew+=player[on_player].username+' threw '+r+'

'; threw.innerHTML=whothrew; threw.style.visibility='visible'; on_player=(on_player+1) % n_players; var ob=document.getElementById('thrown'); if (ordered=8); var r2=1+Math.floor(Math.random()*6); if ((r+r2)==12) tt=" threw double six
Move to private wing"; else if (bootedout) tt=" after 8 failed
attempts is booted out of
A & E to private wing"; else tt=" threw "+r+" and "+r2+"
Remains in A & E"; document.getElementById('thrown').innerHTML=player[on_player].username+tt; if (((r+r2)==12) || (bootedout)) { if (want_sounds) { if (bootedout) gunshot.playclip(); else oohsound.playclip(); } player[on_player].on_square=22; // Go to private wing migrate(sq,22); } else { if (want_sounds) fsound.playclip(); on_player=(on_player+1) % n_players; show_die(1); } } else { var esq=(sq + r) % 30; document.getElementById('thrown').innerHTML=player[on_player].username+" threw "+r; if ((sq+r)>30) collect(); player[on_player].on_square=esq; migrate(sq,esq); } } function xbounce(x,y,dx,dy,ob) { ob.style.left=x+dx+'px'; ob.style.top=y+40*Math.sin(Math.PI+steps*dy)+'px'; steps--; if (steps>0) window.setTimeout(function(){xbounce(x+dx,y+dy,dx,dy,ob);},5); } function ybounce(x,y,dx,dy,ob) { ob.style.left=x+20*Math.cos(-Math.PI/2+steps*dx)+'px'; ob.style.top=y+dy+'px'; steps--; if (steps>0) window.setTimeout(function(){ybounce(x+dx,y+dy,dx,dy,ob);},5); } function slide(a,b,ob) { var sx,ex,sy,ey,os; sx=squares[a].x; sy=squares[a].y; ex=squares[b].x; ey=squares[b].y; os=player[on_player].on_square; steps=iterations; if (sx!=ex) { dx=(ex-sx)/steps; dy=Math.PI / steps; xbounce(sx,sy+25,dx,dy,ob); } else { dy=(ey-sy)/steps; dx=Math.PI / steps; ybounce(sx,sy+25,dx,dy,ob); } dietm=0; if (want_sounds) clicksound.playclip(); msteps--; if (msteps>0) { window.setTimeout(function(){slide(a,b,ob);},500); a=b; b=(a+1) % 30; return; } if (os==0) collect(); if (os==15) player[on_player].aecount=0; if ((os!=0) && (os!=15)) show_square(os); else { on_player=(on_player+1) % n_players; show_die(1); } } function migrate(start,stop) { if (stop0) list.remove(list.length-1); list.options[list.length]=new Option("Don't buy anything",-1); for (i=0; i<30; i++) { if ((squares[i].owner==-1) && (squares[i].cost <= player[on_player].balance) && ((squares[i].opcode=='c') || (squares[i].opcode=='p'))) list.options[list.length]=new Option(squares[i].name+' (£'+numformat(squares[i].cost*1000)+')',i); } if (list.length==1) { list.options[0].text='Sorry, nothing is available'; list.options[0].value=-1; } list.selectedIndex=-1; if (want_sounds) boingsound.playclip(); document.getElementById('contractselector').style.visibility='visible'; document.getElementById('blurb').style.visibility='hidden'; } function qpchoice() { var list=document.getElementById('QPSelect'); var n=list.options[list.selectedIndex].value; if (n>=0) buycontract(n); else { on_player=(on_player+1) % n_players; hide_square(); show_die(0); } document.getElementById('contractselector').style.visibility='hidden'; document.getElementById('blurb').style.visibility='visible'; } function monitorthrow() { var r=1+Math.floor(Math.random()*6); var tt=(r==6) ? " threw a six
Choose a contract":" threw "+r+"
Bad luck!"; if (want_sounds) fsound.playclip(); document.getElementById('thrown').innerHTML=player[on_player].username+tt; if (r==6) setlist(); else { on_player=(on_player+1) % n_players; show_die(1); } } function hideballoon() { document.getElementById('helpballoon').style.visibility='hidden'; document.getElementById('helptext').style.visibility='hidden'; } function revealballoon(head,text) { ob=document.getElementById('helpballoon'); if (ob.style.visibility=='visible') { hideballoon(); return; } var x=180; var y=10; ob.style.left=x+'px'; ob.style.top=y+'px'; ob.style.visibility='visible'; obtxt=document.getElementById('helptext'); obtxt.style.left=x+20+'px'; obtxt.style.top=y+35+'px'; obtxt.style.visibility='visible'; } function showhelp() { revealballoon('Hospital Millions','Here is some help

'); }