-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathToken.cs
191 lines (165 loc) · 5.46 KB
/
Token.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
namespace pdachess
{
class Token
{
protected int po_x, po_y;
protected Image img_l = null, img_d = null, img_l_p = null, img_d_p = null, img_l_s = null, img_d_s = null;
protected string side;
private bool initial;
public Token(int x, int y, string side, Image img_l, Image img_d, Image img_l_p, Image img_d_p, Image img_l_s, Image img_d_s)
{
this.po_x = x;
this.po_y = y;
this.img_l = img_l;
this.img_d = img_d;
this.img_l_p = img_l_p;
this.img_d_p = img_d_p;
this.img_l_s = img_l_s;
this.img_d_s = img_d_s;
this.side = side;
initial = true;
}
public virtual string getType() { return null; }
public string getSide() { return side; }
public virtual void setmove(int x,int y)
{
po_x = x;
po_y = y;
if (initial == true) initial = false;
}
public void draw(Graphics g)
{
// Point p=new Point(po_x*30-4,po_y*30-5);
// g.DrawImage(img, p);
// g.DrawImage(img, po_x * 30 , po_y * 30 , 30, 30);
// g.DrawImage(img, new Rectangle(po_x * 30, po_y * 30, 30, 30), new Rectangle(0, 0, 30, 30), GraphicsUnit.Pixel);
if((po_x+po_y)%2==0)
g.DrawImage(img_d, po_x * 60, po_y * 60);
else
g.DrawImage(img_l, po_x * 60, po_y * 60);
}
public void draw(Graphics g, string param)
{
switch (param)
{
case "p":
g.DrawImage(((po_x + po_y) % 2 == 0) ? img_d_p : img_l_p, po_x * 60, po_y * 60);
break;
case "s":
g.DrawImage(((po_x + po_y) % 2 == 0) ? img_d_s : img_l_s, po_x * 60, po_y * 60);
break;
}
}
public bool isHere(int x, int y)
{ return (x == po_x && y == po_y); }
public int getX()
{
return po_x;
}
public int getY()
{
return po_y;
}
public bool isFirstmove() { return initial; }
public virtual object Clone()
{
return null;
}
}
class Pawn:Token
{
public Pawn(int x, int y, string side, Image img_l, Image img_d, Image img_l_p, Image img_d_p, Image img_l_s, Image img_d_s)
: base(x, y,side,img_l, img_d, img_l_p, img_d_p, img_l_s, img_d_s)
{
}
public override string getType()
{
return "Pawn";
}
public override object Clone()
{
return new Pawn(po_x, po_y, side, img_l, img_d, img_l_p, img_d_p, img_l_s, img_d_s);
}
}
class Knight : Token
{
public Knight(int x, int y, string side, Image img_l, Image img_d, Image img_l_p, Image img_d_p, Image img_l_s, Image img_d_s)
: base(x, y, side, img_l, img_d, img_l_p, img_d_p, img_l_s, img_d_s)
{
}
public override string getType()
{
return "Knight";
}
public override object Clone()
{
return new Knight(po_x, po_y, side, img_l, img_d, img_l_p, img_d_p, img_l_s, img_d_s);
}
}
class Queen : Token
{
public Queen(int x, int y, string side, Image img_l, Image img_d, Image img_l_p, Image img_d_p, Image img_l_s, Image img_d_s)
: base(x, y, side, img_l, img_d, img_l_p, img_d_p, img_l_s, img_d_s)
{
}
public override string getType()
{
return "Queen";
}
public override object Clone()
{
return new Queen(po_x, po_y, side, img_l, img_d, img_l_p, img_d_p, img_l_s, img_d_s);
}
}
class Castle : Token
{
public Castle(int x, int y, string side, Image img_l, Image img_d, Image img_l_p, Image img_d_p, Image img_l_s, Image img_d_s)
: base(x, y, side, img_l, img_d, img_l_p, img_d_p, img_l_s, img_d_s)
{
}
public override string getType()
{
return "Castle";
}
public override object Clone()
{
return new Castle(po_x, po_y, side, img_l, img_d, img_l_p, img_d_p, img_l_s, img_d_s);
}
}
class Bishop : Token
{
public Bishop(int x, int y, string side, Image img_l, Image img_d, Image img_l_p, Image img_d_p, Image img_l_s, Image img_d_s)
: base(x, y, side, img_l, img_d, img_l_p, img_d_p, img_l_s, img_d_s)
{
}
public override string getType()
{
return "Bishop";
}
public override object Clone()
{
return new Bishop(po_x, po_y, side, img_l, img_d, img_l_p, img_d_p, img_l_s, img_d_s);
}
}
class King : Token
{
public King(int x, int y, string side, Image img_l, Image img_d, Image img_l_p, Image img_d_p, Image img_l_s, Image img_d_s)
: base(x, y, side, img_l, img_d, img_l_p, img_d_p, img_l_s, img_d_s)
{
}
public override string getType()
{
return "King";
}
public override object Clone()
{
return new King(po_x, po_y, side, img_l, img_d, img_l_p, img_d_p, img_l_s, img_d_s);
}
}
}