complete, step before doing ai

This commit is contained in:
maxwes08
2025-10-14 10:40:53 +02:00
parent 3a2ffc69f0
commit 6662b92891
5 changed files with 515 additions and 39 deletions

56
Box.cs Normal file
View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace TicTacToe
{
public class Box
{
public Action<int> Pressed;
public int Index;
public bool BotOwned = false;
private Button _button;
public bool Filled = false;
public Box(Button button, int index)
{
_button = button;
Index = index;
button.Click += Clicked;
_button.Text = "";
}
private void Clicked(object sender, EventArgs e)
{
Pressed.Invoke(Index);
}
public void Destroy()
{
_button.Text = "";
_button.Click -= Clicked;
}
public void SetEnabled(bool value)
{
_button.Enabled = value;
}
public void PlayerClaim(bool bot)
{
Filled = true;
BotOwned = bot;
if (bot)
{
_button.Text = "O";
}
else
{
_button.Text = "X";
}
}
}
}