예제 #1
0
 private void Game_TurnFinished(object sender, TurnStartedEventArgs e)
 {
     //var game = sender as IGame;
     if (e.CurrentPlayer == this)
     {
         TurnStarted?.Invoke(sender, e);
     }
 }
예제 #2
0
    /// <summary>
    /// Signals the start of the Player's turn.
    /// </summary>
    public virtual void StartTurn()
    {
        if (turnStartedEventArgs == null)
        {
            turnStartedEventArgs = new TurnStartedEventArgs(this);
        }

        OnTurnStarted(turnStartedEventArgs);
    }
예제 #3
0
 void player_TurnStarted(object sender, TurnStartedEventArgs e)
 {
     this.PlayDuration(e.Player);
     if (_TurnStartedEventHandler != null)
     {
         e.Player.TurnStarted -= _TurnStartedEventHandler;
     }
     _TurnStartedEventHandler = null;
 }
예제 #4
0
    protected virtual void OnTurnStarted(TurnStartedEventArgs e)
    {
        if (ThisPlayersTurn != null && ThisPlayersTurn != this)
        {
            ThisPlayersTurn.EndTurn();
        }
        ThisPlayersTurn = this;
        EventHandler <TurnStartedEventArgs> handler = TurnStarted;

        if (handler != null)
        {
            handler(this, e);
        }
    }
예제 #5
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);
        }
예제 #6
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);
            }
        }
예제 #7
0
        private void Player_TurnStarted(object sender, TurnStartedEventArgs e)
        {
            Task.Run(() => {
                var moveSequence = GenerateMovesForTurn();

                if (moveSequence == null)
                {
                    this._mainSyncContext.Send((state) => {
                        this.Game.Surrender((IPlayer)state);
                    }, this.Player);
                    return;
                }

                this._mainSyncContext.Send((s) => {
                    var ms = (MoveSequence)s;
                    int i  = 0;
                    while (!this.Game.TakeTurn(ms.Turn, ms.Moves[i++]))
                    {
                        ;
                    }
                }, moveSequence);
            });
        }