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; } }
public void AddPlayerToGame(int PlayerID) { if (Players.ContainsKey(PlayerID)) { PlayersInGame.Add(PlayerID); } }
// throws if player not found internal void ValidatePlayer(PlayerId playerId) { if (!Players.ContainsKey(playerId)) { throw new PlayerNotFoundException(playerId); } }
public void OnLeaveRegion(PlayerMobile pm) { if (Players.ContainsKey(pm)) { Players.Remove(pm); } }
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); }
public void RemovePlayer(string id) { if (Players.ContainsKey(id)) { Players.Remove(id); } }
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(); } }
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(); } }
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); }
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")); } }
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; } } } }
public void DeletePlayer(int playerId) { if (Players.ContainsKey(playerId)) { Players.Remove(playerId); } SavePlayers(); }
public bool doesPlayerExist(int UID) { if (Players.ContainsKey(UID)) { return(true); } return(false); }
public Player getPlayer(int UID) { if (Players.ContainsKey(UID)) { return(Players[UID]); } return(null); }
public PlayerData.Player GetPlayer(string _Name) { if (Players.ContainsKey(_Name) == false) { Players.Add(_Name, new PlayerData.Player(_Name, Realm)); } return(Players[_Name]); }
public PlayerData.Player FindPlayer(string _Name) { if (Players.ContainsKey(_Name) == false) { return(null); } return(Players[_Name]); }
public Player GetPlayerByID(uint playerID) { if (Players.ContainsKey(playerID)) { return(Players[playerID]); } return(null); }
/// <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); }
public IemUtils.IIemTeamPlayer GetIemPlayerById(string id) { if (Players.ContainsKey(id)) { return((IemUtils.IIemTeamPlayer)Players[id]); } return(null); }
public BaseDiceGame GetGame(PlayerMobile pm) { if (Players == null || !Players.ContainsKey(pm) || Players[pm] == null) { return(null); } return(Players[pm]); }
public int GetPlayerToken(string playerId) { if (Players.ContainsKey(playerId)) { return(Players[playerId]); } throw new Exception("Player not found."); }
public void RemoveGame(PlayerMobile pm, BaseDiceGame game) { if (Players == null || !Players.ContainsKey(pm)) { return; } Players.Remove(pm); }
public Player GetPlayer(string playerId) { if (Players.ContainsKey(playerId)) { return(Players[playerId]); } throw new System.Exception($"No player with ID {playerId} is found"); }
/// <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)); }
public void AddPlayer(string id) { if (Players.ContainsKey(id)) { Console.WriteLine($"Player {id} already Seated"); return; } Players.Add(id, new Player(id)); }
public void addPlayer(int?id, string name) { if (Players.ContainsKey(id)) { } else { Players.Add(id, name); } }
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); } }
/// <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); }
public void AddPlayer(MatchPlayer player) { if (player.Id > 0) { if (!Players.ContainsKey(player.Id)) { Players.Add(player.Id, player); } } }