-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoardPoint.cs
71 lines (60 loc) · 1.82 KB
/
BoardPoint.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
namespace Renju.Core
{
using System;
using System.ComponentModel;
using System.Diagnostics;
using Infrastructure;
using Infrastructure.Model;
[Serializable]
[DebuggerDisplay("[{Index}-({Position.X},{Position.Y}):{Status}]")]
public class BoardPoint : ModelBase, IReadOnlyBoardPoint
{
private int? _index;
private Side? _status = null;
private int _weight;
private bool _requireReevaluateWeight = false;
public BoardPoint(BoardPosition position)
{
Position = position;
}
[ReadOnly(true)]
public BoardPosition Position { get; private set; }
public int? Index
{
get { return _index; }
set { SetProperty(ref _index, value); }
}
public Side? Status
{
get { return _status; }
set { SetProperty(ref _status, value); }
}
public int Weight
{
get { return _weight; }
set { SetProperty(ref _weight, value); }
}
public bool RequiresReevaluateWeight
{
get { return _requireReevaluateWeight; }
set { SetProperty(ref _requireReevaluateWeight, value); }
}
public static Func<int, BoardPoint> CreateIndexBasedFactory(int size)
{
return index => new BoardPoint(new BoardPosition(index % size, index / size));
}
public override string ToString()
{
return string.Format("{0}{1}", Position, Status == null ? String.Empty : (Status.Value == Side.Black ? "●" : "○"));
}
public void ResetToEmpty()
{
Index = null;
Status = null;
}
protected override void OnConstructingNewObject()
{
/* Noop */
}
}
}