Files
IPyConsole/Model/Player.cs

79 lines
1.6 KiB
C#
Raw Permalink Normal View History

2024-11-25 17:20:03 +08:00
using System.ComponentModel;
2024-11-28 17:41:35 +08:00
using System.Runtime.CompilerServices;
2024-11-22 17:52:55 +08:00
2024-11-25 17:20:03 +08:00
namespace Model
2024-11-22 17:52:55 +08:00
{
2024-11-25 17:20:03 +08:00
public class Player: INotifyPropertyChanged
2024-11-22 17:52:55 +08:00
{
private readonly int _id;
private string _name;
private object[] _contents = new object[10];
public int Id => _id;
public string Name
{
get { return _name; }
set
{
_name = value;
OnPropertyChanged(nameof(Name));
}
}
public object[] Contents
{
get { return _contents; }
set
{
if (value.Length == 10)
{
_contents = value;
2024-11-28 17:41:35 +08:00
OnPropertyChanged();
2024-11-22 17:52:55 +08:00
}
}
}
/// <summary>
/// Contents 索引器
/// </summary>
public object this[int index]
{
get
{
return Contents[index];
}
set
{
Contents[index] = value;
2024-11-28 17:41:35 +08:00
OnPropertyChanged();
2024-11-22 17:52:55 +08:00
}
}
public Player() { }
public Player(int id, string name)
{
_id = id;
Name = name;
}
public event PropertyChangedEventHandler? PropertyChanged;
2024-11-28 17:41:35 +08:00
public void OnPropertyChanged([CallerMemberName] string? name = null)
2024-11-22 17:52:55 +08:00
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
2024-11-29 17:53:12 +08:00
public enum PlayerStatus
{
Unknown,
Healthy,
UnHealthy
}
2024-11-22 17:52:55 +08:00
}