예제 #1
0
        /// <summary>
        /// Gets or creates the player save file.
        /// </summary>
        /// <returns>Player save file.</returns>
        public static PlayerSavePivot GetOrCreateSave()
        {
            var save = new PlayerSavePivot();

            try
            {
                if (File.Exists(FullFileName))
                {
                    // TODO decrypt
                    using (var stream = new FileStream(FullFileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        save = (PlayerSavePivot) new BinaryFormatter().Deserialize(stream);
                    }
                }
            }
            catch (Exception ex)
            {
                // TODO find something for release mode
#if DEBUG
                System.Diagnostics.Debug.WriteLine(ex.Message);
#endif
            }

            return(save);
        }
예제 #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="humanPlayerName">The name of the human player; other players will be <see cref="PlayerPivot.IsCpu"/>.</param>
        /// <param name="initialPointsRule">The <see cref="InitialPointsRule"/> value.</param>
        /// <param name="endOfGameRule">The <see cref="EndOfGameRule"/> value.</param>
        /// <param name="save">Player save stats.</param>
        /// <param name="withRedDoras">Optionnal; the <see cref="WithRedDoras"/> value; default value is <c>False</c>.</param>
        /// <param name="useNagashiMangan">Optionnal; the <see cref="UseNagashiMangan"/> value; default value is <c>False</c>.</param>
        /// <param name="useRenhou">Optionnal; the <see cref="UseRenhou"/> value; default value is <c>False</c>.</param>
        public GamePivot(string humanPlayerName,
                         InitialPointsRulePivot initialPointsRule,
                         EndOfGameRulePivot endOfGameRule,
                         PlayerSavePivot save,
                         bool withRedDoras     = false,
                         bool useNagashiMangan = false,
                         bool useRenhou        = false)
        {
            _save = save;

            InitialPointsRule  = initialPointsRule;
            EndOfGameRule      = endOfGameRule;
            _players           = PlayerPivot.GetFourPlayers(humanPlayerName, InitialPointsRule);
            DominantWind       = WindPivot.East;
            EastIndexTurnCount = 1;
            EastIndex          = FirstEastIndex;
            EastRank           = 1;
            WithRedDoras       = withRedDoras;
            UseNagashiMangan   = useNagashiMangan;
            UseRenhou          = useRenhou;

            Round = new RoundPivot(this, EastIndex);
        }