public bool Validate(GameHub hub) { if (!Validation(hub)) { return(false); } if (next != null) { return(next.Validate(hub)); } return(true); }
protected override bool Validation(GameHub hub) { GameHandler.players.TryGetValue(hub.Context.ConnectionId, out GameHandler.PlayerStats clientPlayer); if (clientPlayer.name == null) { clientPlayer.name = "Player"; } string newName = clientPlayer.name; bool unique = true; int sufix = 1; while (true) { foreach (var player in GameHandler.players) { if (player.Value.name == newName && player.Key != hub.Context.ConnectionId) { unique = false; break; } } if (!unique) { newName = $"{clientPlayer.name}{sufix++}"; unique = true; continue; } break; } if (newName != clientPlayer.name) { _ = hub.OverrideName(newName); } return(true); }
protected override bool Validation(GameHub hub) { return(!GameHandler.isGameStarted); }
abstract protected bool Validation(GameHub hub);
protected override bool Validation(GameHub hub) { return(GameHandler.players.Count < GameHandler.maxPlayerCount); }