Exemplo n.º 1
0
        /// <summary>
        /// ターンを追加する
        /// </summary>
        /// <param name="data">Hashtable 型の構造解析データ</param>
        private void AddParsedTurn(List<Hashtable> data)
        {
            try
            {
                // 現在のターン
                int nowTurn = int.Parse(data[0]["turn"].ToString());

                Turn turn = new Turn();
                Ball ball = new Ball();

                // 既に指定されたターン数があれば playmode のみ引き継ぎ
                if (GetExistTurn(nowTurn))
                {
                    // 既にあるターンを取得
                    Turn existTurn = GetTurn(nowTurn);

                    // playmode のみ引き継ぎ
                    turn.SetPlaymode(existTurn.GetPlaymode());
                }
                else
                    // 指定されていなければ前のターンから playmode を取得
                {
                    // 3000 ターンが無い場合などの対処
                    // 2999 → 3001
                    int i = 0;
                    while (true)
                    {
                        i++;
                        if (GetExistTurn(nowTurn - i))
                        {
                            break;
                        }
                    }
                    turn.SetPlaymode(turns[nowTurn - i].GetPlaymode());
                }

                // 現在のターンをセット
                turn.SetTurn(nowTurn);

                // ボールの状態を格納
                ball = ConvertBall(data[0]);
                turn.SetBall(ball);

                // 先頭にあるボールの配列を削除
                data.RemoveAt(0);

                // player データを格納
                foreach (var ht in data)
                {
                    Player player = new Player();
                    player = ConvertPlayer(ht);

                    // チームに分別
                    switch (ht["team"].ToString())
                    {
                        case "l":
                            turn.AddLeftPlayer(player);
                            break;
                        case "r":
                            turn.AddRightPlayer(player);
                            break;
                        default:
                            throw new FormatException();
                    }
                }

                turns[turn.GetTurn()] = turn;
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// parsed Hashtable のデータを Ball 型へ変換
 /// </summary>
 /// <param name="data">Hashtable に保存された Ball データ</param>
 /// <returns>Ball 型</returns>
 private Ball ConvertBall(Hashtable data)
 {
     try
     {
         Ball ball = new Ball();
         ball.Set(data);
         return ball;
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// ボールの状態を追加
 /// </summary>
 public void SetBall(Ball b)
 {
     try
     {
         ball = b;
     }
     catch
     {
         throw;
     }
 }