示例#1
0
        /// <summary>
        /// Constructs new table update result containing only table message
        /// </summary>
        /// <param name="message">Table message to show</param>
        public static TableUpdateResult FromMessage(TableMessage message)
        {
            EditionResult result = new EditionResult();

            result.Message = message;
            return(new TableUpdateResult(result));
        }
示例#2
0
 public void ProcessTableMessage(TableMessage m)
 {
     if (_Client == null)
     {
         return;
     }
     lock (_Client)
     {
         _Client._Table = m.TableObj;
     }
     if (_TableMessageDelegate != null)
     {
         _TableMessageDelegate();
     }
 }
示例#3
0
        private void EditData(PowerTablesData <Toy, Row> powerTablesData, EditionResultWrapper <Row> edit)
        {
            edit.ConfirmedObject.Name      = edit.ConfirmedObject.Name + " - Edited";
            edit.ConfirmedObject.TypeOfToy = ToyType.Dolls;

            var idsToUpdate = new[] { 2750, 2747, 2744 };
            var src         = Data.SourceData.Where(c => idsToUpdate.Contains(c.Id)).ToArray();
            var mapped      = powerTablesData.Configuration.MapRange(src);

            foreach (var row in mapped)
            {
                row.Name   = "UFO edited this label";
                row.IsPaid = true;
            }
            edit.Adjustments.AddOrUpdateAll(mapped);
            edit.Message(TableMessage.User("info", "Objects were updated", "Successful"));
        }
示例#4
0
 public string Decrypt(string message, CardanGrilleKey key)
 {
     decryptMessage = new StringBuilder(new string('_', message.Length));
     this.message = new TableMessage(message, key.MatrixOrder);
     matrixSize = (key.MatrixOrder * key.MatrixOrder) / 4 * 4;
     messagePosition = 0;
     Travel(message, key);
     return decryptMessage.ToString().TrimEnd('_');
 }
示例#5
0
 public string Encrypt(string message, CardanGrilleKey key)
 {
     matrixSize = (key.MatrixOrder * key.MatrixOrder) / 4 * 4;
     var additionalTable = message.Length % matrixSize == 0 ? 0 : 1;
     var encryptMessageSize = (message.Length / matrixSize + additionalTable) * matrixSize;
     encryptMessage = new TableMessage(new string('_', encryptMessageSize), key.MatrixOrder);
     this.message = message;
     
     messagePosition = 0;
     Travel(message, key);
     return encryptMessage.Result;
 }
示例#6
0
文件: Client.cs 项目: toadgee/phazex
        protected Message getMessage()
        {
            byte[] b;
            int    avail;

            try
            {
                //while we're here, look for data in the buffer
                avail = _sock.Available;
                if (avail > 0)
                {
                    buffer.ReadFromSocket(_sock, avail);

                    this.BytesReceived += avail;
                }

                //first see if we can actually decode something
                if (buffer.CanDecode())
                {
                    b = buffer.Decode();
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                PhazeXLog.LogError(ex, GameLibraryVersion.VersionString, 104);
                _connected = false;
                return(null);
            }



            Message m = null;

            if (b.Length == 0)
            {
                return(m);
            }
            else if (b[0] == (byte)pxMessages.Heartbeat)
            {
                m = new HeartBeatMessage(b);
            }
            else if (b[0] == (byte)pxMessages.ChangeName)
            {
                m = new ChangeNameMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.ChangeNameReject)
            {
                m = new ChangeNameRejectMessage(b);
            }
            else if (b[0] == (byte)pxMessages.Chat)
            {
                m = new ChatMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.CompletedPhaze)
            {
                m = new CompletedPhazeMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.CurrentPhaze)
            {
                m = new CurrentPhazeMessage(b, this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.DiscardSkip)
            {
                m = new DiscardSkipMessage(b, this.GetPlayerIDs(), this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.DialogMessage)
            {
                m = new DialogMessage(b);
            }
            else if (b[0] == (byte)pxMessages.ErrorMessage)
            {
                m = new ErrorMessage(b);
            }
            else if (b[0] == (byte)pxMessages.GameOver)
            {
                m = new GameOverMessage(b);
            }
            else if (b[0] == (byte)pxMessages.GameRules)
            {
                m = new GameRulesMessage(b);
            }
            else if (b[0] == (byte)pxMessages.GameStarting)
            {
                m = new GameStartingMessage(b);
            }
            else if (b[0] == (byte)pxMessages.Goodbye)
            {
                m = new GoodbyeMessage(b);
            }
            else if (b[0] == (byte)pxMessages.GotCards)
            {
                m = new GotCardsMessage(b, this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.GotDeckCard)
            {
                m = new GotDeckCardMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.GotDiscard)
            {
                m = new GotDiscardMessage(b, this.GetPlayerIDs(), this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.Hand)
            {
                m = new HandMessage(b, this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.Login)
            {
                m = new LoginMessage(b);
            }
            else if (b[0] == (byte)pxMessages.LoginAcknowledgment)
            {
                m = new LoginAckMessage(b);
            }
            else if (b[0] == (byte)pxMessages.LogOff)
            {
                m = new LogOffMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.NewHand)
            {
                m = new NewHandMessage(b);
            }
            else if (b[0] == (byte)pxMessages.PlayedCardOnTable)
            {
                m = new PlayedCardOnTableMessage(b, this.GetPlayerIDs(), this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.Ready)
            {
                m = new ReadyMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.Scoreboard)
            {
                m = new ScoreboardMessage(b, this.GetPlayerIDs(), this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.SkipNotification)
            {
                m = new SkipNotificationMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.StartGameTimer)
            {
                m = new StartGameTimerMessage(b);
            }
            else if (b[0] == (byte)pxMessages.Status)
            {
                m = new StatusMessage(b, this.GetPlayerIDs(), this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.SystemMessage)
            {
                m = new SystemMessage(b);
            }
            else if (b[0] == (byte)pxMessages.Table)
            {
                m = new TableMessage(b, this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.TurnEnd)
            {
                m = new TurnEndMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.TurnStart)
            {
                m = new TurnStartMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.UpdateDiscard)
            {
                m = new UpdateDiscardMessage(b, this.GetPlayerIDs(), this.GameRules);
            }
            else if (b[0] == (byte)pxMessages.WentOut)
            {
                m = new WentOutMessage(b, this.GetPlayerIDs());
            }
            else if (b[0] == (byte)pxMessages.Won)
            {
                m = new WonMessage(b, this.GetPlayerIDs());
            }
            else
            {
                m = new UnknownMessage(b);
            }

            return(m);
        }
示例#7
0
        /// <summary>
        /// Constructs new table update result from updated/removed sets and table message. Type parameter must be target table's row type
        /// </summary>
        /// <typeparam name="T">Target table's row type</typeparam>
        /// <param name="updated">Set of updated entries</param>
        /// <param name="removed">Set of removed entries. Only primary key specified with configuration's .PrimaryKey will be enough here</param>
        /// <param name="message">Table message to show</param>
        /// <returns></returns>
        public static TableUpdateResult FromRange <T>(IEnumerable <T> updated = null, IEnumerable <T> removed = null, TableMessage message = null)
        {
            EditionResult            result  = new EditionResult();
            EditionResultWrapper <T> wrapper = new EditionResultWrapper <T>(result);

            result.Message = message;
            if (updated != null)
            {
                foreach (var up in updated)
                {
                    wrapper.Adjustments.AddOrUpdate(up);
                }
            }

            if (removed != null)
            {
                foreach (var rem in removed)
                {
                    wrapper.Adjustments.Remove(rem);
                }
            }
            return(new TableUpdateResult(result));
        }
示例#8
0
 /// <summary>
 /// Adds messge to be shown after edition
 /// </summary>
 /// <param name="msg">Message</param>
 public void Message(TableMessage msg)
 {
     EditionResult.Message = msg;
 }