//Constructor for the Subwindow class actionMenu::actionMenu(QWidget *parent) : QWidget(parent) { QPushButton *button1 = new QPushButton(tr("Move")); button1->setFont(QFont("Times", 18, QFont::Bold)); QPushButton *button2 = new QPushButton(tr("Attack")); button2->setFont(QFont("Times", 18, QFont::Bold)); QPushButton *button3 = new QPushButton(tr("Special")); button3->setFont(QFont("Times", 18, QFont::Bold)); QPushButton *button4 = new QPushButton(tr("Other")); button4->setFont(QFont("Times", 18, QFont::Bold)); connect(button1, SIGNAL(clicked()), this, SIGNAL(moveOrder())); connect(button2, SIGNAL(clicked()), this, SIGNAL(attackOrder())); QGridLayout *gridLayout = new QGridLayout; gridLayout->addWidget(button1, 0, 0); gridLayout->addWidget(button2, 1, 0); gridLayout->addWidget(button3, 2, 0); gridLayout->addWidget(button4, 3, 0); setLayout(gridLayout); }
int turn(board_t *board) { int attack_lane, put_lane, put_num, i, check_card; switch(turn_options()) { case 1: i = 0; check_card=0; while(i < NUM_OF_CARDS_IN_HAND) { ++i; if((board->p[P_ONE].hand[i].name[0]!='\0')&&(board->p[P_ONE].hand[i].force!=0)&& (board->p[P_ONE].hand[i].life!=0)&&(board->p[P_ONE].hand[i].cost!=0)&& (board->p[P_ONE].hand[i].cost <= board->p[P_ONE].manapool.current_mana)) { check_card=1; break; } } if(check_card==0) { printf("Not enough mana\n"); break; } printf("Choose a lane\n"); while(1) { put_lane = validate_input(1, 5); // if the lane is not taken if(is_card_empty(board->lanes[P_ONE][put_lane-1])) { break; } printf("This line is taken.\n"); } --put_lane; // the counting is 1-based while(1) { print_hand(board->p[P_ONE]); printf("Choose number of corresponding card\n"); put_num = validate_input(1, num_of_cards_in_hand(board->p[P_ONE])); --put_num; // the actual game uses 0-based counting // mostly needed for when this function is used for the AI if(can_play_card(board, P_ONE, get_card_from_hand(&board->p[P_ONE], put_num), put_lane)) { break; } sleep(2); } play_card(board, P_ONE, get_card_from_hand(&board->p[P_ONE], put_num), put_lane); break; case 2: // yep, empty case; SUE ME mwahahaha break; case 3: return 1; case 4: switch(shuffleChoice()) { case 1: { if(RandomShuffling(&(board->p[P_ONE].deck))) { file_save(&(board->p[P_ONE].deck)); } break; } case 2: { if(manaOrder(&(board->p[P_ONE].deck))) { file_save(&(board->p[P_ONE].deck)); } break; } case 3: { if(lifeOrder(&(board->p[P_ONE].deck))) { file_save(&(board->p[P_ONE].deck)); } break; } case 4: { if(attackOrder(&(board->p[P_ONE].deck))) { file_save(&(board->p[P_ONE].deck)); } break; } case 5: { if(costattackOrder(&(board->p[P_ONE].deck))) { file_save(&(board->p[P_ONE].deck)); } break; } } break; } return 0; }
int main () { srand(time(NULL)); board_t *board = NULL; /*int finished = 0; char blank[255]; while(!finished) { write(1,"\E[H\E[2J",7); print_menu(); int option = validate_input(1, 4); switch(option) { case 1: */ board = (board_t*)malloc(sizeof(board_t)); init_deck(&board->p[P_ONE].deck); load_deck(&board->p[P_ONE].deck, "player_deck.csv"); switch(shuffleChoice()){ case 1:{ if(RandomShuffling(&(board->p[P_ONE].deck))){ file_save(&(board->p[P_ONE].deck)); //printf("ns\n"); } break; } case 2:{ if(manaOrder(&(board->p[P_ONE].deck))){ file_save(&(board->p[P_ONE].deck)); } break; } case 3:{ if(lifeOrder(&(board->p[P_ONE].deck))){ file_save(&(board->p[P_ONE].deck)); } break; } case 4:{ if(attackOrder(&(board->p[P_ONE].deck))){ file_save(&(board->p[P_ONE].deck)); } break; } case 5:{ if(costattackOrder(&(board->p[P_ONE].deck))){ file_save(&(board->p[P_ONE].deck)); } break; } } //printf("ns\n"); //printf("ls\n"); init_deck(&board->p[P_TWO].deck); load_deck(&board->p[P_TWO].deck, "enemy_deck.csv"); //printf("ns\n"); //printf("ls\n"); // the board inits the player and the player needs a deck /*board_init(board); printf("ls\n"); if(rand() % 2 == 0) { printf("The enemy goes first!\n"); sleep(2); write(1,"\E[H\E[2J",7); turn_begin(&board->p[P_TWO]); print_field(*board); sleep(1); write(1,"\E[H\E[2J",7); enemy_AI(board); write(1,"\E[H\E[2J",7); print_field(*board); sleep(1); printf("\nEnemy's turn is over!\n"); //--board.p[P_TWO].manapool.max_mana; // the turn_begin function //--board.p[P_TWO].manapool.current_mana; // increments these } else { printf("The player goes first!\n"); sleep(2); } write(1,"\E[H\E[2J",7); int i; while(1) { turn_begin(&board->p[P_ONE]); turn_begin(&board->p[P_TWO]); print_field(*board); printf("\nGo, go, go!! :)\n"); if(turn(board)) { break; } write(1,"\E[H\E[2J",7); print_field(*board); sleep(1); printf("\nPlayer's turn is over!\n"); sleep(2); enemy_AI(board); write(1,"\E[H\E[2J",7); print_field(*board); sleep(1); printf("\nEnemy's turn is over!\n"); sleep(2); turn_attacks(board); printf("End-of-turn attacks!\n"); if(is_player_dead(board->p[P_ONE])) { printf("Game over! \nThe player is dead!\n"); break; } if(is_player_dead(board->p[P_TWO])) { printf("Game over! \nThe enemy is dead!\n"); break; } sleep(2); write(1,"\E[H\E[2J",7); } free(board); break; case 2: write(1,"\E[H\E[2J",7); read_file("instructions.txt"); printf("\n\nEnter anything to go back to the main menu.\n"); scanf("%s", blank); break; case 3: write(1,"\E[H\E[2J",7); read_file("about.txt"); printf("\nEnter anything to go back to the main menu.\n"); scanf("%s", blank); break; case 4: printf("Thank you for using this software! Please call us to get your free Awesome Person certificate!\n"); finished = 1; break; } }*/ return 0; }