本文整理汇总了C++中Chart::checkField方法的典型用法代码示例。如果您正苦于以下问题:C++ Chart::checkField方法的具体用法?C++ Chart::checkField怎么用?C++ Chart::checkField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chart
的用法示例。
在下文中一共展示了Chart::checkField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
initscr();
noecho();
printw("Kolko i krzyzyk");
try{
//wiadomość z serwera
boost::asio::io_service io_service;
tcp::socket socket(io_service);
tcp::resolver resolver(io_service);
tcp::resolver::query query(tcp::v4(), "localhost", "2020");
tcp::resolver::iterator iterator = resolver.resolve(query);
boost::asio::connect(socket,iterator);
boost::array<char, 10> buf;
boost::system::error_code error;
Chart chart;
printw("\nCzy chcesz wczytac stan gry[t/n]?");
refresh();
char choice = getch();
if(choice == 'T' || choice =='t'){
printw("\nCzekaj na rywala...");
refresh();
Frame f;
f.setType(f.LOAD);
boost::asio::write(socket,boost::asio::buffer(f.getFrame(),10));
}else{
Frame f;
f.setType(f.BEGIN);
boost::asio::write(socket,boost::asio::buffer(f.getFrame(),10));
printw("\nCzekaj na rywala...");
refresh();
}
boost::asio::read(socket,boost::asio::buffer(buf,10));
Frame f(buf);
char p_char;
if(f.getType()==f.LOAD){
chart.loadChart(f.getChart());
boost::asio::read(socket,boost::asio::buffer(buf,10));
Frame f1(buf);
p_char = f1.getChar();
chart.setChar(p_char);
}else{
p_char = f.getChar();
chart.setChar(p_char);
chart.redraw();
}
move(1,0);
clrtoeol();
move(1,0);
printw("Grasz %c.",p_char);
move(8,0);
printw("Naciskajac odpowiedni klawisz wybierasz pole. Naciskajac 's' zapisujesz stan gry.");
refresh();
int c = '0';
while(c){
chart.printInfo("Czekaj na swoj ruch");
boost::asio::read(socket,boost::asio::buffer(buf,10),error);
//cout << error.message() <<endl;
chart.printInfo(error.message().c_str());
chart.printInfo("Twoj ruch");
refresh();
Frame f(buf);
if(f.getChar()!='1')
chart.markField(f.getChar(),f.getPos());
switch(f.getType()){
case f.END:
chart.printEnd(f.getWinner());
refresh();
getch();
//because of some errors
endwin();
exit(1);
c = 0;
break;
case f.TURN:
while(1){
c = getch();
if(c >= '1' && c <= '9' && chart.checkField(c-49)){
chart.markField(c,p_char);
Frame f;
f.setMove(f.MOVE,p_char,c);
//Wysłanie do serwera informacji o wybranym polu
boost::asio::write(socket,boost::asio::buffer(f.getFrame(),10));
chart.markField(p_char,c);
refresh();
break;
}else{
if(c == 's'){
Frame f;
f.setType(f.SAVE);
boost::asio::write(socket,boost::asio::buffer(f.getFrame(),10));
chart.printInfo("Gra zapisana - Twoj ruch");
//.........这里部分代码省略.........