/// <summary> /// Constructor. /// </summary> /// <param name="playerName">Human player name.</param> /// <param name="pointRule">Indicates the initial points count for every players.</param> /// <param name="endOfGameRule">The ruel to end a game.</param> /// <param name="save">Player save file.</param> /// <param name="useRedDoras">Indicates if red doras should be used.</param> /// <param name="useNagashiMangan"><c>True</c> to use the yaku 'Nagashi Mangan'.</param> /// <param name="useRenhou"><c>True</c> to use the yakuman 'Renhou'.</param> public MainWindow(string playerName, InitialPointsRulePivot pointRule, EndOfGameRulePivot endOfGameRule, PlayerSavePivot save, bool useRedDoras, bool useNagashiMangan, bool useRenhou) { InitializeComponent(); LblHumanPlayer.Content = playerName; _game = new GamePivot(playerName, pointRule, endOfGameRule, save, useRedDoras, useNagashiMangan, useRenhou); _tickSound = new System.Media.SoundPlayer(Properties.Resources.tick); _overlayStoryboard = FindResource("StbHideOverlay") as Storyboard; Storyboard.SetTarget(_overlayStoryboard, GrdOverlayCall); ApplyConfigurationToOverlayStoryboard(); SetChronoTime(); FixWindowDimensions(); NewRoundRefresh(); InitializeAutoPlayWorker(); BindConfiguration(); ContentRendered += delegate(object sender, EventArgs evt) { RunAutoPlay(); }; }
// Constructor. private PlayerPivot(string name, WindPivot initialWind, InitialPointsRulePivot initialPointsRulePivot, bool isCpu) { Name = name; InitialWind = initialWind; Points = initialPointsRulePivot.GetInitialPointsFromRule(); IsCpu = isCpu; }
/// <summary> /// Extension; gets the number of points from the specified <see cref="InitialPointsRulePivot"/> value. /// </summary> /// <param name="initialPointsRule">The <see cref="InitialPointsRulePivot"/> value.</param> /// <returns>The number of points.</returns> public static int GetInitialPointsFromRule(this InitialPointsRulePivot initialPointsRule) { switch (initialPointsRule) { case InitialPointsRulePivot.K25: return(25000); case InitialPointsRulePivot.K30: return(30000); default: throw new NotImplementedException(); } }
/// <summary> /// Generates a list of four <see cref="PlayerPivot"/> to start a game. /// </summary> /// <param name="humanPlayerName">The name of the human player; other players will be <see cref="IsCpu"/>.</param> /// <param name="initialPointsRulePivot">Rule for initial points count.</param> /// <returns>List of four <see cref="PlayerPivot"/>, not sorted.</returns> /// <exception cref="ArgumentException"><see cref="Messages.InvalidPlayerName"/></exception> public static List <PlayerPivot> GetFourPlayers(string humanPlayerName, InitialPointsRulePivot initialPointsRulePivot) { humanPlayerName = CheckName(humanPlayerName); int eastIndex = GlobalTools.Randomizer.Next(0, 4); var players = new List <PlayerPivot>(); for (int i = 0; i < 4; i++) { players.Add(new PlayerPivot( i == GamePivot.HUMAN_INDEX ? humanPlayerName : $"{CPU_NAME_PREFIX}{i}", i == eastIndex ? WindPivot.East : (i > eastIndex ? (WindPivot)(i - eastIndex) : (WindPivot)(4 - eastIndex + i)), initialPointsRulePivot, i != GamePivot.HUMAN_INDEX )); } return(players); }
/// <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); }