SetPhase() public method

public SetPhase ( byte phase, byte nextPhase, bool force ) : void
phase byte
nextPhase byte
force bool
return void
示例#1
0
文件: Handler.cs 项目: drilus/OCTGN
        //public void CreateAlias(int[] id, ulong[] type)
        //{
        //    short s = _clients[_sender].Id;
        //    for (int i = 0; i < id.Length; i++)
        //        id[i] = s << 16 | (id[i] & 0xffff);
        //    _broadcaster.CreateAlias(id, type);
        //}

        public void NextTurn(byte nextPlayer, bool setActive, bool force)
        {
            if (!force)
            {
                // find the first phase that a player has stopped
                var firstStop = _phaseStops.Where(x => x.Item1 > _phaseNumber).OrderBy(x => x.Item1).FirstOrDefault();
                if (firstStop != null) //if there's a phase stop set
                {
                    var stopPlayers = _phaseStops.Where(x => x.Item1 == firstStop.Item1).Select(x => x.Item2);
                    _phaseNumber = firstStop.Item1;
                    _broadcaster.SetPhase(_phaseNumber, stopPlayers.ToArray(), force);
                    return;
                }
                // check if a player has the end of turn stopped
                if (_turnStopPlayers.Count > 0)
                {
                    byte stopPlayerId = _turnStopPlayers.First();
                    _turnStopPlayers.Remove(stopPlayerId);
                    _broadcaster.StopTurn(stopPlayerId);
                    return;
                }
            }
            _turnNumber++;
            _phaseNumber = 0;
            _broadcaster.NextTurn(nextPlayer, setActive, force);
        }
示例#2
0
        public void SetPhase(byte phase, byte nextPhase, bool force)
        {
            var stopPlayers = _phaseStopPlayers.Where(x => x.Item2 == phase).ToList();

            if (stopPlayers.Count > 0 && force == false)
            {
                var stopPlayer = stopPlayers.First();
                _phaseStopPlayers.Remove(stopPlayer);
                _broadcaster.StopPhase(stopPlayer.Item1, stopPlayer.Item2);
                return;
            }
            _broadcaster.SetPhase(phase, nextPhase, force);
        }