Exemplo n.º 1
0
 /// <summary>
 /// </summary>
 /// <param name="client">
 /// </param>
 /// <param name="stat">
 /// </param>
 /// <param name="value">
 /// </param>
 /// <param name="announce">
 /// </param>
 public static void SendDirect(IZoneClient client, int stat, uint value, bool announce)
 {
     var statMessage = new StatMessage
                       {
                           Identity = client.Character.Identity,
                           Stats =
                               new[]
                               {
                                   new GameTuple<CharacterStat, uint>
                                   {
                                       Value1 =
                                           (CharacterStat)stat,
                                       Value2 = value
                                   }
                               }
                       };
     client.SendCompressed(statMessage);
 }
Exemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="statsToUpdate">
        /// </param>
        public static void SendBulk(IZoneClient client, Dictionary<int, uint> statsToUpdate)
        {
            if (statsToUpdate.Count == 0)
            {
                return;
            }

            var toPlayfieldIds = new List<int>();
            foreach (KeyValuePair<int, uint> keyValuePair in statsToUpdate)
            {
                if (client.Character.Stats[keyValuePair.Key].AnnounceToPlayfield)
                {
                    toPlayfieldIds.Add(keyValuePair.Key);
                }
            }

            var toPlayfield = new List<GameTuple<CharacterStat, uint>>();
            var toClient = new List<GameTuple<CharacterStat, uint>>();

            foreach (KeyValuePair<int, uint> keyValuePair in statsToUpdate)
            {
                var statValue = new GameTuple<CharacterStat, uint>
                                {
                                    Value1 = (CharacterStat)keyValuePair.Key,
                                    Value2 = keyValuePair.Value
                                };
                toClient.Add(statValue);

                if (toPlayfieldIds.Contains(keyValuePair.Key))
                {
                    toPlayfield.Add(statValue);
                }
            }

            var message = new StatMessage { Identity = client.Character.Identity, Stats = toClient.ToArray() };

            client.SendCompressed(message);

            /* announce to playfield? */
            if (toPlayfieldIds.Count > 0)
            {
                message.Stats = toPlayfield.ToArray();
                client.Character.Playfield.AnnounceOthers(message, client.Character.Identity);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// </summary>
        /// <param name="ch">
        /// </param>
        /// <param name="statsToUpdate">
        /// </param>
        public static void SendBulk(ICharacter ch, Dictionary<int, uint> statsToUpdate)
        {
            if (statsToUpdate.Count == 0)
            {
                return;
            }

            var toPlayfield = new List<int>();
            foreach (KeyValuePair<int, uint> keyValuePair in statsToUpdate)
            {
                if (ch.Stats[keyValuePair.Key].AnnounceToPlayfield)
                {
                    toPlayfield.Add(keyValuePair.Key);
                }
            }

            var stats = new List<GameTuple<CharacterStat, uint>>();
            foreach (KeyValuePair<int, uint> keyValuePair in statsToUpdate)
            {
                if (toPlayfield.Contains(keyValuePair.Key))
                {
                    stats.Add(
                        new GameTuple<CharacterStat, uint>
                        {
                            Value1 = (CharacterStat)keyValuePair.Key,
                            Value2 = keyValuePair.Value
                        });
                }
            }

            /* announce to playfield? */
            if (toPlayfield.Any() == false)
            {
                return;
            }

            var message = new StatMessage { Identity = ch.Identity, Stats = stats.ToArray() };

            ch.Playfield.AnnounceOthers(message, ch.Identity);
        }
Exemplo n.º 4
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="stat">
        /// </param>
        /// <param name="value">
        /// </param>
        /// <param name="announce">
        /// </param>
        public static void Send(IZoneClient client, int stat, uint value, bool announce)
        {
            var statMessage = new StatMessage
                              {
                                  Identity = client.Character.Identity,
                                  Stats =
                                      new[]
                                      {
                                          new GameTuple<CharacterStat, uint>
                                          {
                                              Value1 =
                                                  (CharacterStat)stat,
                                              Value2 = value
                                          }
                                      }
                              };
            var statM = new Message { Body = statMessage };
            if (!client.Character.DoNotDoTimers)
            {
                client.Character.Playfield.Publish(
                    new IMSendAOtomationMessageToClient { client = client, message = statM });
            }

            /* announce to playfield? */
            if (announce)
            {
                client.Character.Playfield.AnnounceOthers(statMessage, client.Character.Identity);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// </summary>
        public void SendChangedStats()
        {
            var message = new StatMessage() { Identity = this.Identity, };
            message.Stats = this.Stats.ChangedAnnouncingStats;
            if (message.Stats.Length > 0)
            {
                this.Playfield.AnnounceOthers(message, this.Identity);
            }

            message.Stats = this.Stats.ChangedStats;
            if (message.Stats.Length > 0)
            {
                this.Playfield.Send(this.Client, message);
            }
        }
        public void StatMessageTest()
        {
            var expected = new StatMessage
                               {
                                   Identity = Identity.None, 
                                   Stats =
                                       new[]
                                           {
                                               new GameTuple<CharacterStat, uint>
                                                   {
                                                       Value1 =
                                                           CharacterStat
                                                           .ACGEntranceStyles, 
                                                       Value2 = 1
                                                   }, 
                                               new GameTuple<CharacterStat, uint>
                                                   {
                                                       Value1 =
                                                           CharacterStat
                                                           .BackMesh, 
                                                       Value2 = 3
                                                   }, 
                                               new GameTuple<CharacterStat, uint>
                                                   {
                                                       Value1 =
                                                           CharacterStat
                                                           .CATAnim, 
                                                       Value2 = 5
                                                   }
                                           }
                               };

            var actual = (StatMessage)this.SerializeDeserialize(expected);

            this.AssertN3Message(expected, actual);

            var expectedChars = expected.Stats.GetEnumerator();
            var actualChars = actual.Stats.GetEnumerator();

            while (expectedChars.MoveNext())
            {
                actualChars.MoveNext();
                var expectedChar = (GameTuple<CharacterStat, uint>)expectedChars.Current;
                var actualChar = (GameTuple<CharacterStat, uint>)actualChars.Current;

                Assert.AreEqual(expectedChar.Value1, actualChar.Value1);
                Assert.AreEqual(expectedChar.Value2, actualChar.Value2);
            }
        }