Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- using COServer.Client;
- using System.Collections.Generic;
- using COServer.Network.GamePackets;
- using System.Collections.Concurrent;
- namespace COServer.Game.Features
- {
- public unsafe class Flowers
- {
- public enum Effect : byte
- {
- None = 0,
- Rouse = 1,
- Lilies = 2,
- Orchids = 3,
- Tulips = 4,
- Kiss = 1,
- love = 2,
- Tins = 3,
- Jade = 4,
- }
- public enum FlowersT : byte
- {
- Rouse = 0,
- Lilies = 1,
- Orchids = 2,
- Tulips = 3,
- Kiss = 4,
- love = 5,
- Tins = 6,
- Jade = 7,
- }
- public Flowers()
- {
- }
- public Flowers(uint _UID, string name)
- {
- UID = _UID;
- Name = name;
- }
- public uint UID;
- public uint aFlower = 1;
- public uint SendDay = 0;
- public string Name = "";
- public int SendScreenValue(FlowersT typ, int rak)
- {
- if (rak == 0 || rak > 100)
- return 0;
- return (int)(30000002 + (uint)(100 * (byte)typ) + GetRank(rak));
- }
- public ushort GetRank(int rank)
- {
- if (rank == 1)
- return 0;
- if (rank == 2)
- return 10000;
- if (rank == 3)
- return 20000;
- if (rank > 3)
- return 30000;
- return 0;
- }
- public int BoySendScreenValue(FlowersT typ, int rak)
- {
- int ret = 0;
- if (rak == -1) return 0;
- if (rak > 100) return 0;
- ret = (int)(30000402 + (uint)(100 * (byte)typ));
- return ret;
- }
- public int RankRoses = 0;
- public int RankLilies = 0;//max 10 start with -1.
- public int RankOrchids = 0;//max 10 start with -1.
- public int RankTuilps = 0;//max 10 start with -1.
- public uint RedRoses;//kiss
- public uint RedRoses2day;
- public uint Lilies;//love
- public uint Lilies2day;
- public uint Orchads;//wine
- public uint Orchads2day;
- public uint Tulips;//jade
- public uint Tulips2day;
- public override string ToString()
- {
- return UID + "#"
- + Name + "#"
- + RedRoses + "#"
- + RedRoses2day + "#"
- + Lilies + "#"
- + Lilies2day + "#"
- + Orchads + "#"
- + Orchads2day + "#"
- + Tulips + "#"
- + Tulips2day + "#"
- + SendDay + "#"
- + aFlower + "#"
- + 0 + "#"
- + 0 + "#"
- + 0 + "#"
- + 0 + "#"
- + 0 + "#";
- }
- public void Read(string aLine)
- {
- if (aLine == "" || aLine == null) return;
- string[] line = aLine.Split('#');
- UID = uint.Parse(line[0]);
- Name = line[1];
- RedRoses = uint.Parse(line[2]);
- RedRoses2day = uint.Parse(line[3]);
- Lilies = uint.Parse(line[4]);
- Lilies2day = uint.Parse(line[5]);
- Orchads = uint.Parse(line[6]);
- Orchads2day = uint.Parse(line[7]);
- Tulips = uint.Parse(line[8]);
- Tulips2day = uint.Parse(line[9]);
- SendDay = uint.Parse(line[10]);
- aFlower = uint.Parse(line[11]);
- Reset();
- }
- public void Reset()
- {
- if (SendDay != DateTime.Now.Day)
- {
- RedRoses2day = Lilies2day = Orchads2day = Tulips2day = 0;
- aFlower = 1;
- SendDay = (uint)DateTime.Now.Day;
- }
- }
- public static ConcurrentDictionary<uint, Flowers> Flowers_Poll = new ConcurrentDictionary<uint, Flowers>();
- public static ConcurrentDictionary<uint, Flowers> BoyFlowers = new ConcurrentDictionary<uint, Flowers>();
- public static Flowers[] KissTop100 = new Flowers[0];
- public static Flowers[] LoveTop100 = new Flowers[0];
- public static Flowers[] TineTop100 = new Flowers[0];
- public static Flowers[] JadeTop100 = new Flowers[0];
- public static Flowers[] RedRousesTop100 = new Flowers[0];
- public static Flowers[] LiliesTop100 = new Flowers[0];
- public static Flowers[] OrchidsTop100 = new Flowers[0];
- public static Flowers[] TulipsTop100 = new Flowers[0];
- public static object RouseLock = new object();
- public static object LilisLock = new object();
- public static object OrchidsLock = new object();
- public static object TulipsLock = new object();
- public static object KissLock = new object();
- public static object LoveLock = new object();
- public static object TineLock = new object();
- public static object JadeLock = new object();
- public static List<Flowers> RankKiss = new List<Flowers>();
- public static List<Flowers> RankLove = new List<Flowers>();
- public static List<Flowers> RankTine = new List<Flowers>();
- public static List<Flowers> RankJade = new List<Flowers>();
- public static List<Flowers> Rankrose = new List<Flowers>();
- public static List<Flowers> Ranklili = new List<Flowers>();
- public static List<Flowers> Rankorchid = new List<Flowers>();
- public static List<Flowers> RankTulips = new List<Flowers>();
- public static void CulculateRankJade(Flowers afflow)
- {
- lock (JadeLock)
- {
- try
- {
- if (!RankJade.Contains(afflow))
- RankJade.Add(afflow);
- var data = RankJade.ToArray();
- Array.Sort(data, (c1, c2) => { return c2.Tulips.CompareTo(c1.Tulips); });
- var room = data.ToArray();
- List<Flowers> backUpd = new List<Flowers>();
- int x = 1;
- foreach (Flowers flow in room)
- {
- if (flow.Tulips == 0) continue;
- if (x < 100)
- {
- flow.RankTuilps = x;
- backUpd.Add(flow);
- }
- else
- flow.RankTuilps = 0;
- x++;
- }
- lock (JadeTop100)
- {
- RankJade = new List<Flowers>(backUpd);
- JadeTop100 = backUpd.ToArray();
- }
- }
- catch (Exception e) { Console.WriteLine(e.ToString()); }
- }
- }
- public static void CulculateRankTine(Flowers afflow)
- {
- lock (TineLock)
- {
- try
- {
- if (!RankTine.Contains(afflow))
- RankTine.Add(afflow);
- var data = RankTine.ToArray();
- Array.Sort(data, (c1, c2) => { return c2.Orchads.CompareTo(c1.Orchads); });
- var room = data.ToArray();
- List<Flowers> backUpd = new List<Flowers>();
- int x = 1;
- foreach (Flowers flow in room)
- {
- if (flow.Orchads == 0) continue;
- if (x < 100)
- {
- flow.RankOrchids = x;
- backUpd.Add(flow);
- }
- else
- flow.RankOrchids = 0;
- x++;
- }
- lock (TineTop100)
- {
- RankTine = new List<Flowers>(backUpd);
- TineTop100 = backUpd.ToArray();
- }
- }
- catch (Exception e) { Console.WriteLine(e.ToString()); }
- }
- }
- public static void CulculateRankLove(Flowers afflow)
- {
- lock (LoveLock)
- {
- try
- {
- if (!RankLove.Contains(afflow))
- RankLove.Add(afflow);
- var data = RankLove.ToArray();
- Array.Sort(data, (c1, c2) => { return c2.Lilies.CompareTo(c1.Lilies); });
- var room = data.ToArray();
- List<Flowers> backUpd = new List<Flowers>();
- int x = 1;
- foreach (Flowers flow in room)
- {
- if (flow.Lilies == 0) continue;
- if (x < 100)
- {
- flow.RankLilies = x;
- backUpd.Add(flow);
- }
- else
- flow.RankLilies = 0;
- x++;
- }
- lock (LoveTop100)
- {
- RankLove = new List<Flowers>(backUpd);
- LoveTop100 = backUpd.ToArray();
- }
- }
- catch (Exception e) { Console.WriteLine(e.ToString()); }
- }
- }
- public static void CulculateRankKiss(Flowers afflow)
- {
- lock (KissLock)
- {
- try
- {
- if (!RankKiss.Contains(afflow))
- RankKiss.Add(afflow);
- var data = RankKiss.ToArray();
- Array.Sort(data, (c1, c2) => { return c2.RedRoses.CompareTo(c1.RedRoses); });
- var room = data.ToArray();
- List<Flowers> backUpd = new List<Flowers>();
- int x = 1;
- foreach (Flowers flow in room)
- {
- if (flow.RedRoses == 0) continue;
- if (x < 100)
- {
- flow.RankRoses = x;
- backUpd.Add(flow);
- }
- else
- flow.RankRoses = 0;
- x++;
- }
- lock (KissTop100)
- {
- RankKiss = new List<Flowers>(backUpd);
- KissTop100 = backUpd.ToArray();
- }
- }
- catch (Exception e) { Console.WriteLine(e.ToString()); }
- }
- }
- public static void CulculateRankRouse(Flowers afflow)
- {
- lock (RouseLock)
- {
- try
- {
- if (!Rankrose.Contains(afflow))
- Rankrose.Add(afflow);
- var data = Rankrose.ToArray();
- Array.Sort(data, (c1, c2) => { return c2.RedRoses.CompareTo(c1.RedRoses); });
- var room = data.ToArray();
- List<Flowers> backUpd = new List<Flowers>();
- int x = 1;
- foreach (Flowers flow in room)
- {
- if (flow.RedRoses == 0) continue;
- if (x < 100)
- {
- flow.RankRoses = x;
- backUpd.Add(flow);
- }
- else
- {
- flow.RankRoses = 0;
- }
- x++;
- }
- lock (RedRousesTop100)
- {
- Rankrose = new List<Flowers>(backUpd);
- RedRousesTop100 = backUpd.ToArray();
- }
- }
- catch (Exception e) { Console.WriteLine(e.ToString()); }
- }
- }
- public static void CulculateRankLilies(Flowers afflow)
- {
- lock (LilisLock)
- {
- if (!Ranklili.Contains(afflow))
- Ranklili.Add(afflow);
- var data = Ranklili.ToArray();
- Array.Sort(data, (c1, c2) => { return c2.Lilies.CompareTo(c1.Lilies); });
- //IEnumerable<Flowers> query = data.OrderBy(redrous => redrous.Tulips);
- //var room = query.ToArray();
- var room = data.ToArray();
- List<Flowers> backUpd = new List<Flowers>();
- int x = 1;
- foreach (Flowers flow in room)
- {
- if (flow.Lilies == 0) continue;
- if (x < 100)
- {
- flow.RankLilies = x;
- backUpd.Add(flow);
- }
- else
- {
- flow.RankLilies = 0;
- }
- x++;
- }
- lock (LiliesTop100)
- {
- Ranklili = new List<Flowers>(backUpd);
- LiliesTop100 = backUpd.ToArray();
- }
- }
- }
- public static void CulculateRankOrchids(Flowers afflow)
- {
- lock (OrchidsLock)
- {
- if (!Rankorchid.Contains(afflow))
- Rankorchid.Add(afflow);
- var data = Rankorchid.ToArray();
- Array.Sort(data, (c1, c2) => { return c2.Orchads.CompareTo(c1.Orchads); });
- //IEnumerable<Flowers> query = data.OrderBy(redrous => redrous.Tulips);
- //var room = query.ToArray();
- var room = data.ToArray();
- List<Flowers> backUpd = new List<Flowers>();
- int x = 1;
- foreach (Flowers flow in room)
- {
- if (flow.Orchads == 0) continue;
- if (x < 100)
- {
- flow.RankOrchids = x;
- backUpd.Add(flow);
- }
- else
- {
- flow.RankOrchids = 0;
- }
- x++;
- }
- lock (OrchidsTop100)
- {
- Rankorchid = new List<Flowers>(backUpd);
- OrchidsTop100 = backUpd.ToArray();
- }
- }
- }
- public static void CulculateRankTulips(Flowers afflow)
- {
- lock (TulipsLock)
- {
- if (!RankTulips.Contains(afflow))
- RankTulips.Add(afflow);
- var data = RankTulips.ToArray();
- Array.Sort(data, (c1, c2) => { return c2.Tulips.CompareTo(c1.Tulips); });
- var room = data.ToArray();
- List<Flowers> backUpd = new List<Flowers>();
- int x = 1;
- foreach (Flowers flow in room)
- {
- if (flow.Tulips == 0) continue;
- if (x < 100)
- {
- flow.RankTuilps = x;
- backUpd.Add(flow);
- }
- else
- {
- flow.RankTuilps = 0;
- }
- x++;
- }
- lock (TulipsTop100)
- {
- RankTulips = new List<Flowers>(backUpd);
- TulipsTop100 = backUpd.ToArray();
- }
- }
- }
- public static void MsgRank(byte[] packet, GameState client)
- {
- MsgRank ranking = new MsgRank(false);
- ranking.Deserialize(packet);
- switch (ranking.Mode)
- {
- case Network.GamePackets.MsgRank.Ranking:
- {
- if (ranking.RankingType >= Network.GamePackets.MsgRank.Prestige && ranking.RankingType < Network.GamePackets.MsgRank.Prestige + 11)
- {
- foreach (var c in Kernel.GamePool.Values)
- {
- PerfectionManager.CalcAndAdd(c);
- }
- PerfectionManager.ShowRank(ranking, client);
- }
- if (ranking.RankingType == 70000000)
- MsgTrainingVitality.ShowGenericRanking3(ranking, client);
- if (ranking.RankingType >= Network.GamePackets.MsgRank.DragonChi && ranking.RankingType <= Network.GamePackets.MsgRank.TurtleChi)
- MsgTrainingVitality.ShowGenericRanking(ranking, client);
- else if (ranking.RankingType >= Network.GamePackets.MsgRank.RoseFairy && ranking.RankingType <= Network.GamePackets.MsgRank.TulipFairy)
- MsgTrainingVitality.ShowGenericRanking2(ranking, client);
- else if (ranking.RankingType >= Network.GamePackets.MsgRank.Kiss && ranking.RankingType <= Network.GamePackets.MsgRank.Jade)
- MsgTrainingVitality.ShowGenericRanking2(ranking, client);
- break;
- }
- case Network.GamePackets.MsgRank.QueryCount:
- {
- if (ranking.RankingType == 70000000)
- {
- if (client.Player.InnerPower != null)
- {
- MsgRank genericRanking3 = new MsgRank(true);
- genericRanking3.Mode = 2;
- genericRanking3.RankingType = ranking.RankingType;
- genericRanking3.Count = 1;
- genericRanking3.Append((uint)client.Player.InnerPower.Rank, client.Player.InnerPower.TotalScore, client.Player.UID, client.Player.Name);
- client.Send(genericRanking3.ToArray());
- }
- return;
- }
- if (Flowers.IsGirl((uint)client.Player.Body))
- {
- if (client.Player.MyFlowers != null)
- {
- int num61 = -1;
- uint num62 = Flowers.CreateMyRank(client, out num61);
- packet[4] = 5;
- client.Send(packet);
- client.Player.FlowerRank = (uint)client.Player.MyFlowers.SendScreenValue((Game.Features.Flowers.FlowersT)num62, num61);
- MsgRank genericRanking2 = new MsgRank(true);
- genericRanking2.Mode = 2u;
- genericRanking2.RankingType = client.Player.FlowerRank;
- genericRanking2.Count = 1u;
- int rank = num61;
- if (client.Player.MyFlowers.RankRoses < 100 && client.Player.MyFlowers.RankRoses > 0)
- {
- genericRanking2.RankingType = Network.GamePackets.MsgRank.RoseFairy;
- genericRanking2.Append((uint)client.Player.MyFlowers.RankRoses, client.Player.MyFlowers.RedRoses, client.Player.UID, client.Player.Name);
- client.Send(genericRanking2.ToArray());
- }
- if (client.Player.MyFlowers.RankLilies < 100 && client.Player.MyFlowers.RankLilies > 0)
- {
- genericRanking2.Reset();
- genericRanking2.RankingType = Network.GamePackets.MsgRank.LilyFairy;
- genericRanking2.Append((uint)client.Player.MyFlowers.RankLilies, client.Player.MyFlowers.Lilies, client.Player.UID, client.Player.Name);
- client.Send(genericRanking2.ToArray());
- }
- if (client.Player.MyFlowers.RankOrchids < 100 && client.Player.MyFlowers.RankOrchids > 0)
- {
- genericRanking2.Reset();
- genericRanking2.RankingType = Network.GamePackets.MsgRank.OrchidFairy;
- genericRanking2.Append((uint)client.Player.MyFlowers.RankOrchids, client.Player.MyFlowers.Orchads, client.Player.UID, client.Player.Name);
- client.Send(genericRanking2.ToArray());
- }
- if (client.Player.MyFlowers.RankTuilps < 100 && client.Player.MyFlowers.RankTuilps > 0)
- {
- genericRanking2.Reset();
- genericRanking2.RankingType = Network.GamePackets.MsgRank.TulipFairy;
- genericRanking2.Append((uint)client.Player.MyFlowers.RankTuilps, client.Player.MyFlowers.Tulips, client.Player.UID, client.Player.Name);
- client.Send(genericRanking2.ToArray());
- }
- //switch (num62)
- //{
- // case 0u:
- // genericRanking2.Append((uint)rank, client.Player.MyFlowers.RedRoses, client.Player.UID, client.Player.Name);
- // break;
- // case 1u:
- // genericRanking2.Append((uint)rank, client.Player.MyFlowers.Lilies, client.Player.UID, client.Player.Name);
- // break;
- // case 2u:
- // genericRanking2.Append((uint)rank, client.Player.MyFlowers.Orchads, client.Player.UID, client.Player.Name);
- // break;
- // case 3u:
- // genericRanking2.Append((uint)rank, client.Player.MyFlowers.Tulips, client.Player.UID, client.Player.Name);
- // break;
- //}
- //client.Send(genericRanking2.ToArray());
- packet[4] = 5;
- client.Send(packet);
- break;
- }
- break;
- }
- else
- {
- if (client.Player.MyFlowers != null)
- {
- MsgRank genericRanking3 = new MsgRank(true);
- genericRanking3.Mode = 2u;
- genericRanking3.RankingType = 30000402u;
- genericRanking3.Count = 1u;
- if (client.Player.MyFlowers.RankRoses < 100 && client.Player.MyFlowers.RankRoses > 0)
- {
- genericRanking3.Append((uint)client.Player.MyFlowers.RankRoses, client.Player.MyFlowers.RedRoses, client.Player.UID, client.Player.Name);
- client.Send(genericRanking3.ToArray());
- }
- if (client.Player.MyFlowers.RankLilies < 100 && client.Player.MyFlowers.RankLilies > 0)
- {
- genericRanking3.Reset();
- genericRanking3.Append((uint)client.Player.MyFlowers.RankLilies, client.Player.MyFlowers.Lilies, client.Player.UID, client.Player.Name);
- genericRanking3.RankingType = 30000502u;
- client.Send(genericRanking3.ToArray());
- }
- if (client.Player.MyFlowers.RankOrchids < 100 && client.Player.MyFlowers.RankOrchids > 0)
- {
- genericRanking3.Reset();
- genericRanking3.Append((uint)client.Player.MyFlowers.RankOrchids, client.Player.MyFlowers.Orchads, client.Player.UID, client.Player.Name);
- genericRanking3.RankingType = 30000602u;
- client.Send(genericRanking3.ToArray());
- }
- if (client.Player.MyFlowers.RankTuilps < 100 && client.Player.MyFlowers.RankTuilps > 0)
- {
- genericRanking3.Reset();
- genericRanking3.Append((uint)client.Player.MyFlowers.RankTuilps, client.Player.MyFlowers.Tulips, client.Player.UID, client.Player.Name);
- genericRanking3.RankingType = 30000702u;
- client.Send(genericRanking3.ToArray());
- }
- packet[4] = 5;
- client.Send(packet);
- break;
- }
- }
- break;
- }
- }
- }
- public static void MsgFlower(Client.GameState client, byte[] packet)
- {
- byte typ1 = packet[4];
- uint Target = BitConverter.ToUInt32(packet, 8);
- uint ITEM_UID = BitConverter.ToUInt32(packet, 12);
- if (IsBoy(client.Player.Body) && typ1 == 0)//boy send
- {
- switch (ITEM_UID)
- {
- case 0://send my flower
- {
- if (client.Player.MyFlowers.aFlower == 0) break;
- Client.GameState target_client;
- if (Kernel.GamePool.TryGetValue(Target, out target_client))
- {
- if (!IsGirl(target_client.Player.Body)) return;
- client.Player.MyFlowers.aFlower = 0;
- client.Player.MyFlowers.SendDay = (uint)DateTime.Now.Day;
- target_client.Player.MyFlowers.RedRoses2day += 1;
- target_client.Player.MyFlowers.RedRoses += 1;
- SendFlower flow = new SendFlower();
- flow.Typing = 0;
- flow.Effect = (byte)Game.Features.Flowers.Effect.Tulips;
- flow.Amount = 1;
- flow.SenderName = client.Player.Name;
- flow.ReceiverName = target_client.Player.Name;
- flow.FType = (byte)Game.Features.Flowers.FlowersT.Rouse;
- client.SendScreen(flow.ToArray(), true);
- }
- break;
- }
- default:
- {
- Network.GamePackets.MsgItemInfo Item = null;
- if (client.Inventory.TryGetItem(ITEM_UID, out Item))
- {
- Client.GameState target_client;
- if (Kernel.GamePool.TryGetValue(Target, out target_client))
- {
- if (!IsGirl(target_client.Player.Body)) return;
- uint Amount = Item.ID % 1000;
- SendFlower flow = new SendFlower();
- flow.Typing = typ1;
- flow.Amount = Amount;
- flow.SenderName = client.Player.Name;
- flow.ReceiverName = target_client.Player.Name;
- switch (GetFlowerTyp(Item.ID))
- {
- case (byte)Game.Features.Flowers.FlowersT.Rouse:
- {
- flow.Effect = (byte)Game.Features.Flowers.Effect.Rouse;
- flow.FType = (byte)Game.Features.Flowers.FlowersT.Rouse;
- target_client.Player.MyFlowers.RedRoses2day += Amount;
- target_client.Player.MyFlowers.RedRoses += Amount;
- if (Game.Features.Flowers.RedRousesTop100.Length > 98)
- {
- if (Game.Features.Flowers.RedRousesTop100[98].RedRoses <= target_client.Player.MyFlowers.RedRoses)
- {
- Game.Features.Flowers.CulculateRankRouse(target_client.Player.MyFlowers);
- }
- }
- else Game.Features.Flowers.CulculateRankRouse(target_client.Player.MyFlowers);
- break;
- }
- case (byte)Game.Features.Flowers.FlowersT.Lilies:
- {
- flow.Effect = (byte)Game.Features.Flowers.Effect.Lilies;
- flow.FType = (byte)Game.Features.Flowers.FlowersT.Lilies;
- target_client.Player.MyFlowers.Lilies2day += Amount;
- target_client.Player.MyFlowers.Lilies += Amount;
- if (Game.Features.Flowers.LiliesTop100.Length > 98)
- {
- if (Game.Features.Flowers.LiliesTop100[98].Lilies <= target_client.Player.MyFlowers.Lilies)
- {
- Game.Features.Flowers.CulculateRankLilies(target_client.Player.MyFlowers);
- }
- }
- else Game.Features.Flowers.CulculateRankLilies(target_client.Player.MyFlowers);
- break;
- }
- case (byte)Game.Features.Flowers.FlowersT.Orchids:
- {
- flow.Effect = (byte)Game.Features.Flowers.Effect.Orchids;
- flow.FType = (byte)Game.Features.Flowers.FlowersT.Orchids;
- target_client.Player.MyFlowers.Orchads2day += Amount;
- target_client.Player.MyFlowers.Orchads += Amount;
- if (Game.Features.Flowers.OrchidsTop100.Length > 98)
- {
- if (Game.Features.Flowers.OrchidsTop100[98].Orchads <= target_client.Player.MyFlowers.Orchads)
- {
- Game.Features.Flowers.CulculateRankOrchids(target_client.Player.MyFlowers);
- }
- }
- else Game.Features.Flowers.CulculateRankOrchids(target_client.Player.MyFlowers);
- break;
- }
- case (byte)Game.Features.Flowers.FlowersT.Tulips:
- {
- flow.Effect = (byte)Game.Features.Flowers.Effect.Tulips;
- flow.FType = (byte)Game.Features.Flowers.FlowersT.Tulips;
- target_client.Player.MyFlowers.Tulips2day += Amount;
- target_client.Player.MyFlowers.Tulips += Amount;
- if (Game.Features.Flowers.TulipsTop100.Length > 98)
- {
- if (Game.Features.Flowers.TulipsTop100[98].Tulips <= target_client.Player.MyFlowers.Tulips)
- {
- Game.Features.Flowers.CulculateRankTulips(target_client.Player.MyFlowers);
- }
- }
- else Game.Features.Flowers.CulculateRankTulips(target_client.Player.MyFlowers);
- break;
- }
- }
- client.Inventory.Remove(Item, Enums.ItemUse.Remove);
- client.SendScreen(flow.ToArray(), true);
- }
- }
- break;
- }
- }
- }
- else if (IsGirl(client.Player.Body) && typ1 == 1)//girl send
- {
- switch (ITEM_UID)
- {
- case 0://curent flower
- {
- if (client.Player.MyFlowers.aFlower == 0)
- return;
- Client.GameState target_client;
- if (Kernel.GamePool.TryGetValue(Target, out target_client))
- {
- if (!IsBoy(target_client.Player.Body)) return;
- client.Player.MyFlowers.aFlower = 0;
- client.Player.MyFlowers.SendDay = (uint)DateTime.Now.Day;
- target_client.Player.MyFlowers.RedRoses += 1;
- target_client.Player.MyFlowers.RedRoses2day += 1;
- SendFlower flow = new SendFlower();
- flow.Typing = 1;
- flow.Effect = (byte)Game.Features.Flowers.Effect.Kiss;
- flow.Amount = 1;
- flow.SenderName = client.Player.Name;
- flow.ReceiverName = target_client.Player.Name;
- flow.FType = (byte)Game.Features.Flowers.FlowersT.Kiss;
- client.SendScreen(flow.ToArray(), true);
- }
- break;
- }
- default:
- {
- MsgItemInfo Item = null;
- if (client.Inventory.TryGetItem(ITEM_UID, out Item))
- {
- Client.GameState target_client = null;
- if (Kernel.GamePool.TryGetValue(Target, out target_client))
- {
- if (!IsBoy(target_client.Player.Body)) return;
- uint Amount = Item.ID % 1000;
- SendFlower flow = new SendFlower();
- flow.Typing = 1;
- flow.Amount = Amount;
- flow.SenderName = client.Player.Name;
- flow.ReceiverName = target_client.Player.Name;
- switch (GetFlowerTyp(Item.ID))
- {
- case (byte)Game.Features.Flowers.FlowersT.Rouse:
- {
- flow.Effect = (byte)Game.Features.Flowers.Effect.Kiss;
- flow.FType = (byte)Game.Features.Flowers.FlowersT.Kiss;
- target_client.Player.MyFlowers.RedRoses2day += Amount;
- target_client.Player.MyFlowers.RedRoses += Amount;
- if (Game.Features.Flowers.KissTop100.Length > 98)
- {
- if (Game.Features.Flowers.KissTop100[98].RedRoses <= target_client.Player.MyFlowers.RedRoses)
- {
- Game.Features.Flowers.CulculateRankKiss(target_client.Player.MyFlowers);
- }
- }
- else Game.Features.Flowers.CulculateRankKiss(target_client.Player.MyFlowers);
- break;
- }
- case (byte)Game.Features.Flowers.FlowersT.Lilies:
- {
- flow.Effect = (byte)Game.Features.Flowers.Effect.love;
- flow.FType = (byte)Game.Features.Flowers.FlowersT.love;
- target_client.Player.MyFlowers.Lilies2day += Amount;
- target_client.Player.MyFlowers.Lilies += Amount;
- if (Game.Features.Flowers.LoveTop100.Length > 98)
- {
- if (Game.Features.Flowers.LoveTop100[98].Lilies <= target_client.Player.MyFlowers.Lilies)
- {
- Game.Features.Flowers.CulculateRankLove(target_client.Player.MyFlowers);
- }
- }
- else Game.Features.Flowers.CulculateRankLove(target_client.Player.MyFlowers);
- break;
- }
- case (byte)Game.Features.Flowers.FlowersT.Orchids:
- {
- flow.Effect = (byte)Game.Features.Flowers.Effect.Tins;
- flow.FType = (byte)Game.Features.Flowers.FlowersT.Tins;
- target_client.Player.MyFlowers.Orchads2day += Amount;
- target_client.Player.MyFlowers.Orchads += Amount;
- if (Game.Features.Flowers.TineTop100.Length > 98)
- {
- if (Game.Features.Flowers.TineTop100[98].Orchads <= target_client.Player.MyFlowers.Orchads)
- {
- Game.Features.Flowers.CulculateRankTine(target_client.Player.MyFlowers);
- }
- }
- else Game.Features.Flowers.CulculateRankTine(target_client.Player.MyFlowers);
- break;
- }
- case (byte)Game.Features.Flowers.FlowersT.Tulips:
- {
- flow.Effect = (byte)Game.Features.Flowers.Effect.Jade;
- flow.FType = (byte)Game.Features.Flowers.FlowersT.Jade;
- target_client.Player.MyFlowers.Tulips2day += Amount;
- target_client.Player.MyFlowers.Tulips += Amount;
- if (Game.Features.Flowers.JadeTop100.Length > 98)
- {
- if (Game.Features.Flowers.JadeTop100[98].Tulips <= target_client.Player.MyFlowers.Tulips)
- {
- Game.Features.Flowers.CulculateRankJade(target_client.Player.MyFlowers);
- }
- }
- else Game.Features.Flowers.CulculateRankJade(target_client.Player.MyFlowers);
- break;
- }
- }
- client.Inventory.Remove(Item, Enums.ItemUse.Remove);
- client.SendScreen(flow.ToArray(), true);
- }
- }
- break;
- }
- }
- }
- }
- public static uint CreateMyRank(Client.GameState client, out int rank)
- {
- List<ClientRank> FRanks = new List<ClientRank>()
- {
- new ClientRank(){Rank = (uint)client.Player.MyFlowers.RankLilies, Amount = client.Player.MyFlowers.Lilies}
- , new ClientRank(){Rank = (uint)client.Player.MyFlowers.RankOrchids, Amount = client.Player.MyFlowers.Orchads}
- , new ClientRank(){Rank = (uint)client.Player.MyFlowers.RankRoses, Amount = client.Player.MyFlowers.RedRoses}
- , new ClientRank(){Rank = (uint)client.Player.MyFlowers.RankTuilps, Amount = client.Player.MyFlowers.Tulips}
- };
- var array = FRanks.Where((f1) => f1.Rank != 0).ToArray();
- Array.Sort(array, (f1, f2) =>
- {
- int n_rank = f1.Rank.CompareTo(f2.Rank);
- if (f2.Rank == f1.Rank)
- return f2.Amount.CompareTo(f1.Amount);
- return n_rank;
- });
- if (array != null && array.Length > 0)
- {
- ClientRank BestRank = array[0];
- if (BestRank.Rank != 0)
- {
- rank = (int)BestRank.Rank;
- if (client.Player.MyFlowers.RankLilies == BestRank.Rank && client.Player.MyFlowers.Lilies == BestRank.Amount)
- return (byte)Game.Features.Flowers.FlowersT.Lilies;
- if (client.Player.MyFlowers.RankOrchids == BestRank.Rank && client.Player.MyFlowers.Orchads == BestRank.Amount)
- return (byte)Game.Features.Flowers.FlowersT.Orchids;
- if (client.Player.MyFlowers.RankRoses == BestRank.Rank && client.Player.MyFlowers.RedRoses == BestRank.Amount)
- return (byte)Game.Features.Flowers.FlowersT.Rouse;
- if (client.Player.MyFlowers.RankTuilps == BestRank.Rank && client.Player.MyFlowers.Tulips == BestRank.Amount)
- return (byte)Game.Features.Flowers.FlowersT.Tulips;
- }
- }
- rank = 0;
- return 0;
- }
- public static uint GetFlowerTyp(uint ID)
- {
- if (ID >= 751001 && ID <= 751999 || ID >= 755001 && ID <= 755999)
- return (uint)Game.Features.Flowers.FlowersT.Rouse;
- if (ID >= 752001 && ID <= 752999 || ID >= 756001 && ID <= 756999)
- return (uint)Game.Features.Flowers.FlowersT.Lilies;
- if (ID >= 753001 && ID <= 753999 || ID >= 757001 && ID <= 757999)
- return (uint)Game.Features.Flowers.FlowersT.Orchids;
- if (ID >= 754001 && ID <= 754999 || ID >= 758001 && ID <= 758999)
- return (uint)Game.Features.Flowers.FlowersT.Tulips;
- return 0;
- }
- public static bool IsBoy(uint mesh)
- {
- return mesh == 1003 || mesh == 1004;
- }
- public static bool IsGirl(uint mesh)
- {
- return mesh == 2001 || mesh == 2002;
- }
- public class ClientRank
- {
- public uint Rank;
- public uint Amount;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement