Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 45.90 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Linq;
  4. using System.Text;
  5. using COServer.Client;
  6. using System.Collections.Generic;
  7. using COServer.Network.GamePackets;
  8. using System.Collections.Concurrent;
  9.  
  10. namespace COServer.Game.Features
  11. {
  12.     public unsafe class Flowers
  13.     {
  14.         public enum Effect : byte
  15.         {
  16.             None = 0,
  17.  
  18.             Rouse = 1,
  19.             Lilies = 2,
  20.             Orchids = 3,
  21.             Tulips = 4,
  22.  
  23.             Kiss = 1,
  24.             love = 2,
  25.             Tins = 3,
  26.             Jade = 4,
  27.         }
  28.         public enum FlowersT : byte
  29.         {
  30.             Rouse = 0,
  31.             Lilies = 1,
  32.             Orchids = 2,
  33.             Tulips = 3,
  34.  
  35.             Kiss = 4,
  36.             love = 5,
  37.             Tins = 6,
  38.             Jade = 7,
  39.         }
  40.  
  41.         public Flowers()
  42.         {
  43.         }
  44.         public Flowers(uint _UID, string name)
  45.         {
  46.             UID = _UID;
  47.             Name = name;
  48.         }
  49.         public uint UID;
  50.         public uint aFlower = 1;
  51.         public uint SendDay = 0;
  52.         public string Name = "";
  53.  
  54.         public int SendScreenValue(FlowersT typ, int rak)
  55.         {
  56.             if (rak == 0 || rak > 100)
  57.                 return 0;
  58.             return (int)(30000002 + (uint)(100 * (byte)typ) + GetRank(rak));
  59.         }
  60.         public ushort GetRank(int rank)
  61.         {
  62.             if (rank == 1)
  63.                 return 0;
  64.             if (rank == 2)
  65.                 return 10000;
  66.             if (rank == 3)
  67.                 return 20000;
  68.             if (rank > 3)
  69.                 return 30000;
  70.             return 0;
  71.         }
  72.         public int BoySendScreenValue(FlowersT typ, int rak)
  73.         {
  74.             int ret = 0;
  75.             if (rak == -1) return 0;
  76.             if (rak > 100) return 0;
  77.             ret = (int)(30000402 + (uint)(100 * (byte)typ));
  78.             return ret;
  79.         }
  80.  
  81.         public int RankRoses = 0;
  82.         public int RankLilies = 0;//max 10 start with -1.
  83.         public int RankOrchids = 0;//max 10 start with -1.
  84.         public int RankTuilps = 0;//max 10 start with -1.
  85.  
  86.         public uint RedRoses;//kiss
  87.         public uint RedRoses2day;
  88.         public uint Lilies;//love
  89.         public uint Lilies2day;
  90.         public uint Orchads;//wine
  91.         public uint Orchads2day;
  92.         public uint Tulips;//jade
  93.         public uint Tulips2day;
  94.  
  95.         public override string ToString()
  96.         {
  97.             return UID + "#"
  98.                 + Name + "#"
  99.                 + RedRoses + "#"
  100.                 + RedRoses2day + "#"
  101.                 + Lilies + "#"
  102.                 + Lilies2day + "#"
  103.                 + Orchads + "#"
  104.                 + Orchads2day + "#"
  105.                 + Tulips + "#"
  106.                 + Tulips2day + "#"
  107.                 + SendDay + "#"
  108.                 + aFlower + "#"
  109.                 + 0 + "#"
  110.                 + 0 + "#"
  111.                 + 0 + "#"
  112.                 + 0 + "#"
  113.                 + 0 + "#";
  114.         }
  115.         public void Read(string aLine)
  116.         {
  117.             if (aLine == "" || aLine == null) return;
  118.             string[] line = aLine.Split('#');
  119.             UID = uint.Parse(line[0]);
  120.             Name = line[1];
  121.             RedRoses = uint.Parse(line[2]);
  122.             RedRoses2day = uint.Parse(line[3]);
  123.             Lilies = uint.Parse(line[4]);
  124.             Lilies2day = uint.Parse(line[5]);
  125.             Orchads = uint.Parse(line[6]);
  126.             Orchads2day = uint.Parse(line[7]);
  127.             Tulips = uint.Parse(line[8]);
  128.             Tulips2day = uint.Parse(line[9]);
  129.             SendDay = uint.Parse(line[10]);
  130.             aFlower = uint.Parse(line[11]);
  131.             Reset();
  132.         }
  133.         public void Reset()
  134.         {
  135.             if (SendDay != DateTime.Now.Day)
  136.             {
  137.                 RedRoses2day = Lilies2day = Orchads2day = Tulips2day = 0;
  138.                 aFlower = 1;
  139.                 SendDay = (uint)DateTime.Now.Day;
  140.             }
  141.         }
  142.  
  143.         public static ConcurrentDictionary<uint, Flowers> Flowers_Poll = new ConcurrentDictionary<uint, Flowers>();
  144.         public static ConcurrentDictionary<uint, Flowers> BoyFlowers = new ConcurrentDictionary<uint, Flowers>();
  145.  
  146.         public static Flowers[] KissTop100 = new Flowers[0];
  147.         public static Flowers[] LoveTop100 = new Flowers[0];
  148.         public static Flowers[] TineTop100 = new Flowers[0];
  149.         public static Flowers[] JadeTop100 = new Flowers[0];
  150.  
  151.         public static Flowers[] RedRousesTop100 = new Flowers[0];
  152.         public static Flowers[] LiliesTop100 = new Flowers[0];
  153.         public static Flowers[] OrchidsTop100 = new Flowers[0];
  154.         public static Flowers[] TulipsTop100 = new Flowers[0];
  155.  
  156.         public static object RouseLock = new object();
  157.         public static object LilisLock = new object();
  158.         public static object OrchidsLock = new object();
  159.         public static object TulipsLock = new object();
  160.  
  161.         public static object KissLock = new object();
  162.         public static object LoveLock = new object();
  163.         public static object TineLock = new object();
  164.         public static object JadeLock = new object();
  165.  
  166.         public static List<Flowers> RankKiss = new List<Flowers>();
  167.         public static List<Flowers> RankLove = new List<Flowers>();
  168.         public static List<Flowers> RankTine = new List<Flowers>();
  169.         public static List<Flowers> RankJade = new List<Flowers>();
  170.  
  171.         public static List<Flowers> Rankrose = new List<Flowers>();
  172.         public static List<Flowers> Ranklili = new List<Flowers>();
  173.         public static List<Flowers> Rankorchid = new List<Flowers>();
  174.         public static List<Flowers> RankTulips = new List<Flowers>();
  175.  
  176.         public static void CulculateRankJade(Flowers afflow)
  177.         {
  178.             lock (JadeLock)
  179.             {
  180.                 try
  181.                 {
  182.                     if (!RankJade.Contains(afflow))
  183.                         RankJade.Add(afflow);
  184.                     var data = RankJade.ToArray();
  185.  
  186.                     Array.Sort(data, (c1, c2) => { return c2.Tulips.CompareTo(c1.Tulips); });
  187.  
  188.                     var room = data.ToArray();
  189.  
  190.                     List<Flowers> backUpd = new List<Flowers>();
  191.  
  192.                     int x = 1;
  193.                     foreach (Flowers flow in room)
  194.                     {
  195.                         if (flow.Tulips == 0) continue;
  196.                         if (x < 100)
  197.                         {
  198.  
  199.                             flow.RankTuilps = x;
  200.                             backUpd.Add(flow);
  201.                         }
  202.                         else
  203.                             flow.RankTuilps = 0;
  204.                         x++;
  205.                     }
  206.                     lock (JadeTop100)
  207.                     {
  208.                         RankJade = new List<Flowers>(backUpd);
  209.                         JadeTop100 = backUpd.ToArray();
  210.                     }
  211.                 }
  212.                 catch (Exception e) { Console.WriteLine(e.ToString()); }
  213.             }
  214.         }
  215.         public static void CulculateRankTine(Flowers afflow)
  216.         {
  217.             lock (TineLock)
  218.             {
  219.                 try
  220.                 {
  221.                     if (!RankTine.Contains(afflow))
  222.                         RankTine.Add(afflow);
  223.                     var data = RankTine.ToArray();
  224.  
  225.                     Array.Sort(data, (c1, c2) => { return c2.Orchads.CompareTo(c1.Orchads); });
  226.  
  227.                     var room = data.ToArray();
  228.  
  229.                     List<Flowers> backUpd = new List<Flowers>();
  230.  
  231.                     int x = 1;
  232.                     foreach (Flowers flow in room)
  233.                     {
  234.                         if (flow.Orchads == 0) continue;
  235.                         if (x < 100)
  236.                         {
  237.  
  238.                             flow.RankOrchids = x;
  239.                             backUpd.Add(flow);
  240.                         }
  241.                         else
  242.                             flow.RankOrchids = 0;
  243.                         x++;
  244.                     }
  245.                     lock (TineTop100)
  246.                     {
  247.                         RankTine = new List<Flowers>(backUpd);
  248.                         TineTop100 = backUpd.ToArray();
  249.                     }
  250.                 }
  251.                 catch (Exception e) { Console.WriteLine(e.ToString()); }
  252.             }
  253.         }
  254.         public static void CulculateRankLove(Flowers afflow)
  255.         {
  256.             lock (LoveLock)
  257.             {
  258.                 try
  259.                 {
  260.                     if (!RankLove.Contains(afflow))
  261.                         RankLove.Add(afflow);
  262.                     var data = RankLove.ToArray();
  263.  
  264.                     Array.Sort(data, (c1, c2) => { return c2.Lilies.CompareTo(c1.Lilies); });
  265.  
  266.                     var room = data.ToArray();
  267.  
  268.                     List<Flowers> backUpd = new List<Flowers>();
  269.  
  270.                     int x = 1;
  271.                     foreach (Flowers flow in room)
  272.                     {
  273.                         if (flow.Lilies == 0) continue;
  274.                         if (x < 100)
  275.                         {
  276.                             flow.RankLilies = x;
  277.                             backUpd.Add(flow);
  278.                         }
  279.                         else
  280.                             flow.RankLilies = 0;
  281.                         x++;
  282.                     }
  283.                     lock (LoveTop100)
  284.                     {
  285.                         RankLove = new List<Flowers>(backUpd);
  286.                         LoveTop100 = backUpd.ToArray();
  287.                     }
  288.                 }
  289.                 catch (Exception e) { Console.WriteLine(e.ToString()); }
  290.             }
  291.         }
  292.         public static void CulculateRankKiss(Flowers afflow)
  293.         {
  294.             lock (KissLock)
  295.             {
  296.                 try
  297.                 {
  298.                     if (!RankKiss.Contains(afflow))
  299.                         RankKiss.Add(afflow);
  300.                     var data = RankKiss.ToArray();
  301.  
  302.                     Array.Sort(data, (c1, c2) => { return c2.RedRoses.CompareTo(c1.RedRoses); });
  303.  
  304.                     var room = data.ToArray();
  305.  
  306.                     List<Flowers> backUpd = new List<Flowers>();
  307.  
  308.                     int x = 1;
  309.                     foreach (Flowers flow in room)
  310.                     {
  311.                         if (flow.RedRoses == 0) continue;
  312.                         if (x < 100)
  313.                         {
  314.  
  315.                             flow.RankRoses = x;
  316.                             backUpd.Add(flow);
  317.                         }
  318.                         else
  319.                             flow.RankRoses = 0;
  320.                         x++;
  321.                     }
  322.                     lock (KissTop100)
  323.                     {
  324.                         RankKiss = new List<Flowers>(backUpd);
  325.                         KissTop100 = backUpd.ToArray();
  326.                     }
  327.                 }
  328.                 catch (Exception e) { Console.WriteLine(e.ToString()); }
  329.             }
  330.         }
  331.  
  332.         public static void CulculateRankRouse(Flowers afflow)
  333.         {
  334.             lock (RouseLock)
  335.             {
  336.                 try
  337.                 {
  338.                     if (!Rankrose.Contains(afflow))
  339.                         Rankrose.Add(afflow);
  340.                     var data = Rankrose.ToArray();
  341.  
  342.                     Array.Sort(data, (c1, c2) => { return c2.RedRoses.CompareTo(c1.RedRoses); });
  343.  
  344.                     var room = data.ToArray();
  345.  
  346.                     List<Flowers> backUpd = new List<Flowers>();
  347.  
  348.                     int x = 1;
  349.                     foreach (Flowers flow in room)
  350.                     {
  351.                         if (flow.RedRoses == 0) continue;
  352.                         if (x < 100)
  353.                         {
  354.                             flow.RankRoses = x;
  355.                             backUpd.Add(flow);
  356.                         }
  357.                         else
  358.                         {
  359.                             flow.RankRoses = 0;
  360.                         }
  361.  
  362.                         x++;
  363.                     }
  364.                     lock (RedRousesTop100)
  365.                     {
  366.                         Rankrose = new List<Flowers>(backUpd);
  367.                         RedRousesTop100 = backUpd.ToArray();
  368.                     }
  369.                 }
  370.                 catch (Exception e) { Console.WriteLine(e.ToString()); }
  371.             }
  372.         }
  373.         public static void CulculateRankLilies(Flowers afflow)
  374.         {
  375.             lock (LilisLock)
  376.             {
  377.                 if (!Ranklili.Contains(afflow))
  378.                     Ranklili.Add(afflow);
  379.                 var data = Ranklili.ToArray();
  380.  
  381.                 Array.Sort(data, (c1, c2) => { return c2.Lilies.CompareTo(c1.Lilies); });
  382.  
  383.                 //IEnumerable<Flowers> query = data.OrderBy(redrous => redrous.Tulips);
  384.  
  385.                 //var room = query.ToArray();
  386.                 var room = data.ToArray();
  387.                 List<Flowers> backUpd = new List<Flowers>();
  388.  
  389.                 int x = 1;
  390.                 foreach (Flowers flow in room)
  391.                 {
  392.                     if (flow.Lilies == 0) continue;
  393.                     if (x < 100)
  394.                     {
  395.  
  396.                         flow.RankLilies = x;
  397.                         backUpd.Add(flow);
  398.                     }
  399.                     else
  400.                     {
  401.                         flow.RankLilies = 0;
  402.                     }
  403.  
  404.                     x++;
  405.                 }
  406.                 lock (LiliesTop100)
  407.                 {
  408.                     Ranklili = new List<Flowers>(backUpd);
  409.                     LiliesTop100 = backUpd.ToArray();
  410.                 }
  411.             }
  412.         }
  413.         public static void CulculateRankOrchids(Flowers afflow)
  414.         {
  415.             lock (OrchidsLock)
  416.             {
  417.                 if (!Rankorchid.Contains(afflow))
  418.                     Rankorchid.Add(afflow);
  419.                 var data = Rankorchid.ToArray();
  420.  
  421.                 Array.Sort(data, (c1, c2) => { return c2.Orchads.CompareTo(c1.Orchads); });
  422.  
  423.                 //IEnumerable<Flowers> query = data.OrderBy(redrous => redrous.Tulips);
  424.  
  425.                 //var room = query.ToArray();
  426.                 var room = data.ToArray();
  427.  
  428.                 List<Flowers> backUpd = new List<Flowers>();
  429.  
  430.                 int x = 1;
  431.                 foreach (Flowers flow in room)
  432.                 {
  433.                     if (flow.Orchads == 0) continue;
  434.                     if (x < 100)
  435.                     {
  436.                         flow.RankOrchids = x;
  437.                         backUpd.Add(flow);
  438.                     }
  439.                     else
  440.                     {
  441.                         flow.RankOrchids = 0;
  442.  
  443.                     }
  444.  
  445.                     x++;
  446.                 }
  447.                 lock (OrchidsTop100)
  448.                 {
  449.                     Rankorchid = new List<Flowers>(backUpd);
  450.                     OrchidsTop100 = backUpd.ToArray();
  451.                 }
  452.             }
  453.         }
  454.         public static void CulculateRankTulips(Flowers afflow)
  455.         {
  456.             lock (TulipsLock)
  457.             {
  458.                 if (!RankTulips.Contains(afflow))
  459.                     RankTulips.Add(afflow);
  460.                 var data = RankTulips.ToArray();
  461.  
  462.                 Array.Sort(data, (c1, c2) => { return c2.Tulips.CompareTo(c1.Tulips); });
  463.  
  464.                 var room = data.ToArray();
  465.  
  466.                 List<Flowers> backUpd = new List<Flowers>();
  467.  
  468.                 int x = 1;
  469.                 foreach (Flowers flow in room)
  470.                 {
  471.                     if (flow.Tulips == 0) continue;
  472.                     if (x < 100)
  473.                     {
  474.                         flow.RankTuilps = x;
  475.                         backUpd.Add(flow);
  476.                     }
  477.                     else
  478.                     {
  479.                         flow.RankTuilps = 0;
  480.                     }
  481.  
  482.                     x++;
  483.                 }
  484.                 lock (TulipsTop100)
  485.                 {
  486.                     RankTulips = new List<Flowers>(backUpd);
  487.                     TulipsTop100 = backUpd.ToArray();
  488.                 }
  489.             }
  490.         }
  491.  
  492.         public static void MsgRank(byte[] packet, GameState client)
  493.         {
  494.             MsgRank ranking = new MsgRank(false);
  495.             ranking.Deserialize(packet);
  496.             switch (ranking.Mode)
  497.             {
  498.                 case Network.GamePackets.MsgRank.Ranking:
  499.                     {
  500.                         if (ranking.RankingType >= Network.GamePackets.MsgRank.Prestige && ranking.RankingType < Network.GamePackets.MsgRank.Prestige + 11)
  501.                         {
  502.                             foreach (var c in Kernel.GamePool.Values)
  503.                             {
  504.                                 PerfectionManager.CalcAndAdd(c);
  505.                             }
  506.                             PerfectionManager.ShowRank(ranking, client);
  507.                         }
  508.                         if (ranking.RankingType == 70000000)
  509.                             MsgTrainingVitality.ShowGenericRanking3(ranking, client);
  510.                         if (ranking.RankingType >= Network.GamePackets.MsgRank.DragonChi && ranking.RankingType <= Network.GamePackets.MsgRank.TurtleChi)
  511.                             MsgTrainingVitality.ShowGenericRanking(ranking, client);
  512.                         else if (ranking.RankingType >= Network.GamePackets.MsgRank.RoseFairy && ranking.RankingType <= Network.GamePackets.MsgRank.TulipFairy)
  513.                             MsgTrainingVitality.ShowGenericRanking2(ranking, client);
  514.                         else if (ranking.RankingType >= Network.GamePackets.MsgRank.Kiss && ranking.RankingType <= Network.GamePackets.MsgRank.Jade)
  515.                             MsgTrainingVitality.ShowGenericRanking2(ranking, client);
  516.                        
  517.                         break;
  518.                     }
  519.                 case Network.GamePackets.MsgRank.QueryCount:
  520.                     {
  521.                         if (ranking.RankingType == 70000000)
  522.                         {
  523.                             if (client.Player.InnerPower != null)
  524.                             {
  525.                                 MsgRank genericRanking3 = new MsgRank(true);
  526.                                 genericRanking3.Mode = 2;
  527.                                 genericRanking3.RankingType = ranking.RankingType;
  528.                                 genericRanking3.Count = 1;
  529.                                 genericRanking3.Append((uint)client.Player.InnerPower.Rank, client.Player.InnerPower.TotalScore, client.Player.UID, client.Player.Name);
  530.                                 client.Send(genericRanking3.ToArray());
  531.                             }
  532.                             return;
  533.                         }
  534.                         if (Flowers.IsGirl((uint)client.Player.Body))
  535.                         {
  536.                             if (client.Player.MyFlowers != null)
  537.                             {
  538.                                 int num61 = -1;
  539.                                 uint num62 = Flowers.CreateMyRank(client, out num61);
  540.                                 packet[4] = 5;
  541.                                 client.Send(packet);
  542.                                 client.Player.FlowerRank = (uint)client.Player.MyFlowers.SendScreenValue((Game.Features.Flowers.FlowersT)num62, num61);
  543.                                 MsgRank genericRanking2 = new MsgRank(true);
  544.                                 genericRanking2.Mode = 2u;
  545.                                 genericRanking2.RankingType = client.Player.FlowerRank;
  546.                                 genericRanking2.Count = 1u;
  547.                                 int rank = num61;
  548.                                 if (client.Player.MyFlowers.RankRoses < 100 && client.Player.MyFlowers.RankRoses > 0)
  549.                                 {
  550.                                     genericRanking2.RankingType = Network.GamePackets.MsgRank.RoseFairy;
  551.                                     genericRanking2.Append((uint)client.Player.MyFlowers.RankRoses, client.Player.MyFlowers.RedRoses, client.Player.UID, client.Player.Name);
  552.                                     client.Send(genericRanking2.ToArray());
  553.                                 }
  554.                                 if (client.Player.MyFlowers.RankLilies < 100 && client.Player.MyFlowers.RankLilies > 0)
  555.                                 {
  556.                                     genericRanking2.Reset();
  557.                                     genericRanking2.RankingType = Network.GamePackets.MsgRank.LilyFairy;
  558.                                     genericRanking2.Append((uint)client.Player.MyFlowers.RankLilies, client.Player.MyFlowers.Lilies, client.Player.UID, client.Player.Name);
  559.                                     client.Send(genericRanking2.ToArray());
  560.                                 }
  561.                                 if (client.Player.MyFlowers.RankOrchids < 100 && client.Player.MyFlowers.RankOrchids > 0)
  562.                                 {
  563.                                     genericRanking2.Reset();
  564.                                     genericRanking2.RankingType = Network.GamePackets.MsgRank.OrchidFairy;
  565.                                     genericRanking2.Append((uint)client.Player.MyFlowers.RankOrchids, client.Player.MyFlowers.Orchads, client.Player.UID, client.Player.Name);
  566.                                     client.Send(genericRanking2.ToArray());
  567.                                 }
  568.                                 if (client.Player.MyFlowers.RankTuilps < 100 && client.Player.MyFlowers.RankTuilps > 0)
  569.                                 {
  570.                                     genericRanking2.Reset();
  571.                                     genericRanking2.RankingType = Network.GamePackets.MsgRank.TulipFairy;
  572.                                     genericRanking2.Append((uint)client.Player.MyFlowers.RankTuilps, client.Player.MyFlowers.Tulips, client.Player.UID, client.Player.Name);
  573.                                     client.Send(genericRanking2.ToArray());
  574.                                 }
  575.                                 //switch (num62)
  576.                                 //{
  577.                                 //    case 0u:
  578.                                 //        genericRanking2.Append((uint)rank, client.Player.MyFlowers.RedRoses, client.Player.UID, client.Player.Name);
  579.                                 //        break;
  580.                                 //    case 1u:
  581.                                 //        genericRanking2.Append((uint)rank, client.Player.MyFlowers.Lilies, client.Player.UID, client.Player.Name);
  582.                                 //        break;
  583.                                 //    case 2u:
  584.                                 //        genericRanking2.Append((uint)rank, client.Player.MyFlowers.Orchads, client.Player.UID, client.Player.Name);
  585.                                 //        break;
  586.                                 //    case 3u:
  587.                                 //        genericRanking2.Append((uint)rank, client.Player.MyFlowers.Tulips, client.Player.UID, client.Player.Name);
  588.                                 //        break;
  589.                                 //}
  590.                                 //client.Send(genericRanking2.ToArray());
  591.                                 packet[4] = 5;
  592.                                 client.Send(packet);
  593.                                 break;
  594.                             }
  595.                             break;
  596.                         }
  597.                         else
  598.                         {
  599.                             if (client.Player.MyFlowers != null)
  600.                             {
  601.                                 MsgRank genericRanking3 = new MsgRank(true);
  602.                                 genericRanking3.Mode = 2u;
  603.                                 genericRanking3.RankingType = 30000402u;
  604.                                 genericRanking3.Count = 1u;
  605.                                 if (client.Player.MyFlowers.RankRoses < 100 && client.Player.MyFlowers.RankRoses > 0)
  606.                                 {
  607.                                     genericRanking3.Append((uint)client.Player.MyFlowers.RankRoses, client.Player.MyFlowers.RedRoses, client.Player.UID, client.Player.Name);
  608.                                     client.Send(genericRanking3.ToArray());
  609.                                 }
  610.                                 if (client.Player.MyFlowers.RankLilies < 100 && client.Player.MyFlowers.RankLilies > 0)
  611.                                 {
  612.                                     genericRanking3.Reset();
  613.                                     genericRanking3.Append((uint)client.Player.MyFlowers.RankLilies, client.Player.MyFlowers.Lilies, client.Player.UID, client.Player.Name);
  614.                                     genericRanking3.RankingType = 30000502u;
  615.                                     client.Send(genericRanking3.ToArray());
  616.                                 }
  617.                                 if (client.Player.MyFlowers.RankOrchids < 100 && client.Player.MyFlowers.RankOrchids > 0)
  618.                                 {
  619.                                     genericRanking3.Reset();
  620.                                     genericRanking3.Append((uint)client.Player.MyFlowers.RankOrchids, client.Player.MyFlowers.Orchads, client.Player.UID, client.Player.Name);
  621.                                     genericRanking3.RankingType = 30000602u;
  622.                                     client.Send(genericRanking3.ToArray());
  623.                                 }
  624.                                 if (client.Player.MyFlowers.RankTuilps < 100 && client.Player.MyFlowers.RankTuilps > 0)
  625.                                 {
  626.                                     genericRanking3.Reset();
  627.                                     genericRanking3.Append((uint)client.Player.MyFlowers.RankTuilps, client.Player.MyFlowers.Tulips, client.Player.UID, client.Player.Name);
  628.                                     genericRanking3.RankingType = 30000702u;
  629.                                     client.Send(genericRanking3.ToArray());
  630.                                 }
  631.                                 packet[4] = 5;
  632.                                 client.Send(packet);
  633.                                 break;
  634.                             }
  635.                         }
  636.                     break;
  637.                     }
  638.             }
  639.         }
  640.         public static void MsgFlower(Client.GameState client, byte[] packet)
  641.         {
  642.             byte typ1 = packet[4];
  643.             uint Target = BitConverter.ToUInt32(packet, 8);
  644.             uint ITEM_UID = BitConverter.ToUInt32(packet, 12);
  645.             if (IsBoy(client.Player.Body) && typ1 == 0)//boy send
  646.             {
  647.                 switch (ITEM_UID)
  648.                 {
  649.                     case 0://send my flower
  650.                         {
  651.                             if (client.Player.MyFlowers.aFlower == 0) break;
  652.                             Client.GameState target_client;
  653.                             if (Kernel.GamePool.TryGetValue(Target, out target_client))
  654.                             {
  655.                                 if (!IsGirl(target_client.Player.Body)) return;
  656.                                 client.Player.MyFlowers.aFlower = 0;
  657.                                 client.Player.MyFlowers.SendDay = (uint)DateTime.Now.Day;
  658.                                 target_client.Player.MyFlowers.RedRoses2day += 1;
  659.                                 target_client.Player.MyFlowers.RedRoses += 1;
  660.                                 SendFlower flow = new SendFlower();
  661.                                 flow.Typing = 0;
  662.                                 flow.Effect = (byte)Game.Features.Flowers.Effect.Tulips;
  663.                                 flow.Amount = 1;
  664.                                 flow.SenderName = client.Player.Name;
  665.                                 flow.ReceiverName = target_client.Player.Name;
  666.                                 flow.FType = (byte)Game.Features.Flowers.FlowersT.Rouse;
  667.                                 client.SendScreen(flow.ToArray(), true);
  668.                             }
  669.                             break;
  670.                         }
  671.                     default:
  672.                         {
  673.                             Network.GamePackets.MsgItemInfo Item = null;
  674.                             if (client.Inventory.TryGetItem(ITEM_UID, out Item))
  675.                             {
  676.                                 Client.GameState target_client;
  677.                                 if (Kernel.GamePool.TryGetValue(Target, out target_client))
  678.                                 {
  679.                                     if (!IsGirl(target_client.Player.Body)) return;
  680.                                     uint Amount = Item.ID % 1000;
  681.                                     SendFlower flow = new SendFlower();
  682.                                     flow.Typing = typ1;
  683.                                     flow.Amount = Amount;
  684.                                     flow.SenderName = client.Player.Name;
  685.                                     flow.ReceiverName = target_client.Player.Name;
  686.                                     switch (GetFlowerTyp(Item.ID))
  687.                                     {
  688.                                         case (byte)Game.Features.Flowers.FlowersT.Rouse:
  689.                                             {
  690.                                                 flow.Effect = (byte)Game.Features.Flowers.Effect.Rouse;
  691.                                                 flow.FType = (byte)Game.Features.Flowers.FlowersT.Rouse;
  692.                                                 target_client.Player.MyFlowers.RedRoses2day += Amount;
  693.                                                 target_client.Player.MyFlowers.RedRoses += Amount;
  694.                                                 if (Game.Features.Flowers.RedRousesTop100.Length > 98)
  695.                                                 {
  696.                                                     if (Game.Features.Flowers.RedRousesTop100[98].RedRoses <= target_client.Player.MyFlowers.RedRoses)
  697.                                                     {
  698.                                                         Game.Features.Flowers.CulculateRankRouse(target_client.Player.MyFlowers);
  699.                                                     }
  700.                                                 }
  701.                                                 else Game.Features.Flowers.CulculateRankRouse(target_client.Player.MyFlowers);
  702.                                                 break;
  703.                                             }
  704.                                         case (byte)Game.Features.Flowers.FlowersT.Lilies:
  705.                                             {
  706.                                                 flow.Effect = (byte)Game.Features.Flowers.Effect.Lilies;
  707.                                                 flow.FType = (byte)Game.Features.Flowers.FlowersT.Lilies;
  708.                                                 target_client.Player.MyFlowers.Lilies2day += Amount;
  709.                                                 target_client.Player.MyFlowers.Lilies += Amount;
  710.                                                 if (Game.Features.Flowers.LiliesTop100.Length > 98)
  711.                                                 {
  712.                                                     if (Game.Features.Flowers.LiliesTop100[98].Lilies <= target_client.Player.MyFlowers.Lilies)
  713.                                                     {
  714.                                                         Game.Features.Flowers.CulculateRankLilies(target_client.Player.MyFlowers);
  715.                                                     }
  716.                                                 }
  717.                                                 else Game.Features.Flowers.CulculateRankLilies(target_client.Player.MyFlowers);
  718.                                                 break;
  719.                                             }
  720.                                         case (byte)Game.Features.Flowers.FlowersT.Orchids:
  721.                                             {
  722.                                                 flow.Effect = (byte)Game.Features.Flowers.Effect.Orchids;
  723.                                                 flow.FType = (byte)Game.Features.Flowers.FlowersT.Orchids;
  724.  
  725.                                                 target_client.Player.MyFlowers.Orchads2day += Amount;
  726.                                                 target_client.Player.MyFlowers.Orchads += Amount;
  727.                                                 if (Game.Features.Flowers.OrchidsTop100.Length > 98)
  728.                                                 {
  729.                                                     if (Game.Features.Flowers.OrchidsTop100[98].Orchads <= target_client.Player.MyFlowers.Orchads)
  730.                                                     {
  731.                                                         Game.Features.Flowers.CulculateRankOrchids(target_client.Player.MyFlowers);
  732.                                                     }
  733.                                                 }
  734.                                                 else Game.Features.Flowers.CulculateRankOrchids(target_client.Player.MyFlowers);
  735.                                                 break;
  736.                                             }
  737.                                         case (byte)Game.Features.Flowers.FlowersT.Tulips:
  738.                                             {
  739.                                                 flow.Effect = (byte)Game.Features.Flowers.Effect.Tulips;
  740.                                                 flow.FType = (byte)Game.Features.Flowers.FlowersT.Tulips;
  741.  
  742.                                                 target_client.Player.MyFlowers.Tulips2day += Amount;
  743.                                                 target_client.Player.MyFlowers.Tulips += Amount;
  744.                                                 if (Game.Features.Flowers.TulipsTop100.Length > 98)
  745.                                                 {
  746.                                                     if (Game.Features.Flowers.TulipsTop100[98].Tulips <= target_client.Player.MyFlowers.Tulips)
  747.                                                     {
  748.                                                         Game.Features.Flowers.CulculateRankTulips(target_client.Player.MyFlowers);
  749.                                                     }
  750.                                                 }
  751.                                                 else Game.Features.Flowers.CulculateRankTulips(target_client.Player.MyFlowers);
  752.                                                 break;
  753.                                             }
  754.                                     }
  755.                                     client.Inventory.Remove(Item, Enums.ItemUse.Remove);
  756.                                     client.SendScreen(flow.ToArray(), true);
  757.                                 }
  758.                             }
  759.                             break;
  760.                         }
  761.                 }
  762.             }
  763.             else if (IsGirl(client.Player.Body) && typ1 == 1)//girl send
  764.             {
  765.                 switch (ITEM_UID)
  766.                 {
  767.                     case 0://curent flower
  768.                         {
  769.                             if (client.Player.MyFlowers.aFlower == 0)
  770.                                 return;
  771.                             Client.GameState target_client;
  772.                             if (Kernel.GamePool.TryGetValue(Target, out target_client))
  773.                             {
  774.                                 if (!IsBoy(target_client.Player.Body)) return;
  775.                                 client.Player.MyFlowers.aFlower = 0;
  776.                                 client.Player.MyFlowers.SendDay = (uint)DateTime.Now.Day;
  777.                                 target_client.Player.MyFlowers.RedRoses += 1;
  778.                                 target_client.Player.MyFlowers.RedRoses2day += 1;
  779.                                 SendFlower flow = new SendFlower();
  780.                                 flow.Typing = 1;
  781.                                 flow.Effect = (byte)Game.Features.Flowers.Effect.Kiss;
  782.                                 flow.Amount = 1;
  783.                                 flow.SenderName = client.Player.Name;
  784.                                 flow.ReceiverName = target_client.Player.Name;
  785.                                 flow.FType = (byte)Game.Features.Flowers.FlowersT.Kiss;
  786.                                 client.SendScreen(flow.ToArray(), true);
  787.                             }
  788.                             break;
  789.                         }
  790.                     default:
  791.                         {
  792.                             MsgItemInfo Item = null;
  793.                             if (client.Inventory.TryGetItem(ITEM_UID, out Item))
  794.                             {
  795.                                 Client.GameState target_client = null;
  796.                                 if (Kernel.GamePool.TryGetValue(Target, out target_client))
  797.                                 {
  798.                                     if (!IsBoy(target_client.Player.Body)) return;
  799.                                     uint Amount = Item.ID % 1000;
  800.                                     SendFlower flow = new SendFlower();
  801.                                     flow.Typing = 1;
  802.                                     flow.Amount = Amount;
  803.                                     flow.SenderName = client.Player.Name;
  804.                                     flow.ReceiverName = target_client.Player.Name;
  805.                                     switch (GetFlowerTyp(Item.ID))
  806.                                     {
  807.                                         case (byte)Game.Features.Flowers.FlowersT.Rouse:
  808.                                             {
  809.                                                 flow.Effect = (byte)Game.Features.Flowers.Effect.Kiss;
  810.                                                 flow.FType = (byte)Game.Features.Flowers.FlowersT.Kiss;
  811.  
  812.                                                 target_client.Player.MyFlowers.RedRoses2day += Amount;
  813.                                                 target_client.Player.MyFlowers.RedRoses += Amount;
  814.                                                 if (Game.Features.Flowers.KissTop100.Length > 98)
  815.                                                 {
  816.                                                     if (Game.Features.Flowers.KissTop100[98].RedRoses <= target_client.Player.MyFlowers.RedRoses)
  817.                                                     {
  818.                                                         Game.Features.Flowers.CulculateRankKiss(target_client.Player.MyFlowers);
  819.                                                     }
  820.                                                 }
  821.                                                 else Game.Features.Flowers.CulculateRankKiss(target_client.Player.MyFlowers);
  822.                                                 break;
  823.                                             }
  824.                                         case (byte)Game.Features.Flowers.FlowersT.Lilies:
  825.                                             {
  826.                                                 flow.Effect = (byte)Game.Features.Flowers.Effect.love;
  827.                                                 flow.FType = (byte)Game.Features.Flowers.FlowersT.love;
  828.  
  829.                                                 target_client.Player.MyFlowers.Lilies2day += Amount;
  830.                                                 target_client.Player.MyFlowers.Lilies += Amount;
  831.                                                 if (Game.Features.Flowers.LoveTop100.Length > 98)
  832.                                                 {
  833.                                                     if (Game.Features.Flowers.LoveTop100[98].Lilies <= target_client.Player.MyFlowers.Lilies)
  834.                                                     {
  835.                                                         Game.Features.Flowers.CulculateRankLove(target_client.Player.MyFlowers);
  836.                                                     }
  837.                                                 }
  838.                                                 else Game.Features.Flowers.CulculateRankLove(target_client.Player.MyFlowers);
  839.                                                 break;
  840.                                             }
  841.                                         case (byte)Game.Features.Flowers.FlowersT.Orchids:
  842.                                             {
  843.                                                 flow.Effect = (byte)Game.Features.Flowers.Effect.Tins;
  844.                                                 flow.FType = (byte)Game.Features.Flowers.FlowersT.Tins;
  845.  
  846.                                                 target_client.Player.MyFlowers.Orchads2day += Amount;
  847.                                                 target_client.Player.MyFlowers.Orchads += Amount;
  848.                                                 if (Game.Features.Flowers.TineTop100.Length > 98)
  849.                                                 {
  850.                                                     if (Game.Features.Flowers.TineTop100[98].Orchads <= target_client.Player.MyFlowers.Orchads)
  851.                                                     {
  852.                                                         Game.Features.Flowers.CulculateRankTine(target_client.Player.MyFlowers);
  853.                                                     }
  854.                                                 }
  855.                                                 else Game.Features.Flowers.CulculateRankTine(target_client.Player.MyFlowers);
  856.                                                 break;
  857.                                             }
  858.                                         case (byte)Game.Features.Flowers.FlowersT.Tulips:
  859.                                             {
  860.                                                 flow.Effect = (byte)Game.Features.Flowers.Effect.Jade;
  861.                                                 flow.FType = (byte)Game.Features.Flowers.FlowersT.Jade;
  862.  
  863.                                                 target_client.Player.MyFlowers.Tulips2day += Amount;
  864.                                                 target_client.Player.MyFlowers.Tulips += Amount;
  865.                                                 if (Game.Features.Flowers.JadeTop100.Length > 98)
  866.                                                 {
  867.                                                     if (Game.Features.Flowers.JadeTop100[98].Tulips <= target_client.Player.MyFlowers.Tulips)
  868.                                                     {
  869.                                                         Game.Features.Flowers.CulculateRankJade(target_client.Player.MyFlowers);
  870.                                                     }
  871.                                                 }
  872.                                                 else Game.Features.Flowers.CulculateRankJade(target_client.Player.MyFlowers);
  873.                                                 break;
  874.                                             }
  875.                                     }
  876.                                     client.Inventory.Remove(Item, Enums.ItemUse.Remove);
  877.                                     client.SendScreen(flow.ToArray(), true);
  878.                                 }
  879.                             }
  880.                             break;
  881.                         }
  882.                 }
  883.             }
  884.         }
  885.         public static uint CreateMyRank(Client.GameState client, out int rank)
  886.         {
  887.             List<ClientRank> FRanks = new List<ClientRank>()
  888.             {
  889.            new ClientRank(){Rank = (uint)client.Player.MyFlowers.RankLilies, Amount = client.Player.MyFlowers.Lilies}
  890.            ,   new ClientRank(){Rank = (uint)client.Player.MyFlowers.RankOrchids, Amount = client.Player.MyFlowers.Orchads}
  891.            ,   new ClientRank(){Rank = (uint)client.Player.MyFlowers.RankRoses, Amount = client.Player.MyFlowers.RedRoses}
  892.            ,   new ClientRank(){Rank = (uint)client.Player.MyFlowers.RankTuilps, Amount = client.Player.MyFlowers.Tulips}
  893.             };
  894.             var array = FRanks.Where((f1) => f1.Rank != 0).ToArray();
  895.             Array.Sort(array, (f1, f2) =>
  896.             {
  897.                 int n_rank = f1.Rank.CompareTo(f2.Rank);
  898.  
  899.                 if (f2.Rank == f1.Rank)
  900.                     return f2.Amount.CompareTo(f1.Amount);
  901.                 return n_rank;
  902.             });
  903.             if (array != null && array.Length > 0)
  904.             {
  905.                 ClientRank BestRank = array[0];
  906.                 if (BestRank.Rank != 0)
  907.                 {
  908.                     rank = (int)BestRank.Rank;
  909.                     if (client.Player.MyFlowers.RankLilies == BestRank.Rank && client.Player.MyFlowers.Lilies == BestRank.Amount)
  910.                         return (byte)Game.Features.Flowers.FlowersT.Lilies;
  911.                     if (client.Player.MyFlowers.RankOrchids == BestRank.Rank && client.Player.MyFlowers.Orchads == BestRank.Amount)
  912.                         return (byte)Game.Features.Flowers.FlowersT.Orchids;
  913.                     if (client.Player.MyFlowers.RankRoses == BestRank.Rank && client.Player.MyFlowers.RedRoses == BestRank.Amount)
  914.                         return (byte)Game.Features.Flowers.FlowersT.Rouse;
  915.                     if (client.Player.MyFlowers.RankTuilps == BestRank.Rank && client.Player.MyFlowers.Tulips == BestRank.Amount)
  916.                         return (byte)Game.Features.Flowers.FlowersT.Tulips;
  917.                 }
  918.             }
  919.             rank = 0;
  920.             return 0;
  921.         }
  922.         public static uint GetFlowerTyp(uint ID)
  923.         {
  924.             if (ID >= 751001 && ID <= 751999 || ID >= 755001 && ID <= 755999)
  925.                 return (uint)Game.Features.Flowers.FlowersT.Rouse;
  926.             if (ID >= 752001 && ID <= 752999 || ID >= 756001 && ID <= 756999)
  927.                 return (uint)Game.Features.Flowers.FlowersT.Lilies;
  928.             if (ID >= 753001 && ID <= 753999 || ID >= 757001 && ID <= 757999)
  929.                 return (uint)Game.Features.Flowers.FlowersT.Orchids;
  930.             if (ID >= 754001 && ID <= 754999 || ID >= 758001 && ID <= 758999)
  931.                 return (uint)Game.Features.Flowers.FlowersT.Tulips;
  932.             return 0;
  933.         }
  934.         public static bool IsBoy(uint mesh)
  935.         {
  936.             return mesh == 1003 || mesh == 1004;
  937.         }
  938.         public static bool IsGirl(uint mesh)
  939.         {
  940.             return mesh == 2001 || mesh == 2002;
  941.         }
  942.         public class ClientRank
  943.         {
  944.             public uint Rank;
  945.             public uint Amount;
  946.         }
  947.     }
  948. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement