예제 #1
0
            public void AddPlayer(IemUtils.IIemTeamPlayer player)
            {
                if (player.Team != null && player.Team != this)
                {
                    me.Puts("removing palyer from team " + player.Team.Name);
                    player.Team.RemovePlayer(player);
                }

                if (!Players.ContainsKey(player.PlayerId))
                {
                    Players.Add(player.PlayerId, player);
                }

                player.Team     = this;
                player.TeamGame = TeamGame;

                if (!TeamGame.Players.ContainsKey(player.PlayerId))
                {
                    TeamGame.Players.Add(player.PlayerId, player);
                }

                if (Players.Count > 0)
                {
                    State = IemUtils.TeamState.Before;
                }
            }
예제 #2
0
 public void AddPlayerToGame(int PlayerID)
 {
     if (Players.ContainsKey(PlayerID))
     {
         PlayersInGame.Add(PlayerID);
     }
 }
예제 #3
0
 // throws if player not found
 internal void ValidatePlayer(PlayerId playerId)
 {
     if (!Players.ContainsKey(playerId))
     {
         throw new PlayerNotFoundException(playerId);
     }
 }
예제 #4
0
 public void OnLeaveRegion(PlayerMobile pm)
 {
     if (Players.ContainsKey(pm))
     {
         Players.Remove(pm);
     }
 }
예제 #5
0
        public Player AddClient(string playerName, string connectionId, ClientMode mode)
        {
            if (Players.ContainsKey(connectionId))
            {
                throw new Exception("Player already within Team");
            }

            var player = new Player {
                Name = playerName, Mode = mode
            };

            Players[connectionId] = player;

            switch (mode)
            {
            case ClientMode.Player:
            case ClientMode.ParticipatingHost:
                NotifyViewersOfNewPlayer(connectionId, player);
                break;

            case ClientMode.Viewer:
                NotifyNewConnectionOfPlayers(connectionId);
                break;
            }

            return(player);
        }
예제 #6
0
 public void RemovePlayer(string id)
 {
     if (Players.ContainsKey(id))
     {
         Players.Remove(id);
     }
 }
예제 #7
0
 public void SetPlayersInGame(List <int> playerIDs)
 {
     if (playerIDs.Count == 2 && Players.ContainsKey(playerIDs[0]) && Players.ContainsKey(playerIDs[1]))
     {
         PlayersInGame = playerIDs;
     }
 }
 public static void Quit(int index)
 {
     if (Players.ContainsKey(index))
     {
         Players[index].Connection.Disconnect();
     }
 }
예제 #9
0
        public void Leave(Player player)
        {
            rwl.AcquireReaderLock(-1);
            try {
                if (Players.ContainsKey(player))
                {
                    var lc = rwl.UpgradeToWriterLock(-1);
                    try {
                        if (Players.ContainsKey(player))
                        {
                            Console.WriteLine("Leaving System Area {0} - {1}", player.Name, SystemId);
                            Players.Remove(player);
                            if (SpaceShips.Contains(player.SpaceShip))
                            {
                                SpaceShips.Remove(player.SpaceShip);
                            }
                        }
                    } finally {
                        rwl.DowngradeFromWriterLock(ref lc);
                    }

                    foreach (var p in Players.Keys)
                    {
                        if (p != player)
                        {
                            p.Send_ShipLeaveSystem(player.SpaceShip);
                        }
                    }
                }
            } finally {
                rwl.ReleaseReaderLock();
            }
        }
예제 #10
0
        public bool AddVote(ulong userId, ulong mafiaId)
        {
            if (userId == mafiaId)
            {
                return(false);                   // We don't allow you to vote for yourself
            }
            if (!Players.ContainsKey(userId))
            {
                return(false);                              // filter out people voting who aren't in the game
            }
            if (!Players.ContainsKey(mafiaId))
            {
                return(false);                               // filter out votes for users not in the game
            }
            if (!Votes.ContainsKey(userId))
            {
                Votes[userId] = new ulong[] { mafiaId };
                return(true);
            }

            if (Votes[userId].Length >= Mafia.Count)
            {
                return(false);                                     // only accept the first votes of up to the number of mafia
            }
            if (Votes[userId].Contains(mafiaId))
            {
                return(false);                                 // we already counted this vote
            }
            Votes[userId] = Votes[userId].Append(mafiaId).ToArray();
            return(true);
        }
예제 #11
0
        public override async Task <string> SendCapitulationRequest(GameTypes type, string address, string password = "")
        {
            if (!Players.ContainsKey(address))
            {
                return(await Task.FromResult("Player address is not in the list of players!"));
            }

            try
            {
                var dto = new ChessGameDto()
                {
                    GameId              = Id.ToString(),
                    GameState           = string.Empty,
                    Type                = GameDtoTypes.ChessGame,
                    LastGameRecordTxId  = string.Empty,
                    CapitulationRequest = true,
                };

                dto.Players = new Dictionary <string, ChessPlayer>();

                if (Players.TryGetValue(Player1Address, out var pl1))
                {
                    pl1.FigureType = FigureTypes.White;
                }

                if (Players.TryGetValue(Player1Address, out var pl2))
                {
                    pl2.FigureType = FigureTypes.Black;
                }

                foreach (var pl in Players)
                {
                    dto.Players.TryAdd(pl.Key, pl.Value);
                }

                var moveString = JsonConvert.SerializeObject(dto);

                var tkData = new SendTokenTxData()
                {
                    Amount          = 1,
                    Symbol          = TokenSymbol,
                    SenderAddress   = Player1Address,
                    ReceiverAddress = Player2Address,
                    Id = TokenId
                };

                tkData.Metadata.TryAdd("GameId", Id.ToString());
                tkData.Metadata.TryAdd("GameData", moveString);
                tkData.Password = password;

                var res = await NeblioTransactionHelpers.SendNTP1TokenAPI(tkData, 30000);

                return(await Task.FromResult(res));
            }
            catch (Exception ex)
            {
                log.Error("Chess Game - Cannot write move!", ex);
                return(await Task.FromResult("ERROR"));
            }
        }
예제 #12
0
 private void RemoveUser(User user)
 {
     if (user == null)
     {
         return;
     }
     if (Players.ContainsKey(user.Id))
     {
         if (IsInGame)
         {
             FinishGame(user.Id);
         }
         else
         {
             Players[user.Id].Player.GameRoomRef = null;
             Players.Remove(user.Id);
             if (Players.Count < 1)
             {
                 Close(Leader.Id);
             }
             else if (user.Id == Leader.Id)
             {
                 Leader = Players.Values.First().Player;
             }
         }
     }
 }
예제 #13
0
 public void DeletePlayer(int playerId)
 {
     if (Players.ContainsKey(playerId))
     {
         Players.Remove(playerId);
     }
     SavePlayers();
 }
예제 #14
0
 public bool doesPlayerExist(int UID)
 {
     if (Players.ContainsKey(UID))
     {
         return(true);
     }
     return(false);
 }
예제 #15
0
 public Player getPlayer(int UID)
 {
     if (Players.ContainsKey(UID))
     {
         return(Players[UID]);
     }
     return(null);
 }
예제 #16
0
 public PlayerData.Player GetPlayer(string _Name)
 {
     if (Players.ContainsKey(_Name) == false)
     {
         Players.Add(_Name, new PlayerData.Player(_Name, Realm));
     }
     return(Players[_Name]);
 }
예제 #17
0
 public PlayerData.Player FindPlayer(string _Name)
 {
     if (Players.ContainsKey(_Name) == false)
     {
         return(null);
     }
     return(Players[_Name]);
 }
예제 #18
0
파일: Zone.cs 프로젝트: Setz0r/Onyx
 public Player GetPlayerByID(uint playerID)
 {
     if (Players.ContainsKey(playerID))
     {
         return(Players[playerID]);
     }
     return(null);
 }
예제 #19
0
        /// <summary>
        /// 引数のプレイヤーの行動を試合に反映する
        /// </summary>
        /// <param name="playerAction">プレイヤーの行動</param>
        public ReflectionStatus ReflectAction(PlayerAction playerAction)
        {
            // エラー処理関連
            if (MatchInfo.NextPlayerID == Constants.FinishedPlayerID)
            {
                // 誰かがゴール済みのとき、AlreadyFinishedを返す
                return(ReflectionStatus.AlreadyFinished);
            }

            if (playerAction.PlayerID != MatchInfo.NextPlayerID ||
                !Players.ContainsKey(playerAction.PlayerID))
            {
                return(ReflectionStatus.NotYourTurn);                // 行動できるプレイヤーではないのでリターン
            }

            if (playerAction.Length < Constants.ActionMinLength ||
                playerAction.Length > Constants.ActionMaxLength)
            {
                // すごろくの値が不正な場合、エラーを返す
                return(ReflectionStatus.Error);
            }

            if (NextPlayerPrevDice)
            {
                NextPlayerPrevDice = false;
                NoEnqueue          = false;
                var prev = Players[playerAction.PlayerID].Position;
                var next = prev - playerAction.Length;
                Players[playerAction.PlayerID].Position = next;
                IncrementTurn();
                return(ReflectionStatus.PrevDiceSuccess);
            }

            // プレイヤーの移動
            var prePos  = Players[playerAction.PlayerID].Position;
            var nextPos = prePos + playerAction.Length;

            if (nextPos >= Constants.GoalPosition)
            {
                // Goal(MatchInfo.NextPlayerID);
                End(playerAction.PlayerID);
                Players[playerAction.PlayerID].Position = 30;
                return(ReflectionStatus.PlayerGoal);
            }

            // イベントの実行
            Players[playerAction.PlayerID].Position = nextPos;
            Field.Squares[nextPos].Event(this, MatchInfo.NextPlayerID);

            // 次のターンに進める
            if (!NextPlayerPrevDice)
            {
                IncrementTurn();
            }

            return(ReflectionStatus.NextSuccess);
        }
예제 #20
0
            public IemUtils.IIemTeamPlayer GetIemPlayerById(string id)
            {
                if (Players.ContainsKey(id))
                {
                    return((IemUtils.IIemTeamPlayer)Players[id]);
                }

                return(null);
            }
예제 #21
0
        public BaseDiceGame GetGame(PlayerMobile pm)
        {
            if (Players == null || !Players.ContainsKey(pm) || Players[pm] == null)
            {
                return(null);
            }

            return(Players[pm]);
        }
예제 #22
0
파일: GameInfo.cs 프로젝트: sychoi3/9dt
        public int GetPlayerToken(string playerId)
        {
            if (Players.ContainsKey(playerId))
            {
                return(Players[playerId]);
            }

            throw new Exception("Player not found.");
        }
예제 #23
0
        public void RemoveGame(PlayerMobile pm, BaseDiceGame game)
        {
            if (Players == null || !Players.ContainsKey(pm))
            {
                return;
            }

            Players.Remove(pm);
        }
예제 #24
0
        public Player GetPlayer(string playerId)
        {
            if (Players.ContainsKey(playerId))
            {
                return(Players[playerId]);
            }

            throw new System.Exception($"No player with ID {playerId} is found");
        }
예제 #25
0
        /// <summary>
        /// Removes the given <code>Mobile</code> from the player list
        /// </summary>
        public virtual bool RemovePlayer(Mobile m)
        {
            if (!Players.ContainsKey(m))
            {
                return(false);
            }

            return(Players.Remove(m));
        }
예제 #26
0
        public void AddPlayer(string id)
        {
            if (Players.ContainsKey(id))
            {
                Console.WriteLine($"Player {id} already Seated");
                return;
            }

            Players.Add(id, new Player(id));
        }
예제 #27
0
 public void addPlayer(int?id, string name)
 {
     if (Players.ContainsKey(id))
     {
     }
     else
     {
         Players.Add(id, name);
     }
 }
예제 #28
0
 public void FinishGame(string playerId)
 {
     if (IsInGame && Players.ContainsKey(playerId) &&
         Players[playerId].Player.GameRoomRef != null && Players[playerId].Player.GameRoomRef.Id == this.Id)
     {
         //IsInGame = false;
         //todo
         Close(playerId);
     }
 }
예제 #29
0
        /// <summary>
        /// Checks if the player is in the room's list already and calls StorePlayer() if not.
        /// </summary>
        /// <param name="player">The new player - identified by ID.</param>
        /// <returns>False if the player could not be added (cause it was in the list already).</returns>
        public virtual bool AddPlayer(Player player)
        {
            if (!Players.ContainsKey(player.ID))
            {
                StorePlayer(player);
                return(true);
            }

            return(false);
        }
예제 #30
0
 public void AddPlayer(MatchPlayer player)
 {
     if (player.Id > 0)
     {
         if (!Players.ContainsKey(player.Id))
         {
             Players.Add(player.Id, player);
         }
     }
 }