2015-03-08 17:20:10 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin
|
|
|
|
|
{
|
2015-03-09 21:28:37 -04:00
|
|
|
|
class Stats
|
|
|
|
|
{
|
2015-03-13 19:40:16 -04:00
|
|
|
|
public Stats(int K, int D, double kdr, double skill)
|
2015-03-09 21:28:37 -04:00
|
|
|
|
{
|
|
|
|
|
Kills = K;
|
|
|
|
|
Deaths = D;
|
2015-03-10 16:45:20 -04:00
|
|
|
|
KDR = Math.Round(kdr,2);
|
2015-03-09 21:28:37 -04:00
|
|
|
|
Skill = Math.Round(skill,2);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-11 21:25:14 -04:00
|
|
|
|
public void updateKDR()
|
2015-03-09 21:28:37 -04:00
|
|
|
|
{
|
|
|
|
|
KDR = Math.Round((double)((double)Kills / (double)Deaths), 2);
|
2015-03-11 21:25:14 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateSkill(double enemySkill)
|
|
|
|
|
{
|
2015-03-13 19:40:16 -04:00
|
|
|
|
Skill = Math.Round(Math.Log(KDR + 1) * ((enemySkill / 2) + 1) + (Math.Log(Deaths) * 0.3) * 12, 2);
|
2015-03-09 21:28:37 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Kills;
|
|
|
|
|
public int Deaths;
|
|
|
|
|
public double KDR;
|
|
|
|
|
public double Skill;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-13 19:40:16 -04:00
|
|
|
|
class Aliases
|
|
|
|
|
{
|
|
|
|
|
public Aliases(int Num, String N, String I)
|
|
|
|
|
{
|
|
|
|
|
Number = Num;
|
|
|
|
|
Names = N;
|
|
|
|
|
IPS = I;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> getNames()
|
|
|
|
|
{
|
|
|
|
|
return new List<String>(Names.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> getIPS()
|
|
|
|
|
{
|
|
|
|
|
return new List<String>(IPS.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getIPSDB()
|
|
|
|
|
{
|
|
|
|
|
return IPS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getNamesDB()
|
|
|
|
|
{
|
|
|
|
|
return Names;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getNumber()
|
|
|
|
|
{
|
|
|
|
|
return Number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addName(String Name)
|
|
|
|
|
{
|
|
|
|
|
Names += Names + ';';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addIP(String IP)
|
|
|
|
|
{
|
|
|
|
|
IPS += IP + ';';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String Names;
|
|
|
|
|
private String IPS;
|
|
|
|
|
private int Number;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-08 17:20:10 -04:00
|
|
|
|
class Player
|
|
|
|
|
{
|
|
|
|
|
public enum Permission
|
|
|
|
|
{
|
|
|
|
|
Banned = -1,
|
|
|
|
|
User = 0,
|
|
|
|
|
Moderator = 1,
|
|
|
|
|
Administrator = 2,
|
|
|
|
|
SeniorAdmin = 3,
|
|
|
|
|
Owner = 4,
|
|
|
|
|
Creator = 5,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Player(string n, string id, int num, int l)
|
|
|
|
|
{
|
|
|
|
|
Name = n;
|
|
|
|
|
npID = id;
|
|
|
|
|
Number = num;
|
|
|
|
|
Level = (Player.Permission)l;
|
|
|
|
|
LastOffense = null;
|
|
|
|
|
Connections = 0;
|
|
|
|
|
Warnings = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-13 19:40:16 -04:00
|
|
|
|
public Player(string n, string id, int num, Player.Permission l, int cind, String lo, int con, String IP2)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
|
|
|
|
Name = n;
|
|
|
|
|
npID = id;
|
|
|
|
|
Number = num;
|
|
|
|
|
Level = l;
|
|
|
|
|
dbID = cind;
|
|
|
|
|
LastOffense = lo;
|
2015-03-09 16:11:09 -04:00
|
|
|
|
Connections = con + 1;
|
2015-03-13 19:40:16 -04:00
|
|
|
|
IP = IP2;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
Warnings = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getName()
|
|
|
|
|
{
|
|
|
|
|
return Name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getID()
|
|
|
|
|
{
|
|
|
|
|
return npID;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-09 21:28:37 -04:00
|
|
|
|
public int getDBID()
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2015-03-09 21:28:37 -04:00
|
|
|
|
return dbID;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getClientNum()
|
|
|
|
|
{
|
|
|
|
|
return Number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Player.Permission getLevel()
|
|
|
|
|
{
|
|
|
|
|
return Level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getConnections()
|
|
|
|
|
{
|
|
|
|
|
return Connections;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getLastO()
|
|
|
|
|
{
|
|
|
|
|
return LastOffense;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-13 19:40:16 -04:00
|
|
|
|
public String getIP()
|
|
|
|
|
{
|
|
|
|
|
return IP;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-10 23:32:23 -04:00
|
|
|
|
public void updateName(String n)
|
|
|
|
|
{
|
|
|
|
|
Name = n;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-13 19:40:16 -04:00
|
|
|
|
public void updateIP(String I)
|
|
|
|
|
{
|
|
|
|
|
IP = I;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-08 17:20:10 -04:00
|
|
|
|
// BECAUSE IT NEEDS TO BE CHANGED!
|
|
|
|
|
public void setLevel(Player.Permission Perm)
|
|
|
|
|
{
|
|
|
|
|
Level = Perm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Tell(String Message)
|
|
|
|
|
{
|
|
|
|
|
lastEvent.Owner.Tell(Message, this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Warn(String Message)
|
|
|
|
|
{
|
|
|
|
|
lastEvent.Owner.Broadcast(Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Kick(String Message)
|
|
|
|
|
{
|
|
|
|
|
lastEvent.Owner.Kick(Message, this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void tempBan(String Message)
|
|
|
|
|
{
|
|
|
|
|
lastEvent.Owner.tempBan(Message, this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Ban(String Message, Player Sender)
|
|
|
|
|
{
|
|
|
|
|
lastEvent.Owner.Ban(Message, this, Sender);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//should be moved to utils
|
|
|
|
|
public Player findPlayer(String Nme)
|
|
|
|
|
{
|
|
|
|
|
foreach (Player P in lastEvent.Owner.getPlayers())
|
|
|
|
|
{
|
|
|
|
|
if (P == null)
|
|
|
|
|
continue;
|
|
|
|
|
if (P.getName().ToLower().Contains(Name.ToLower()))
|
|
|
|
|
return P;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string Name;
|
|
|
|
|
private string npID;
|
|
|
|
|
private int Number;
|
|
|
|
|
private Player.Permission Level;
|
|
|
|
|
private int dbID;
|
|
|
|
|
private int Connections;
|
2015-03-13 19:40:16 -04:00
|
|
|
|
private String IP;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
|
|
|
|
public Event lastEvent;
|
|
|
|
|
public String LastOffense;
|
|
|
|
|
public int Warnings;
|
2015-03-09 21:28:37 -04:00
|
|
|
|
public Stats stats;
|
2015-03-13 19:40:16 -04:00
|
|
|
|
public Aliases Alias;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|