Esempio n. 1
0
        public static void Main(string[] args)
        {
            JObject config = JObject.Parse(File.ReadAllText("Game.json"));

            Base = (string)config["auth"]["url"];
            int topic = (int)config["auth"]["thread"];
            int skip  = (int)config["state"]["startpost"];

            foreach (string player in config["state"]["players"])
            {
                Player p = new Player()
                {
                    Name = player
                };
                Players[player.ToLower()] = p;
            }

            foreach (JObject post in GetPosts(topic))
            {
                if ((int)post["post_number"] < skip)
                {
                    continue;
                }
                var actor = ((string)post["username"]).ToLower();
                if (Players.ContainsKey(actor))
                {
                    Players[actor].LastPost = DateTime.Parse((string)post["created_at"]);
                    Players[actor].Postcount++;
                    ProcessActions(post, ProcessAction);
                }
            }

            var Quiets = "<table><tr><th>Player</th><th>Posts</th></tr>" + String.Join("",
                                                                                       Players.Values.OrderByDescending(p => p.Postcount).Select(p => string.Format("<tr><td>{0}</td><td>{1}</td></tr>",
                                                                                                                                                                    p.Name, p.Postcount))) + "</table>";

            var t = new PostTemplate();

            t.Session             = new Dictionary <string, object>();
            t.Session["Day"]      = (int)config["state"]["day"];
            t.Session["Motd"]     = (string)config["state"]["motd"];
            t.Session["Deadline"] = DateTime.Parse((string)config["state"]["deadline"]);
            t.Session["Players"]  = Players.Values;
            t.Session["Topic"]    = topic;

            t.Initialize();
            var vcpost = t.TransformText();

            System.Console.Write(vcpost);

            System.Diagnostics.Debugger.Break();
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            JObject config = JObject.Parse(File.ReadAllText("Game.json"));
            Base = (string) config["auth"]["url"];
            int topic = (int) config["auth"]["thread"];
            int skip = (int) config["state"]["startpost"];
            foreach(string player in config["state"]["players"]) {
                Player p = new Player() { Name = player };
                Players[player.ToLower()] = p;
            }

            foreach(JObject post in GetPosts(topic)) {
                if((int) post["post_number"] < skip)
                    continue;
                var actor = ((string) post["username"]).ToLower();
                if(Players.ContainsKey(actor)) {
                    Players[actor].LastPost = DateTime.Parse((string) post["created_at"]);
                    Players[actor].Postcount++;
                    ProcessActions(post, ProcessAction);
                }
            }

            var Quiets = "<table><tr><th>Player</th><th>Posts</th></tr>" + String.Join("",
                             Players.Values.OrderByDescending(p => p.Postcount).Select(p => string.Format("<tr><td>{0}</td><td>{1}</td></tr>",
                                 p.Name, p.Postcount))) + "</table>";

            var t = new PostTemplate();
            t.Session = new Dictionary<string, object>();
            t.Session["Day"] = (int) config["state"]["day"];
            t.Session["Motd"] = (string) config["state"]["motd"];
            t.Session["Deadline"] = DateTime.Parse((string) config["state"]["deadline"]);
            t.Session["Players"] = Players.Values;
            t.Session["Topic"] = topic;

            t.Initialize();
            var vcpost = t.TransformText();
            System.Console.Write(vcpost);

            System.Diagnostics.Debugger.Break();
        }