using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Jogo_da_velha
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class Global
{
public static bool turn, button_disable;
public static int player1_wins = 0, player2_wins = 0, tie = 0, rounds = 0, A = 0, B = 0, C = 0, D = 0,
E = 0, F = 0, G = 0, H = 0, I = 0;
}
private void button1_Click(object sender, EventArgs e)
{
// Verificação da jogada do player 1(X):
if (Global.turn == false && Global.button_disable == false && Global.A == 0)
{
button1.Text = "X";
Global.A = 1;
Global.rounds++;
checkingWinner();
Global.turn = true;
}
// Verificação da jogada do player 2(O):
if (Global.turn == true && Global.button_disable == false && Global.A == 0)
{
button1.Text = "O";
Global.A = 2;
Global.rounds++;
checkingWinner();
Global.turn = false;
}
}
private void checkingWinner()
{
}
private void button2_Click(object sender, EventArgs e)
{
if (Global.turn == false && Global.button_disable == false && Global.B == 0)
{
button2.Text = "X";
Global.B = 1;
Global.rounds++;
checkingWinner();
Global.turn = true;
}
if (Global.turn == true && Global.button_disable == false && Global.B == 0)
{
button2.Text = "O";
Global.B = 2;
Global.rounds++;
checkingWinner();
Global.turn = false;
}
}
private void button3_Click(object sender, EventArgs e)
{
if (Global.turn == false && Global.button_disable == false && Global.C == 0)
{
button3.Text = "X";
Global.C = 1;
Global.rounds++;
checkingWinner();
Global.turn = true;
}
if (Global.turn == true && Global.button_disable == false && Global.C == 0)
{
button3.Text = "O";
Global.C = 2;
Global.rounds++;
checkingWinner();
Global.turn = false;
}
}
private void button4_Click(object sender, EventArgs e)
{
if (Global.turn == false && Global.button_disable == false && Global.D == 0)
{
button4.Text = "X";
Global.D = 1;
Global.rounds++;
checkingWinner();
Global.turn = true;
}
if (Global.turn == true && Global.button_disable == false && Global.D == 0)
{
button4.Text = "O";
Global.D = 2;
Global.rounds++;
checkingWinner();
Global.turn = false;
}
}
private void button5_Click(object sender, EventArgs e)
{
if (Global.turn == false && Global.button_disable == false && Global.E == 0)
{
button5.Text = "X";
Global.E = 1;
Global.rounds++;
checkingWinner();
Global.turn = true;
}
if (Global.turn == true && Global.button_disable == false && Global.E == 0)
{
button5.Text = "O";
Global.E = 2;
Global.rounds++;
checkingWinner();
Global.turn = false;
}
}
private void button6_Click(object sender, EventArgs e)
{
if (Global.turn == false && Global.button_disable == false && Global.F == 0)
{
button6.Text = "X";
Global.F = 1;
Global.rounds++;
checkingWinner();
Global.turn = true;
}
if (Global.turn == true && Global.button_disable == false && Global.F == 0)
{
button6.Text = "O";
Global.F = 2;
Global.rounds++;
checkingWinner();
Global.turn = false;
}
}
private void button7_Click(object sender, EventArgs e)
{
if (Global.turn == false && Global.button_disable == false && Global.G == 0)
{
button7.Text = "X";
Global.G = 1;
Global.rounds++;
checkingWinner();
Global.turn = true;
}
if (Global.turn == true && Global.button_disable == false && Global.G == 0)
{
button7.Text = "O";
Global.G = 2;
Global.rounds++;
checkingWinner();
Global.turn = false;
}
}
private void button8_Click(object sender, EventArgs e)
{
if (Global.turn == false && Global.button_disable == false && Global.H == 0)
{
button8.Text = "X";
Global.H = 1;
Global.rounds++;
checkingWinner();
Global.turn = true;
}
if (Global.turn == true && Global.button_disable == false && Global.H == 0)
{
button8.Text = "O";
Global.H = 2;
Global.rounds++;
checkingWinner();
Global.turn = false;
}
}
private void button9_Click(object sender, EventArgs e)
{
if (Global.turn == false && Global.button_disable == false && Global.I == 0)
{
button9.Text = "X";
Global.I = 1;
Global.rounds++;
checkingWinner();
Global.turn = true;
}
if (Global.turn == true && Global.button_disable == false && Global.I == 0)
{
button9.Text = "O";
Global.I = 2;
Global.rounds++;
checkingWinner();
Global.turn = false;
}
}
}
}