Пример #1
0
        /// <summary>
        /// プレイヤー毎の手持ちのカード数の初期値と、
        /// 期待結果をCSVファイルから読み込み
        /// </summary>
        /// <param name="path">CSVファイルのパス</param>
        public void ReadInput(string path)
        {
            if (!File.Exists(path)) throw new FileNotFoundException(path);

            this.playerList = new List<Player>();
            this.expectedList = new List<Player>();

            const string SituationPlayer = "default";
            const string SituationExpected = "result";

            string[] lines = File.ReadAllLines(path);
            for (int i = 1; i < lines.Length; ++i)
            {
                string[] data = lines[i].Split(',');

                if (data.Length < 6) continue;

                // プレイヤー情報を読み込み
                if (data[5] == SituationPlayer)
                {
                    Player player = new Player(data[4], data[4].Replace("user_", ""));
                    player.SetCard(int.Parse(data[1]), int.Parse(data[2]), int.Parse(data[3]), int.Parse(data[0]));
                    this.playerList.Add(player);
                }

                // 期待結果を読み込み
                if (data[5] == SituationExpected)
                {
                    Player player = new Player(data[4], data[4].Replace("user_", ""));
                    player.SetCard(int.Parse(data[1]), int.Parse(data[2]), int.Parse(data[3]), int.Parse(data[0]));
                    this.expectedList.Add(player);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// プレイヤーの情報をディープコピー
 /// 但し、対戦結果はコピーしない
 /// </summary>
 /// <returns>プレイヤー</returns>
 public Player DeepCopyTo()
 {
     Player copy = new Player(this.Id, this.Name);
     copy.SetCard(this.cardList.Count(x => x == Master.CardStringGu),
                 this.cardList.Count(x => x == Master.CardStringTyoki),
                 this.cardList.Count(x => x == Master.CardStringPa),
                 this.Star);
     return copy;
 }