• R/O
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonbathyscaphephpgamewindowsguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

オセロのゲーム


コミットメタ情報

リビジョン54 (tree)
日時2015-06-02 20:48:17
作者bellyoshi

ログメッセージ

変更サマリ

差分

--- VisualBasic/ReversiGame2/ReversiGame/frmCodes.Designer.vb (revision 53)
+++ VisualBasic/ReversiGame2/ReversiGame/frmCodes.Designer.vb (revision 54)
@@ -22,18 +22,18 @@
2222 'コード エディターを使って変更しないでください。
2323 <System.Diagnostics.DebuggerStepThrough()> _
2424 Private Sub InitializeComponent()
25- Me.ListBox1 = New System.Windows.Forms.ListBox()
25+ Me.lstCodes = New System.Windows.Forms.ListBox()
2626 Me.Button1 = New System.Windows.Forms.Button()
2727 Me.SuspendLayout()
2828 '
29- 'ListBox1
29+ 'lstCodes
3030 '
31- Me.ListBox1.FormattingEnabled = True
32- Me.ListBox1.ItemHeight = 15
33- Me.ListBox1.Location = New System.Drawing.Point(2, 2)
34- Me.ListBox1.Name = "ListBox1"
35- Me.ListBox1.Size = New System.Drawing.Size(271, 439)
36- Me.ListBox1.TabIndex = 0
31+ Me.lstCodes.FormattingEnabled = True
32+ Me.lstCodes.ItemHeight = 15
33+ Me.lstCodes.Location = New System.Drawing.Point(2, 2)
34+ Me.lstCodes.Name = "lstCodes"
35+ Me.lstCodes.Size = New System.Drawing.Size(271, 439)
36+ Me.lstCodes.TabIndex = 0
3737 '
3838 'Button1
3939 '
@@ -50,12 +50,12 @@
5050 Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
5151 Me.ClientSize = New System.Drawing.Size(298, 494)
5252 Me.Controls.Add(Me.Button1)
53- Me.Controls.Add(Me.ListBox1)
53+ Me.Controls.Add(Me.lstCodes)
5454 Me.Name = "frmCodes"
5555 Me.Text = "frmCodes"
5656 Me.ResumeLayout(False)
5757
5858 End Sub
59- Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
59+ Friend WithEvents lstCodes As System.Windows.Forms.ListBox
6060 Friend WithEvents Button1 As System.Windows.Forms.Button
6161 End Class
--- VisualBasic/ReversiGame2/ReversiGame/frmCodes.vb (revision 53)
+++ VisualBasic/ReversiGame2/ReversiGame/frmCodes.vb (revision 54)
@@ -1,3 +1,39 @@
1-Public Class frmCodes
1+Imports System.IO
22
3+Public Class frmCodes
4+ Public Property Board As Board
5+
6+ Private Sub frmCodes_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
7+ ShowCodes()
8+ End Sub
9+
10+ Public Sub ShowCodes()
11+ Dim codes As New List(Of Point)
12+ For Each log As ReverseLog In Board.UpdateLogs
13+ codes.Add(log.PutDisc)
14+ Next
15+ lstCodes.DataSource = codes
16+ lstCodes.DisplayMember = "ToString"
17+ End Sub
18+
19+ Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
20+ Dim codesLine As String = String.Empty
21+ For Each log As ReverseLog In Board.UpdateLogs
22+ codesLine += log.PutDisc.ToString
23+ Next
24+ Dim fileName As String = IOUtil.GetExePath + "/reversi.book"
25+ Try
26+ '書込むファイルを指定する
27+ '(2番目の引数をtrueにすることで既存ファイルに追記する)
28+ Dim sw As StreamWriter = New StreamWriter _
29+ (fileName, True, System.Text.Encoding.Default)
30+ 'ファイルに書込む
31+ sw.WriteLine(codesLine)
32+ sw.Flush()
33+ sw.Close()
34+ Catch ex As Exception
35+ Console.WriteLine("ファイルに書込めません:")
36+ Console.WriteLine(ex.Message)
37+ End Try
38+ End Sub
339 End Class
\ No newline at end of file
--- VisualBasic/ReversiGame2/ReversiGame/IOUtil.vb (nonexistent)
+++ VisualBasic/ReversiGame2/ReversiGame/IOUtil.vb (revision 54)
@@ -0,0 +1,50 @@
1+Public Class IOUtil
2+ ''' <summary>
3+ ''' ディレクトリを作成する。
4+ ''' </summary>
5+ ''' <param name="path"></param>
6+ ''' <returns>作成に成功したらTure 失敗したらFlase</returns>
7+ ''' <remarks></remarks>
8+ Public Shared Function CreateDirectoryIfNotExist(ByVal path As String) As Boolean
9+ If Not System.IO.File.Exists(path) Then
10+ Try
11+ System.IO.Directory.CreateDirectory(path)
12+ Catch ex As Exception
13+ ' Log.Err("Can Not Create Directory:" & path)
14+ Return False
15+ End Try
16+ End If
17+ Return True
18+ End Function
19+
20+ ''' <summary>
21+ ''' フォルダの中にあるファイル名の一覧を返す。
22+ ''' </summary>
23+ ''' <param name="directoryPath"></param>
24+ ''' <returns></returns>
25+ ''' <remarks></remarks>
26+ Public Shared Function GetFileNames(ByVal directoryPath As String) As IList(Of String)
27+ Dim fileFullPathNames As String() = System.IO.Directory.GetFiles(
28+ directoryPath, "*", System.IO.SearchOption.TopDirectoryOnly)
29+ Dim fileNames As New List(Of String)
30+ For Each path As String In fileFullPathNames
31+ fileNames.Add(IO.Path.GetFileName(path))
32+ Next
33+ Return fileNames
34+ End Function
35+
36+ ''' <summary>
37+ ''' 現在の実行ファイルのパスを開く
38+ ''' </summary>
39+ ''' <returns></returns>
40+ ''' <remarks></remarks>
41+ Public Shared Function GetExePath() As String
42+ Dim exeName As String = System.Reflection.Assembly.GetEntryAssembly().Location
43+ Return System.IO.Path.GetDirectoryName(exeName)
44+ End Function
45+
46+ Public Shared Function GetDirectryFileNames(ByVal path As String, searchPattern As String) As String()
47+ Return System.IO.Directory.GetFiles(path, searchPattern, System.IO.SearchOption.TopDirectoryOnly)
48+ End Function
49+
50+End Class
--- VisualBasic/ReversiGame2/ReversiGame/Board.vb (revision 53)
+++ VisualBasic/ReversiGame2/ReversiGame/Board.vb (revision 54)
@@ -33,6 +33,11 @@
3333 End Property
3434
3535 Protected _updateLogs As New List(Of ReverseLog)
36+ Public ReadOnly Property UpdateLogs As IList(Of ReverseLog)
37+ Get
38+ Return _updateLogs
39+ End Get
40+ End Property
3641
3742 Private _movableDir(MAX_TURNS, SIZE_X + 1, SIZE_Y + 1) As Direction
3843 Private _movablePos(MAX_TURNS) As List(Of Point)
--- VisualBasic/ReversiGame2/ReversiGame/frmMain.Designer.vb (revision 53)
+++ VisualBasic/ReversiGame2/ReversiGame/frmMain.Designer.vb (revision 54)
@@ -29,6 +29,7 @@
2929 Me.btnNew = New System.Windows.Forms.Button()
3030 Me.Button1 = New System.Windows.Forms.Button()
3131 Me.Button2 = New System.Windows.Forms.Button()
32+ Me.btnCodes = New System.Windows.Forms.Button()
3233 CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
3334 Me.SuspendLayout()
3435 '
@@ -82,11 +83,21 @@
8283 Me.Button2.Text = "2手戻す"
8384 Me.Button2.UseVisualStyleBackColor = True
8485 '
86+ 'btnCodes
87+ '
88+ Me.btnCodes.Location = New System.Drawing.Point(522, 12)
89+ Me.btnCodes.Name = "btnCodes"
90+ Me.btnCodes.Size = New System.Drawing.Size(89, 23)
91+ Me.btnCodes.TabIndex = 4
92+ Me.btnCodes.Text = "棋譜表示"
93+ Me.btnCodes.UseVisualStyleBackColor = True
94+ '
8595 'frmMain
8696 '
8797 Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 15.0!)
8898 Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
8999 Me.ClientSize = New System.Drawing.Size(650, 542)
100+ Me.Controls.Add(Me.btnCodes)
90101 Me.Controls.Add(Me.Button2)
91102 Me.Controls.Add(Me.Button1)
92103 Me.Controls.Add(Me.btnNew)
@@ -105,5 +116,6 @@
105116 Friend WithEvents btnNew As System.Windows.Forms.Button
106117 Friend WithEvents Button1 As System.Windows.Forms.Button
107118 Friend WithEvents Button2 As System.Windows.Forms.Button
119+ Friend WithEvents btnCodes As System.Windows.Forms.Button
108120
109121 End Class
--- VisualBasic/ReversiGame2/ReversiGame/frmMain.vb (revision 53)
+++ VisualBasic/ReversiGame2/ReversiGame/frmMain.vb (revision 54)
@@ -1,6 +1,6 @@
11 Public Class frmMain
22 Private Property CellSize As Integer = 40
3-
3+ Private _frmCode As New frmCodes
44 Private _nowBoard As New Board
55 Private _computerAIPlayer1 As computerPlayer
66 Private _computerAIPlayer2 As computerPlayer
@@ -76,11 +76,18 @@
7676 End If
7777 If _nowBoard.CanMove(x, y) Then
7878 _nowBoard.Move(New Point(x, y))
79- PictureBox1.Invalidate()
79+ frmReflesh()
8080 TurnChangeAndDecideGameWinner()
8181 End If
8282 End Sub
8383
84+ Private Sub frmReflesh()
85+ If _nowBoard IsNot Nothing AndAlso _frmCode IsNot Nothing AndAlso Not _frmCode.IsDisposed Then
86+ _frmCode.Board = _nowBoard
87+ _frmCode.ShowCodes()
88+ End If
89+ PictureBox1.Invalidate()
90+ End Sub
8491 Private Sub TurnChangeAndDecideGameWinner()
8592 If _nowBoard.IsGameEnd Then
8693 Dim whiteCount As Integer = _nowBoard.StoneCount(DiscColor.WHITE)
@@ -110,6 +117,7 @@
110117
111118
112119 Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
120+ _frmCode.Board = _nowBoard
113121 _computerAIPlayer1 = New computerPlayer
114122 _computerAIPlayer2 = New computerPlayer
115123
@@ -124,7 +132,7 @@
124132 If Not _nowBoard.IsGameEnd Then
125133 If _nowBoard.CurrentColor = _computerAIPlayer1.MyColor Then
126134 _computerAIPlayer1.DoPut(_nowBoard)
127- PictureBox1.Invalidate()
135+ frmReflesh()
128136 TurnChangeAndDecideGameWinner()
129137 End If
130138 End If
@@ -137,7 +145,7 @@
137145 If Not _nowBoard.IsGameEnd Then
138146 If _nowBoard.CurrentColor = _computerAIPlayer2.MyColor Then
139147 _computerAIPlayer2.DoPut(_nowBoard)
140- PictureBox1.Invalidate()
148+ frmReflesh()
141149 TurnChangeAndDecideGameWinner()
142150 End If
143151 End If
@@ -153,7 +161,7 @@
153161 PictureBox1.Height = Me.Width - 50
154162 PictureBox1.Width = Me.Width - 50
155163 End If
156- PictureBox1.Invalidate()
164+ frmReflesh()
157165 End Sub
158166
159167 Private Sub btnPlayer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlayer.Click
@@ -179,15 +187,14 @@
179187 Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
180188 ShowPlayerChange()
181189 _nowBoard = New Board
182- PictureBox1.Invalidate()
190+ frmReflesh()
183191 End Sub
184192
185193 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
186194 If _nowBoard.CanUndo Then
187195 _nowBoard.Undo()
196+ frmReflesh()
188197 End If
189-
190- PictureBox1.Invalidate()
191198 End Sub
192199
193200 Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
@@ -196,7 +203,13 @@
196203 If _nowBoard.CanUndo() Then
197204 _nowBoard.Undo()
198205 End If
206+ frmReflesh()
199207 End If
200- PictureBox1.Invalidate()
201208 End Sub
209+
210+ Private Sub btnCodes_Click(sender As System.Object, e As System.EventArgs) Handles btnCodes.Click
211+
212+ _frmCode.Show()
213+
214+ End Sub
202215 End Class