|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PlayConquer.Client;
using System.IO;
namespace PlayConquer.Game
{
public interface IJiangHu
{
string OwnName { get; set; }
string CustomizedName { get; set; }
uint UID { get; set; }
byte Talent { get; set; }
byte Stage { get; set; }
byte Star { get; set; }
DateTime StartCountDwon { get; set; }
DateTime CountDownEnd { get; set; }
uint Time { get; }
uint FreeTimeTodey { get; set; }
uint FreeTimeTodeyUsed { get; set; }
uint Inner_Strength { get; set; }
uint FreeCourse { get; set; }
JiangHu.JiangStages[] Stagers { get; set; }
byte Rank { get; set; }
byte Level { get; set; }
ushort RoundBuyPoints { get; set; }
bool OnJiangMode { get; set; }
}
public class JiangHu : IJiangHu
{
public enum AttackFlag
{
None = 0,
NotHitFriends = 1,
NotHitClanMembers = 2,
NotHitGuildMembers = 4,
NotHitAlliedGuild = 8,
NoHitAlliesClan = 16
}
public static System.Collections.Concurrent.ConcurrentDictionary <uint, IJiangHu> JiangHuClients = new System.Collections.Concurrent.ConcurrentDictionary <uint, IJiangHu>();
public static class JiangHuRanking
{
private static System.Collections.Concurrent.ConcurrentDictionary <uint, IJiangHu> TopRank = new System.Collections.Concurrent.ConcurrentDictionary <uint, IJiangHu>();
public static IJiangHu[] TopRank100 = null;
private static object SyncRoot = new object();
public static void UpdateRank(IJiangHu jiang)
{
lock (SyncRoot)
{
if (!TopRank.ContainsKey(jiang.UID))
TopRank.TryAdd(jiang.UID, jiang);
CalculateRanks();
}
}
private static void CalculateRanks()
{
foreach (var jiang in TopRank.Values)
jiang.Rank = 0;
var rankdictionar = TopRank.Values.ToArray();
var ordonateRank = from jiang in rankdictionar orderby jiang.Inner_Strength descending select jiang;
List<IJiangHu> BackUp = new List<IJiangHu>();
byte x = 1;
foreach (var jiang in ordonateRank)
{
if (x == 101)
break;
jiang.Rank = x;
BackUp.Add(jiang);
x++;
}
TopRank100 = BackUp.ToArray();
TopRank = new System.Collections.Concurrent.ConcurrentDictionary <uint, IJiangHu>();
foreach (var jiang in BackUp)
TopRank.TryAdd(jiang.UID, jiang);
BackUp = null;
}
}
public class GetNewStar
{
public byte Stage;
public byte PositionStar;
public JiangStages.Star Star;
}
public class JiangStages
{
public class Star
{
public AtributesType Typ;
public byte Level;
public ushort UID;
public bool Activate = false;
public override string ToString()
{
StringBuilder build = new StringBuilder();
build.Append((byte)(Activate ? 1 : 0) + "#" + UID + "#");
return build.ToString();
}
}
public enum AtributesType
{
None = 0,
MaxLife,//1
PAttack,//2
MAttack,//3
PDefense,//4
Mdefense,//5
FinalAttack,//6
FinalMagicAttack,//7
FinalDefense,//8
FinalMagicDefense,//9
CriticalStrike,//10
SkillCriticalStrike,//11
Immunity,//12
Breakthrough,//13
Counteraction,//14
MaxMana//15
}
public Star[] Stars;
public bool Activate = false;
public JiangStages()
{
Stars = new Star[9];
for (byte x = 0; x < 9; x++)
Stars[x] = new Star();
}
public bool ContainAtribut(AtributesType typ)
{
foreach (var atr in Stars)
if (atr.Typ == typ)
return true;
return false;
}
public override string ToString()
{
StringBuilder build = new StringBuilder();
build.Append((byte)(Activate ? 1 : 0) + "#");
foreach (var obj in Stars)
build.Append(obj.ToString());
return build.ToString();
}
}
public ushort ValueToRoll(JiangStages.AtributesType status, byte level)
{
return (ushort)((ushort)status + level * 256);
}
public byte GetValueLevel(ushort val)
{
return (byte)((val - (ushort)(val % 256)) / 256);
}
public JiangStages.AtributesType GetValueType(uint val)
{
return (JiangStages.AtributesType)(val % 256);
}
public GetNewStar MyNewStart = null;
public byte CalculateJiangScoreLevel()
{
byte c = 0;
byte level1 = 0;
byte level2 = 0;
byte level3 = 0;
byte level4 = 0;
byte level5 = 0;
byte level6 = 0;
foreach (var stg in Stagers)
{
if (!stg.Activate) continue;
c += 1;
foreach (var star in stg.Stars)
{
if (star.Level == 0) continue;
if (star.Level >= 1) level1++;
if (star.Level >= 2) level2++;
if (star.Level >= 3) level3++;
if (star.Level >= 4) level4++;
if (star.Level >= 5) level5++;
if (star.Level >= 6) level6++;
}
}
if (level1 >= 81) c++;
if (level2 >= 81) c++;
if (level3 >= 81) c++;
if (level4 >= 81) c++;
if (level5 >= 81) c++;
if (level6 >= 81) c++;
return c;
}
byte jlevel = 0;
public void CreateRollValue(Client.GameState client, byte mStar, byte mStage, bool super = false, byte Higher = 0)
{
jlevel = client.Entity.MyJiang.CalculateJiangScoreLevel();
JiangStages n_stage = Stagers[mStage - 1];
if (!n_stage.Activate) return;
MyNewStart = new GetNewStar();
MyNewStart.PositionStar = mStar;
MyNewStart.Stage = mStage;
MyNewStart.Star = new JiangStages.Star();
MyNewStart.Star.Activate = true;
var level = MyNewStart.Star.Level;
MyNewStart.Star.Level = GetStatusLevel(super);
if (Higher == 1)
{
if (Kernel.Rate(4))
{
MyNewStart.Star.Level = (byte)Random.Next(1, 15);
}
}
if (Higher == 2)
{
if (Kernel.Rate(70))
{
MyNewStart.Star.Level = (byte)Random.Next(1, 5);
while (MyNewStart.Star.Level == 6 && Kernel.Rate(50))
{
MyNewStart.Star.Level--;
}
if (MyNewStart.Star.Level > 6) MyNewStart.Star.Level = 6;
}
}
MyNewStart.Star.Typ = (JiangStages.AtributesType)Random.Next(1, 16);
do
{
MyNewStart.Star.Typ = (JiangStages.AtributesType)Random.Next(1, 16);
}
while (!Database.JiangHu.CultivateStatus[mStage].Contains((byte)MyNewStart.Star.Typ));
MyNewStart.Star.UID = ValueToRoll(MyNewStart.Star.Typ, MyNewStart.Star.Level);
Network.GamePackets.JiangHuUpdate upd = new Network.GamePackets.JiangHuUpdate();
upd.Atribute = MyNewStart.Star.UID;
upd.FreeCourse = FreeCourse;
upd.Stage = mStage;
upd.Star = mStar;
upd.FreeTimeTodeyUsed = (byte)FreeTimeTodeyUsed;
upd.RoundBuyPoints = RoundBuyPoints;
client.Send(upd.ToArray());
if (MyNewStart.Star.Level >= 6)
{
foreach (var player in Kernel.GamePool.Values)
{
player.Send(new Network.GamePackets.Message("Wow, " + client.Entity.Name + " went down the Chaotic Path and improved the attribute to Epic!", System.Drawing.Color.Red, 2026));
}
}
}
private static bool CanKeepChiPower(JiangStages strct, GetNewStar nstar, GameState client)
{
//#if NOTMULTIPLECHIPOWERS
if (client.Entity.VIPLevel > 3)
{
var stars = strct.Stars;
for (int i = 0; i < stars.Length; i++)
if (i != (nstar.PositionStar - 1))
if (stars[i].Typ == nstar.Star.Typ)
return false;
}
//#endif
return true;
}
public void ApplayNewStar(Client.GameState client)
{
if (MyNewStart == null)
return;
JiangStages n_stage = Stagers[MyNewStart.Stage - 1];
if (!n_stage.Activate) return;
JiangStages.Star n_star = n_stage.Stars[MyNewStart.PositionStar - 1];
if (!n_star.Activate)
{
Star++;
n_star.Activate = true;
}
n_star.Level = MyNewStart.Star.Level;
n_star.Typ = MyNewStart.Star.Typ;
n_star.UID = MyNewStart.Star.UID;
client.LoadItemStats();
if (MyNewStart.Stage < 9)
{
if (MyNewStart.PositionStar == 9 && !Stagers[MyNewStart.Stage].Activate)
{
Stage++;
Stagers[MyNewStart.Stage].Activate = true;
SendInfo(client, Network.GamePackets.JiangHu.OpenStage, Stage.ToString());
}
}
//JiangHuRanking.UpdateRank(this);
MyNewStart = null;
if (client.Entity.MyJiang != null && client.Entity.MyJiang.Inner_Strength >= 81000)
{
new Network.GamePackets.TitleStorage().AddTitle(client , 2004, 5, false);
}
if (jlevel != client.Entity.MyJiang.CalculateJiangScoreLevel() && jlevel != 0)
{
foreach (var player in Kernel.GamePool.Values)
{
if (client.Entity.MyJiang.CalculateJiangScoreLevel() < 10) break;
player.Send(new Network.GamePackets.Message(client.Entity.Name + " increased Score Level to " + client.Entity.MyJiang.CalculateJiangScoreLevel() + "!", System.Drawing.Color.Red, 2026));
}
client.Send(new Network.GamePackets.Message("You unlocked Stage " + client.Entity.MyJiang.CalculateJiangScoreLevel() + "!", System.Drawing.Color.Red, Network.GamePackets.Message.System));
}
}
public static byte Getlve = 6;
public byte GetStatusLevel(bool super = false)
{
if (super)
return 6;
byte first = (byte)Random.Next(1, 7);
if (first >= 5)
{
first = (byte)Random.Next(1, 7);
if (first > 6)
first = 6;
}
return first;
}
public void CreateStatusAtributes(Game.Entity client)
{
uint oldInner_Strength = Inner_Strength;
Inner_Strength = 0;
foreach (var nstage in Stagers)
{
if (!nstage.Activate) continue;
var atr = nstage.Stars.Where(p => p.UID != 0).ToArray();
byte count_doble = 0;
Dictionary<uint, List<JiangStages.Star>> alignementstars = new Dictionary<uint, List<JiangStages.Star>>();
List<JiangStages.Star> normalstarts = new List<JiangStages.Star>();
ushort counts_alignements = 0;
for (byte x = 0; x < atr.Length; x++)
{
var atribut = atr[x];
count_doble = 0;
bool wasadd = false;
for (byte y = (byte)(x + 1); y < atr.Length; y++)
{
var atr2nd = atr[y];
if (atr2nd.Typ == atribut.Typ)
{
if (!wasadd)
{
if (!alignementstars.ContainsKey(counts_alignements))
{
alignementstars.Add(counts_alignements, new List<JiangStages.Star>());
alignementstars[counts_alignements].Add(atribut);
}
}
if (!alignementstars.ContainsKey(counts_alignements))
{
alignementstars.Add(counts_alignements, new List<JiangStages.Star>());
alignementstars[counts_alignements].Add(atr2nd);
}
else
alignementstars[counts_alignements].Add(atr2nd);
wasadd = true;
x = y;
count_doble++;
}
else
{
break;
}
}
uint counts = 1;
if (count_doble != 0)
{
counts = (byte)(count_doble + 1);
counts_alignements++;
}
if (counts == 1)
normalstarts.Add(atribut);
}
byte percent = (byte)Database.JiangHu.AlignmentExtraPoints(count_ doble);
foreach (var allignement in alignementstars.Values)
{
for (int i = 0; i < allignement.Count; i++)
{
Database.JiangHu.Atribut Atri_bas = Database.JiangHu.Atributes[allignement[i].UID];
if (client != null)
IncreaseStatus(client, (JiangStages.AtributesType)Atri_bas.Type, (ushort)((Atri_bas.Power + (Atri_bas.Power * percent) / 100)));
}
}
count_doble = 0;
foreach (var allignement in alignementstars.Values)
CalculateInner_StrengthAlignements(allignement);
for (int x = 0; x < normalstarts.Count; x++)
{
Database.JiangHu.Atribut Atri_bas = Database.JiangHu.Atributes[normalstarts[x].UID];
if (client != null)
IncreaseStatus(client, (JiangStages.AtributesType)Atri_bas.Type, (ushort)Atri_bas.Power);
Inner_Strength += Database.JiangHu.GetStatusPoints(normalstarts[x].Level);
}
}
if (oldInner_Strength != Inner_Strength)
JiangHuRanking.UpdateRank(this);
}
public void CalculateInner_StrengthAlignements(List<JiangStage s.Star> collection)
{
ushort points = 0;
for (int x = 0; x < collection.Count; x++)
{
points += Database.JiangHu.GetStatusPoints(collection[x].Level);
}
if (collection.Count > 0 && collection.Count < 9)
Inner_Strength += (ushort)(points + ((points * ((collection.Count) * 10) / 100)));
else if (collection.Count == 9)
Inner_Strength += (ushort)(points * 2);
}
public void IncreaseStatus(Entity client, JiangStages.AtributesType status, ushort Power)
{
switch (status)
{
case JiangStages.AtributesType.Breakthrough:
client.Breaktrough += Power;
break;
case JiangStages.AtributesType.Counteraction:
client.Counteraction += Power; break;
case JiangStages.AtributesType.CriticalStrike:
client.CriticalStrike += Power; break;
case JiangStages.AtributesType.FinalAttack:
client.PhysicalDamageIncrease += Power; break;
case JiangStages.AtributesType.FinalDefense:
client.PhysicalDamageDecrease += Power; break;
case JiangStages.AtributesType.FinalMagicAttack:
client.MagicDamageIncrease += Power; break;
case JiangStages.AtributesType.FinalMagicDefense:
client.MagicDamageDecrease += Power; break;
case JiangStages.AtributesType.Immunity:
client.Immunity += Power; break;
case JiangStages.AtributesType.MAttack:
{
client.MAttack += Power;
client.BaseMagicAttack += Power; break;
}
case JiangStages.AtributesType.MaxLife:
client.ItemHP += Power; break;//24283 27118 - 24283
case JiangStages.AtributesType.MaxMana:
client.ItemMP += Power; break;
case JiangStages.AtributesType.Mdefense:
{
//client.MDefense += Power;
client.MagicDefence += Power; break;
}
case JiangStages.AtributesType.PAttack:
{
// client.TQMAXATTACK += Power;
// client.TQMINATTACK += Power;
client.BaseMaxAttack += Power;
client.BaseMinAttack += Power; break;
}
case JiangStages.AtributesType.PDefense:
client.Defence += Power; break;
case JiangStages.AtributesType.SkillCriticalStrike:
client.SkillCStrike += Power; break;
}
}
public void DecreaseStatus(Entity client, JiangStages.AtributesType status, ushort Power)
{
switch (status)
{
case JiangStages.AtributesType.Breakthrough:
client.Breaktrough -= Power;
break;
case JiangStages.AtributesType.Counteraction:
client.Counteraction -= Power; break;
case JiangStages.AtributesType.CriticalStrike:
client.CriticalStrike -= Power; break;
case JiangStages.AtributesType.FinalAttack:
client.PhysicalDamageIncrease -= Power; break;
case JiangStages.AtributesType.FinalDefense:
client.PhysicalDamageDecrease -= Power; break;
case JiangStages.AtributesType.FinalMagicAttack:
client.MagicDamageIncrease -= Power; break;
case JiangStages.AtributesType.FinalMagicDefense:
client.MagicDamageDecrease -= Power; break;
case JiangStages.AtributesType.Immunity:
client.Immunity -= Power; break;
case JiangStages.AtributesType.MAttack:
client.MagicAttack -= Power; break;
case JiangStages.AtributesType.MaxLife:
client.MaxHitpoints -= Power; break;
case JiangStages.AtributesType.MaxMana:
client.MaxMana -= Power; break;
case JiangStages.AtributesType.Mdefense:
client.MagicDefence -= Power; break;
case JiangStages.AtributesType.PAttack:
{
client.BaseMaxAttack -= Power;
client.BaseMinAttack -= Power; break;
}
case JiangStages.AtributesType.PDefense:
client.Defence -= Power; break;
case JiangStages.AtributesType.SkillCriticalStrike:
client.SkillCStrike -= Power; break;
}
}
public void CreateStarDMG(JiangStages stage)
{
}
public uint UID { get; set; }
public string OwnName { get; set; }
public string CustomizedName { get; set; }
public byte Level { get; set; }
public byte Talent { get; set; }
public byte Stage { get; set; }
public byte Star { get; set; }
public uint FreeCourse { get; set; }
public byte Rank { get; set; }
public DateTime StartCountDwon { get; set; }
public DateTime CountDownEnd { get; set; }
public DateTime RemoveJiangMod;
public DateTime TimerStamp;
public uint Time
{
get
{
return (uint)(CountDownEnd - new DateTime(1970, 1, 1).ToLocalTime()).TotalSeconds;
}
}
public bool OnJiangMode { get; set; }
public uint FreeTimeTodey { get; set; }
public uint FreeTimeTodeyUsed { get; set; }
public uint Inner_Strength { get; set; }
public ushort RoundBuyPoints { get; set; }
public Random Random = new Random();
public JiangStages[] Stagers { get; set; }
public override string ToString()
{
if (StartCountDwon.Ticks > CountDownEnd.Ticks)
CreateTime();
uint SecoundesLeft = (uint)((CountDownEnd.Ticks - StartCountDwon.Ticks) / 10000000);
if (OwnName.Contains('#'))
OwnName = OwnName.Replace("#", "");
if (CustomizedName.Contains('#'))
CustomizedName = CustomizedName.Replace("#", "");
StringBuilder build = new StringBuilder();
build.Append(UID + "#" + OwnName + "#" + CustomizedName + "#" + Level + "#" +
Talent + "#" + Stage + "#" + Star + "#" + FreeTimeTodeyUsed + "#" +
(byte)(OnJiangMode ? 0 : 1) + "#" + FreeCourse + "#" + SecoundesLeft + "#" + RoundBuyPoints + "#");
foreach (var obj in Stagers)
build.Append(obj.ToString());
return build.ToString();
}
public void Load(string Line, uint nUID = 0)
{
try
{
if (Line == null) return;
if (Line == "") return;
if (!Line.Contains('#')) return;
string[] data = Line.Split('#');
if (nUID != 0)
UID = nUID;
else
UID = uint.Parse(data[0]);
OwnName = data[1];
CustomizedName = data[2];
try
{
Level = byte.Parse(data[3]);
}
catch (Exception)
{
}
Talent = byte.Parse(data[4]);
Stage = byte.Parse(data[5]);
Star = byte.Parse(data[6]);
FreeTimeTodey = byte.Parse(data[7]);
OnJiangMode = byte.Parse(data[8]) == 1;
FreeCourse = uint.Parse(data[9]);
StartCountDwon = DateTime.Now;
TimerStamp = DateTime.Now;
CountDownEnd = DateTime.Now.AddSeconds(uint.Parse(data[10]));
RoundBuyPoints = ushort.Parse(data[11]);
ushort position = 12;
foreach (var nstage in Stagers)
{
nstage.Activate = byte.Parse(data[position]) == 1;
position++;
foreach (var nstar in nstage.Stars)
{
nstar.Activate = byte.Parse(data[position]) == 1;
position++;
nstar.UID = ushort.Parse(data[position]);
position++;
if (nstar.Activate)
{
nstar.Typ = GetValueType(nstar.UID);
nstar.Level = GetValueLevel(nstar.UID);
Inner_Strength += Database.JiangHu.GetStatusPoints(nstar.Level);
}
}
}
}
catch (Exception) { }
}
public void Deserialize(BinaryReader reader)
{
try
{
Level = reader.ReadByte();
Talent = reader.ReadByte();
Stage = reader.ReadByte();
Star = reader.ReadByte();
FreeTimeTodey = reader.ReadUInt32();
OnJiangMode = reader.ReadBoolean();
FreeCourse = reader.ReadUInt32();
StartCountDwon = DateTime.Now;
TimerStamp = DateTime.Now;
CountDownEnd = DateTime.Now.AddSeconds(reader.ReadUInt32());
RoundBuyPoints = reader.ReadUInt16();
foreach (var nstage in Stagers)
{
nstage.Activate = reader.ReadBoolean();
foreach (var nstar in nstage.Stars)
{
nstar.Activate = reader.ReadBoolean();
nstar.UID = reader.ReadUInt16();
if (nstar.Activate)
{
nstar.Typ = GetValueType(nstar.UID);
nstar.Level = GetValueLevel(nstar.UID);
Inner_Strength += Database.JiangHu.GetStatusPoints(nstar.Level);
}
}
}
}
catch (Exception) { }
}
public void Serialize(BinaryWriter writer)
{
try
{
if (StartCountDwon.Ticks > CountDownEnd.Ticks)
CreateTime();
uint SecoundesLeft = (uint)((CountDownEnd.Ticks - StartCountDwon.Ticks) / 10000000);
writer.Write(Level);
writer.Write(Talent);
writer.Write(Stage);
writer.Write(Star);
writer.Write(FreeTimeTodey);
writer.Write(OnJiangMode);
writer.Write(FreeCourse);
writer.Write(SecoundesLeft);
writer.Write(RoundBuyPoints);
foreach (var nstage in Stagers)
{
writer.Write(nstage.Activate);
foreach (var nstar in nstage.Stars)
{
writer.Write(nstar.Activate);
writer.Write(nstar.UID);
}
}
}
catch (Exception)
{
}
}
public JiangHu(uint m_UID)
{
Talent = 3;
Stage = 1;
Star = 1;
FreeCourse = 100000;
FreeTimeTodey = 10;
UID = m_UID;
CountDownEnd = new DateTime();
StartCountDwon = new DateTime();
TimerStamp = new DateTime();
RemoveJiangMod = new DateTime();
Stagers = new JiangStages[9];
for (byte x = 0; x < 9; x++)
Stagers[x] = new JiangStages();
if (!JiangHuClients.ContainsKey(UID) && UID != 0)
JiangHuClients.TryAdd(UID, this);
OnJiangMode = true;
TimerStamp = DateTime.Now;
}
public void ResetDay(Client.GameState client)
{
RoundBuyPoints = 0;
FreeTimeTodeyUsed = 0;
SendStatus(client, client);
}
public void OnloginClient(Client.GameState client)
{
SendStatus(client, client);
SendStatusMode(client, true);
TimerStamp = DateTime.Now;
}
public void SendStatusMode(Client.GameState client, bool justlogen = false)
{
client.Entity.JiangTalent = Talent;
client.Entity.JiangActive = OnJiangMode;
if (OnJiangMode == false && !justlogen)
client.Send(new Network.GamePackets.Message("You have temporarily quit the Jiang Hu!", System.Drawing.Color.Red, Network.GamePackets.Message.System));
SendInfo(client, Network.GamePackets.JiangHu.InfoStauts, client.Entity.UID.ToString(), Talent.ToString(),
OnJiangMode ? "1" : "2");
if (OnJiangMode)
RemoveJiangMod = DateTime.Now;
client.SendScreen(client.Entity.SpawnPacket, false);
}
public void CreateTime()
{
StartCountDwon = DateTime.Now;
CountDownEnd = DateTime.Now.AddMinutes(Database.JiangHu.GetMinute sOnTalent(Talent));
}
public void TheadTime(Client.GameState client)
{
try
{
if (client == null)
return;
if (client.Entity == null)
return;
if (!client.Entity.FullyLoaded)
return;
if (DateTime.Now > TimerStamp.AddMinutes(1))
{
if (client.Entity.PKMode != Enums.PKMode.Jiang)
{
if (OnJiangMode)
{
if (DateTime.Now >= RemoveJiangMod.AddMinutes(10))
{
OnJiangMode = false;
SendStatusMode(client);
}
}
}
if (client.Entity.PKMode == Enums.PKMode.Jiang)
{
OnJiangMode = true;
RemoveJiangMod = DateTime.Now;
}
if (FreeCourse < 1000000)
{
if (InTwinCastle(client.Entity))
{
StartCountDwon = StartCountDwon.AddMinutes(Database.JiangHu.GetMinu tesInCastle(Talent));
FreeCourse += Database.JiangHu.GetFreeCourseInCastle(Talent);
}
else
{
FreeCourse += Database.JiangHu.GetFreeCourse(Talent);
StartCountDwon = StartCountDwon.AddMinutes(1);
}
if (StartCountDwon > CountDownEnd)
GetReward(client);
SendInfo(client, Network.GamePackets.JiangHu.UpdateTime, FreeCourse.ToString(), Time.ToString());
if (FreeCourse % 10000 == 0)
GetReward(client);
}
else
FreeCourse = 10000000;
TimerStamp = DateTime.Now;
}
}
catch (Exception)
{
}
}
public bool GetRate(byte val)
{
return (Random.Next() % 100) < val;
}
public void GetKill(Client.GameState attacker, JiangHu attacked)
{
if (attacker.Entity.JiangTalent < 4)
{
if (attacker.Entity.JiangTalent <= attacked.Talent)
{
attacked.Talent -= 1;
Talent += 1;
attacker.Entity.JiangTalent = Talent;
SendInfo(attacker, Network.GamePackets.JiangHu.UpdateTalent, attacker.Entity.UID.ToString(), Talent.ToString());
}
}
}
public bool SameCourseStage(uint first, uint last)
{
if (first > 100000)
return first.ToString()[2] == last.ToString()[2];
else
return first.ToString()[1] == last.ToString()[1];
}
public void GetReward(Client.GameState client)
{
do FreeCourse++; while (FreeCourse % 1000 != 0);
SendInfo(client, Network.GamePackets.JiangHu.UpdateTime, FreeCourse.ToString(), Time.ToString());
CreateTime();
}
public bool InTwinCastle(Entity location)
{
ushort x = location.X;
ushort y = location.Y;
if (location.MapID != 1002)
return false;
if (x <= 357 && x >= 274 && y <= 277 && y >= 110)
return true;
if (x >= 335 && x <= 370 && y <= 235 && y >= 232)
return true;
if (x >= 281 && x <= 350 && y >= 268 && y <= 322)
return true;
if (x >= 247 && x <= 291 && y >= 200 && y <= 243)
return true;
return false;
}
public object sync = new object();
public void SendInfo(Client.GameState client, byte mode = 1, params string[] data)
{
lock (sync)
{
try
{
Network.GamePackets.JiangHu jinag = new Network.GamePackets.JiangHu();
jinag.Mode = mode;
jinag.Texts = new List<string>(data);
jinag.CreateArray();
jinag.Send(client);
}
catch (Exception)
{
}
}
}
public void SendStatus(Client.GameState client, Client.GameState Attacked)
{
try
{
var dictionary = Stagers.Where(p => p.Activate);
Network.GamePackets.JiangHuStatus stat = new Network.GamePackets.JiangHuStatus((byte)dictionary .Count());
stat.Name = CustomizedName;
stat.FreeTimeTodey = 10;//FreeTimeTodey;
stat.Talent = Talent;
stat.Stage = Stage;
stat.RoundBuyPoints = RoundBuyPoints;
stat.FreeTimeTodeyUsed = (byte)FreeTimeTodeyUsed;
stat.StudyPoints = Attacked.Entity.SubClasses.StudyPoints;
if (client.Entity.UID != Attacked.Entity.UID)
stat.Timer = 13751297;
else
stat.Timer = 15500800;
stat.Apprend(dictionary.ToArray());
client.Send(stat.ToArray());
}
catch (Exception) { }
}
public void UpdateStundyPoints(Client.GameState client, ushort amount)
{
Network.GamePackets._String str = new Network.GamePackets._String(true);
str.Type = Network.GamePackets._String.Effect;
str.UID = client.Entity.UID;
str.Texts.Add("zf2-e300");
client.SendScreen(str.ToArray(), true);
}
public static bool AllowNameCaracters(string Name)
{
if (Name.Contains('['))
return false;
if (Name.Contains(']'))
return false;
if (Name.Contains("GM"))
return false;
if (Name.Contains("PM"))
return false;
if (Name.Contains("!") || Name.Contains("@") || Name.Contains("#"))
return false;
if (Name.Contains("$") || Name.Contains("%") || Name.Contains("^"))
return false;
if (Name.Contains("&") || Name.Contains("*") || Name.Contains("/") || Name.Contains("|"))
return false;
return true;
}
}
}
using system;
using system.collections.generic;
using system.linq;
using system.text;
using playconquer.client;
using system.io;
namespace playconquer.game
{
public interface ijianghu
{
string ownname { get; set; }
string customizedname { get; set; }
uint uid { get; set; }
byte talent { get; set; }
byte stage { get; set; }
byte star { get; set; }
datetime startcountdwon { get; set; }
datetime countdownend { get; set; }
uint time { get; }
uint freetimetodey { get; set; }
uint freetimetodeyused { get; set; }
uint inner_strength { get; set; }
uint freecourse { get; set; }
jianghu.jiangstages[] stagers { get; set; }
byte rank { get; set; }
byte level { get; set; }
ushort roundbuypoints { get; set; }
bool onjiangmode { get; set; }
}
public class jianghu : Ijianghu
{
public enum attackflag
{
none = 0,
nothitfriends = 1,
nothitclanmembers = 2,
nothitguildmembers = 4,
nothitalliedguild = 8,
nohitalliesclan = 16
}
public static system.collections.concurrent.concurrentdictionary <uint, ijianghu> jianghuclients = new system.collections.concurrent.concurrentdictionary <uint, ijianghu>();
public static class jianghuranking
{
private static system.collections.concurrent.concurrentdictionary <uint, ijianghu> toprank = new system.collections.concurrent.concurrentdictionary <uint, ijianghu>();
public static ijianghu[] toprank100 = null;
private static object syncroot = new object();
public static void updaterank(ijianghu jiang)
{
lock (syncroot)
{
if (!toprank.containskey(jiang.uid))
toprank.tryadd(jiang.uid, jiang);
calculateranks();
}
}
private static void calculateranks()
{
foreach (var jiang in toprank.values)
jiang.rank = 0;
var rankdictionar = toprank.values.toarray();
var ordonaterank = from jiang in rankdictionar orderby jiang.inner_strength descending select jiang;
list<ijianghu> backup = new list<ijianghu>();
byte x = 1;
foreach (var jiang in ordonaterank)
{
if (x == 101)
break;
jiang.rank = x;
backup.add(jiang);
x++;
}
toprank100 = backup.toarray();
toprank = new system.collections.concurrent.concurrentdictionary <uint, ijianghu>();
foreach (var jiang in backup)
toprank.tryadd(jiang.uid, jiang);
backup = null;
}
}
public class getnewstar
{
public byte stage;
public byte positionstar;
public jiangstages.star star;
}
public class jiangstages
{
public class star
{
public atributestype typ;
public byte level;
public ushort uid;
public bool activate = false;
public override string tostring()
{
stringbuilder build = new stringbuilder();
build.append((byte)(activate ? 1 : 0) + "#" + uid + "#");
return build.tostring();
}
}
public enum atributestype
{
none = 0,
maxlife,//1
pattack,//2
mattack,//3
pdefense,//4
mdefense,//5
finalattack,//6
finalmagicattack,//7
finaldefense,//8
finalmagicdefense,//9
criticalstrike,//10
skillcriticalstrike,//11
immunity,//12
breakthrough,//13
counteraction,//14
maxmana//15
}
public star[] stars;
public bool activate = false;
public jiangstages()
{
stars = new star[9];
for (byte x = 0; x < 9; x++)
stars[x] = new star();
}
public bool containatribut(atributestype typ)
{
foreach (var atr in stars)
if (atr.typ == typ)
return true;
return false;
}
public override string tostring()
{
stringbuilder build = new stringbuilder();
build.append((byte)(activate ? 1 : 0) + "#");
foreach (var obj in stars)
build.append(obj.tostring());
return build.tostring();
}
}
public ushort valuetoroll(jiangstages.atributestype status, byte level)
{
return (ushort)((ushort)status + level * 256);
}
public byte getvaluelevel(ushort val)
{
return (byte)((val - (ushort)(val % 256)) / 256);
}
public jiangstages.atributestype getvaluetype(uint val)
{
return (jiangstages.atributestype)(val % 256);
}
public getnewstar mynewstart = null;
public byte calculatejiangscorelevel()
{
byte c = 0;
byte level1 = 0;
byte level2 = 0;
byte level3 = 0;
byte level4 = 0;
byte level5 = 0;
byte level6 = 0;
foreach (var stg in stagers)
{
if (!stg.activate) continue;
c += 1;
foreach (var star in stg.stars)
{
if (star.level == 0) continue;
if (star.level >= 1) level1++;
if (star.level >= 2) level2++;
if (star.level >= 3) level3++;
if (star.level >= 4) level4++;
if (star.level >= 5) level5++;
if (star.level >= 6) level6++;
}
}
if (level1 >= 81) c++;
if (level2 >= 81) c++;
if (level3 >= 81) c++;
if (level4 >= 81) c++;
if (level5 >= 81) c++;
if (level6 >= 81) c++;
return c;
}
byte jlevel = 0;
public void createrollvalue(client.gamestate client, byte mstar, byte mstage, bool super = false, byte higher = 0)
{
jlevel = client.entity.myjiang.calculatejiangscorelevel();
jiangstages n_stage = stagers[mstage - 1];
if (!n_stage.activate) return;
mynewstart = new getnewstar();
mynewstart.positionstar = mstar;
mynewstart.stage = mstage;
mynewstart.star = new jiangstages.star();
mynewstart.star.activate = true;
var level = mynewstart.star.level;
mynewstart.star.level = getstatuslevel(super);
if (higher == 1)
{
if (kernel.rate(4))
{
mynewstart.star.level = (byte)random.next(1, 15);
}
}
if (higher == 2)
{
if (kernel.rate(70))
{
mynewstart.star.level = (byte)random.next(1, 5);
while (mynewstart.star.level == 6 && kernel.rate(50))
{
mynewstart.star.level--;
}
if (mynewstart.star.level > 6) mynewstart.star.level = 6;
}
}
mynewstart.star.typ = (jiangstages.atributestype)random.next(1, 16);
do
{
mynewstart.star.typ = (jiangstages.atributestype)random.next(1, 16);
}
while (!database.jianghu.cultivatestatus[mstage].contains((byte)mynewstart.star.typ));
mynewstart.star.uid = valuetoroll(mynewstart.star.typ, mynewstart.star.level);
network.gamepackets.jianghuupdate upd = new network.gamepackets.jianghuupdate();
upd.atribute = mynewstart.star.uid;
upd.freecourse = freecourse;
upd.stage = mstage;
upd.star = mstar;
upd.freetimetodeyused = (byte)freetimetodeyused;
upd.roundbuypoints = roundbuypoints;
client.send(upd.toarray());
if (mynewstart.star.level >= 6)
{
foreach (var player in kernel.gamepool.values)
{
player.send(new network.gamepackets.message("wow, " + client.entity.name + " went down the chaotic path and improved the attribute to epic!", system.drawing.color.red, 2026));
}
}
}
private static bool cankeepchipower(jiangstages strct, getnewstar nstar, gamestate client)
{
//#if notmultiplechipowers
if (client.entity.viplevel > 3)
{
var stars = strct.stars;
for (int i = 0; i < stars.length; i++)
if (i != (nstar.positionstar - 1))
if (stars[i].typ == nstar.star.typ)
return false;
}
//#endif
return true;
}
public void applaynewstar(client.gamestate client)
{
if (mynewstart == null)
return;
jiangstages n_stage = stagers[mynewstart.stage - 1];
if (!n_stage.activate) return;
jiangstages.star n_star = n_stage.stars[mynewstart.positionstar - 1];
if (!n_star.activate)
{
star++;
n_star.activate = true;
}
n_star.level = mynewstart.star.level;
n_star.typ = mynewstart.star.typ;
n_star.uid = mynewstart.star.uid;
client.loaditemstats();
if (mynewstart.stage < 9)
{
if (mynewstart.positionstar == 9 && !stagers[mynewstart.stage].activate)
{
stage++;
stagers[mynewstart.stage].activate = true;
sendinfo(client, network.gamepackets.jianghu.openstage, stage.tostring());
}
}
//jianghuranking.updaterank(this);
mynewstart = null;
if (client.entity.myjiang != null && client.entity.myjiang.inner_strength >= 81000)
{
new network.gamepackets.titlestorage().addtitle(client , 2004, 5, false);
}
if (jlevel != client.entity.myjiang.calculatejiangscorelevel() && jlevel != 0)
{
foreach (var player in kernel.gamepool.values)
{
if (client.entity.myjiang.calculatejiangscorelevel() < 10) break;
player.send(new network.gamepackets.message(client.entity.name + " increased score level to " + client.entity.myjiang.calculatejiangscorelevel() + "!", system.drawing.color.red, 2026));
}
client.send(new network.gamepackets.message("you unlocked stage " + client.entity.myjiang.calculatejiangscorelevel() + "!", system.drawing.color.red, network.gamepackets.message.system));
}
}
public static byte getlve = 6;
public byte getstatuslevel(bool super = false)
{
if (super)
return 6;
byte first = (byte)random.next(1, 7);
if (first >= 5)
{
first = (byte)random.next(1, 7);
if (first > 6)
first = 6;
}
return first;
}
public void createstatusatributes(game.entity client)
{
uint oldinner_strength = inner_strength;
inner_strength = 0;
foreach (var nstage in stagers)
{
if (!nstage.activate) continue;
var atr = nstage.stars.where(p => p.uid != 0).toarray();
byte count_doble = 0;
dictionary<uint, list<jiangstages.star>> alignementstars = new dictionary<uint, list<jiangstages.star>>();
list<jiangstages.star> normalstarts = new list<jiangstages.star>();
ushort counts_alignements = 0;
for (byte x = 0; x < atr.length; x++)
{
var atribut = atr[x];
count_doble = 0;
bool wasadd = false;
for (byte y = (byte)(x + 1); y < atr.length; y++)
{
var atr2nd = atr[y];
if (atr2nd.typ == atribut.typ)
{
if (!wasadd)
{
if (!alignementstars.containskey(counts_alignements))
{
alignementstars.add(counts_alignements, new list<jiangstages.star>());
alignementstars[counts_alignements].add(atribut);
}
}
if (!alignementstars.containskey(counts_alignements))
{
alignementstars.add(counts_alignements, new list<jiangstages.star>());
alignementstars[counts_alignements].add(atr2nd);
}
else
alignementstars[counts_alignements].add(atr2nd);
wasadd = true;
x = y;
count_doble++;
}
else
{
break;
}
}
uint counts = 1;
if (count_doble != 0)
{
counts = (byte)(count_doble + 1);
counts_alignements++;
}
if (counts == 1)
normalstarts.add(atribut);
}
byte percent = (byte)database.jianghu.alignmentextrapoints(count_ doble);
foreach (var allignement in alignementstars.values)
{
for (int i = 0; i < allignement.count; i++)
{
database.jianghu.atribut atri_bas = database.jianghu.atributes[allignement[i].uid];
if (client != null)
increasestatus(client, (jiangstages.atributestype)atri_bas.type, (ushort)((atri_bas.power + (atri_bas.power * percent) / 100)));
}
}
count_doble = 0;
foreach (var allignement in alignementstars.values)
calculateinner_strengthalignements(allignement);
for (int x = 0; x < normalstarts.count; x++)
{
database.jianghu.atribut atri_bas = database.jianghu.atributes[normalstarts[x].uid];
if (client != null)
increasestatus(client, (jiangstages.atributestype)atri_bas.type, (ushort)atri_bas.power);
inner_strength += database.jianghu.getstatuspoints(normalstarts[x].level);
}
}
if (oldinner_strength != inner_strength)
jianghuranking.updaterank(this);
}
public void calculateinner_strengthalignements(list<jiangstage s.star> collection)
{
ushort points = 0;
for (int x = 0; x < collection.count; x++)
{
points += database.jianghu.getstatuspoints(collection[x].level);
}
if (collection.count > 0 && collection.count < 9)
inner_strength += (ushort)(points + ((points * ((collection.count) * 10) / 100)));
else if (collection.count == 9)
inner_strength += (ushort)(points * 2);
}
public void increasestatus(entity client, jiangstages.atributestype status, ushort power)
{
switch (status)
{
case jiangstages.atributestype.breakthrough:
Client.breaktrough += power;
break;
case jiangstages.atributestype.counteraction:
Client.counteraction += power; break;
case jiangstages.atributestype.criticalstrike:
Client.criticalstrike += power; break;
case jiangstages.atributestype.finalattack:
Client.physicaldamageincrease += power; break;
case jiangstages.atributestype.finaldefense:
Client.physicaldamagedecrease += power; break;
case jiangstages.atributestype.finalmagicattack:
Client.magicdamageincrease += power; break;
case jiangstages.atributestype.finalmagicdefense:
Client.magicdamagedecrease += power; break;
case jiangstages.atributestype.immunity:
Client.immunity += power; break;
case jiangstages.atributestype.mattack:
{
client.mattack += power;
client.basemagicattack += power; break;
}
case jiangstages.atributestype.maxlife:
Client.itemhp += power; break;//24283 27118 - 24283
case jiangstages.atributestype.maxmana:
Client.itemmp += power; break;
case jiangstages.atributestype.mdefense:
{
//client.mdefense += power;
client.magicdefence += power; break;
}
case jiangstages.atributestype.pattack:
{
// client.tqmaxattack += power;
// client.tqminattack += power;
client.basemaxattack += power;
client.baseminattack += power; break;
}
case jiangstages.atributestype.pdefense:
Client.defence += power; break;
case jiangstages.atributestype.skillcriticalstrike:
Client.skillcstrike += power; break;
}
}
public void decreasestatus(entity client, jiangstages.atributestype status, ushort power)
{
switch (status)
{
case jiangstages.atributestype.breakthrough:
Client.breaktrough -= power;
break;
case jiangstages.atributestype.counteraction:
Client.counteraction -= power; break;
case jiangstages.atributestype.criticalstrike:
Client.criticalstrike -= power; break;
case jiangstages.atributestype.finalattack:
Client.physicaldamageincrease -= power; break;
case jiangstages.atributestype.finaldefense:
Client.physicaldamagedecrease -= power; break;
case jiangstages.atributestype.finalmagicattack:
Client.magicdamageincrease -= power; break;
case jiangstages.atributestype.finalmagicdefense:
Client.magicdamagedecrease -= power; break;
case jiangstages.atributestype.immunity:
Client.immunity -= power; break;
case jiangstages.atributestype.mattack:
Client.magicattack -= power; break;
case jiangstages.atributestype.maxlife:
Client.maxhitpoints -= power; break;
case jiangstages.atributestype.maxmana:
Client.maxmana -= power; break;
case jiangstages.atributestype.mdefense:
Client.magicdefence -= power; break;
case jiangstages.atributestype.pattack:
{
client.basemaxattack -= power;
client.baseminattack -= power; break;
}
case jiangstages.atributestype.pdefense:
Client.defence -= power; break;
case jiangstages.atributestype.skillcriticalstrike:
Client.skillcstrike -= power; break;
}
}
public void createstardmg(jiangstages stage)
{
}
public uint uid { get; set; }
public string ownname { get; set; }
public string customizedname { get; set; }
public byte level { get; set; }
public byte talent { get; set; }
public byte stage { get; set; }
public byte star { get; set; }
public uint freecourse { get; set; }
public byte rank { get; set; }
public datetime startcountdwon { get; set; }
public datetime countdownend { get; set; }
public datetime removejiangmod;
public datetime timerstamp;
public uint time
{
get
{
return (uint)(countdownend - new datetime(1970, 1, 1).tolocaltime()).totalseconds;
}
}
public bool onjiangmode { get; set; }
public uint freetimetodey { get; set; }
public uint freetimetodeyused { get; set; }
public uint inner_strength { get; set; }
public ushort roundbuypoints { get; set; }
public random random = new random();
public jiangstages[] stagers { get; set; }
public override string tostring()
{
if (startcountdwon.ticks > countdownend.ticks)
createtime();
uint secoundesleft = (uint)((countdownend.ticks - startcountdwon.ticks) / 10000000);
if (ownname.contains('#'))
ownname = ownname.replace("#", "");
if (customizedname.contains('#'))
customizedname = customizedname.replace("#", "");
stringbuilder build = new stringbuilder();
build.append(uid + "#" + ownname + "#" + customizedname + "#" + level + "#" +
talent + "#" + stage + "#" + star + "#" + freetimetodeyused + "#" +
(byte)(onjiangmode ? 0 : 1) + "#" + freecourse + "#" + secoundesleft + "#" + roundbuypoints + "#");
foreach (var obj in stagers)
build.append(obj.tostring());
return build.tostring();
}
public void load(string line, uint nuid = 0)
{
try
{
if (line == null) return;
if (line == "") return;
if (!line.contains('#')) return;
string[] data = line.split('#');
if (nuid != 0)
uid = nuid;
else
uid = uint.parse(data[0]);
ownname = data[1];
customizedname = data[2];
try
{
level = byte.parse(data[3]);
}
catch (exception)
{
}
talent = byte.parse(data[4]);
stage = byte.parse(data[5]);
star = byte.parse(data[6]);
freetimetodey = byte.parse(data[7]);
onjiangmode = byte.parse(data[8]) == 1;
freecourse = uint.parse(data[9]);
startcountdwon = datetime.now;
timerstamp = datetime.now;
countdownend = datetime.now.addseconds(uint.parse(data[10]));
roundbuypoints = ushort.parse(data[11]);
ushort position = 12;
foreach (var nstage in stagers)
{
nstage.activate = byte.parse(data[position]) == 1;
position++;
foreach (var nstar in nstage.stars)
{
nstar.activate = byte.parse(data[position]) == 1;
position++;
nstar.uid = ushort.parse(data[position]);
position++;
if (nstar.activate)
{
nstar.typ = getvaluetype(nstar.uid);
nstar.level = getvaluelevel(nstar.uid);
inner_strength += database.jianghu.getstatuspoints(nstar.level);
}
}
}
}
catch (exception) { }
}
public void deserialize(binaryreader reader)
{
try
{
level = reader.readbyte();
talent = reader.readbyte();
stage = reader.readbyte();
star = reader.readbyte();
freetimetodey = reader.readuint32();
onjiangmode = reader.readboolean();
freecourse = reader.readuint32();
startcountdwon = datetime.now;
timerstamp = datetime.now;
countdownend = datetime.now.addseconds(reader.readuint32());
roundbuypoints = reader.readuint16();
foreach (var nstage in stagers)
{
nstage.activate = reader.readboolean();
foreach (var nstar in nstage.stars)
{
nstar.activate = reader.readboolean();
nstar.uid = reader.readuint16();
if (nstar.activate)
{
nstar.typ = getvaluetype(nstar.uid);
nstar.level = getvaluelevel(nstar.uid);
inner_strength += database.jianghu.getstatuspoints(nstar.level);
}
}
}
}
catch (exception) { }
}
public void serialize(binarywriter writer)
{
try
{
if (startcountdwon.ticks > countdownend.ticks)
createtime();
uint secoundesleft = (uint)((countdownend.ticks - startcountdwon.ticks) / 10000000);
writer.write(level);
writer.write(talent);
writer.write(stage);
writer.write(star);
writer.write(freetimetodey);
writer.write(onjiangmode);
writer.write(freecourse);
writer.write(secoundesleft);
writer.write(roundbuypoints);
foreach (var nstage in stagers)
{
writer.write(nstage.activate);
foreach (var nstar in nstage.stars)
{
writer.write(nstar.activate);
writer.write(nstar.uid);
}
}
}
catch (exception)
{
}
}
public jianghu(uint m_uid)
{
talent = 3;
stage = 1;
star = 1;
freecourse = 100000;
freetimetodey = 10;
uid = m_uid;
countdownend = new datetime();
startcountdwon = new datetime();
timerstamp = new datetime();
removejiangmod = new datetime();
stagers = new jiangstages[9];
for (byte x = 0; x < 9; x++)
stagers[x] = new jiangstages();
if (!jianghuclients.containskey(uid) && uid != 0)
jianghuclients.tryadd(uid, this);
onjiangmode = true;
timerstamp = datetime.now;
}
public void resetday(client.gamestate client)
{
roundbuypoints = 0;
freetimetodeyused = 0;
sendstatus(client, client);
}
public void onloginclient(client.gamestate client)
{
sendstatus(client, client);
sendstatusmode(client, true);
timerstamp = datetime.now;
}
public void sendstatusmode(client.gamestate client, bool justlogen = false)
{
client.entity.jiangtalent = talent;
client.entity.jiangactive = onjiangmode;
if (onjiangmode == false && !justlogen)
client.send(new network.gamepackets.message("you have temporarily quit the jiang hu!", system.drawing.color.red, network.gamepackets.message.system));
sendinfo(client, network.gamepackets.jianghu.infostauts, client.entity.uid.tostring(), talent.tostring(),
onjiangmode ? "1" : "2");
if (onjiangmode)
removejiangmod = datetime.now;
client.sendscreen(client.entity.spawnpacket, false);
}
public void createtime()
{
startcountdwon = datetime.now;
countdownend = datetime.now.addminutes(database.jianghu.getminute sontalent(talent));
}
public void theadtime(client.gamestate client)
{
try
{
if (client == null)
return;
if (client.entity == null)
return;
if (!client.entity.fullyloaded)
return;
if (datetime.now > timerstamp.addminutes(1))
{
if (client.entity.pkmode != enums.pkmode.jiang)
{
if (onjiangmode)
{
if (datetime.now >= removejiangmod.addminutes(10))
{
onjiangmode = false;
sendstatusmode(client);
}
}
}
if (client.entity.pkmode == enums.pkmode.jiang)
{
onjiangmode = true;
removejiangmod = datetime.now;
}
if (freecourse < 1000000)
{
if (intwincastle(client.entity))
{
startcountdwon = startcountdwon.addminutes(database.jianghu.getminu tesincastle(talent));
freecourse += database.jianghu.getfreecourseincastle(talent);
}
else
{
freecourse += database.jianghu.getfreecourse(talent);
startcountdwon = startcountdwon.addminutes(1);
}
if (startcountdwon > countdownend)
getreward(client);
sendinfo(client, network.gamepackets.jianghu.updatetime, freecourse.tostring(), time.tostring());
if (freecourse % 10000 == 0)
getreward(client);
}
else
freecourse = 10000000;
timerstamp = datetime.now;
}
}
catch (exception)
{
}
}
public bool getrate(byte val)
{
return (random.next() % 100) < val;
}
public void getkill(client.gamestate attacker, jianghu attacked)
{
if (attacker.entity.jiangtalent < 4)
{
if (attacker.entity.jiangtalent <= attacked.talent)
{
attacked.talent -= 1;
talent += 1;
attacker.entity.jiangtalent = talent;
sendinfo(attacker, network.gamepackets.jianghu.updatetalent, attacker.entity.uid.tostring(), talent.tostring());
}
}
}
public bool samecoursestage(uint first, uint last)
{
if (first > 100000)
return first.tostring()[2] == last.tostring()[2];
else
return first.tostring()[1] == last.tostring()[1];
}
public void getreward(client.gamestate client)
{
do freecourse++; while (freecourse % 1000 != 0);
sendinfo(client, network.gamepackets.jianghu.updatetime, freecourse.tostring(), time.tostring());
createtime();
}
public bool intwincastle(entity location)
{
ushort x = location.x;
ushort y = location.y;
if (location.mapid != 1002)
return false;
if (x <= 357 && x >= 274 && y <= 277 && y >= 110)
return true;
if (x >= 335 && x <= 370 && y <= 235 && y >= 232)
return true;
if (x >= 281 && x <= 350 && y >= 268 && y <= 322)
return true;
if (x >= 247 && x <= 291 && y >= 200 && y <= 243)
return true;
return false;
}
public object sync = new object();
public void sendinfo(client.gamestate client, byte mode = 1, params string[] data)
{
lock (sync)
{
try
{
network.gamepackets.jianghu jinag = new network.gamepackets.jianghu();
jinag.mode = mode;
jinag.texts = new list<string>(data);
jinag.createarray();
jinag.send(client);
}
catch (exception)
{
}
}
}
public void sendstatus(client.gamestate client, client.gamestate attacked)
{
try
{
var dictionary = stagers.where(p => p.activate);
network.gamepackets.jianghustatus stat = new network.gamepackets.jianghustatus((byte)dictionary .count());
stat.name = customizedname;
stat.freetimetodey = 10;//freetimetodey;
stat.talent = talent;
stat.stage = stage;
stat.roundbuypoints = roundbuypoints;
stat.freetimetodeyused = (byte)freetimetodeyused;
stat.studypoints = attacked.entity.subclasses.studypoints;
if (client.entity.uid != attacked.entity.uid)
stat.timer = 13751297;
else
stat.timer = 15500800;
stat.apprend(dictionary.toarray());
client.send(stat.toarray());
}
catch (exception) { }
}
public void updatestundypoints(client.gamestate client, ushort amount)
{
network.gamepackets._string str = new network.gamepackets._string(true);
str.type = network.gamepackets._string.effect;
str.uid = client.entity.uid;
str.texts.add("zf2-e300");
client.sendscreen(str.toarray(), true);
}
public static bool allownamecaracters(string name)
{
if (name.contains('['))
return false;
if (name.contains(']'))
return false;
if (name.contains("gm"))
return false;
if (name.contains("pm"))
return false;
if (name.contains("!") || name.contains("@") || name.contains("#"))
return false;
if (name.contains("$") || name.contains("%") || name.contains("^"))
return false;
if (name.contains("&") || name.contains("*") || name.contains("/") || name.contains("|"))
return false;
return true;
}
}
}
public void CreateStarDMG(JiangStages stage) { } public uint UID { get; set; } public string OwnName { get; set; } public string CustomizedName { get; set; } public byte Level { get; set; } public byte Talent { get; set; } public byte Stage { get; set; } public byte Star { get; set; } public uint FreeCourse { get; set; } public byte Rank { get; set; } public DateTime StartCountDwon { get; set; } public DateTime CountDownEnd { get; set; } public DateTime RemoveJiangMod; public DateTime TimerStamp; public uint Time { get { return (uint)(CountDownEnd - new DateTime(1970, 1, 1).ToLocalTime()).TotalSeconds; }
public void createstardmg(jiangstages stage) { } public uint uid { get; set; } public string ownname { get; set; } public string customizedname { get; set; } public byte level { get; set; } public byte talent { get; set; } public byte stage { get; set; } public byte star { get; set; } public uint freecourse { get; set; } public byte rank { get; set; } public datetime startcountdwon { get; set; } public datetime countdownend { get; set; } public datetime removejiangmod; public datetime timerstamp; public uint time { get { return (uint)(countdownend - new datetime(1970, 1, 1).tolocaltime()).totalseconds; }
الذين يشاهدون محتوى الموضوع الآن : 2 ( الأعضاء 0 والزوار 2) | |
أدوات الموضوع | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
تظبيط الجانج مود في المدن | محمد ياسر | تطوير سيرفرات كونكر | 1 | 2019-08-28 07:11 AM |
حل مشكله كود التسيف فى الجانج | Mr. Co | تطوير سيرفرات كونكر | 2 | 2019-08-01 11:31 AM |
مشكلة فى الجانج يجماعة | osama | مشكلات السيرفيرات كونكر الشخصيه | 16 | 2019-07-23 01:43 AM |
مشكلة بخصوص الجانج | osama | مشكلات السيرفيرات كونكر الشخصيه | 11 | 2019-07-13 11:00 AM |
التحكم في الاكونت الجديد | Hassan Emprator | تطوير سيرفرات كونكر | 3 | 2019-05-04 02:43 AM |