コード例 #1
0
        public void Should_AddMoveToMoveNotationHistory()
        {
            // setup
            IMoveHistory  history = ModelLocator.MoveHistory;
            IPiece        piece1  = _chessPieceFactory.CreatePawn(ChessPosition.A2, ChessColor.White);
            IPlayerAction move1   = ModelLocator.Move;

            move1.StartingPosition = piece1.Location;
            move1.EndingPosition   = ChessPosition.A4;

            IPiece        piece2 = _chessPieceFactory.CreatePawn(ChessPosition.A7, ChessColor.Black);
            IPlayerAction move2  = ModelLocator.Move;

            move2.StartingPosition = piece1.Location;
            move2.EndingPosition   = ChessPosition.A5;

            // execute
            history.Add(piece1, move1);
            var notation1 = new string(history.MovesByNotation.First().ToCharArray());

            history.Add(piece2, move2);
            var notation2 = new string(history.MovesByNotation.First().ToCharArray());

            //validate
            Assert.AreNotEqual(notation1, notation2);
            Assert.IsTrue(notation2.StartsWith(notation1));
        }
コード例 #2
0
        public void Should_ReturnTrueForCaptureInLastFifty()
        {
            // setup
            IMoveHistory  history = ModelLocator.MoveHistory;
            IPiece        piece1  = _chessPieceFactory.CreatePawn(ChessPosition.A2, ChessColor.White);
            IPlayerAction move1   = ModelLocator.Move;

            move1.StartingPosition = piece1.Location;
            move1.EndingPosition   = ChessPosition.A4;

            IPiece        piece2 = _chessPieceFactory.CreatePawn(ChessPosition.A7, ChessColor.Black);
            IPlayerAction move2  = ModelLocator.Move;

            move2.StartingPosition = piece1.Location;
            move2.EndingPosition   = ChessPosition.A5;

            // execute
            for (var i = 0; i < 50; i++)
            {
                history.Add(piece1, move1);
                history.Add(piece2, move2);
            }

            history.Add(piece1, new Capture {
                StartingPosition = piece1.Location, EndingPosition = ChessPosition.B3
            });

            // validate
            Assert.IsTrue(history.WasPieceCapturedInLastFiftyMoves);
        }
コード例 #3
0
 public void StartDrag(IPlayerAction action)
 {
     Reset();
     DragAction = action;
     DragSprite = IoCManager.Resolve<IResourceManager>().GetSprite(action.Icon);
     IsEntity = false;
 }
コード例 #4
0
        public void NotifyStateChanged(PlayerState state)
        {
            if (state == PlayerState.Professor)
            {
                //ChatHub.Instance.PrintMessage("I'm professor", Player.LocalPlayer.PlayerName, ChatType.Player);
                _mainFireAction = new CatchAction(_raycastTransform, _remotePlayerLayer, _playerController);
            }
            else if (state == PlayerState.Student)
            {
                //ChatHub.Instance.PrintMessage("I'm Student", Player.LocalPlayer.PlayerName, ChatType.Player);
                _mainFireAction = new StartMiniGameAction();
            }
            else
            {
                _mainFireAction = new StunByAssignmentAction(_raycastTransform, _remotePlayerLayer, _playerController);
                GameManager.Instance.PrintMessage($"{_player.PlayerName} is now assistant.", "SYSTEM", ChatType.Info);
            }

            if (isLocalPlayer)
            {
                var cooltimeAction = _mainFireAction as CooltimeAction;

                if (cooltimeAction != null)
                {
                    PlayerSetup.PlayerUI.SetCooltimeAction(cooltimeAction);
                }
            }
        }
コード例 #5
0
        public async Task <IGameAction> GetGameActionAsync(IPlayerAction playerAction)
        {
            if (playerAction.ActionType == PlayerActionType.DrawCard || !playerAction.CardIds.Any())
            {
                return(_services.GetRequiredService <DrawPlayerAction>());
            }

            var playedCards = await Task.WhenAll(playerAction.CardIds.Select(id => _cardResolver.GetCardAsync(id)));

            var distinctCardTypeCount = playedCards.Select(c => c.Family).Distinct().Count();

            if (distinctCardTypeCount == 1 && playedCards.Length == 3)
            {
                return(_services.GetRequiredService <ThreeOfAKindCardAction>());
            }

            if (distinctCardTypeCount == 1 && playedCards.Length == 2)
            {
                return(_services.GetRequiredService <TwoOfAKindCardAction>());
            }

            if (playerAction.CardIds.Count == 1)
            {
                return(GetCardAction(playedCards.Single().Family));
            }

            throw new NotImplementedException();
        }
コード例 #6
0
        public void PlayTurn(PlayerState currentPlayer)
        {
            System.Threading.Interlocked.Increment(ref turnTotalCount);
            currentPlayer.numberOfTurnsPlayed += 1;
            IPlayerAction currentPlayerAction = currentPlayer.actions;

            this.gameLog.BeginTurn(currentPlayer);
            this.gameLog.PushScope();
            currentPlayer.InitializeTurn();

            ReturnCardsToHandAtStartOfTurn(currentPlayer);
            DoActionsQueuedFromPreviousTurn(currentPlayer);
            DoDurationActionsFromPreviousTurn(currentPlayer);
            DoActionPhase(currentPlayer);
            DoPlayTreasures(currentPlayer);
            currentPlayer.RequestPlayerSpendCoinTokensBeforeBuyPhase(this);
            DoBuyPhase(currentPlayer);
            DoCleanupPhase(currentPlayer);

            int cardCountForNextTurn = this.doesCurrentPlayerNeedOutpostTurn ? 3 : 5;

            currentPlayer.EnterPhase(PlayPhase.DrawCards);
            currentPlayer.DrawUntilCountInHand(cardCountForNextTurn, this);
            currentPlayer.EnterPhase(PlayPhase.NotMyTurn);

            this.gameLog.PopScope();
            this.gameLog.EndTurn(currentPlayer);

            // turn counters need to be 0 such that if this player ends up looking at the state while not it's turn
            // e.g. as reaction or attack, it can make correct choices on current state such as AvailableCoin.
            currentPlayer.InitializeTurn();
        }
コード例 #7
0
 public void StartDrag(IPlayerAction action)
 {
     Reset();
     DragAction = action;
     DragSprite = IoCManager.Resolve <IResourceManager>().GetSprite(action.Icon);
     IsEntity   = false;
 }
コード例 #8
0
        public void PlayTurn(PlayerState currentPlayer)
        {
            System.Threading.Interlocked.Increment(ref turnTotalCount);
            currentPlayer.numberOfTurnsPlayed += 1;
            IPlayerAction currentPlayerAction = currentPlayer.actions;

            this.gameLog.BeginTurn(currentPlayer);
            this.gameLog.PushScope();
            currentPlayer.InitializeTurn();

            ReturnCardsToHandAtStartOfTurn(currentPlayer);
            DoActionsQueuedFromPreviousTurn(currentPlayer);
            DoDurationActionsFromPreviousTurn(currentPlayer);
            DoActionPhase(currentPlayer);
            DoPlayTreasures(currentPlayer);
            currentPlayer.RequestPlayerSpendCoinTokensBeforeBuyPhase(this);
            DoBuyPhase(currentPlayer);
            DoCleanupPhase(currentPlayer);

            int cardCountForNextTurn = this.doesCurrentPlayerNeedOutpostTurn ? 3 : 5;

            currentPlayer.EnterPhase(PlayPhase.DrawCards);
            currentPlayer.DrawUntilCountInHand(cardCountForNextTurn);
            currentPlayer.EnterPhase(PlayPhase.NotMyTurn);

            this.gameLog.PopScope();
            this.gameLog.EndTurn(currentPlayer);
        }
コード例 #9
0
ファイル: GameState.cs プロジェクト: peterhal/Dominulator
        public GameState(             
            IGameLog gameLog,
            IPlayerAction[] players,
            GameConfig gameConfig,
            Random random,
            IEnumerable<CardCountPair>[] startingDeckPerPlayer = null)
        {
            int playerCount = players.Length;
            this.gameLog = gameLog;
            this.cardGameSubset = gameConfig.cardGameSubset;
            this.supplyPiles = gameConfig.GetSupplyPiles(playerCount, random);
            this.nonSupplyPiles = gameConfig.GetNonSupplyPiles();

            this.mapCardToPile = new MapOfCards<PileOfCards>(this.cardGameSubset);
            this.BuildMapOfCardToPile();

            this.players = new PlayerCircle(playerCount, players, this.gameLog, random, this.cardGameSubset);

            this.hasPileEverBeenGained = new MapPileOfCardsToProperty<bool>(this.supplyPiles);
            this.pileEmbargoTokenCount = new MapPileOfCardsToProperty<int>(this.supplyPiles);
            this.trash = new BagOfCards(this.cardGameSubset);

            this.GainStartingCards(gameConfig);

            this.players.AllPlayersDrawInitialCards(gameConfig);

            foreach (PileOfCards cardPile in this.supplyPiles)
            {
                cardPile.ProtoTypeCard.DoSpecializedSetupIfInSupply(this);
            }
        }
コード例 #10
0
        internal PlayerState(IPlayerAction actions, int playerIndex, Game game)
        {
            this.game = game;

            CardGameSubset gameSubset = game.CardGameSubset;
            this.actions = new PlayerActionWithSelf(actions, this);
            this.EnterPhase(PlayPhase.NotMyTurn);
            this.playerIndex = playerIndex;

            // duplicates
            this.allOwnedCards = new BagOfCards(gameSubset);
            this.cardsInPlay = new BagOfCards(gameSubset, this.allOwnedCards);
            this.cardsInPlayAtBeginningOfCleanupPhase = new BagOfCards(gameSubset);

            // partition
            this.islandMat = new BagOfCards(gameSubset, this.allOwnedCards);
            this.nativeVillageMat = new BagOfCards(gameSubset, this.allOwnedCards);
            this.tavernMat = new BagOfCards(gameSubset, this.allOwnedCards);
            this.deck = new ListOfCards(gameSubset, this.allOwnedCards);
            this.discard = new BagOfCards(gameSubset, this.allOwnedCards);
            this.cardsBeingPlayed = new ListOfCards(gameSubset, this.allOwnedCards);  // a stack for recursion
            this.cardsBeingRevealed = new BagOfCards(gameSubset, this.allOwnedCards);
            this.hand = new BagOfCards(gameSubset, this.allOwnedCards);
            this.cardsPlayed = new BagOfCards(gameSubset, this.cardsInPlay);
            this.durationCards = new BagOfCards(gameSubset, this.cardsInPlay);
            this.cardsToReturnToHandAtStartOfTurn = new BagOfCards(gameSubset, this.allOwnedCards);
            this.cardToPass = new SingletonCardHolder(this.allOwnedCards);
            this.cardBeingDiscarded = new ListOfCards(gameSubset, this.allOwnedCards);
            this.cardsSetAside = new BagOfCards(gameSubset, this.allOwnedCards);

            this.turnCounters = new PlayerTurnCounters(gameSubset);
        }
コード例 #11
0
		/// <summary>
		///     Create a new instance
		/// </summary>
		/// <param name="text">the output text</param>
		/// <param name="message">the output message, text without timestamp or tags</param>
		/// <param name="type">the message type</param>
		/// <param name="action">if any player action was described, the player action object</param>
		public OutputParseResult(string text, string message, MessageType type, IPlayerAction action = null)
		{
			Time = DateTime.Now;
			Text = text;
			Message = message;
			Type = type;
			Action = action;
		}
コード例 #12
0
        public PlayerEvent Execute(IPlayerAction action)
        {
            var ret = action.Execute(this);

            this.Events.Add(ret);

            return(ret);
        }
コード例 #13
0
 /// <summary>
 /// Create a new instance
 /// </summary>
 /// <param name="text">the output text</param>
 /// <param name="message">the output message, text without timestamp or tags</param>
 /// <param name="type">the message type</param>
 /// <param name="action">if any player action was described, the player action object</param>
 public OutputParseResult(string text, string message, MessageType type, IPlayerAction action = null)
 {
     Time    = DateTime.Now;
     Text    = text;
     Message = message;
     Type    = type;
     Action  = action;
 }
コード例 #14
0
    private void changedPlayer(IPlayerAction action, Global.typeOfPlayer type)
    {
        action.changedPlayer(LevelManager.instance.listOfPlayers, botaoMudarJogador, playerAtivo);

        hearths       = ScoreController.instance.getHearthsFromPlayer(type);
        currentHealth = ScoreController.instance.getCurrentHealthFromPlayer(type);
        setQuantidadeCoracao(hearths);
        //updateHealthShow();
    }
コード例 #15
0
        private void SetCooldown(uint uid, uint seconds)
        {
            IPlayerAction toSet = Actions.FirstOrDefault(x => x.Uid == uid);

            if (toSet != null)
            {
                toSet.CooldownExpires = DateTime.Now.AddSeconds(seconds);
            }
        }
コード例 #16
0
        public void SendDoAction(IPlayerAction action, object target)
        {
            if (!Actions.Contains(action))
            {
                return;
            }

            double cdLeft = action.CooldownExpires.Subtract(DateTime.Now).TotalSeconds;

            if (cdLeft > 0)
            {
                return;
            }

            switch (action.TargetType)
            {
            case PlayerActionTargetType.Any:
            {
                var trg = (Entity)target;
                Owner.SendComponentNetworkMessage(this, NetDeliveryMethod.ReliableUnordered,
                                                  ComponentMessageType.DoAction, action.Uid, action.TargetType,
                                                  trg.Uid);
                break;
            }

            case PlayerActionTargetType.None:
            {
                Owner.SendComponentNetworkMessage(this, NetDeliveryMethod.ReliableUnordered,
                                                  ComponentMessageType.DoAction, action.Uid, action.TargetType,
                                                  Owner.Uid);
                break;
            }

            case PlayerActionTargetType.Other:
            {
                var trg = (Entity)target;
                if (trg == Owner)
                {
                    return;
                }
                Owner.SendComponentNetworkMessage(this, NetDeliveryMethod.ReliableUnordered,
                                                  ComponentMessageType.DoAction, action.Uid, action.TargetType,
                                                  trg.Uid);
                break;
            }

            case PlayerActionTargetType.Point:
            {
                var trg = (Vector2f)target;
                Owner.SendComponentNetworkMessage(this, NetDeliveryMethod.ReliableUnordered,
                                                  ComponentMessageType.DoAction, action.Uid, action.TargetType,
                                                  trg.X, trg.Y);
                break;
            }
            }
        }
コード例 #17
0
 /// <summary>
 /// 初始化状态
 /// </summary>
 protected void Initial()
 {
     state   = new PlayerState(info);
     action  = new PlayerAction(this);
     request = new PlayerRequest(this);
     trigger = new PlayerTrigger(this);
     //process = new PlayerProcess(this);
     function = new PlayerFunction(this);
     //AIsvr = new AIProcessService(this);
 }
コード例 #18
0
ファイル: PlayerCircle.cs プロジェクト: peterhal/Dominulator
        private PlayerState[] players; // circular list, higher numbers to the left;

        #endregion Fields

        #region Constructors

        public PlayerCircle(int playerCount, IPlayerAction[] players, IGameLog gameLog, Random random, CardGameSubset gameSubset)
        {
            this.players = new PlayerState[playerCount];
            for (int playerIndex = 0; playerIndex < this.players.Length; ++playerIndex)
            {
                this.players[playerIndex] = new PlayerState(players[playerIndex], playerIndex, gameLog, random, gameSubset);
            }

            this.currentPlayerIndex = 0;
        }
コード例 #19
0
 private void OnPlayerInput(IPlayerAction action)
 {
     if (networkNode.Peer is NetPeer peer)
     {
         var msg  = new IClientMsg.PlayerAction(action);
         var data = MessagePackSerializer.Serialize <IClientMsg>(msg);
         peer.Send(data, DeliveryMethod.ReliableOrdered);
         Console.WriteLine("Send: Move");
     }
 }
コード例 #20
0
        /// <summary>
        ///     Handle a player disconnect event
        /// </summary>
        private static void HandlePlayerDisconnect(string text, OutputParseResult outputParseResult,
                                                   IPlayerAction playeraction)
        {
            Player player = GetOnlinePlayerByName(playeraction.PlayerName);

            if (player != null)
            {
                RemovePlayer(player);
            }
        }
コード例 #21
0
        public override Card GuessCardTopOfDeck(GameState gameState)
        {
            IPlayerAction playerAction = this.GetActionForCurrentCardContext(gameState);

            if (playerAction != null)
            {
                return(playerAction.GuessCardTopOfDeck(gameState));
            }
            return(playerAction.GuessCardTopOfDeck(gameState));
        }
コード例 #22
0
        private static void RaisePlayerIpBanEvent(string text, OutputParseResult outputParseResult,
                                                  IPlayerAction playerAction)
        {
            PlayerEventHandler handler = PlayerIpBan;

            if (handler != null)
            {
                handler(text, outputParseResult, playerAction);
            }
        }
コード例 #23
0
        /// <summary>
        ///     Handle a player join event
        /// </summary>
        private static void HandlePlayerJoin(
            string text,
            OutputParseResult outputparseresult,
            IPlayerAction playeraction)
        {
            PlayerActionJoin join = (PlayerActionJoin)playeraction;

            Player player = new Player(join.PlayerName, join.Ip, join.PlayerName);

            AddPlayer(player);
        }
コード例 #24
0
 private void ShowBanTray(string text, OutputParseResult outputParseResult,
                          IPlayerAction playerAction)
 {
     if (!_alwaysShowBalloons && MainForm.Reference.Visible)
     {
         return;                 // if visible and balloons shouldn't be shown always, don't show.
     }
     _icon.ShowBalloonTip(BalloonDuration,
                          playerAction.PlayerName + " " + Locale.Tr("was banned from the server"),
                          outputParseResult.Message, ToolTipIcon.Warning);
 }
コード例 #25
0
    // Use this for initialization
    void Start( )
    {
        m_netId = GetComponent <NetworkIdentity>();
        //if (!m_netId.hasAuthority)
        //{
        //    return;
        //}

        instance       = this;
        m_playerAction = GetComponent <IPlayerAction>();
        m_camera       = Camera.main.transform;
    }
コード例 #26
0
        // we use a playerposition array instead of just using the order in the playerActions array so that
        // we can gather stats about a player using it's player index - which will be constant from game to game
        public PlayerCircle(int playerCount, IPlayerAction[] playerActions, int[] playerPosition, Game game)
        {
            this.players = new PlayerState[playerCount];
            for (int playerIndex = 0; playerIndex < this.players.Length; ++playerIndex)
            {
                int           playPosition = playerPosition[playerIndex];
                IPlayerAction playerAction = playerActions[playerIndex];
                this.players[playPosition] = new PlayerState(playerAction, playerIndex, game);
            }

            this.currentPlayerIndex = 0;
        }
コード例 #27
0
        private PlayerState[] players; // circular list, higher numbers to the left;

        #endregion Fields

        #region Constructors

        // we use a playerposition array instead of just using the order in the playerActions array so that
        // we can gather stats about a player using it's player index - which will be constant from game to game
        public PlayerCircle(int playerCount, IPlayerAction[] playerActions, int[] playerPosition, Game game)
        {
            this.players = new PlayerState[playerCount];
            for (int playerIndex = 0; playerIndex < this.players.Length; ++playerIndex)
            {
                int playPosition = playerPosition[playerIndex];
                IPlayerAction playerAction = playerActions[playerIndex];
                this.players[playPosition] = new PlayerState(playerAction, playerIndex, game);
            }

            this.currentPlayerIndex = 0;
        }
コード例 #28
0
        /// <summary>
        ///  Enters targeting mode for given action.
        /// </summary>
        public void StartTargeting(IPlayerAction act)
        {
            if (act.TargetType == PlayerActionTargetType.None)
            {
                return;
            }

            IoCManager.Resolve <IPlacementManager>().Clear();
            DragInfo.Reset();

            targetingAction = act;
        }
コード例 #29
0
        public override PlayerActionChoice ChooseBetween(GameState gameState, IsValidChoice acceptableChoice)
        {
            IPlayerAction playerAction = this.GetActionForCurrentCardContext(gameState);

            if (playerAction != null)
            {
                return(playerAction.ChooseBetween(gameState, acceptableChoice));
            }
            else
            {
                return(base.ChooseBetween(gameState, acceptableChoice));
            }
        }
コード例 #30
0
        public override Card BanCardForCurrentPlayerPurchase(GameState gameState)
        {
            IPlayerAction playerAction = this.GetActionForCurrentCardContext(gameState);

            if (playerAction != null)
            {
                return(playerAction.BanCardForCurrentPlayerPurchase(gameState));
            }
            else
            {
                return(base.BanCardForCurrentPlayerPurchase(gameState));
            }
        }
コード例 #31
0
        public override DeckPlacement ChooseBetweenTrashTopDeckDiscard(GameState gameState, Card card)
        {
            IPlayerAction playerAction = this.GetActionForCurrentCardContext(gameState);

            if (playerAction != null)
            {
                return(playerAction.ChooseBetweenTrashTopDeckDiscard(gameState, card));
            }
            else
            {
                return(base.ChooseBetweenTrashTopDeckDiscard(gameState, card));
            }
        }
コード例 #32
0
        public override Card ChooseCardToPlayFirst(GameState gameState, Card card1, Card card2)
        {
            IPlayerAction playerAction = this.GetActionForCurrentCardContext(gameState);

            if (playerAction != null)
            {
                return(playerAction.ChooseCardToPlayFirst(gameState, card1, card2));
            }
            else
            {
                return(base.ChooseCardToPlayFirst(gameState, card1, card2));
            }
        }
コード例 #33
0
        public override int GetCoinAmountToUseInButcher(GameState gameState)
        {
            IPlayerAction playerAction = this.GetActionForCurrentCardContext(gameState);

            if (playerAction != null)
            {
                return(playerAction.GetCoinAmountToUseInButcher(gameState));
            }
            else
            {
                return(base.GetCoinAmountToUseInButcher(gameState));
            }
        }
コード例 #34
0
        public override int GetCoinAmountToOverpayForCard(GameState gameState, Card card)
        {
            IPlayerAction playerAction = this.GetActionForCurrentCardContext(gameState);

            if (playerAction != null)
            {
                return(playerAction.GetCoinAmountToOverpayForCard(gameState, card));
            }
            else
            {
                return(base.GetCoinAmountToOverpayForCard(gameState, card));
            }
        }
コード例 #35
0
        public override bool ShouldGainCard(GameState gameState, Card card)
        {
            IPlayerAction playerAction = this.GetActionForCurrentCardContext(gameState);

            if (playerAction != null)
            {
                return(playerAction.ShouldGainCard(gameState, card));
            }
            else
            {
                return(base.ShouldGainCard(gameState, card));
            }
        }
コード例 #36
0
        public override Card GetTreasureFromHandToPlay(GameState gameState, CardPredicate acceptableCard, bool isOptional)
        {
            IPlayerAction playerAction = this.GetActionForCurrentCardContext(gameState);

            if (playerAction != null)
            {
                return(playerAction.GetTreasureFromHandToPlay(gameState, acceptableCard, isOptional));
            }
            else
            {
                return(base.GetTreasureFromHandToPlay(gameState, acceptableCard, isOptional));
            }
        }
コード例 #37
0
        public PlayerActionButton(IPlayerAction _assigned, IResourceManager resourceManager)
        {
            UiMgr = IoCManager.Resolve<IUserInterfaceManager>();
            _resourceManager = resourceManager;

            _buttonSprite = _resourceManager.GetSprite(_assigned.Icon);
            assignedAction = _assigned;
            Color = Color.White;

            timeLeft = new TextSprite("cooldown" + _assigned.Uid.ToString() + _assigned.Name, "",
                                      _resourceManager.GetFont("CALIBRI"));
            timeLeft.Color = Color.NavajoWhite;
            timeLeft.ShadowColor = Color.Black;
            timeLeft.ShadowOffset = new Vector2(1, 1);
            timeLeft.Shadowed = true;

            tooltip = new TextSprite("tooltipAct" + _assigned.Uid.ToString() + _assigned.Name, "",
                                     _resourceManager.GetFont("CALIBRI"));
            tooltip.Color = Color.Black;

            Update(0);
        }
コード例 #38
0
ファイル: Log.cs プロジェクト: Jiwan/Civilisation
 /// <summary>
 /// Writes the specified action.
 /// </summary>
 /// <param name="action">The action.</param>
 public void Write(IPlayerAction action)
 {
     Write(action.GetLog());
 }
コード例 #39
0
ファイル: PlayerLobbyInput.cs プロジェクト: 10123815/YSDACT
    // Use this for initialization
    void Start( )
    {
        m_netId = GetComponent<NetworkIdentity>();
        //if (!m_netId.hasAuthority)
        //{
        //    return;
        //}

        instance = this;
        m_playerAction = GetComponent<IPlayerAction>();
        m_camera = Camera.main.transform;
    }
コード例 #40
0
 private Better CurrentPlayersAction(IPlayerAction PlayersAction)
 {
     if (PlayersAction is FoldPlayerAction)
         return new Better { Player = CurrentPlayer, HasFolded = true, Bet = 0 };
     if (PlayersAction is CallPlayerAction)
         return new Better { Player = CurrentPlayer, HasFolded = false, Bet = LastRaiser.Bet };
     if (PlayersAction is BetPlayerAction)
         return new Better { Player = CurrentPlayer, HasFolded = false, Bet = (PlayersAction as BetPlayerAction).Bet};
     return new Better();
 }
コード例 #41
0
ファイル: Hotbar.cs プロジェクト: Gartley/ss13remake
 private void assignAction(int slot, IPlayerAction act)
 {
     slots[slot] = new PlayerActionButton(act, _resourceManager);
     slots[slot].UserData = slot;
 }
コード例 #42
0
ファイル: Notifications.cs プロジェクト: CaptainTF/bukkitgui2
		private void ShowBanTray(string text, OutputParseResult outputParseResult,
			IPlayerAction playerAction)
		{
			if (!_alwaysShowBalloons && MainForm.Reference.Visible)
				return; // if visible and balloons shouldn't be shown always, don't show.

			_icon.ShowBalloonTip(BalloonDuration,
				playerAction.PlayerName + " " + Locale.Tr("was banned from the server"),
				outputParseResult.Message, ToolTipIcon.Warning);
		}
コード例 #43
0
        public GameState(                         
            IPlayerAction[] playerActions,
            int[] playerPositions,
            Game game)
        {
            if (playerActions.Length != playerPositions.Length)
                throw new Exception();

            this.game = game;
            GameConfig gameConfig = game.GameConfig;

            this.emptyCardCollection = new CollectionCards(this.CardGameSubset, null);

            int playerCount = playerActions.Length;
            this.supplyPiles = gameConfig.GetSupplyPiles(playerCount, game.random);
            this.nonSupplyPiles = gameConfig.GetNonSupplyPiles(playerCount);

            this.mapCardToPile = new MapOfCardsForGameSubset<PileOfCards>(this.CardGameSubset);
            this.BuildMapOfCardToPile();

            this.players = new PlayerCircle(playerCount, playerActions, playerPositions, game);

            this.hasPileEverBeenGained = new MapPileOfCards<bool>(this.supplyPiles);
            this.pileEmbargoTokenCount = new MapPileOfCards<int>(this.supplyPiles);
            this.trash = new BagOfCards(this.CardGameSubset);

            this.cardContextStack = new CardContextStack();

            this.GainStartingCards(gameConfig);

            foreach (PileOfCards cardPile in this.supplyPiles)
            {
                cardPile.ProtoTypeCard.DoSpecializedSetupIfInSupply(this);
            }

            this.players.AllPlayersDrawInitialCards(gameConfig, this);
        }
コード例 #44
0
		private static void RaisePlayerIpBanEvent(string text, OutputParseResult outputParseResult,
			IPlayerAction playerAction)
		{
			PlayerEventHandler handler = PlayerIpBan;
			if (handler != null)
			{
				handler(text, outputParseResult, playerAction);
			}
		}
コード例 #45
0
ファイル: Notifications.cs プロジェクト: CaptainTF/bukkitgui2
		/// <summary>
		///     Play the player left sound
		/// </summary>
		private void SoundPlayerLeave(string text, OutputParseResult outputParseResult, IPlayerAction playerAction)
		{
			new Audio().Play(Resources.sound_disconnect, AudioPlayMode.Background);
		}
コード例 #46
0
ファイル: IPlayerAction.cs プロジェクト: peterhal/Dominulator
 public PlayerActionWithSelf(IPlayerAction playerAction, PlayerState self)
 {
     this.playerAction = playerAction;
     this.self = self;
 }
コード例 #47
0
        public void SendDoAction(IPlayerAction action, object target)
        {
            if (!Actions.Contains(action)) return;

            double cdLeft = action.CooldownExpires.Subtract(DateTime.Now).TotalSeconds;
            if (cdLeft > 0) return;

            switch (action.TargetType)
            {
                case PlayerActionTargetType.Any:
                    {
                        var trg = (Entity) target;
                        Owner.SendComponentNetworkMessage(this, NetDeliveryMethod.ReliableUnordered,
                                                          ComponentMessageType.DoAction, action.Uid, action.TargetType,
                                                          trg.Uid);
                        break;
                    }
                case PlayerActionTargetType.None:
                    {
                        Owner.SendComponentNetworkMessage(this, NetDeliveryMethod.ReliableUnordered,
                                                          ComponentMessageType.DoAction, action.Uid, action.TargetType,
                                                          Owner.Uid);
                        break;
                    }
                case PlayerActionTargetType.Other:
                    {
                        var trg = (Entity) target;
                        if (trg == Owner) return;
                        Owner.SendComponentNetworkMessage(this, NetDeliveryMethod.ReliableUnordered,
                                                          ComponentMessageType.DoAction, action.Uid, action.TargetType,
                                                          trg.Uid);
                        break;
                    }
                case PlayerActionTargetType.Point:
                    {
                        var trg = (PointF) target;
                        Owner.SendComponentNetworkMessage(this, NetDeliveryMethod.ReliableUnordered,
                                                          ComponentMessageType.DoAction, action.Uid, action.TargetType,
                                                          trg.X, trg.Y);
                        break;
                    }
            }
        }
コード例 #48
0
		/// <summary>
		///     Handle a player disconnect event
		/// </summary>
		private static void HandlePlayerDisconnect(string text, OutputParseResult outputParseResult,
			IPlayerAction playeraction)
		{
			Player player = GetOnlinePlayerByName(playeraction.PlayerName);
			if (player != null) RemovePlayer(player);
		}
コード例 #49
0
		/// <summary>
		///     Handle a player join event
		/// </summary>
		private static void HandlePlayerJoin(
			string text,
			OutputParseResult outputparseresult,
			IPlayerAction playeraction)
		{
			PlayerActionJoin join = (PlayerActionJoin) playeraction;

			Player player = new Player(join.PlayerName, join.Ip, join.PlayerName);

			AddPlayer(player);
		}