Exemple #1
0
        public Match(Player attacker, Player defender, SwinecideServer server)
        {
            attacker.currentMatch = this;
            defender.currentMatch = this;

            this.attacker = attacker;
            this.defender = defender;
            this.server = server;
            this.attackerLifeRequest = 0;
            this.defenderLifeRequest = 0;
            this.entityCounter = 1;
            this.messagelog = "";
            /*
             * { "msgType":"LogInRequest", "role":"defender" }
             */
            MsgObjects.LogIn temp = new MsgObjects.LogIn("attacker");
            this.SendMessage(attacker.ws, temp.ToJSON());
            temp = new MsgObjects.LogIn("defender");
            this.SendMessage(defender.ws, temp.ToJSON());

            var task = Task.Run(() => ScheduleMatchEnd());
        }
Exemple #2
0
        public void ws_disconnected(WebSocket ws)
        {
            Dictionary<String, String> tempDict = new Dictionary<string, string>();
            if (ws.RemoteEndpoint.Equals(defender.ws.RemoteEndpoint))
            {
                MsgObjects.LogIn temp = new MsgObjects.LogIn("attacker");
                Console.WriteLine("Defender disconnected - attacker wins!");
                this.SendMessage(attacker.ws, temp.ToJSON());
            }
            else
            {
                MsgObjects.LogIn temp = new MsgObjects.LogIn("defender");
                Console.WriteLine("Attacker disconnected - defender wins!");
                this.SendMessage(defender.ws, temp.ToJSON());
            }
            server.ReportMatchDone(this);

            this.Dispose();
        }