示例#1
0
        static void Main(string[] argv)
        {
            const string USAGE = "Commands:\n"
                + "exit - exits the game, writing all changes out to the game file\n"
                + "flush [<fname>] - opens the game file and writes the current state of the game to it. If <fname> is provided, writes current state to fname as backup\n"
                + "init <pfile> <gfile> - creates a new game using <pfile> as the participants list and outputting the game state to <gfile>\n"
                + "open <gfile> - loads the game located at gfile, defaults to 'society-tag.gfile' in the local directory\n"
                + "tag <chaserID> <targetID> - attempts to register a tag of user chaserID on user targetID (IDs are numbers)\n"
                + "status <playerID> - prints out the state of user playerID (Name, Email, Target, Alive/Dead, points)\n"
                + "dump - prints out every user's status\n"
                + "top <number> - prints out the top <number> scorers\n"
                + "count - prints out the number of players\n"
                + "disqualify <id>- disqualifies user <id> from game\n"
                + "configure <bonus> <penalty> - changes the score modifier to <bonus> * tags (- <penalty> if dead)\n"
                + "mail - transfer control over to the mail subsystem\n";

            Game game = new Game();
            MailSystem.SetGame(game);
            string line;
            string[] cmdargs;
            string output;
            char[] spacearray = new char[] { ' ' };
            bool cont = true;
            while (cont)
            {
                output = "";
                Console.Write("Please enter a command: ");
                line = Console.ReadLine();
                cmdargs = line.Split(spacearray);
                if (cmdargs.Length == 0)
                {
                    Console.WriteLine(USAGE);
                    continue;
                }
                switch (cmdargs[0])
                {
                    case ("exit"):
                        game.Exit();
                        MailSystem.Cleanup();
                        cont = false;
                        output = "Thank you for using Society-Tag";
                        break;
                    case ("flush"):
                        game.Flush(cmdargs);
                        break;
                    case ("init"):
                        game.Init(cmdargs);
                        break;
                    case ("open"):
                        game.Open(cmdargs);
                        break;
                    case ("tag"):
                        game.Tag(cmdargs);
                        break;
                    case ("status"):
                        game.Status(cmdargs);
                        break;
                    case ("dump"):
                        game.Dump();
                        break;
                    case ("top"):
                        game.Top(cmdargs);
                        break;
                    case ("disqualify"):
                        game.Disqualify(cmdargs);
                        break;
                    case ("configure"):
                        game.Configure(cmdargs);
                        break;
                    case ("count"):
                        game.Count();
                        break;
                    case ("mail"):
                        //MailSystem.Shell();
                        break;
                    default:
                        output = USAGE;
                        break;
                }
                if (output == "")
                    output = game.Response();
                Console.Write(output);
            }
            Console.ReadLine();
        }
示例#2
0
 public static void SetGame(Game game)
 {
     MailSystem.game = game;
 }