thisclient.Fight.IsFriendInviteSend = true;
}
else
{
thisclient.Fight.FriendInvite = null;
thisclient.Fight.IsFriendInviteSend = false;
}
}
#endregion
switch (thisclient.Flag)
{
#region Lesson
case PlayerFlags.LESSON:
#region Start - отсчет времени
if (thisclient.Fight.Status == FightStatus.Start)
{
if (thisclient.Fight.TimeStarting >= DateTime.Now)
break;
thisclient.Fight.Start();
}
#endregion
#region Fighting - сражение
else if (thisclient.Fight.Status
== FightStatus.Fighting)
{
if (thisclient.Fight.TryDie())
break;
Bot bot = (Bot)thisclient.Fight.Enemy;
sw2.Restart();
thisclient.Fight.TrySendQuestion();
sw2.Stop();
if (sw2.ElapsedMilliseconds > 30)
Log.Write(EType.Notice, "{0} [{1}]*SendQuestion-->{2},
flag:{3}", thisclient.ID, Thread.CurrentThread.Name,
sw2.ElapsedMilliseconds,thisclient.Flag);
//Нанести урон от бота
sw2.Restart();
if (thisclient.CurrentHP > 0f)
{
bot.CalculateDamage(thisclient);
}
sw2.Stop();
if (sw2.ElapsedMilliseconds > 30)
Log.Write(EType.Notice, "{0} [{1}]*CalculateDMG-->{2},
flag:{3}", thisclient.ID, Thread.CurrentThread.Name,
sw2.ElapsedMilliseconds, thisclient.Flag);
sw2.Restart();
thisclient.Fight.TryBullet(bot.IsManiken);
sw2.Stop();
if (sw2.ElapsedMilliseconds > 30)
Log.Write(EType.Notice, "{0} [{1}]*PlayerBullet-->{2},
flag:{3}", thisclient.ID, Thread.CurrentThread.Name,
sw2.ElapsedMilliseconds, thisclient.Flag);
sw2.Restart();
for (int j = 0; j < bot.Fight.Bullet.Count;
j++)
{
Bullet b = bot.Fight.Bullet[j];
if ((DateTime.Now - b.StartTime).TotalMilliseconds
> Config.TimeForBullet)
{
thisclient.CurrentHP -= b.Dmg;
bot.Fight.Bullet.RemoveAt(j);
}
}
sw2.Stop();
if (sw2.ElapsedMilliseconds > 30)
Log.Write(EType.Notice, "{0} [{1}]*BotBullet-->{2},
flag:{3}", thisclient.ID, Thread.CurrentThread.Name,
sw2.ElapsedMilliseconds, thisclient.Flag);
}
#endregion
#region End - конец тренировки. Записываем
знания,даем деньги и т.п.
else if (thisclient.Fight.Status
== FightStatus.End)
{
Bot bot = (Bot)thisclient.Fight.Enemy;
//byte itemIdForWinner = 0;
int oldLevel = thisclient.Level;
byte win = 0;//проиграл
#region ничья
if (thisclient.CurrentHP == 0f && bot.CurrentHP
== 0f)
{
win = 2;//ничья
thisclient.CountFightFriendBotTie++;
thisclient.AddMoney(Config.MoneyForTieFriendBot);
}
#endregion
#region win
else if (bot.CurrentHP == 0f)
{
win = 1;//выйграл
if (bot.IsManiken)
{
thisclient.AddMoney(Config.MoneyForWinnerManiken);
thisclient.CountFightManikenWin++;
}
else
{
thisclient.AddMoney(Config.MoneyForWinnerFriendBot);
thisclient.CountFightFriendBotWin++;
}
}
#endregion
else
{
if (bot.IsManiken)
thisclient.CountFightManikenLose++;
else thisclient.CountFightFriendBotLose++;
}
School.GoSchool(thisclient);
if (win == 1)
{
if (bot.IsManiken)
thisclient.SendFightEnd(PlayerFlags.LESSON, win, Config.MoneyForWinnerManiken, 0);
else thisclient.SendFightEnd(PlayerFlags.LESSON, win, Config.MoneyForWinnerFriendBot, 0);
}
else if (win == 2)
thisclient.SendFightEnd(PlayerFlags.LESSON, win, Config.MoneyForTieFriendBot, 0);
else
thisclient.SendFightEnd(PlayerFlags.LESSON, win, 0,
0);
thisclient.Fight.Reset();
for (int j = 0; j < thisclient.Brains.Count;
j++)
{
Brain b = thisclient.Brains[j];
if (b.InFight > 0)
b.Write(thisclient);
}
thisclient.CurrentHP = thisclient.MaxHP;
if (oldLevel < thisclient.Level)
{
thisclient.AddMoney(Config.MoneyForLevelUp);
if (thisclient.CurrentEP < thisclient.MaxEP)
thisclient.CurrentEP = thisclient.MaxEP;
thisclient.SendUserLevelUp();
}
thisclient.SendAttributes();
//награды
if (bot.IsManiken)
AwardsManager.UA_KillManiken(thisclient);
else AwardsManager.UA_KillFriendBot(thisclient);
}
#endregion
break;
#endregion
#region PVP
case PlayerFlags.PVP:
#region Wait - подбираем противника для
тренировки
if (thisclient.Fight.Status == FightStatus.Wait)
{
#region time up
if (DateTime.Now > thisclient.Fight.TimeWeit)
{
#region setbot
try
{
List<PlDb> curBot = WorldServer.data_allusers.Where(n
=> n.id != thisclient.ID && Math.Abs(n.brains - thisclient.GetAllBrains)
<= Config.RaznicaBrains).ToList();
PlDb mypl = new PlDb();
if (curBot.Count > 1)
mypl = curBot[WorldServer.rand_q.Next(0,
curBot.Count - 1)];
else
{
if (Config.serverType == "vk")
mypl.id = WorldServer.rand_q.Next(100000,
9999999);
else mypl.id = WorldServer.rand_q.Next(1,
900000);
mypl.listBrains = thisclient.Brains;
mypl.brains = thisclient.GetAllBrains;
}
thisclient.Fight.BeginTraining(mypl.id, mypl.listBrains, 0, false);
}
catch (Exception ex)
{
Arena.GoArena(thisclient);
Log.Write(EType.Player, "{0} Arena - Not Find Enemy!",
thisclient.ID);
Log.Write(EType.Error, "{0} bot conn error:"
+ ex);
}
#endregion
break;
}
#endregion
}
#endregion
#region Start
else if (thisclient.Fight.Status
== FightStatus.Start)
{
BasePlayer enemy = thisclient.Fight.Enemy;
if (enemy == null || (!enemy.IsBot &&
!WorldServer.world_players.Contains((Client)enemy)))
{
thisclient.Fight.End();