Esempio n. 1
0
        public string DeletePlayer(Session session, string[] parms)
        {
            bool   help       = false;
            string playerName = string.Empty;

            try
            {
                var p = new OptionSet
                {
                    { "?|help|h", v => help = true },
                    { "p=|player=", v => playerName = v.TrimMatchingQuotes() }
                };
                p.Parse(parms);
            }
            catch (Exception)
            {
                help = true;
            }

            if (help || string.IsNullOrEmpty(playerName))
            {
                return("deleteplayer --player=player");
            }

            uint playerId;

            if (!world.FindPlayerId(playerName, out playerId))
            {
                return("Player not found");
            }

            IPlayer player;

            return(locker.Lock(playerId, out player).Do(() =>
            {
                if (player == null)
                {
                    return "Player not found";
                }

                if (player.Session != null)
                {
                    try
                    {
                        player.Session.CloseSession();
                    }
                    catch (Exception)
                    {
                    }
                }

                foreach (ICity city in player.GetCityList())
                {
                    CityRemover cr = cityRemoverFactory.CreateCityRemover(city.Id);
                    cr.Start();
                }

                return "OK!";
            }));
        }
Esempio n. 2
0
        public override void WorkerRemoved(bool wasKilled)
        {
            ICity city;

            locker.Lock(newCityId, out city).Do(() =>
            {
                CityRemover remover = cityRemoverFactory.CreateCityRemover(newCityId);
                remover.Start();

                StateChange(ActionState.Failed);
            });
        }