<%@ Language=JScript %> <% var gametype = String(Request.form("gametype")); if (gametype == "undefined") gametype = "all"; var content = ""; content += "

The ladder

"; content += "(This is the ratings of all players, and the stats of rated games. You can read an explanation of the rating system here
"; content += "Red player names are inactive players, i.e. they haven't finished a game within the last 3 months"; content += "
)

"; content += "
"; content += "Check out the ladder history!"; content += "

"; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; if (gametype == "tournament") { var rs = Server.CreateObject("adodb.recordset"); sql = "SELECT id, ((SELECT (count(*) * 3) from game inner join gamenegotiation on "; sql += "gamenegotiation.gameid = game.id where (user1id = user.id or user2id = user.id)"; sql += " AND (gametype1id = 2 OR gametype1id = 3) and winnerid = user.id "; sql += " and messageid = 6 and rated = 1) + "; sql += " (SELECT count(*) from game inner join gamenegotiation on "; sql += "gamenegotiation.gameid = game.id where (user1id = user.id or user2id = user.id)"; sql += " AND (gametype1id = 2 OR gametype1id = 3) and winnerid = 0 "; sql += " and messageid = 6 and rated = 1)) as tr FROM [user]"; rs.Open(sql, conn); while (!(rs.eof || rs.bof)) { sql = "UPDATE [user] set tournamentrating = " + String(rs("tr")); sql += " WHERE user.id = " + rs("id"); conn.Execute(sql); rs.movenext(); } } var rs = Server.CreateObject("adodb.recordset"); var sql = "select "; if (gametype == "tournament") { sql += " ((SELECT (count(*) * 3) from game inner join gamenegotiation on "; sql += "gamenegotiation.gameid = game.id where (user1id = user.id or user2id = user.id)"; sql += " AND (gametype1id = 2 OR gametype1id = 3) and winnerid = user.id "; sql += " and messageid = 6 and rated = 1) + "; sql += " (SELECT count(*) from game inner join gamenegotiation on "; sql += "gamenegotiation.gameid = game.id where (user1id = user.id or user2id = user.id)"; sql += " AND (gametype1id = 2 OR gametype1id = 3) and winnerid = 0 "; sql += " and messageid = 6 and rated = 1))"; sql += " as tournamentrating, "; } else if (gametype == "2004") { sql += " ((SELECT (count(*) * 3) from game inner join gamenegotiation on "; sql += "gamenegotiation.gameid = game.id where (user1id = user.id or user2id = user.id)"; sql += " AND (gametype1id = 3) and winnerid = user.id "; sql += " and messageid = 6 and rated = 1) + "; sql += " (SELECT count(*) from game inner join gamenegotiation on "; sql += "gamenegotiation.gameid = game.id where (user1id = user.id or user2id = user.id)"; sql += " AND (gametype1id = 3) and winnerid = 0 "; sql += " and messageid = 6 and rated = 1))"; sql += " as tournamentrating, "; } sql += "username, rating, tournamentrating, id, "; sql += "(select count(game.id) from game where game.id IN (select gamenegotiation.gameid from gamenegotiation where messageid = 6) and (user1id = user.id or user2id = user.id)"; if (gametype == "tournament") sql += " AND (gametype1id = 2 OR gametype1id = 3) "; else if (gametype == "2004") sql += " AND (gametype1id = 3) "; sql += " and rated = 1) as games "; sql += ", (select count(game.id) from game where game.id IN (select gamenegotiation.gameid from gamenegotiation where messageid = 6) and (user1id = user.id or user2id = user.id)"; if (gametype == "tournament") sql += " AND (gametype1id = 2 OR gametype1id = 3) "; else if (gametype == "2004") sql += " AND (gametype1id = 3) "; sql += " and winnerid = user.id and rated = 1) as wins "; sql += ", (select count(game.id) from game where game.id IN (select gamenegotiation.gameid from gamenegotiation where messageid = 6) and (user1id = user.id or user2id = user.id)"; if (gametype == "tournament") sql += " AND (gametype1id = 2 OR gametype1id = 3) "; else if (gametype == "2004") sql += " AND (gametype1id = 3) "; sql += " and winnerid = 0 and rated = 1) as draws "; sql += ", (select count(game.id) from game where game.id IN (select gamenegotiation.gameid from gamenegotiation where messageid = 6) and (user1id = user.id or user2id = user.id)"; if (gametype == "tournament") sql += " AND (gametype1id = 2 OR gametype1id = 3) "; else if (gametype == "2004") sql += " AND (gametype1id = 3) "; sql += " and winnerid <> user.id and winnerid <> 0 and rated = 1) as losses "; sql += ", (select top 1 completetime from game where gamestatusid = 3 AND rated = 1 AND user1rating IS NOT NULL "; sql += "AND (user1id = user.id OR user2id = user.id) "; sql += "order by completetime desc) as completetime "; sql += "from [user] "; sql += " where (select count(game.id) from game where game.id IN (select gamenegotiation.gameid from gamenegotiation where messageid = 6) and (user1id = user.id or user2id = user.id)"; if (gametype == "tournament") sql += " AND (gametype1id = 2 OR gametype1id = 3) "; else if (gametype == "2004") sql += " AND (gametype1id = 3) "; sql += " and rated = 1) > 0"; if (gametype != "tournament" && gametype != "2004") sql += " order by rating desc, username asc"; else sql += " order by tournamentrating desc, username"; //Response.write(sql); rs.Open(sql, conn, 2, 3); //if (gametype == "tournament") // rs.Sort = "username asc"; i = 1; var bgcolor = ""; var dlimit = new Date(); dlimit = dlimit.setMonth(dlimit.getMonth() - 3); while (!(rs.EOF || rs.BOF)) { if (bgcolor == "#FFF1B5") bgcolor = "#FFF9DB"; else bgcolor = "#FFF1B5"; content += ""; content += ""; content += ""; //player //check whether the player is active or not (having completed a game within the last 3 months... //get the time of the lastest completed game var completedate = String(rs("completetime")); var y = completedate.substr(0, 4); var m = completedate.substr(5, 2); var d = completedate.substr(8, 2); cd = new Date(y, m - 1, d); content += ""; //games played content += ""; //wins content += ""; //draws content += ""; //losses content += ""; content += ""; rs.Movenext; i++; } content += "
RankRatingPlayerGames playedWinsDrawsLosses
"; content += i; content += ""; if (gametype != "tournament") content += String(rs("rating")); else content += String(rs("tournamentrating")); content += ""; content += " cd) content += " style=\"color: #FF0000\" "; content += ">"; content += String(rs("username")); content += ""; content += ""; content += String(rs("games")); content += ""; content += String(rs("wins")); content += ""; content += String(rs("draws")); content += ""; content += String(rs("losses")); content += "


"; var title = "The Empire Deluxe Ladder"; pageTemplate(content, title); %>