Skip to content
Snippets Groups Projects
Commit 7f33c82b authored by deuce's avatar deuce
Browse files

Add a separate menu for enntering a guarded sector, and fix calculations of

captured holds when destroying an enemy.
parent 518e012e
Branches
Tags
No related merge requests found
ɹForward Viewͻ͹TradeWars2/JavaScript Sector Invasionͻ
 . .. 
 .  . .  Attack
 . ... Info on you
. .   Quit the Game 
 .  ..  ReDisplay Sector
 .  Retreat
ͼͼ
...@@ -195,8 +195,8 @@ function AttackPlayer() ...@@ -195,8 +195,8 @@ function AttackPlayer()
var j; var j;
console.writeln("You destroyed the ship and salvaged these cargo holds:"); console.writeln("You destroyed the ship and salvaged these cargo holds:");
var holds=new Array(Commodities.length+1); var holds=new Array(Commodities.length);
for(i=0; i<holds.length+1; i++) for(i=0; i<holds.length; i++)
holds[i]=0; holds[i]=0;
for(i=0; i<otherplayer.Holds; i++) { for(i=0; i<otherplayer.Holds; i++) {
var limit=0; var limit=0;
...@@ -549,9 +549,9 @@ function DoBattle(opp, otherteam) ...@@ -549,9 +549,9 @@ function DoBattle(opp, otherteam)
console.writeln("You lost "+lost+" fighter(s), "+player.Fighters+" remain."); console.writeln("You lost "+lost+" fighter(s), "+player.Fighters+" remain.");
if(opp.Fighters > 0) if(opp.Fighters > 0)
console.write("You destroyed "+killed+" enemy fighters, "+opp.Fighters+" remain."); console.writeln("You destroyed "+killed+" enemy fighters, "+opp.Fighters+" remain.");
else else
console.write("You destroyed all of the enemy fighters."); console.writeln("You destroyed all of the enemy fighters.");
return(killed); return(killed);
} }
} }
......
...@@ -79,13 +79,13 @@ function EnterSector() /* 20000 */ ...@@ -79,13 +79,13 @@ function EnterSector() /* 20000 */
console.attributes="Y"; console.attributes="Y";
sector=db.read(Settings.DB,'sectors.'+player.Sector,LOCK_READ); sector=db.read(Settings.DB,'sectors.'+player.Sector,LOCK_READ);
DisplaySector(sector,player.Sector,false);
if(sector.FighterOwner > 0) { if(sector.FighterOwner > 0) {
otherplayer=players.Get(sector.FighterOwner); otherplayer=players.Get(sector.FighterOwner);
if(otherplayer.TeamNumber > 0) if(otherplayer.TeamNumber > 0)
fighterteam=otherplayer.TeamNumber; fighterteam=otherplayer.TeamNumber;
} }
while(sector.FighterOwner != player.Record && sector.Fighters > 0 && fighterteam != player.TeamNumber) { while(sector.FighterOwner != player.Record && sector.Fighters > 0 && fighterteam != player.TeamNumber) {
DisplaySector(sector,player.Sector,false,'enter.ans');
console.writeln("You have to destroy the fighters before you can enter this sector."); console.writeln("You have to destroy the fighters before you can enter this sector.");
console.writeln("Fighters: "+player.Fighters+" / "+sector.Fighters); console.writeln("Fighters: "+player.Fighters+" / "+sector.Fighters);
console.write("Option? (A,D,I,Q,R,?):? "); console.write("Option? (A,D,I,Q,R,?):? ");
...@@ -111,7 +111,7 @@ function EnterSector() /* 20000 */ ...@@ -111,7 +111,7 @@ function EnterSector() /* 20000 */
case 'D': case 'D':
console.writeln("<Display>"); console.writeln("<Display>");
sector=db.read(Settings.DB,'sectors.'+player.Sector,LOCK_READ); sector=db.read(Settings.DB,'sectors.'+player.Sector,LOCK_READ);
DisplaySector(sector,player.Sector,false); DisplaySector(sector,player.Sector,false,'enter.ans');
break; break;
case 'I': case 'I':
console.writeln("<Info>"); console.writeln("<Info>");
...@@ -198,10 +198,11 @@ function EnterSector() /* 20000 */ ...@@ -198,10 +198,11 @@ function EnterSector() /* 20000 */
console.writeln("Invalid command. ? = Help"); console.writeln("Invalid command. ? = Help");
} }
} }
DisplaySector(sector,player.Sector,false,'main.ans');
return(true); return(true);
} }
function DisplaySector(sector, secnum, helponly) function DisplaySector(sector, secnum, helponly, mainfname)
{ {
var i; var i;
var count=0; var count=0;
...@@ -215,7 +216,7 @@ function DisplaySector(sector, secnum, helponly) ...@@ -215,7 +216,7 @@ function DisplaySector(sector, secnum, helponly)
} }
if(user.settings&USER_ANSI) { if(user.settings&USER_ANSI) {
console.printfile(fname("main.ans")); console.printfile(fname(mainfname));
if(sector.Port > 0) if(sector.Port > 0)
console.printfile(fname("port.ans")); console.printfile(fname("port.ans"));
if(sector.Planet > 0) if(sector.Planet > 0)
......
...@@ -85,7 +85,7 @@ function Menu(sector) ...@@ -85,7 +85,7 @@ function Menu(sector)
case 'D': case 'D':
console.writeln("<Display>"); console.writeln("<Display>");
sector=db.read(Settings.DB,'sectors.'+player.Sector,LOCK_READ); sector=db.read(Settings.DB,'sectors.'+player.Sector,LOCK_READ);
DisplaySector(sector,player.Sector,false); DisplaySector(sector,player.Sector,false,'main.ans');
continue; continue;
case 'E': case 'E':
if(user.level < 90) if(user.level < 90)
...@@ -138,7 +138,7 @@ function Menu(sector) ...@@ -138,7 +138,7 @@ function Menu(sector)
console.crlf(); console.crlf();
if(user.settings&USER_ANSI) { if(user.settings&USER_ANSI) {
sector=db.read(Settings.DB,'sectors.'+player.Sector,LOCK_READ); sector=db.read(Settings.DB,'sectors.'+player.Sector,LOCK_READ);
DisplaySector(sector,player.Sector,true); DisplaySector(sector,player.Sector,true,'main.ans');
} }
else else
console.printfile(fname("main.asc")); console.printfile(fname("main.asc"));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment