コード例 #1
0
        public Error Remove(ITribe tribe)
        {
            if (tribe.AssignmentCount > 0)
            {
                return(Error.TribeHasAssignment);
            }

            if (!Tribes.TryRemove(tribe.Id, out tribe))
            {
                return(Error.TribeNotFound);
            }

            strongholdManager.RemoveStrongholdsFromTribe(tribe);

            tribe.Owner.LastDeletedTribe = SystemClock.Now;
            dbManager.Save(tribe.Owner);

            foreach (var tribesman in new List <ITribesman>(tribe.Tribesmen))
            {
                tribe.RemoveTribesman(tribesman.Player.PlayerId, wasKicked: false, doNotRemoveIfOwner: false);
            }

            UnsubscribeEvents(tribe);

            // Soft delete tribe
            dbManager.Query(
                String.Format("UPDATE `{0}` SET deleted = 1, name = @name WHERE id = @id LIMIT 1",
                              Tribe.DB_TABLE),
                new[]
            {
                new DbColumn("id", tribe.Id, DbType.String),
                new DbColumn("name", String.Format("{0} (DELETED)", tribe.Name), DbType.String)
            });

            return(Error.Ok);
        }