Develop and Download Open Source Software

Browse Subversion Repository

Diff of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 21 by yamat0jp, Sat Jul 18 22:36:44 2015 UTC revision 24 by yamat0jp, Sun Jul 19 01:35:48 2015 UTC
# Line 38  type Line 38  type
38      FTurnNumber: integer;      FTurnNumber: integer;
39      FTurnIndex: integer;      FTurnIndex: integer;
40      FActive: Boolean;      FActive: Boolean;
41      List: TList;      FList: TList;
42      FEffectStone: TStoneType;      FEffectStone: TStoneType;
43      FBool: Boolean;      FBool: Boolean;
44      FTerminated: Boolean;      FTerminated: Boolean;
# Line 105  type Line 105  type
105      procedure MenuItem10Click(Sender: TObject);      procedure MenuItem10Click(Sender: TObject);
106      procedure MenuItem11Click(Sender: TObject);      procedure MenuItem11Click(Sender: TObject);
107      procedure Timer2Timer(Sender: TObject);      procedure Timer2Timer(Sender: TObject);
108        procedure FormDeactivate(Sender: TObject);
109        procedure FormActivate(Sender: TObject);
110    private    private
111      { Private 宣言 }      { Private 宣言 }
112      StoneGrid: TStoneGrid;      StoneGrid: TStoneGrid;
# Line 136  begin Line 138  begin
138    if CanSetStone(Stone, X, Y, true) = true then    if CanSetStone(Stone, X, Y, true) = true then
139    begin    begin
140      case Stone of      case Stone of
141      stBlack:        stBlack:
142        Stone := stWhite;          Stone := stWhite;
143      stWhite:        stWhite:
144        Stone := stBlack;          Stone := stBlack;
145      stEffect:        stEffect:
146        Stone := FEffectStone;          Stone := FEffectStone;
147      end;      end;
148      result := 0;      result := 0;
149      for i := 0 to Count - 1 do      for i := 0 to Count - 1 do
# Line 175  var Line 177  var
177      begin      begin
178        s := GetStrings(X + m * i, Y + n * i);        s := GetStrings(X + m * i, Y + n * i);
179        if s = stEffect then        if s = stEffect then
180          s:=FEffectStone;          s := FEffectStone;
181        if (s = stNone) or (s = stError) then        if (s = stNone) or (s = stError) then
182          break          break
183        else if s = Stone then        else if s = Stone then
# Line 191  var Line 193  var
193                Form1.PaintBox1.Repaint;                Form1.PaintBox1.Repaint;
194                if Visible = true then                if Visible = true then
195                begin                begin
196                  FEffectStone:=Stone;                  FEffectStone := Stone;
197                  New(q);                  New(q);
198                  q^.Left := X + m * j;                  q^.Left := X + m * j;
199                  q^.Top := Y + n * j;                  q^.Top := Y + n * j;
200                  q^.Stone := Stone;                  q^.Stone := Stone;
201                  q^.X := 0;                  q^.X := 0;
202                  q^.Y := 0;                  q^.Y := 0;
203                  List.Add(q);                  FList.Add(q);
204                  SetStrings(q^.Left, q^.Top, stEffect);                  SetStrings(q^.Left, q^.Top, stEffect);
205                  for k := 1 to 100 do                  for k := 1 to 100 do
206                  begin                  begin
# Line 249  procedure TStoneGrid.Clear; Line 251  procedure TStoneGrid.Clear;
251  var  var
252    i, j: integer;    i, j: integer;
253  begin  begin
254      for i := 0 to FList.Count - 1 do
255        Dispose(FList[i]);
256      FList.Clear;
257    for i := 0 to Count - 1 do    for i := 0 to Count - 1 do
258      for j := 0 to Count - 1 do      for j := 0 to Count - 1 do
259        Strings[i, j] := stNone;        Strings[i, j] := stNone;
# Line 264  end; Line 269  end;
269  constructor TStoneGrid.Create;  constructor TStoneGrid.Create;
270  begin  begin
271    inherited;    inherited;
272    List := TList.Create;    FList := TList.Create;
273  end;  end;
274    
275  destructor TStoneGrid.Destroy;  destructor TStoneGrid.Destroy;
276  var  var
277    i: integer;    i: integer;
278  begin  begin
279    for i := 0 to List.Count - 1 do    for i := 0 to FList.Count - 1 do
280      Dispose(List[i]);      Dispose(FList[i]);
281    List.Free;    FList.Free;
282    inherited;    inherited;
283  end;  end;
284    
# Line 296  var Line 301  var
301    p: ^TEffectData;    p: ^TEffectData;
302    i: integer;    i: integer;
303  begin  begin
304    if List.Count = 0 then    if FList.Count = 0 then
305      result := false      result := false
306    else    else
307    begin    begin
308      for i := 0 to List.Count - 1 do      for i := 0 to FList.Count - 1 do
309      begin      begin
310        p := List.List[i];        p := FList[i];
311        if p^.X < FIndex_X - 1 then        if p^.X < FIndex_X - 1 then
312          p^.X := p^.X + 1          p^.X := p^.X + 1
313        else if p^.Y < FIndex_Y - 1 then        else if p^.Y < FIndex_Y - 1 then
# Line 314  begin Line 319  begin
319        begin        begin
320          SetStrings(p^.Left, p^.Top, p^.Stone);          SetStrings(p^.Left, p^.Top, p^.Stone);
321          Dispose(p);          Dispose(p);
322          List[i] := nil;          FList[i] := nil;
323        end;        end;
324      end;      end;
325      for i := List.Count - 1 downto 0 do      for i := FList.Count - 1 downto 0 do
326        if List[i] = nil then        if FList[i] = nil then
327          List.Delete(i);          FList.Delete(i);
328      if List.Count = 0 then      if FList.Count = 0 then
329      begin      begin
330        if FTerminated = true then        if FTerminated = true then
331          FActive:=false          FActive := false
332        else        else
333          FActive := FBool;          FActive := FBool;
334        inc(FTurnIndex);        inc(FTurnIndex);
# Line 363  begin Line 368  begin
368    m := Form1.Image3.Bitmap.Width;    m := Form1.Image3.Bitmap.Width;
369    n := Form1.Image3.Bitmap.Height;    n := Form1.Image3.Bitmap.Height;
370    k := Form1.Size;    k := Form1.Size;
371    for i := 0 to List.Count - 1 do    for i := 0 to FList.Count - 1 do
372    begin    begin
373      p := List[i];      p := FList[i];
374      if p^.Stone = stBlack then      if p^.Stone = stBlack then
375        s := Form1.Image1.Bitmap        s := Form1.Image1.Bitmap
376      else      else
# Line 378  end; Line 383  end;
383    
384  procedure TStoneGrid.Pause;  procedure TStoneGrid.Pause;
385  begin  begin
386    FTerminated:=true;    if FActive = true then
387        FActive := false;
388      FTerminated := true;
389  end;  end;
390    
391  procedure TStoneGrid.Restart;  procedure TStoneGrid.Restart;
# Line 387  begin Line 394  begin
394    begin    begin
395      FActive := true;      FActive := true;
396      FTurnIndex := FTurnNumber;      FTurnIndex := FTurnNumber;
397      FTerminated:=false;      FTerminated := false;
398    end;    end;
399  end;  end;
400    
# Line 411  end; Line 418  end;
418  procedure TStoneGrid.Start;  procedure TStoneGrid.Start;
419  begin  begin
420    Clear;    Clear;
421    FTerminated:=false;    FTerminated := false;
422    FActive := true;    FActive := true;
423  end;  end;
424    
# Line 451  var Line 458  var
458    end;    end;
459    
460  begin  begin
461      Timer1.Enabled:=false;
462    Main;    Main;
463    if Execute = false then    if Execute = false then
464    begin    begin
# Line 483  begin Line 491  begin
491    end    end
492    else    else
493      Caption := s;      Caption := s;
494      Timer1.Enabled:=true;
495  end;  end;
496    
497  procedure TForm1.CompStone;  procedure TForm1.CompStone;
# Line 497  end; Line 506  end;
506    
507  procedure TForm1.GameStart;  procedure TForm1.GameStart;
508  begin  begin
509      Timer1.Enabled:=false;
510    Index := Player1;    Index := Player1;
511    StoneGrid.Start;    StoneGrid.Start;
512    PaintBox1.Repaint;    PaintBox1.Repaint;
513    Caption := '黒から始めます';    Caption := '黒から始めます';
514      Timer1.Enabled:=true;
515  end;  end;
516    
517  procedure TForm1.MenuItem10Click(Sender: TObject);  procedure TForm1.MenuItem10Click(Sender: TObject);
# Line 590  begin Line 601  begin
601    Size := Min(ClientWidth, ClientHeight) div Count;    Size := Min(ClientWidth, ClientHeight) div Count;
602  end;  end;
603    
604    procedure TForm1.FormActivate(Sender: TObject);
605    begin
606      Timer1.Enabled := true;
607    end;
608    
609  procedure TForm1.FormCreate(Sender: TObject);  procedure TForm1.FormCreate(Sender: TObject);
610  begin  begin
611    StoneGrid := TStoneGrid.Create;    StoneGrid := TStoneGrid.Create;
# Line 610  begin Line 626  begin
626    GameStart;    GameStart;
627  end;  end;
628    
629    procedure TForm1.FormDeactivate(Sender: TObject);
630    begin
631      Timer1.Enabled := false;
632    end;
633    
634  procedure TForm1.FormDestroy(Sender: TObject);  procedure TForm1.FormDestroy(Sender: TObject);
635  begin  begin
636    StoneGrid.Free;    StoneGrid.Free;
# Line 631  end; Line 652  end;
652    
653  procedure TForm1.Timer2Timer(Sender: TObject);  procedure TForm1.Timer2Timer(Sender: TObject);
654  begin  begin
655    if (StoneGrid.Active = false)and(StoneGrid.ListExecute = true) then    if (StoneGrid.Active = false) and (StoneGrid.ListExecute = true) then
656      PaintBox1.Repaint;      PaintBox1.Repaint;
657  end;  end;
658    

Legend:
Removed from v.21  
changed lines
  Added in v.24

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26