/*
 *	Instructions command for rogue clone.
 */

#ifndef CURSES
#include <curses.h>
#endif CURSES
#include "rogue.h"
#include <string.h>

char *instr =
"Movement                                                y  k  u\n"
"        With SHIFT or CTRL to move until you hit         \\ | /\n"
"        an obstacle                                     h -+- l\n"
"                                                         / | \\\n"
"        .        Rest                                   b  j  n\n"
"        m <direction>    Move onto something without taking it\n"
"        ,                Pick up item at your location.\n"
"\n"
"Command Keys\n"
"s          search                    i                inventory\n"
"f          fight                     F                fight (to the death)\n"
"e          Eat                       q                Quaff\n"
"r          Read a scroll             d                Drop\n"
"P          Put on ring               R                Remove a ring\n"
"CTRL-P     See previous message      >                Descend level\n"
"<          Ascend level              )                List weapons\n"
"]          List armour               =                List rings\n"
"^          Identify trap             I                Short inventory\n"
"T          Take off                  W                Wear armour\n"
"w          Wield weapon              c                Call something a name\n"
"z          Zap something             t<direction>     Throw something\n"
"v          Version                   Q                Quit\n"
"CTRL-A     Show average hit points   S                Save game\n\n";

void Instructions()
{
	char buffer[DROWS+1][DCOLS+1];
	char buf[256];
	char *ptr;
	short row;
	int i,j,k;
	for (row = 0; row < DROWS; row++) {
		for (j = 0; j < DCOLS; j++) {
			buffer[row][j] = mvinch(row, j);
		}
		buffer[row][j] = 0;
		mvaddstr(row, 0, buffer[row]);
		clrtoeol();
	}
	move(0,0);
	for(i=0;i<DROWS;i++)
	{
		move(i,0);
		clrtoeol();
	}	
	refresh();
	ptr=instr;
	for(i=0;i<DROWS;i++)
	{
		k = 0;
		do
		{
			buf[k++]=*ptr++;
		}
		while(*(ptr-1)!='\n');
		if(strchr(buf,'\n')!=NULL)
			*strchr(buf,'\n')=0;
		move(i,0);
		clrtoeol();
		mvaddstr(i,0,buf);
	}
	refresh();
	rgetchar();
	move(0,0);
	clrtoeol();
	for(i=0;i<DROWS;i++)
	{
		move(i,0);
		clrtoeol();
	}
	refresh();
	for(i=0;i<DROWS;i++)
	{
		mvaddstr(i,0,buffer[i]);
	}
	refresh();
}
