Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. void initBoard(Game &game, char *argv[])
  2. {
  3. string line, num, role, color;
  4. int sqr;
  5. ifstream boardstm ( argv[1] );
  6.  
  7. for (int i=0; i<game.board.numSquares; i++) {
  8. game.board.squares[ i ].slide.kind = REGULAR;
  9. game.board.squares[ i ].slide.color = NONE;
  10. }
  11.  
  12. if ( boardstm.is_open() )
  13. {
  14. getline (boardstm,line, ' ');
  15. getline (boardstm,line);
  16. game.board.numSquares = atoi( line.c_str() );
  17.  
  18. while ( boardstm.good() )
  19. {
  20. getline (boardstm, num, ' ');
  21. sqr = atoi( num.c_str() );
  22. getline (boardstm, role, ' ');
  23. getline (boardstm, color);
  24.  
  25. if ( role.compare( "BEGIN" ) == 0 )
  26. game.board.squares[ sqr ].slide.kind = BEGIN;
  27. else if ( role.compare( "END" ) == 0 )
  28. game.board.squares[ sqr ].slide.kind = END;
  29. else if ( role.compare( "STARTSQ" ) == 0 )
  30. game.board.squares[ sqr ].slide.kind = STARTSQ;
  31. else if ( role.compare( "HOMESQ" ) == 0 )
  32. game.board.squares[ sqr ].slide.kind = HOMESQ;
  33.  
  34.  
  35. if ( color.compare( "BLUE" ) == 0 )
  36. game.board.squares[ sqr ].slide.color = BLUE;
  37. else if ( color.compare( "YELLOW" ) == 0 )
  38. game.board.squares[ sqr ].slide.color = YELLOW;
  39. else if ( color.compare( "GREEN" ) == 0 )
  40. game.board.squares[ sqr ].slide.color = GREEN;
  41. else if ( color.compare( "RED" ) == 0 )
  42. game.board.squares[ sqr ].slide.color = RED;
  43.  
  44. }
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement