Пример #1
0
        public void OnClick()//変更前static void Main(string[] args)//static入れると動かないので抜いた
        {
            Debug.Log("sucsess call");


            var service = new MainService();

            // TODO : 実行時にユーザーが画面で指定する情報
            var param = new SimulationParam()
            {
                //Deck = new ICardInfo[]//IEne...インスタンスの生成
                //{

                //    //new Village() { Priority = 2 },
                //},
                Count           = 20,
                IsShowAllResult = false
            };
            //やりたいことの雰囲気


            //Debug.Log(deck.Count);
            BuildDeck buildDeck = GameObject.Find("DeckBuilder").GetComponent <BuildDeck>();

            //param.Deck = Enumerable.Repeat(new Copper(), numCopper);

            service.Exec(param);

            Debug.Log("終了。Press Any Key.");
            //Console.ReadKey();
        }
Пример #2
0
        public BuildDeck(SimulationParam prm) //コンストラクタを
        {
            NumCopper = NumCopper.GetComponent <InputField>();
            NumSilver = NumSilver.GetComponent <InputField>();

            int numCopper = int.Parse(NumCopper.text);
            int numSilver = int.Parse(NumSilver.text);

            var deck = new List <ICardInfo>();

            //for (int i = 0; i < _numCopper; i++)
            //{
            //    var _copper = new Copper();
            //    deck.Add(_copper);

            //    Debug.Log(i);

            //}
            deck.AddRange(Enumerable.Repeat(new Copper(), numCopper));
            deck.AddRange(Enumerable.Repeat(new Silver(), numSilver));

            prm.Deck = deck;
        }
Пример #3
0
        public void Exec(SimulationParam param)
        {
            for (int i = 0; i < param.Count; i++)
            {
                // ex. PS情報設定
                // TODO : リファクタ。関数化。
                _playerStatus         = new PlayerStatus();
                _playerStatus.Action  = 1;
                _playerStatus.Coin    = 0;
                _playerStatus.Buy     = 1;
                _playerStatus.Deck    = param.Deck.OrderBy(x => Guid.NewGuid()).ToList();
                _playerStatus.Hands   = new List <ICardInfo>();
                _playerStatus.Played  = new List <ICardInfo>();
                _playerStatus.Discard = new List <ICardInfo>();

                // 0. 初期処理
                // デッキからランダムで5枚引く
                for (int j = 0; j < 5; j++)
                {
                    var tmpCard = _playerStatus.Deck.FirstOrDefault();
                    if (tmpCard == null)
                    {
                        break;
                    }
                    _playerStatus.Deck.Remove(tmpCard);
                    _playerStatus.Hands.Add(tmpCard);
                }

                // 1. アクション
                // TBD
                while (_playerStatus.Action >= 1)
                {
                    var tmpCard = _playerStatus.Hands.Where(x => x.CardType.HasFlag(CardTypeAttr.Action)).FirstOrDefault();
                    if (tmpCard == null)
                    {
                        break;
                    }

                    if (param.IsShowAllResult)
                    {
                        Console.Write($"{tmpCard.Name},");
                    }
                    // TODO : IActionCardにCast出来ない場合の例外処理
                    _playerStatus.Action--;
                    ((IActionCard)tmpCard).DoAction(_playerStatus);
                    _playerStatus.Hands.Remove(tmpCard);
                    _playerStatus.Played.Add(tmpCard);
                }

                // 2. 購入
                while (_playerStatus.Hands.Any(x => x.CardType.HasFlag(CardTypeAttr.Treasure)))
                {
                    var tmpCard = _playerStatus.Hands.First(x => x.CardType.HasFlag(CardTypeAttr.Treasure));

                    ((ITresureCard)tmpCard).DoTreasure(_playerStatus);
                    _playerStatus.Hands.Remove(tmpCard);
                    _playerStatus.Played.Add(tmpCard);
                }

                // 3. 夜行

                // 4. クリンナップ

                // 欲しい情報書き出し
                if (param.IsShowAllResult)
                {
                    Console.WriteLine($"{i + 1}回目:Coin {_playerStatus.Coin}, 残り山札 {_playerStatus.Deck.Count}");
                }
                _allResult.Add(_playerStatus);
            }

            Console.WriteLine("-----------------------------------");
            Console.WriteLine($"平均金量:{_allResult.Average(x => x.Coin).ToString("0.###")}");
            Console.WriteLine($"残り山枚数:{_allResult.Average(x => x.Deck.Count)}");
        }
Пример #4
0
        static void Main(string[] args)
        {
            var service = new MainService();

            // TODO : 実行時にユーザーが画面で指定する情報
            var param = new SimulationParam()
            {
                Deck = new ICardInfo[]
                {
                    new Copper(),
                    new Copper(),
                    new Copper(),
                    new Copper(),
                    new Copper(),
                    new Copper(),
                    new Copper(),
                    new Estate(),
                    new Estate(),
                    new Estate(),
                    new Smithy()
                    {
                        Priority = 1
                    },
                    new Smithy()
                    {
                        Priority = 1
                    },
                    new Smithy()
                    {
                        Priority = 1
                    },
                    new Village()
                    {
                        Priority = 2
                    },
                    new Village()
                    {
                        Priority = 2
                    },
                    new Village()
                    {
                        Priority = 2
                    },
                    new Village()
                    {
                        Priority = 2
                    },
                    new Village()
                    {
                        Priority = 2
                    },
                },
                Count           = 20,
                IsShowAllResult = true
            };

            service.Exec(param);

            Console.WriteLine("終了。Press Any Key.");
            Console.ReadKey();
        }