private void _Player_TurnStarted(object sender, DominionBase.Players.TurnStartedEventArgs e)
        {
            if (cardHand.Dispatcher.CheckAccess())
            {
                if (this.IsUIPlayer)
                {
                    cardHand.IsClickable = true;
                }

                else
                {
                    cardHand.IsClickable = false;
                }
            }
            else
            {
                cardHand.Dispatcher.BeginInvoke(new EventHandler <DominionBase.Players.TurnStartedEventArgs>(_Player_TurnStarted), System.Windows.Threading.DispatcherPriority.Normal, sender, e);
            }
        }
Пример #2
0
		internal void Start(Turn turn)
		{
			if (TurnStarting != null)
			{
				TurnStartingEventArgs tsea = new TurnStartingEventArgs(this);
				tsea.GrantedBy = turn.GrantedBy;
				TurnStarting(this, tsea);
				if (tsea.Cancelled)
					return;
			}
			_CurrentTurn = turn;
			_Actions = _Buys = 1;
			Phase = PhaseEnum.Starting;
			if (BenefitsChanged != null)
			{
				BenefitsChangedEventArgs bcea = new BenefitsChangedEventArgs(this);
				BenefitsChanged(this, bcea);
			}
			if (TurnStarted != null)
			{
				TurnStartedEventArgs tsea = null;

				List<Object> handledBy = new List<Object>();
				Boolean actionPerformed = false;
				do 
				{
					actionPerformed = false;

					tsea = new TurnStartedEventArgs(this);

					tsea.HandledBy.AddRange(handledBy);
					TurnStarted(this, tsea);
					handledBy = tsea.HandledBy;

					IEnumerator<Player> enumerator = this._Game.GetPlayersStartingWithEnumerator(this);
					while (enumerator.MoveNext())
					{
						OptionCollection options = new OptionCollection();
						IEnumerable<String> cardTypes = tsea.Actions.Keys;
						foreach (String key in cardTypes)
						{
							if (enumerator.Current == tsea.Actions[key].Player)
								options.Add(tsea.Actions[key].Text, tsea.Actions[key].IsRequired);
						}
						if (options.Count > 0)
						{
							options.Sort();
							Choice choice = new Choice(String.Format("{0} turn has started", this == enumerator.Current ? "Your" : String.Format("{0}'s", this)), options, this, tsea);
							ChoiceResult result = enumerator.Current.MakeChoice(choice);

							if (result.Options.Count > 0)
							{
								tsea.Actions.First(kvp => kvp.Value.Text == result.Options[0]).Value.Method(enumerator.Current, ref tsea);
								actionPerformed = true;
							}
						}
					}

				} while (TurnStarted != null && actionPerformed);
			}
			_SetAside.Refresh(this);
			Phase = PhaseEnum.Action;
			//TakeTurn(this._Game, this);
		}
Пример #3
0
		internal void player_Action(Player player, ref TurnStartedEventArgs e)
		{
			e.Player.Actions++;
			e.Player.AddCardInto(DeckLocation.InPlay, this._SetAsideCard);
			this._SetAsideCardInPlay = this._SetAsideCard;
			this._SetAsideCard = null;

			e.Player.PlayerMats[TypeClass.PrinceSetAside].Refresh(e.Player);

			e.Player.PlayCardInternal(this._SetAsideCardInPlay.LogicalCard, String.Format(" from {0}", this.Name));

			_CardsDiscardingEventHandler = new Player.CardsDiscardingEventHandler(player_CardsDiscarding);
			e.Player.CardsDiscarding += _CardsDiscardingEventHandler;

			e.HandledBy.Add(this);
		}
Пример #4
0
		void player_TurnStarted(object sender, TurnStartedEventArgs e)
		{
			if (e.HandledBy.Contains(this))
				return;

			_SetAsideCardInPlay = null;
			if (this._SetAsideCard != null)
			{
				String key = String.Format("{0}:{1}", this, this._SetAsideCard);
				if (e.Actions.ContainsKey(key))
					return;

				e.Actions[key] = new TurnStartedAction(e.Player, this, String.Format("Play {0} from {1}", this._SetAsideCard, this.PhysicalCard), player_Action, true);
			}
		}
Пример #5
0
		void player_TurnStarted(object sender, TurnStartedEventArgs e)
		{
			this.PlayDuration(e.Player);
			if (_TurnStartedEventHandler != null)
				e.Player.TurnStarted -= _TurnStartedEventHandler;
			_TurnStartedEventHandler = null;
		}
Пример #6
0
		void player_TurnStarted(object sender, TurnStartedEventArgs e)
		{
			Player player = sender as Player;

			if (_TurnStartedEventHandler != null && _TurnStartedPlayer != null)
				_TurnStartedPlayer.TurnStarted -= _TurnStartedEventHandler;
			_TurnStartedPlayer = null;
			_TurnStartedEventHandler = null;
		}
Пример #7
0
		internal void player_Action(Player player, ref TurnStartedEventArgs e)
		{
			this.PlayDuration(e.Player);
			if (_TurnStartedEventHandler != null)
				e.Player.TurnStarted -= _TurnStartedEventHandler;
			_TurnStartedPlayer = null;
			_TurnStartedEventHandler = null;
		}
Пример #8
0
		void player_TurnStarted(object sender, TurnStartedEventArgs e)
		{
			String key = this.ToString();
			if (!e.Actions.ContainsKey(key))
				e.Actions[key] = new TurnStartedAction(e.Player, this, String.Format("Play {0}", this.PhysicalCard), player_Action, true);
		}