カットできるリスト。
とりこびと ぶろぐ。:混ざるかな?
なんか引っこ抜いて、上にのっけるあたりが気持ち悪い(見た目にも両手に存在するタイミングがある感じ)なので
引っこ抜けるリスト作ってごまかしてみた。
引っこ抜く:引っこ抜いたリストを返し、元のリストから削除する。
もとのディーラーの実装はこうなる↓。
Public Class CuttableList(Of T)
Inherits System.Collections.Generic.List(Of T)
Public Function CutOut(ByVal index As Integer, ByVal count As Integer) As CuttableList(Of T)
Dim list As New CuttableList(Of T)
list.AddRange(Me.GetRange(index, count))
Me.RemoveRange(index, count)Return list
End Function
Public Function CutOutAll() As CuttableList(Of T)
Dim list As New CuttableList(Of T)
list.AddRange(Me)
Me.Clear()Return list
End Function
End Class
Public Class TorikobiDealer
Inherits AbstractDealer
Public Overrides Sub Shuffle()
Dim leftHand As CuttableList(Of PlayingCard) = Me.Deck
Dim rightHand As New CuttableList(Of PlayingCard)Dim r As New Random()
For i As Integer = 0 To 100
Dim cutStartIndex As Integer = r.Next(Deck.Count)
Dim cutEndIndex As Integer = r.Next(cutStartIndex, Deck.Count)' 引っこ抜いて
rightHand = leftHand.CutOut(cutStartIndex, cutEndIndex - cutStartIndex)
' 上にのっける。
leftHand.InsertRange(0, rightHand.CutOutAll)Next
End Sub
End Class
自己満足以外のナニモノでもない・・・。orz