//
//  A minimal T2 test game, to test misc stuff in XTads.
//

#include <adv.t>
#include <std.t>

#define USE_HTML_PROMPT 1


startroom: room
    //sdesc = "XTads T2 ad-hoc test game!"
    turnCount = 0
    sdesc = "sdesc"
    ldesc = {

"<B><FONT COLOR=\"GREEN\">School";



/*
if ((turnCount % 2) = 0) {
	"<body input=red>body#input=red";
} else {
	"<body input=blue>body#input=blue";
}
turnCount := turnCount + 1;
*/

/*
if (turnCount = 0) {
	"before body";
} else {
	"<body input=blue>body#input=blue";
}
turnCount := turnCount + 1;
*/

/*
if (turnCount = 0) {
	"<body input=link>link input";
	//	morePrompt();
} else {
	"<body input=statusbg>statusbg input";
}
turnCount := turnCount + 1;
*/

//"<body input=foobar>foobar input";

//"<body input=statusbg>statusbg input";

/*
if (turnCount = 0) {
	"<body input=red>red input";
} else {
	"<body>??? input";
}
turnCount := turnCount + 1;
*/

//"<body input=link>link input";

//"<body input=red>red input"; 

//----------------------------

//"<body text=red>red text";

/*
if (turnCount = 0) {
	//"<body input=red>";
	//"body input=red ";
	"input=default ";
} else {
	"<body input=blue>";
	"body input=blue ";
}
turnCount := turnCount + 1;
*/
    
/*    
"<body input=foobar>";
"whatever";
*/

/*
"<body text=red input=black>";
"whatever";
*/

/*
"<font color=red>";
"whatever";
*/

/*
"Before";
"<!-- text in comment -->";
"After";
*/

/*
// threnody missing newline before command prompt:    
"<BR><b><font face='trebuchet ms,Arial,Geneva,TADS-Sans' size='+1'";
" ";
"color='text'>PROLOGUE</font></b>";
"
";
"<BR HEIGHT=0>";
"<BR HEIGHT=0>";
"In the beginning, darkness was upon the face of the deep.";
"
";
"<BR HEIGHT=0>";
"Your world seems without form, and void.";

"<AboutBox>";

"<center>";
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"400\">";
	"<tr>";
		"<td align='center'><img src=\"Icons/miniThrenody.jpg\">";
			"<font color=\"#000000\">";
				"<center>";
					"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor='bgcolor'>";
						"<tr>";
							"<td width=\"80\"><img src=\"Icons/ikonLogo.png\"></td>";
							"<td>";
								"
								";
								"<BR HEIGHT=0>";
								"<font size='+1' face='trebuchet ms,arial,geneva,TADS-Sans'";
								" ";
								"color='text'><b>Threnody</b></font>";
								"
								";
								"<BR HEIGHT=0>";
								"<font face='trebuchet ms,arial,geneva,TADS-Sans' color='text'><i>A cat o' nine";
								" ";
								"tails; a tale of nine cats.</i></font>";
								"
								";
								"<BR HEIGHT=0>";
								"<font size='-1' face='trebuchet ms,arial,geneva,TADS-Sans'";
								" ";
								"color='text'>Copyright 2005, John \"Doppler\" Schiff</font>";
								"
								";
								"<BR HEIGHT=0>";
								"<font size='-1' face='trebuchet ms,arial,geneva,TADS-Sans' color='text'>version";
								" ";
								"1.0b, created for Spring Thing";
								" ";
								"2005</font>";
							"</td>";
						"</tr>";
					"</table>";
				"</center>";
			"</font>";
		"</td>";
	"</tr>";
"</table>";
"</center>";

"</AboutBox>";

"
";
"<BR HEIGHT=0>";
"<BR HEIGHT=0>";
"<BR HEIGHT=0>";
"<BR HEIGHT=0>";
"<BR HEIGHT=0>";
"<BR HEIGHT=0>";
"<BR HEIGHT=0>";
"<BR HEIGHT=0>";
*/

/* askfile() in cmd record/replay
local i;
for (i := 0; i < 3; i++) {
	local res;
	"ask file (<<i+1>>/3):";
    res := askfile('File',
                        ASKFILE_PROMPT_OPEN, FILE_TYPE_SAVE,
                        ASKFILE_EXT_RESULT);
	"Got: <<res[1]>> <<res[2]>> <br>";
}
"Done<br>";
*/

/* inputdialog() in cmd record/replay
local i;
for (i := 0; i < 3; i++) {
	local idx;
	"input dialog (<<i+1>>/3):";
	idx := inputdialog(INDLG_ICON_NONE, 'Meh?',
                       ['&OK'],
                       1, 1);
	"Got: <<idx>><br>";
}
"Done<br>";
*/

/* inputevent() in cmd record/replay
local i;
for (i := 0; i < 3; i++) {
	"input event (<<i+1>>/3):";
	inputevent();
	"Got it<br>";
}
"Done<br>";
*/

/* morePrompt() in cmd record/replay
local i;
for (i := 0; i < 3; i++) {
	"VM more prompt (<<i+1>>/3):";
	morePrompt();
	"Got it<br>";
}
"Done<br>";
*/

/* inputkey() in cmd record/replay
local i;
for (i := 0; i < 3; i++) {
	local key;
	"Press a key (<<i+1>>/3):";
	key := inputkey();
	"Got: <<key>><br>";
}

/* input() in cmd record/replay
local line1 = 'nothing1';
local line2 = 'nothing2';
local line3 = 'nothing3';
"Enter a line (1/3)<br>";
line1 := input();
"Got: <<line1>><br>";
"Enter a line (2/3)<br>";
line2 := input();
"Got: <<line2>><br>";
"Enter a line (3/3)<br>";
line3 := input();
"Got: <<line3>><br>";
"Ok, bye.";
*/

/* non-VM more prompts in cmd replay
local ii := 0;
"Press enter to start...<br>";
input();
for (ii := 0; ii < 2; ii++) {
	local i := 0;
	for (i := 0; i < 100; i++) {
		"line <<i>><br>";
	}
	"Enter a line: ";
	input();
}
"Done<br>";
*/

/*
"<BR>";
"<TAB MULTIPLE=4>The road stretches off into the dim <TAB MULTIPLE=4>moonlight to the east and<br>";
//TODO use: "<TAB MULTIPLE=4>The road stretches off into the dim moonlight to the east and<br>";
*/

/* plant sign alignment bug:
"
";
"<BR HEIGHT=0>";
"<br>";
"(Opening the passenger's door)";
"
";
"<BR HEIGHT=0>";
"Mr.&nbsp;Teeterwaller opens his door and comes with you.";
"
";
"<BR HEIGHT=0>";
"
";
"<BR>Road, near car";
"
";
"<BR HEIGHT=0>";
"<TAB MULTIPLE=4>The road stretches off into the dim moonlight to the east and";
" ";
"west.  Mr.&nbsp;Teeterwaller's car sits in the shoulder, parked just slightly";
" ";
"off the road.";
"
";
"<BR HEIGHT=0>";
"<TAB MULTIPLE=4>";
"
";
"<BR HEIGHT=0>";
"<BR HEIGHT=0>";
"<BR HEIGHT=0>";
"
";
"<BR>A corner of the sky glows briefly with a lightning flash.";
"
";
"<BR HEIGHT=0>";
"
";
"<BR>The hazard lights flash on and off.";
"
";
"<BR HEIGHT=0>";
"<BR HEIGHT=0>";
"<BR HEIGHT=0>";
"
";
"<BR>&gt;";
*/

/* plant sign alignment bug:
"before
<blockquote><font face='TADS-Sans'>Conners City&nbsp;&nbsp;&nbsp;&nbsp;<tab 
id=dist>25 mi <br>Knighting<tab to=dist>37 mi <br>Milltown<tab to=dist>51 mi 
</font></blockquote>
after";
*/
    
    	/*
    	"ldesc";

		// Sent with bug report to mjr 2017-01-17:
    	/ * Fails:
    	"ldesc<b";
    	">bold</b>";
    	* /
    	/ * Fails:
    	"ldesc<";
    	"b>bold</b>";
    	* /
    	/ * Works:
    	"ldesc";
    	"<b>bold</b>";
    	* /
    	/ * Works:
    	"ldesc<b>bold</b>";
		* /
		*/
    	
    	//"ldesc<BR>ldesc<BR><TAB MULTIPLE=4>An adventure";
		//"zz<b><BR HEIGHT=0>4.  A French audio tape.</B></FONT> <BR HEIGHT=0><TAB MULTIPLE=4>The winner of";
    	
		//"mmm<B>Bold?</B>nnn<I>Italics?</i><BR><font face='TADS-Sans' size=2> <TABLE> ";
		//"mmm<BR><font face='TADS-Sans' size=2> <TABLE> ";
		//"<TR align=center><TH COLSPAN=4><B>Useful Verbs</B> <TR align=left><TD>strip <TD>ask <I>person</I></table>" ;
    	
    	//"foo<br>bar<BR HEIGHT=0><TAB INDENT=5>What";
    	
    	//"<BR>normal?<b>bold?<font face='TADS-Input'>input?</font>bold</b>normal?";
    	//"<BR>normal?<b>bold?<font face='Impact'>input?</font>bold</b>normal?";
    	//"<BR>normal?<b>bold?<font face='Consolas, TADS-Input'>input?</font>bold</b>normal?";
    	//"<BR>normal?<b>bold?<font face='Zzonsolas, TADS-Input'>input?</font>bold</b>normal?";
    	//"<BR>normal?<font size=+2>font+2?<font face='TADS-Input'>input?</font>font+2?</font>normal?";
    	//"<BR>normal?<font size=6>font6?<font face='TADS-Input'>input?</font>font6?</font>normal?";
    	//"<BR>normal?<big>big?<font face='TADS-Input'>input?</font>big?</big>normal?";
    	
    	//"xy<br><i>ab <b>Writers:<\b <TAB MULTIPLE=4>Karen M. Sandler</i>";
    	//"xy<br><i>ab <b>Writers:<\b<TAB MULTIPLE=4>Karen M. Sandler</i>";
    	//"xy<br><i>ab <b>Writers:<\b T<AB MULTIPLE=4>Karen M. Sandler</i>";
    	//"xy<br><i>ab <b>Writers:<\b <TAB MULTIPLE=4>Karen M. Sandler</i>";
    	//"xy<br><i>ab <b>Writers:<\b MULTIPLE='4>'Karen M. Sandler</i>";
    	//"xy<br><i>ab <b>Writers:<\b MULTIPLE=\"4>\"Karen M. Sandler</i> ab";
    	//"xy<br><i>ab <b>Writers:</b MULTIPLE=4=>Karen M. Sandler</i> ab";
    	//"xy<br><i>ab <b>Writers:</b=>Karen M. Sandler</i> ab";
    	//"xy<br>ab <b>Writers:</b=>Karen M. Sandler ab";
    	    	
    	//"m</p w== mu>pp";
    		// works like on qtads
    	//"m</p w=x< mu>pp";
    		// works like on qtads    	
    	//"m>c<p w=x< mu>s";
    		// works like on qtads    	
    	//"m<p w=x< mu>pp";
    		// works like on qtads    	
    	//"m<p w. mu>pp";
    		// works like on qtads
    	//"m<p w== mu>pp";
    		// works like on qtads
    	//"a<br HEIGHT='/>'>b";
    		// works like on qtads
    	//"<br HEIGHT='/>'>";
    		// works like on qtads
    	//"<br HEIGHT='>'>";
    		// works like on qtads
    	//"xy<br>a<\b HEIGHT='4>'b";
    		// works like on qtads
    	//"xy<br><b>a<\b HEIGHT='4>'b";
    		// works like on qtads
    	//"xy<br><b>a<b HEIGHT='4>'b";
    		// works like on qtads
    	//"xy<br><b>a</b HEIGHT='4>'b";
    		// works like on qtads
		//"a<br HEIGHT='/>'>b ";
    		// works like on qtads		
    	//"xy<br>a<br HEIGHT='4>'b";
    		// works like on qtads

    	//"a</br HEIGHT='>'>b";
    		// works like on qtads
    	//"xy<br>a<br HEIGHT='a>'>b";
    		// works like on qtads
    	//"</br HEIGHT='>'>";
    		// works like on qtads
    	//"xy<br>a<br HEIGHT='2z'>b";
    		// works like on qtads
    	//"xy<br>a<br HEIGHT='4>'>b"; 
    		// works like on qtads
    	//"xy<br>a<br HEIGHT='4>'b>c";
    		// works like on qtads
    	//"xy<br>a<br HEIGHT='10a>'>b";
    		// works like on qtads
    	
    	//"a<br><tab>a<br><tab><tab>a";
    	
    	//"\na\n\ta\n\t\ta\n\t\t\ta\n\t\t\t\ta";
    	
    	//"\n32/4\tTrolls\n6/5\tSome\n17/5\tImplementors\n\t\tQuendor\n17/55\tImplementors";
    }
	statusLine =
		{
		//TODO qtads doesn't not print space after cmd prompt - xtads does
		//" ";
 		//"<banner id=StatusLine height=previous border><i>Basement? </i></banner>";
 		//"<banner id=StatusLine height=previous border>Basement? </banner>";
 		//"<banner id=StatusLine height=previous border>Basement?</banner>";

		// plant sign bug: 		
		//"<banner id=StatusLine height=previous border> <body bgcolor=statusbg ";
		//"text=statustext><b> <a plain href='look'>In the car</a></b> <tab body ";
		//"align=right><i><a plain href='Full Score'>0/0</a></i> &nbsp;&nbsp;&nbsp;&nbsp; ";
		//"<a plain href='Help' title='Help'><img src='help.jpg'></a> </banner>";
		
		"<banner id=StatusLine height=previous border>";
		" ";
		"<body bgcolor=statusbg text=statustext><b> <a plain href='Look'><B><FONT ";
		" ";
		"COLOR=\"GREEN\">School</FONT></B></a></b> <tab align=right><i><a ";
		" ";
		"plain href='Score'>Score 0 Moves 0</a></i> </banner>";
		}
  ;

replace commonInit: function
{
    // turn on html mode
    "\H+";
}

#ifdef USE_HTML_PROMPT
/*
 *   commandPrompt - this displays the command prompt.  For HTML games, we
 *   switch to the special TADS-Input font, which lets the player choose
 *   the font for command input through the preferences dialog.
 */
commandPrompt: function(code)
{
    //"**** commandPrompt";

    /* display the normal prompt */
    "\b&gt;";

    /* 
     *   switch the font to TADS-Input - the standard text-only
     *   interpreter will simply ignore this, so we don't have to worry
     *   about whether we're using an HTML-enabled interpreter or not 
     */
    //"<font face='TADS-Input'>";
    "<font face='Consolas' size=6>";
    //"<i>";
    //"<big>";
}

/*
 *   commandAfterRead - this is called just after each command is entered.
 *   For HTML games, we'll switch back to the original font that was in
 *   effect before commandPrompt switched to TADS-Input. 
 */
commandAfterRead: function(code)
{
    "</font>";
    //"</i>";
    //"</big>";
}
#endif /* USE_HTML_PROMPT */

/*
replace inputline: function
{
    local ret;
    local html_mode;
    
    "**** inputline";

    //* note whether we're in HTML mode * /
    html_mode := (systemInfo(__SYSINFO_SYSINFO) = true
                  && systemInfo(__SYSINFO_HTML_MODE));

    //* if in HTML mode, switch to TADS-Input font * /
    if (html_mode)
        "<font face='TADS-Input'>";

    //* read the input * /
    ret := input();

    //* exit TADS-Input font mode if appropriate * /
    if (html_mode)
        "</font>";

    //* return the line of text * /
    return ret;
}*/
