public void SetupRequest() { //TBD - set GameProperties to new Hashtable() instead of checking for null everywhere? this.properties = this.GameProperties ?? new Hashtable(); if (this.properties != null && this.properties.Count > 0) { string[] expectedUsers; this.isValid = GameParameterReader.TryGetProperties( this.properties, out this.newMaxPlayer, out this.newIsOpen, out this.newIsVisible, out this.newLobbyProperties, out expectedUsers, out this.errorMessage); } if (this.IsValid && this.AddUsers != null) { if (this.newMaxPlayer.HasValue && this.newMaxPlayer != 0 && this.AddUsers.Length >= this.newMaxPlayer) { this.isValid = false; this.errorMessage = "Reserved slots count is more then max player value"; return; } if (this.AddUsers.Any(string.IsNullOrEmpty)) { this.isValid = false; this.errorMessage = "slot name can not be empty"; return; } } }
/// <summary> /// Initializes a new instance of the <see cref="SetPropertiesRequest"/> class. /// </summary> /// <param name="protocol"> /// The protocol. /// </param> /// <param name="operationRequest"> /// Operation request containing the operation parameters. /// </param> public SetPropertiesRequest(IRpcProtocol protocol, OperationRequest operationRequest) : base(protocol, operationRequest) { if (!this.IsValid) { return; } // special handling for game and actor properties send by AS3/Flash (Amf3 protocol) or JSON clients if (protocol.ProtocolType == ProtocolType.Amf3V16 || protocol.ProtocolType == ProtocolType.Json) { if (this.UpdatingGameProperties) { Utilities.ConvertAs3WellKnownPropertyKeys(this.Properties, null); Utilities.ConvertAs3WellKnownPropertyKeys(this.ExpectedValues, null); } else { Utilities.ConvertAs3WellKnownPropertyKeys(null, this.Properties); Utilities.ConvertAs3WellKnownPropertyKeys(null, this.ExpectedValues); } } if (this.UpdatingGameProperties) { this.isValid = GameParameterReader.TryGetProperties(this.Properties, out this.newMaxPlayer, out this.newIsOpen, out this.newIsVisible, out this.newLobbyProperties, out this.MasterClientId, out this.ExpectedUsers, out this.errorMessage); } }
public bool TrySetProperties(Hashtable gameProperties, out bool changed, out string debugMessage) { changed = false; byte?maxPlayer; bool?isOpen; bool?isVisible; object[] propertyFilter; string[] expectedUsers; if (!GameParameterReader.TryGetProperties(gameProperties, out maxPlayer, out isOpen, out isVisible, out propertyFilter, out expectedUsers, out debugMessage)) { return(false); } if (maxPlayer.HasValue && maxPlayer.Value != this.MaxPlayer) { this.MaxPlayer = maxPlayer.Value; this.properties[(byte)GameParameter.MaxPlayers] = (byte)this.MaxPlayer; changed = true; } if (isOpen.HasValue && isOpen.Value != this.IsOpen) { this.IsOpen = isOpen.Value; this.properties[(byte)GameParameter.IsOpen] = this.MaxPlayer; changed = true; } if (isVisible.HasValue && isVisible.Value != this.IsVisible) { this.IsVisible = isVisible.Value; changed = true; } this.properties.Clear(); foreach (DictionaryEntry entry in gameProperties) { if (entry.Value != null) { this.properties[entry.Key] = entry.Value; } } debugMessage = string.Empty; this.IsJoinable = this.CheckIsGameJoinable(); return(true); }
public SetPropertiesRequest(int actorNr, Hashtable properties, Hashtable expected, bool broadcast) { this.ActorNumber = actorNr; this.Properties = properties; this.ExpectedValues = expected; this.Broadcast = broadcast; if (this.UpdatingGameProperties) { this.isValid = GameParameterReader.TryGetProperties(this.Properties, out this.newMaxPlayer, out this.newIsOpen, out this.newIsVisible, out this.newLobbyProperties, out this.MasterClientId, out this.ExpectedUsers, out this.errorMessage); } }