예제 #1
0
        private void OnReplay(GamePacketReader packet)
        {
            byte[] replay = packet.ReadToEnd();

            const string directory = "Replays";
            if (!Directory.Exists(directory))
                Directory.CreateDirectory(directory);

            string otherName = _room.Position == 0 ? _room.Names[1] : _room.Names[0];
            string file = DateTime.Now.ToString("yyyy-MM-dd.HH-mm.") + otherName + ".yrp";
            string fullname = Path.Combine(directory, file);

            if (Regex.IsMatch(file, @"^[\w\-. ]+$"))
                File.WriteAllBytes(fullname, replay);

            Connection.Close();
        }
예제 #2
0
파일: Player.cs 프로젝트: mycard/ygosharp
 private void OnResponse(GamePacketReader packet)
 {
     if (Game.State != GameState.Duel)
         return;
     if (State != PlayerState.Response)
         return;
     byte[] resp = packet.ReadToEnd();
     if (resp.Length > 64)
         return;
     State = PlayerState.None;
     Game.SetResponse(resp);
 }