private void GenCheck(StatsDatabase Driver)
{
Log("Processing GENERAL Rank", LogLevel.Notice);
// Vars
List<Dictionary<string, object>> Rows;
List<Dictionary<string, object>> Players;
// Fetch all Sergeant Major's, Order by Score
Players = Driver.Query("SELECT id, score FROM player WHERE rank=20 OR rank=21 ORDER BY score DESC LIMIT 1");
if (Players.Count == 1)
{
int Id = Int32.Parse(Players[0]["id"].ToString());
// Check for currently awarded Smoc
Rows = Driver.Query("SELECT id, earned FROM awards WHERE awd=6666667 LIMIT 1");
if (Rows.Count > 0)
{
// Check for same and determine if minimum tenure servred
int MinTenure = Program.Config.ASP_SpecialRankTenure * 86400;
int Sid = Int32.Parse(Rows[0]["id"].ToString());
int Earned = Int32.Parse(Rows[0]["earned"].ToString());
// Assign new Smoc If the old SMOC's tenure is up, and the current SMOC is not the highest scoring SGM
if (Id != Sid && (Earned + MinTenure) < this.RoundEndTime)
{
// Delete the GENERAL award
Driver.Execute("DELETE FROM awards WHERE id=@P0 AND awd=6666667", Sid);
// Change current GENERAL rank back to 3 Star Gen
Driver.Execute("UPDATE player SET rank=20, chng=0, decr=1 WHERE id =" + Sid);
// Award new GENERAL award
Driver.Execute("INSERT INTO awards(id,awd,earned) VALUES(@P0,@P1,@P2)", Id, 6666667, this.RoundEndTime);
// Update new GENERAL's rank
Driver.Execute("UPDATE player SET rank=21, chng=1, decr=0 WHERE id =" + Id);
}
}
else
{
// Award GENERAL award
Driver.Execute("INSERT INTO awards(id,awd,earned) VALUES(@P0,@P1,@P2)", Id, 6666667, this.RoundEndTime);
// Update GENERAL rank
Driver.Execute("UPDATE player SET rank=21, chng=1, decr=0 WHERE id =" + Id);
}
}
}