void AddRun(TRuns Runs, int dir) { TCell Near; TCheck Who; TCheck W2; TRun R2; Near = Pos.Near(dir); if (Pole.Who(Near, out Who)) { if (Who == null) { Runs.Add(new TRun(this, Near)); } else { if (Who.C != C) { Near = Who.Pos.Near(dir); if (Pole.Who(Near, out W2)) { if (W2 == null) { R2 = new TRun(this, Near); R2.Killed.Add(Who); Runs.Add(R2); } } } } } }
private void cmClick(object sender, MouseButtonEventArgs e) { Point XY = e.GetPosition(gPole); TCell Z = Pole.GetCell(XY); if (CheckFor == null) { Pole.Who(Z, out CheckFor); if (CheckFor == null) { return; } if (CheckFor.C != WB.W) { CheckFor = null; return; } } else { ArrayList arr = new ArrayList(); TRun Run = new TRun(CheckFor, Z); TRuns Runs; TRuns RunsKill; for (int n = 0; n < Pole.CW.Count; n++) { RunsKill = Pole.CW[n].GetRunsKill(Pole); for (int k = 0; k < RunsKill.Count; k++) { arr.Add(RunsKill[k]); } } if (arr.Count > 0) { for (int k = 0; k < arr.Count; k++) { TRun R = (TRun)arr[k]; if ((Run.Check.Pos.Eq(R.Check.Pos)) && (Run.PosTo.Eq(R.PosTo))) { R.Check.Run(Pole, R); IsW = !IsW; cmRun(null, null); CheckFor = null; return; } } CheckFor = null; return; } else { arr.Clear(); for (int n = 0; n < Pole.CW.Count; n++) { Runs = Pole.CW[n].GetRuns(Pole); for (int k = 0; k < Runs.Count; k++) { arr.Add(Runs[k]); } } if (arr.Count > 0) { for (int k = 0; k < arr.Count; k++) { TRun R = (TRun)arr[k]; if ((Run.Check.Pos.Eq(R.Check.Pos)) && (Run.PosTo.Eq(R.PosTo))) { R.Check.Run(Pole, R); IsW = !IsW; cmRun(null, null); CheckFor = null; return; } } CheckFor = null; return; } else { IsGame = false; WB Cx; if (IsW) { Cx = WB.W; } else { Cx = WB.B; } Pole.GameOver(Cx); Pole = new TPole(gPole); } } } }
public TCell NearDama(int dir, TPole Pole) { TNote B_ = B; int n_ = n; TCheck Who; if (dir == 1) { while ((B_ != TNote.A) && (n_ != 8)) { B_ = B_ - 1; n_ = n_ + 1; Pole.Who(new TCell(B_, n_), out Who); if (Who != null) { return(new TCell(B_, n_)); } } } if (dir == 2) { while ((B_ != TNote.H) && (n_ != 8)) { B_ = B_ + 1; n_ = n_ + 1; Pole.Who(new TCell(B_, n_), out Who); if (Who != null) { return(new TCell(B_, n_)); } } } if (dir == 3) { while ((B_ != TNote.A) && (n_ != 1)) { B_ = B_ - 1; n_ = n_ - 1; Pole.Who(new TCell(B_, n_), out Who); if (Who != null) { return(new TCell(B_, n_)); } } } if (dir == 4) { while ((B_ != TNote.H) && (n_ != 1)) { B_ = B_ + 1; n_ = n_ - 1; Pole.Who(new TCell(B_, n_), out Who); if (Who != null) { return(new TCell(B_, n_)); } } } return(null); }
public TCell[] NearsDama(int dir, TPole Pole) { ArrayList arr = new ArrayList(8); TNote B_ = B; int n_ = n; arr.Add(new TCell(B_, n)); TCheck Who; if (dir == 1) { while ((B_ != TNote.A) && (n_ != 8)) { B_ = B_ - 1; n_ = n_ + 1; Pole.Who(new TCell(B_, n_), out Who); if (Who == null) { arr.Add(new TCell(B_, n_)); } else { break; } } } if (dir == 2) { while ((B_ != TNote.H) && (n_ != 8)) { B_ = B_ + 1; n_ = n_ + 1; Pole.Who(new TCell(B_, n_), out Who); if (Who == null) { arr.Add(new TCell(B_, n_)); } else { break; } } } if (dir == 3) { while ((B_ != TNote.A) && (n_ != 1)) { B_ = B_ - 1; n_ = n_ - 1; Pole.Who(new TCell(B_, n_), out Who); if (Who == null) { arr.Add(new TCell(B_, n_)); } else { break; } } } if (dir == 4) { while ((B_ != TNote.H) && (n_ != 1)) { B_ = B_ + 1; n_ = n_ - 1; Pole.Who(new TCell(B_, n_), out Who); if (Who == null) { arr.Add(new TCell(B_, n_)); } else { break; } } } TCell[] Res = null; if (arr.Count > 0) { Res = new TCell[arr.Count]; for (int i = 0; i < arr.Count; i++) { Res[i] = (TCell)arr[i]; } } return(Res); }