Beispiel #1
0
        public void WatchMatch(Character watcher, uint idRole)
        {
            ArenaMatch match = FindUser(idRole);

            if (match == null) // match doesn't exist
            {
                return;
            }

            if (FindUser(watcher.Identity) != null) // can't watch, already fighting
            {
                return;
            }

            if (match.Identity1 == watcher.Identity ||
                match.Identity2 == watcher.Identity)    // user is one of the players (might not happen)
            {
                return;
            }

            if (!match.IsRunning()) // fight has ended
            {
                return;
            }

            if (watcher.Map.IsRecordDisable())
            {
                uint  dwMapId = watcher.RecordMapIdentity;
                Point pos     = new Point(watcher.RecordMapX, watcher.RecordMapY);

                watcher.Map.GetRebornMap(ref dwMapId, ref pos);
                watcher.SetRecordPos(dwMapId, (ushort)pos.X, (ushort)pos.Y);
            }
            else
            {
                watcher.SetRecordPos(watcher.MapIdentity, watcher.MapX, watcher.MapY);
            }
            //match.Map.AddClient(watcher);
            watcher.ChangeMap((ushort)ThreadSafeRandom.RandGet(35, 70),
                              (ushort)ThreadSafeRandom.RandGet(35, 70), match.Map.Identity);

            match.SendToMap();
        }
Beispiel #2
0
        public void FindMatch(Character user)
        {
            Character pTarget = FindClosestPoints(user.ArenaQualifier.Points, user.Identity);

            if (pTarget == null || pTarget.ArenaStatus == ArenaWaitStatus.WAITING_INACTIVE)
            {
                return;
            }

            if (user.Map.IsPrisionMap())
            {
                Uninscribe(user);
                return;
            }

            if (pTarget.Map.IsPrisionMap())
            {
                Uninscribe(user);
                return;
            }

            ArenaMatch pMatch = new ArenaMatch(user, pTarget, PrepareMap());

            if (!pMatch.Notify())
            {
                return;
            }

            Character trash;

            m_pPlayers.TryRemove(user.Identity, out trash);
            m_pPlayers.TryRemove(pTarget.Identity, out trash);

            user.ArenaQualifier.Status    = ArenaWaitStatus.WAITING_INACTIVE;
            pTarget.ArenaQualifier.Status = ArenaWaitStatus.WAITING_INACTIVE;
            if (!m_pMatches.TryAdd(pMatch.MapIdentity, pMatch))
            {
                user.ArenaQualifier.Status    = ArenaWaitStatus.NOT_SIGNED_UP;
                pTarget.ArenaQualifier.Status = ArenaWaitStatus.NOT_SIGNED_UP;
                user.Send(ServerString.STR_ARENIC_ERROR);
                pTarget.Send(ServerString.STR_ARENIC_ERROR);
            }
        }