Example #1
0
bool manager::menu_select(){
//turn is the index of the current player

char userinput; //make temp variable for user single char input

	while(userinput != 'X'){
		cout << "\n\nThis is the T R A G I C Menu Selection System.\n" 
		 << "Please enter one of the following choices: \n"
		 << "A - Place card from your hand onto the battlefield\n"
		 << "D - Draw a card from the deck\n"
		 << "T - Tap a card on the battlefield\n"
		 << "Y - Attack the other player\n"
		 << "H - Display cards in hand\n"
		 << "B - Display battlefield\n"
		 << "X - End your turn\n"
		 << "Enter here: "; //tell the options they have
		cin >> userinput; //get their selection
		cin.ignore(100, '\n'); //ignore input buffer
		userinput = toupper(userinput); //capitalize character for matching
	
		if (userinput == 'A' ){ //if matches call appropriate function
			hand2battlefield();
		}

		else if (userinput == 'D'){
			draw();
		}
		
		else if (userinput == 'D'){
			draw();
		}

		else if (userinput == 'T'){
			tap();
		}

		else if (userinput == 'Y'){
			attack();
		}
		
		else if (userinput == 'H'){
			display_hand();
		}

		else if (userinput == 'B'){
			display_battlefield();
		}
	

		else if (userinput == 'X') //if want to quit, return false and while looop in main will die and program will exit
			userinput = 'X'; //let them go, when the loop goes around again
	}
}
Example #2
0
//系统主函数
void main (void)
{
//	uint i;
	LED1=1;
	LED0=0;
	OEC=1;
	Exti_init();
	Time_init();	  //两个定时器初始化
	//TR0=0;
	UART_init();
	UART_Send_Str("知趣电子欢迎你!");
	while(1)
	{ 	
	
		if(irreceok)
    	{  
		    irreceok=0;	
			//P0=0X00;
			IR_pros();
			if(irprosok)
			{
				irprosok=0;
				P0=ircode[2];
			}
		}
		//if(open_close_flang)
	//	{
		///	open_close_flang=0;
			//TR0=1;
		//display_pic();
	//	}
		//else {
		//TR0=0;
		//}
		 display_hand();
		 //display_pic();
		 //display_figure();
		/*if(uart_flang)
		{
			//uart_flang=0;
			P0=0x00;
		//	if(pic_ch_flag)
		//	{
		//		pic_ch_flag=0;
			 TR1=1;   

		//	}
			
		}
		*/
	}
}