|
public static void Sort(
public static void Sort(uint updateUID)
{
SafeDictionary<uint, NobilityInformation> sortedBoard = new SafeDictionary<uint, NobilityInformation>();
int Place = 0;
foreach (NobilityInformation entry in Board.Values.OrderByDescending((p) => p.Donation))
{
Client.GameState client = null;
try
{
int previousPlace = entry.Position;
entry.Position = Place;
NobilityRank Rank = NobilityRank.Serf;
if (Place >= 50)
{
if (entry.Donation == 1)
{
Rank = NobilityRank.King;
}
else
{
if (entry.Donation >= 200000000)
{
Rank = NobilityRank.Earl;
}
else if (entry.Donation >= 100000000)
{
Rank = NobilityRank.Baron;
}
else if (entry.Donation >= 30000000)
{
Rank = NobilityRank.Knight;
}
else
{
Rank = NobilityRank.Serf;
}
}
}
else
{
if (entry.Donation == 1)
{
Rank = NobilityRank.King;
}
else
{
if (Place < 2)//serverrank
{
Rank = NobilityRank.King;
}
else if (Place < 24)
{
Rank = NobilityRank.Prince;
}
else
{
Rank = NobilityRank.Duke;
}
}
}
var oldRank = entry.Rank;
entry.Rank = Rank;
if (Kernel.GamePool.TryGetValue(entry.EntityUID, out client))
{
bool updateTheClient = false;
if (oldRank != Rank)
{
updateTheClient = true;
if (Rank == NobilityRank.Duke)
{
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " has the Duke title in Frozen||Hell.", System.Drawing.Color.White, Message.Center), Program.Values);
}
if (Rank == NobilityRank.Prince)
{
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " has the Prince title in Frozen||Hell.", System.Drawing.Color.White, Message.Center), Program.Values);
}
if (Rank == NobilityRank.King)
{
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " has become the new King/Queen in Frozen||Hell.", System.Drawing.Color.White, Message.Center), Program.Values);
}
}
else
{
if (previousPlace != Place)
{
updateTheClient = true;
}
}
if (updateTheClient || client.Entity.UID == updateUID)
{
NobilityInfo update = new NobilityInfo(true);
update.Type = NobilityInfo.Icon;
update.dwParam = entry.EntityUID;
update.UpdateString(entry);
client.SendScreen(update, true);
client.Entity.NobilityRank = entry.Rank;
}
}
sortedBoard.Add(entry.EntityUID, entry);
Place++;
}
catch { }
}
Board = sortedBoard;
lock (BoardList)
BoardList = Board.Values.ToList();
}
public static void Sort(
public static void Sort(uint updateUID)
{
SafeDictionary<uint, NobilityInformation> sortedBoard = new SafeDictionary<uint, NobilityInformation>();
int Place = 0;
foreach (NobilityInformation entry in Board.Values.OrderByDescending((p) => p.Donation))
{
Client.GameState client = null;
try
{
int previousPlace = entry.Position;
entry.Position = Place;
NobilityRank Rank = NobilityRank.Serf;
if (Place >= 50)
{
if (entry.Donation == 1)
{
Rank = NobilityRank.King;
}
else
{
if (entry.Donation >= 200000000)
{
Rank = NobilityRank.Earl;
}
else if (entry.Donation >= 100000000)
{
Rank = NobilityRank.Baron;
}
else if (entry.Donation >= 30000000)
{
Rank = NobilityRank.Knight;
}
else
{
Rank = NobilityRank.Serf;
}
}
}
else
{
if (entry.Donation == 1)
{
Rank = NobilityRank.King;
}
else
{
if (Place < 2)//serverrank
{
Rank = NobilityRank.King;
}
else if (Place < 24)
{
Rank = NobilityRank.Prince;
}
else
{
Rank = NobilityRank.Duke;
}
}
}
var oldRank = entry.Rank;
entry.Rank = Rank;
if (Kernel.GamePool.TryGetValue(entry.EntityUID, out client))
{
bool updateTheClient = false;
if (oldRank != Rank)
{
updateTheClient = true;
if (Rank == NobilityRank.Duke)
{
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " has the Duke title in Frozen||Hell.", System.Drawing.Color.White, Message.Center), Program.Values);
}
if (Rank == NobilityRank.Prince)
{
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " has the Prince title in Frozen||Hell.", System.Drawing.Color.White, Message.Center), Program.Values);
}
if (Rank == NobilityRank.King)
{
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " has become the new King/Queen in Frozen||Hell.", System.Drawing.Color.White, Message.Center), Program.Values);
}
}
else
{
if (previousPlace != Place)
{
updateTheClient = true;
}
}
if (updateTheClient || client.Entity.UID == updateUID)
{
NobilityInfo update = new NobilityInfo(true);
update.Type = NobilityInfo.Icon;
update.dwParam = entry.EntityUID;
update.UpdateString(entry);
client.SendScreen(update, true);
client.Entity.NobilityRank = entry.Rank;
}
}
sortedBoard.Add(entry.EntityUID, entry);
Place++;
}
catch { }
}
Board = sortedBoard;
lock (BoardList)
BoardList = Board.Values.ToList();
}
public static void Sort(
public static void Sort(uint updateUID)
{
SafeDictionary<uint, NobilityInformation> sortedBoard = new SafeDictionary<uint, NobilityInformation>();
int Place = 0;
foreach (NobilityInformation entry in Board.Values.OrderByDescending((p) => p.Donation))
{
Client.GameState client = null;
try
{
int previousPlace = entry.Position;
entry.Position = Place;
NobilityRank Rank = NobilityRank.Serf;
if (Place >= 50)
{
if (entry.Donation == 1)
{
Rank = NobilityRank.King;
}
else
{
if (entry.Donation >= 200000000)
{
Rank = NobilityRank.Earl;
}
else if (entry.Donation >= 100000000)
{
Rank = NobilityRank.Baron;
}
else if (entry.Donation >= 30000000)
{
Rank = NobilityRank.Knight;
}
else
{
Rank = NobilityRank.Serf;
}
}
}
else
{
if (entry.Donation == 1)
{
Rank = NobilityRank.King;
}
else
{
if (Place < 2)//serverrank
{
Rank = NobilityRank.King;
}
else if (Place < 24)
{
Rank = NobilityRank.Prince;
}
else
{
Rank = NobilityRank.Duke;
}
}
}
var oldRank = entry.Rank;
entry.Rank = Rank;
if (Kernel.GamePool.TryGetValue(entry.EntityUID, out client))
{
bool updateTheClient = false;
if (oldRank != Rank)
{
updateTheClient = true;
if (Rank == NobilityRank.Duke)
{
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " has the Duke title in Frozen||Hell.", System.Drawing.Color.White, Message.Center), Program.Values);
}
if (Rank == NobilityRank.Prince)
{
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " has the Prince title in Frozen||Hell.", System.Drawing.Color.White, Message.Center), Program.Values);
}
if (Rank == NobilityRank.King)
{
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " has become the new King/Queen in Frozen||Hell.", System.Drawing.Color.White, Message.Center), Program.Values);
}
}
else
{
if (previousPlace != Place)
{
updateTheClient = true;
}
}
if (updateTheClient || client.Entity.UID == updateUID)
{
NobilityInfo update = new NobilityInfo(true);
update.Type = NobilityInfo.Icon;
update.dwParam = entry.EntityUID;
update.UpdateString(entry);
client.SendScreen(update, true);
client.Entity.NobilityRank = entry.Rank;
}
}
sortedBoard.Add(entry.EntityUID, entry);
Place++;
}
catch { }
}
Board = sortedBoard;
lock (BoardList)
BoardList = Board.Values.ToList();
}
using System;
using System.IO;
using System.Linq;
using Viorx.Client;
using System.Collections.Generic;
using Viorx.Network.GamePackets;
namespace Viorx.Game.ConquerStructures
{
public class Nobility : Network.Writer
{
public static SafeDictionary<uint, NobilityInformation> Board = new SafeDictionary<uint, NobilityInformation>(10000);
public static void Handle(NobilityInfo information, Client.GameState client)
{
switch (information.Type)
{
case NobilityInfo.Donate:
{
if (client.Trade.InTrade)
return;
if (client.Entity.PokerHack == true)
return;
ulong silvers = information.dwParam;
bool newDonator = false;
client.NobilityInformation.Gender = (byte)(client.Entity.Body % 10);
if (client.NobilityInformation.Donation == 0)
newDonator = true;
if (information.MoneyType == 1)
{
ulong cps = silvers / 1;
if (client.Entity.ConquerPoints >= cps)
{
client.Entity.ConquerPoints -= (uint)cps;
client.NobilityInformation.Donation += silvers;
}
}
else
{
if (client.Entity.Money >= silvers)
{
client.Entity.Money -= (ulong)silvers;
client.NobilityInformation.Donation += silvers;
}
}
if (!Board.ContainsKey(client.Entity.UID) && client.NobilityInformation.Donation == silvers && newDonator)
{
Board.Add(client.Entity.UID, client.NobilityInformation);
try
{
Database.NobilityTable.InsertNobilityInformation(c lient.NobilityInformation);
}
catch
{
Database.NobilityTable.UpdateNobilityInformation(c lient.NobilityInformation);
}
}
else
{
Database.NobilityTable.UpdateNobilityInformation(c lient.NobilityInformation);
}
Sort(client.Entity.UID);
break;
}
case NobilityInfo.List:
{
byte[] packet = new byte[608];
WriteUInt16((ushort)(packet.Length - 8), 0, packet);
WriteUInt16(2064, 2, packet);
WriteUInt16(2, 4, packet);
WriteUInt16((ushort)(Board.Count > 50 ? 5 : (Board.Count / 10) + 1), 10, packet);
int offset = 120;
ushort rank = 0;
rank = (ushort)(information.wParam1 * 10);
foreach (var entity in Board.Values.OrderByDescending(e => e.Donation).Skip(information.wParam1 * 10).Take(10))
{
WriteUInt32(entity.EntityUID, offset, packet);
offset += 4;
WriteUInt32(1, offset, packet);
offset += 4;
WriteUInt32(entity.Mesh, offset, packet);
offset += 4;
WriteString(entity.Name, offset, packet);
offset += 20;
WriteUInt64(entity.Donation, offset, packet);
offset += 8;
entity.Rank = getMyRank(entity.Donation, rank);
WriteUInt32((uint)entity.Rank, offset, packet);
offset += 4;
WriteUInt32((uint)rank, offset, packet);
offset += 4;
rank++;
}
WriteUInt16(rank, 12, packet);
client.Send(packet);
break;
}
}
}
private static void Sort(uint p)
{
throw new NotImplementedException();
}
private static NobilityRank getMyRank(ulong donation, int currentRank)
{
if (currentRank >= 0 && currentRank < 999999)
{
return NobilityRank.King;
}
else if (currentRank >= 10 && currentRank < 0)
{
return NobilityRank.Prince;
}
else if (currentRank >= 50 && currentRank < 0)
{
return NobilityRank.Duke;
}
else
{
return NobilityRank.Serf;
}
}
public static void Donate(ulong silvers, Client.GameState client)
{
bool newDonator = false;
client.NobilityInformation.Gender = (byte)(client.Entity.Body % 10);
if (client.NobilityInformation.Donation == 0) newDonator = true;
client.NobilityInformation.Donation += silvers;
int oldpos = client.NobilityInformation.Position;
if (!Board.ContainsKey(client.Entity.UID) && client.NobilityInformation.Donation == silvers && newDonator)
{
Board.Add(client.Entity.UID, client.NobilityInformation);
try
{
Database.NobilityTable.InsertNobilityInformation(c lient.NobilityInformation);
}
catch
{
Database.NobilityTable.UpdateNobilityInformation(c lient.NobilityInformation);
}
}
else
{
Database.NobilityTable.UpdateNobilityInformation(c lient.NobilityInformation);
}
updateOthers(oldpos, client);
}
private static void updateOthers(int oldPosition, GameState client)
{
int newpos = getPosition(client.Entity.UID);
var Rank = getMyRank(client.NobilityInformation.Donation, newpos);
if (oldPosition != newpos)
{
if (Rank == NobilityRank.King || Rank == NobilityRank.Prince || Rank == NobilityRank.Duke)
foreach (var p in Board.Values.OrderByDescending(e => e.Donation).Skip(newpos).Take(50 - newpos))
{
GameState cl = null;
if (Kernel.GamePool.TryGetValue(p.EntityUID, out cl))
SendIconToClient(cl);
}
}
SendIconToClient(client);
}
private static int getPosition(uint entityuid)
{
int currentPos = -1, post = -1;
if (Board.ContainsKey(entityuid))
{
foreach (var p in Board.Values.OrderByDescending(e => e.Donation))
{
currentPos++;
if (entityuid == p.EntityUID)
{
post = currentPos;
break;
}
}
}
return post;
}
public static void SendIconToClient(Client.GameState client)
{
if (client != null && client.NobilityInformation != null)
{
int pos = getPosition(client.Entity.UID);
client.Entity.NobilityRank = client.NobilityInformation.Rank = getMyRank(client.NobilityInformation.Donation, pos);
NobilityInfo update = new NobilityInfo(true);
update.Type = NobilityInfo.Icon;
update.dwParam = client.Entity.UID;
client.NobilityInformation.Position = pos;
update.UpdateString(client.NobilityInformation);
client.SendScreen(update, true);
}
}
}
public class NobilityInformation
{
public string Name;
public uint EntityUID;
public uint Mesh;
public ulong Donation;
public byte Gender;
public int Position;
public NobilityRank Rank;
}
public enum NobilityRank : byte
{
Serf = 0,
Knight = 1,
Baron = 3,
Earl = 5,
Duke = 7,
Prince = 9,
King = 12,
}
}
using system;
using system.io;
using system.linq;
using viorx.client;
using system.collections.generic;
using viorx.network.gamepackets;
namespace viorx.game.conquerstructures
{
public class nobility : Network.writer
{
public static safedictionary<uint, nobilityinformation> board = new safedictionary<uint, nobilityinformation>(10000);
public static void handle(nobilityinfo information, client.gamestate client)
{
switch (information.type)
{
case nobilityinfo.donate:
{
if (client.trade.intrade)
return;
if (client.entity.pokerhack == true)
return;
ulong silvers = information.dwparam;
bool newdonator = false;
client.nobilityinformation.gender = (byte)(client.entity.body % 10);
if (client.nobilityinformation.donation == 0)
newdonator = true;
if (information.moneytype == 1)
{
ulong cps = silvers / 1;
if (client.entity.conquerpoints >= cps)
{
client.entity.conquerpoints -= (uint)cps;
client.nobilityinformation.donation += silvers;
}
}
else
{
if (client.entity.money >= silvers)
{
client.entity.money -= (ulong)silvers;
client.nobilityinformation.donation += silvers;
}
}
if (!board.containskey(client.entity.uid) && client.nobilityinformation.donation == silvers && newdonator)
{
board.add(client.entity.uid, client.nobilityinformation);
try
{
database.nobilitytable.insertnobilityinformation(c lient.nobilityinformation);
}
catch
{
database.nobilitytable.updatenobilityinformation(c lient.nobilityinformation);
}
}
else
{
database.nobilitytable.updatenobilityinformation(c lient.nobilityinformation);
}
sort(client.entity.uid);
break;
}
case nobilityinfo.list:
{
byte[] packet = new byte[608];
writeuint16((ushort)(packet.length - 8), 0, packet);
writeuint16(2064, 2, packet);
writeuint16(2, 4, packet);
writeuint16((ushort)(board.count > 50 ? 5 : (board.count / 10) + 1), 10, packet);
int offset = 120;
ushort rank = 0;
rank = (ushort)(information.wparam1 * 10);
foreach (var entity in board.values.orderbydescending(e => e.donation).skip(information.wparam1 * 10).take(10))
{
writeuint32(entity.entityuid, offset, packet);
offset += 4;
writeuint32(1, offset, packet);
offset += 4;
writeuint32(entity.mesh, offset, packet);
offset += 4;
writestring(entity.name, offset, packet);
offset += 20;
writeuint64(entity.donation, offset, packet);
offset += 8;
entity.rank = getmyrank(entity.donation, rank);
writeuint32((uint)entity.rank, offset, packet);
offset += 4;
writeuint32((uint)rank, offset, packet);
offset += 4;
rank++;
}
writeuint16(rank, 12, packet);
client.send(packet);
break;
}
}
}
private static void sort(uint p)
{
throw new notimplementedexception();
}
private static nobilityrank getmyrank(ulong donation, int currentrank)
{
if (currentrank >= 0 && currentrank < 999999)
{
return nobilityrank.king;
}
else if (currentrank >= 10 && currentrank < 0)
{
return nobilityrank.prince;
}
else if (currentrank >= 50 && currentrank < 0)
{
return nobilityrank.duke;
}
else
{
return nobilityrank.serf;
}
}
public static void donate(ulong silvers, client.gamestate client)
{
bool newdonator = false;
client.nobilityinformation.gender = (byte)(client.entity.body % 10);
if (client.nobilityinformation.donation == 0) newdonator = true;
client.nobilityinformation.donation += silvers;
int oldpos = client.nobilityinformation.position;
if (!board.containskey(client.entity.uid) && client.nobilityinformation.donation == silvers && newdonator)
{
board.add(client.entity.uid, client.nobilityinformation);
try
{
database.nobilitytable.insertnobilityinformation(c lient.nobilityinformation);
}
catch
{
database.nobilitytable.updatenobilityinformation(c lient.nobilityinformation);
}
}
else
{
database.nobilitytable.updatenobilityinformation(c lient.nobilityinformation);
}
updateothers(oldpos, client);
}
private static void updateothers(int oldposition, gamestate client)
{
int newpos = getposition(client.entity.uid);
var rank = getmyrank(client.nobilityinformation.donation, newpos);
if (oldposition != newpos)
{
if (rank == nobilityrank.king || rank == nobilityrank.prince || rank == nobilityrank.duke)
foreach (var p in board.values.orderbydescending(e => e.donation).skip(newpos).take(50 - newpos))
{
gamestate cl = null;
if (kernel.gamepool.trygetvalue(p.entityuid, out cl))
sendicontoclient(cl);
}
}
sendicontoclient(client);
}
private static int getposition(uint entityuid)
{
int currentpos = -1, post = -1;
if (board.containskey(entityuid))
{
foreach (var p in board.values.orderbydescending(e => e.donation))
{
currentpos++;
if (entityuid == p.entityuid)
{
post = currentpos;
break;
}
}
}
return post;
}
public static void sendicontoclient(client.gamestate client)
{
if (client != null && client.nobilityinformation != null)
{
int pos = getposition(client.entity.uid);
client.entity.nobilityrank = client.nobilityinformation.rank = getmyrank(client.nobilityinformation.donation, pos);
nobilityinfo update = new nobilityinfo(true);
update.type = nobilityinfo.icon;
update.dwparam = client.entity.uid;
client.nobilityinformation.position = pos;
update.updatestring(client.nobilityinformation);
client.sendscreen(update, true);
}
}
}
public class nobilityinformation
{
public string name;
public uint entityuid;
public uint mesh;
public ulong donation;
public byte gender;
public int position;
public nobilityrank rank;
}
public enum nobilityrank : Byte
{
serf = 0,
knight = 1,
baron = 3,
earl = 5,
duke = 7,
prince = 9,
king = 12,
}
}
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
ازاى اعدل علي شكل التوب الي بيكون علي الاكونت | Omar Mohamed100 | مشكلات السيرفيرات كونكر الشخصيه | 4 | 2023-10-30 07:10 PM |
طلب بخصوص حاجة جمب الاسم | abdocoder | مشكلات السيرفيرات كونكر الشخصيه | 2 | 2020-04-29 06:14 PM |
حاجة مهمة مساعده من اى شخص محترم | nova | مشكلات السيرفيرات كونكر الشخصيه | 2 | 2019-11-18 11:14 PM |
محتاج شرح كما حاجة كده بسيط | اسلام | مشكلات السيرفيرات كونكر الشخصيه | 1 | 2019-09-26 07:13 AM |
حل مشكله بقاء الاكونت في التوب بعد اغلاق وفتحه الاكونت | Tefa | تطوير سيرفرات كونكر | 0 | 2019-08-02 08:44 PM |