diff --git a/xtrn/tw2/input.js b/xtrn/tw2/input.js index ed0fed58ba0bdefde9e013cd1804d89bacce1a97..c0da611607f1595d3d72bef16a71b867270ebe40 100644 --- a/xtrn/tw2/input.js +++ b/xtrn/tw2/input.js @@ -1,12 +1,3 @@ -function GetKeyEcho() -{ - var ret=console.getkey().toUpperCase(); - if(ret=="\x0a" || ret=="\x0d") - ret=''; - console.writeln(ret); - return(ret); -} - var lastmisc; var laststatus; try { diff --git a/xtrn/tw2/planets.js b/xtrn/tw2/planets.js index 47d9601d32c519e6dd864f21113cac6bffed0f9c..0d6685fcd9f49a49fa1f01450770b445e70f1fb4 100644 --- a/xtrn/tw2/planets.js +++ b/xtrn/tw2/planets.js @@ -100,7 +100,7 @@ function CreatePlanet(sector) } console.writeln("You have " + player.Credits + " credits."); console.write("Do you wish to buy a planet(Y/N) [N]? "); - if(GetKeyEcho()=='Y') { + if(InputFunc(['Y','N'])=='Y') { var i; var planet; for(i=1; i<planets.length; i++) { @@ -219,7 +219,7 @@ function DestroyPlanet(planet) console.crlf(); console.attributes="Y"; console.write("Are you sure (Y/N)[N]? "); - if(GetKeyEcho()=='Y') { + if(InputFunc(['Y','N'])=='Y') { planet.Created=false; var sector=sectors.Get(planet.Sector); sector.Planet=0; diff --git a/xtrn/tw2/players.js b/xtrn/tw2/players.js index fbd5dcfbd668e4e519aaacbcc0bd6c3022f04345..792337dfd929bde6dedefe31eb886b5bbb9e6a80 100644 --- a/xtrn/tw2/players.js +++ b/xtrn/tw2/players.js @@ -135,7 +135,7 @@ function AttackPlayer() && !otherplayer.Online) { count++; console.write("Attack "+otherplayer.Alias+" (Y/N)[Y]? "); - if(GetKeyEcho()!='N') { + if(InputFunc(['Y','N'])!='N') { console.writeln("<Yes>"); break; } @@ -471,12 +471,8 @@ function MatchPlayer(name) continue; if(p.Alias.toUpperCase().indexOf(name)!=-1) { console.write(p.Alias+" (Y/N)[Y]? "); - switch(GetKeyEcho()) { - case 'N': - break; - default: - return(p); - } + if(InputFunc(['Y','N'])!='N') + return(p); } } console.writeln("Not found."); diff --git a/xtrn/tw2/teams.js b/xtrn/tw2/teams.js index 1592b08121c0af1f3059f2688868639aad6c2d3f..015839ea6c41ab74a05a023c15f0761b34d7c17f 100644 --- a/xtrn/tw2/teams.js +++ b/xtrn/tw2/teams.js @@ -190,7 +190,7 @@ function QuitTeam() return(false); } console.write("Are you sure you wish to quit your Team [N]? "); - if(GetKeyEcho()=='Y') { + if(InputFunc(['Y','N'])=='Y') { var team=teams.Get(player.TeamNumber); player.TeamNumber=0; var i; @@ -217,7 +217,7 @@ function QuitTeam() function TeamTransfer(type) { console.write("Transfer "+type+" to another Team member [N]? "); - if(GetKeyEcho()!='Y') + if(InputFunc(['Y','N'])!='Y') return(false); if(player[type] < 1) { console.writeln("You don't have any "+type+"."); @@ -236,7 +236,7 @@ function TeamTransfer(type) && otherplayer.UserNumber!=0 && otherplayer.TeamNumber==player.TeamNumber) { console.write("Transfer "+type+" to " + otherplayer.Alias + " (Y/[N])? "); - if(GetKeyEcho()=='Y') + if(InputFunc(['Y','N'])=='Y') break; } otherplayer=null; @@ -257,7 +257,7 @@ function TeamTransfer(type) if(otherplayer.Credits + transfer > 25000) { console.writeln("You Team mate will have more than 25,000 credits"); console.write("Do you wish to complete the Transfer [N]? "); - if(GetKeyEcho()!='Y') + if(InputFunc(['Y','N'])!='Y') return(false); } } diff --git a/xtrn/tw2/tw2.js b/xtrn/tw2/tw2.js index a4fb9bbc8d0088896674cfe1bbbf1eeac6d30d85..033f0d540ad95ad1048c602a4c3298093f4cde4e 100644 --- a/xtrn/tw2/tw2.js +++ b/xtrn/tw2/tw2.js @@ -124,10 +124,9 @@ function Menu() // break; // console.writeln("<TW Editor>"); // console.write("Do you wish to use the editor? Y/N [N] "); -// switch(GetKeyEcho()) { -// case 'Y': -// console.writeln("Running Tradewars ][ Editor..."); -// /* TODO: TWEdit */ +// if(InputFunc(['Y','N'])=='Y') { +// console.writeln("Running Tradewars ][ Editor..."); +// /* TODO: TWEdit */ // } // break; case 'F':