Ejemplo n.º 1
0
        //
        // GET: Forum/Threads/GroupId
        public async Task <ActionResult> Threads(int groupId, int?page)
        {
            ICollection <ThreadsViewModel> model = new List <ThreadsViewModel>();
            Group group = await GroupManager.FindByIdAsync(groupId);

            IEnumerable <Thread> threads = group.Threads;

            const int threadsPerPage = 40;

            ViewBag.GroupId   = groupId;
            ViewBag.GroupName = await GroupManager.GetGroupNameByIdAsync(groupId);

            // Sorting first on date and then on if there pinned
            threads = threads.OrderByDescending(t => t.Messages.LastOrDefault().TimeStamp).OrderBy(t => t.Pinned).AsEnumerable();

            foreach (Thread thread in threads)
            {
                model.Add(new ThreadsViewModel
                {
                    Id   = thread.Id,
                    Name = thread.Name,
                    LastMessageTimeStamp = thread.Messages.LastOrDefault().TimeStamp,
                    LastMessageUserName  = thread.Messages.LastOrDefault().User.UserName,
                    NumberOfMessages     = thread.Messages.Count(),
                    StartedByUserName    = thread.User.UserName,
                    StartedTimeStamp     = thread.Messages.FirstOrDefault().TimeStamp.ToLongTimeString(),
                    ViewCount            = thread.ViewCount,
                    Vote = await ReputationSystem.GetThreadReputationAsync(thread)
                });
            }

            return(View(model.ToPagedList(page ?? 1, threadsPerPage)));
        }
Ejemplo n.º 2
0
        public async Task <JsonResult> MessageReputationDown(int messageId)
        {
            // We will downvote on the message and get the current repuitation on the message
            int messageReputation = await ReputationSystem.DownVoteOnMessageAsync(messageId);

            // we will return that current reputation
            return(Json(new { reputation = messageReputation }));
        }
Ejemplo n.º 3
0
        public async Task <JsonResult> MessageReputationUp(int messageId)
        {
            // We will upvote the mssage and get the current reputation on the message
            int messageReputation = await ReputationSystem.UpVoteOnMessageAsync(messageId);

            // we will return the current reputation
            return(Json(new { reputation = messageReputation }));
        }
Ejemplo n.º 4
0
 void TryGetReputationsys()
 {
     if (ReputationSystem.Instance == null)
     {
         return;
     }
     RS    = ReputationSystem.Instance;
     hasrs = true;
 }
Ejemplo n.º 5
0
        //
        // GET: Forum/Thread/ThreadId&GroupId
        public async Task <ActionResult> Thread(int threadId, int groupId, int?page)
        {
            const int messagesPerPage = 20;

            // Filling in the viewbags
            ViewBag.GroupName = await GroupManager.GetGroupNameByIdAsync(groupId);

            ViewBag.GroupId  = groupId;
            ViewBag.ThreadId = threadId;

            // Creating a list of messages
            ThreadViewModel model  = new ThreadViewModel();
            Thread          thread = await ThreadManager.FindByIdAsync(threadId);

            ICollection <MessagesViewModel> messagesViewModels = new List <MessagesViewModel>();

            model.ThreadName = thread.Name;

            // TODO: make this so this is only if the user is loged in
            model.Subscribed = ThreadManager.IsUserSubscribedToThreac(thread);

            // Creating the messages
            foreach (Message message in thread.Messages)
            {
                messagesViewModels.Add(new MessagesViewModel
                {
                    Id            = message.Id,
                    UserName      = UserManager.FindById(message.User.UserId).UserName,
                    JoinDate      = message.User.JoinDate,
                    Posts         = message.User.PostsCount,
                    Signiture     = message.User.Signature,
                    Reputation    = message.Reputation,
                    ThreadId      = threadId,
                    GroupId       = groupId,
                    Image         = ProfilePictureSystem.GetProfilePicture(message.User.UserId),
                    Country       = (await UserManager.FindByIdAsync(message.User.UserId)).Country,
                    VotingEnabled = ReputationSystem.CanUserVote(message),
                    IsCreator     = (message.User.UserId == User.Identity.GetUserId()),

                    Body          = message.Body,
                    MessagePost   = message.TimeStamp,
                    MessageNumber = message.MessagePlacementInThread
                });
            }

            // Sorts the list by date
            messagesViewModels = messagesViewModels.OrderByDescending(m => m.MessagePost).ToList();

            // Changing to it a page list
            model.Messages = messagesViewModels.ToPagedList(page ?? 1, messagesPerPage);

            // Increase the view count
            await ThreadManager.AddThreadViewwCountAsync(thread.Id);

            return(View(model));
        }
Ejemplo n.º 6
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_userManager != null)
         {
             _userManager.Dispose();
             _userManager = null;
         }
         if (_forumService != null)
         {
             _forumService.Dispose();
             _forumService = null;
         }
         if (_reputationSystem != null)
         {
             _reputationSystem.Dispose();
             _reputationSystem = null;
         }
         if (_forumUserManager != null)
         {
             _forumUserManager.Dispose();
             _forumUserManager = null;
         }
         if (_groupManager != null)
         {
             _groupManager.Dispose();
             _groupManager = null;
         }
         if (_messageManager != null)
         {
             _messageManager.Dispose();
             _messageManager = null;
         }
         if (_privateMessagingSystem != null)
         {
             _privateMessagingSystem.Dispose();
             _privateMessagingSystem = null;
         }
         if (_threadManager != null)
         {
             _threadManager.Dispose();
             _threadManager = null;
         }
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 7
0
    public static void OnDoodadDeath(SkEntity cur, SkEntity caster)
    {
        caster = PETools.PEUtil.GetCaster(caster);
        SkAliveEntity curAlive = cur as SkAliveEntity;
        SkAliveEntity casAlive = caster as SkAliveEntity;

        if (curAlive != null && casAlive != null)
        {
            int curPlayerID = Mathf.RoundToInt(curAlive.GetAttribute(AttribType.DefaultPlayerID));
            if (ReputationSystem.IsReputationTarget(curPlayerID))
            {
                int casPlayerID = Mathf.RoundToInt(casAlive.GetAttribute(AttribType.DefaultPlayerID));
                int casLvl      = (int)ReputationSystem.Instance.GetReputationLevel(casPlayerID, curPlayerID); //operate value depend the one be killed
                //lz-2017.05.11 冒险模式如果声望等级大于Cold的时候,攻击一下直接掉为Cold
                if (PeGameMgr.IsAdventure && casLvl > (int)ReputationSystem.ReputationLevel.Cold)
                {
                    int targetLvl   = (int)ReputationSystem.ReputationLevel.Cold;
                    int reduceValue = 0;
                    for (int i = targetLvl; i < casLvl; i++)
                    {
                        reduceValue -= ReputationSystem.GetLevelThreshold((ReputationSystem.ReputationLevel)i);
                    }
                    ReputationSystem.Instance.ChangeReputationValue(casPlayerID, curPlayerID, reduceValue, true);
                }
                else
                {
                    DoodadProtoDb.Item protoItem = DoodadProtoDb.Get(curAlive.Entity.entityProto.protoId);
                    RepVal             repVal;
                    if (protoItem != null && s_dicRepVals.TryGetValue(protoItem.repValId, out repVal))
                    {
                        int reduceValue = (int)(repVal._vals[casLvl] * ReputationSystem.ChangeValueProportion);         //reduceValue = addvalue * ChangeValueProportion;
                        ReputationSystem.Instance.ChangeReputationValue(casPlayerID, curPlayerID, reduceValue, true);   // reudce self no mater other side would be add;
                    }
                }
            }
        }
    }
Ejemplo n.º 8
0
 public void ResetState()
 {
     level        = ReputationSystem.ConvntValueToLevel((exValue > 0)?exValue:reputationValue);
     belligerency = level < ReputationLevel.Neutral;
 }