Example #1
0
        /// <summary>
        /// Constructor which gets ip adress of the server and login name, creates ClientsLibrary class with ip address.
        /// Creates log file
        /// Hooks up all events from Clients Library
        /// Creates history
        /// Invoke Login method on Clients Library
        /// </summary>
        /// <param name="ipAddress"> Arena Server adress provided in the form XXX.XXX.XXX.XXX </param>
        /// <param name="login">Robot login name provided by the client</param>
        public ClientsGamePreview(string ipAddress, string login)
        {
            InitializeComponent();
            this.MouseDown += delegate { DragMove(); };
            var localPath = System.Reflection.Assembly.GetEntryAssembly().Location;
            var pos       = localPath.LastIndexOf(@"\") + 1;

            logFilePath = localPath.Substring(0, pos) + "Client_" + login + "_Log.txt";


            EventLog.WriteMessageToLog(logFilePath, "User " + login + " trying to connect to server on " + ipAddress);
            _cl = new ClientsLibrary(ipAddress);

            _cl.InitialMessageReciveEvent  += ClientsLibrary_InitialMessageReciveEvent;
            _cl.GamePlayMessageReciveEvent += cl_GamePlayMessageReciveEvent;
            _cl.RoundEndEvent   += cl_RoundEndEvent;
            _cl.RoundStartEvent += cl_RoundStartEvent;
            _cl.GameEndEvent    += cl_GameEndEvent;
            _cl.GameStartEvent  += cl_GameStartEvent;

            _history = new List <ActionHistory>();
            _login   = login;
            _cl.Login(_login);
            EventLog.WriteMessageToLog(logFilePath, "User " + login + " trying to log to game");
        }
Example #2
0
        public ClientsGamePreview()
        {
            InitializeComponent();
            cl = new ClientsLibrary();
            //buildMap(17, 17);
            cl.InitialMessageReciveEvent  += ClientsLibrary_MessageReciveEvent;
            cl.GamePlayMessageReciveEvent += cl_GamePlayMessageReciveEvent;
            cl.RoundEndEvent   += cl_RoundEndEvent;
            cl.RoundStartEvent += cl_RoundStartEvent;
            cl.GameEndEvent    += cl_GameEndEvent;
            cl.GameStartEvent  += cl_GameStartEvent;

            cl.Login("Test" + new Random().Next(0, 100).ToString());
            //cl.MakeMove();
        }