Skip to content

Commit

Permalink
Document the functions and variables (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Panquesito7 authored Oct 23, 2023
1 parent 9a99ffd commit eb7bb5e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/TicTacToe.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ namespace TicTacToe {

}
#pragma endregion
array<Button^>^ buttons = gcnew array<Button^>(11); // Array of buttons
// Array containing the buttons to place O and X.
array<Button^>^ buttons = gcnew array<Button^>(11);

private: System::Void button_click(System::Object^ sender, System::EventArgs^ e) { // Buttons to place O and X
is_match(sender, buttons, label2);
Expand Down
13 changes: 11 additions & 2 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@ using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

int turn = 0; // Whether to choose if the X or the O will place.
bool match_ended = false; // If the match has ended or not.
int turn = 0;
bool match_ended = false;

/**
* @brief The function to determine if it's a match or not
* Also updates the text of the buttons when clicking on them,
* the current turn, and a label that shows who's the winner.
* @param sender The item that triggered the event
* @param buttons An array containing various buttons
* @param label2 The label that shows who's the winner
* @return void
*/
void is_match(System::Object^ sender, array<Button^>^ buttons, Label^ label2) {
Button^ button = safe_cast<Button^>(sender);

Expand Down
4 changes: 2 additions & 2 deletions src/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#ifndef GAME_HPP
#define GAME_HPP

extern int turn;
extern bool match_ended;
extern int turn; // Whether to choose if the X or the O will place.
extern bool match_ended; // If the match has ended or not.

void is_match(System::Object^, array<System::Windows::Forms::Button^>^, System::Windows::Forms::Label^);

Expand Down
26 changes: 26 additions & 0 deletions src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/**
* @brief Shows the necessary buttons and labels that
* lets the user choose who's going to start first.
* This function can also hide those elements.
* @param turn_o The button that lets the user choose the O to start first
* @param turn_x The button that lets the user choose the X to start first
* @param label3 A label with the text "Who's going to start first?"
* @param backmodeselect A button that lets the user go back to the mode selection
* @param mode A boolean that determines if the elements should be shown or not
* @return void
*/
void choose_turn(Button^ turn_o, Button^ turn_x, Label^ label3, Button^ backmodeselect, bool mode) {
if (mode == true) {
turn_o->Enabled = true;
Expand All @@ -46,6 +57,21 @@ void choose_turn(Button^ turn_o, Button^ turn_x, Label^ label3, Button^ backmode
}
}

/**
* @brief Shows the necessary buttons and labels that
* lets the user choose the mode of the game.
* This function can also hide those elements, and show or hide
* the elements called in the `choose_turn` function.
* @param multiplayer_mode The button that will choose multiplayer as the current mode
* @param ai_mode The button that will choose A.I. as the current mode
* @param label4 A label with the text "Choose the mode of the game"
* @param turn_o The button that lets the user choose the O to start first
* @param turn_x The button that lets the user choose the X to start first
* @param backmodeselect A button that lets the user go back to the mode selection
* @param label3 A label with the text "Who's going to start first?"
* @param mode A boolean that determines if the elements should be shown or not
* @return void
*/
void choose_mode(Button^ multiplayer_mode, Button^ ai_mode, Label^ label4, Button^ turn_o, Button^ turn_x, Button^ backmodeselect, Label^ label3, bool mode) {
if (mode == true) {
multiplayer_mode->Enabled = true;
Expand Down

0 comments on commit eb7bb5e

Please sign in to comment.