public ActionResult Index()
        {
            ClanUser         clanUser = HttpContext.GetCurrentLoginInformation();
            List <ActionLog> logs     = ActionLogManager.GetAll().OrderByDescending(p => p.addedOn).ToList();

            return(View(logs));
        }
Beispiel #2
0
 public static void UpgradeClan(virtualUser User)
 {
     if (User.ClanID == -1)
     {
         User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> You doesn't own a clan!", User.SessionID, User.Nickname));
     }
     else if (User.ClanRank != 2)
     {
         User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> You're not the owner of the clan!", User.SessionID, User.Nickname));
     }
     else if (User.Cash - 10000 < 0)
     {
         User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> Not enough money!", User.SessionID, User.Nickname));
     }
     else if (getClan(User.ClanID).maxUsers >= 100)
     {
         User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> Your clan cannot be extended more!!", User.SessionID, User.Nickname));
     }
     else
     {
         int MaxUsers = getClan(User.ClanID).maxUsers;
         getClan(User.ClanID).maxUsers += 20;
         int NewMaxUsers = getClan(User.ClanID).maxUsers;
         foreach (virtualUser ClanUser in getClanUsers(User.ClanID))
         {
             ClanUser.send(new PACKET_CHAT("ClanSystem", PACKET_CHAT.ChatType.Clan, "ClanSystem >> " + User.Nickname + " has upgraded clan slots from: " + MaxUsers + " to: " + NewMaxUsers + ":)!", User.ClanID, "NULL"));
         }
         DB.runQuery("UPDATE clans SET maxusers=maxusers+20 WHERE id='" + User.ClanID + "'");
     }
 }
Beispiel #3
0
        public ActionResult RegisterClan(RegisterClanViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Clan newClan = new Clan();

                    newClan.name               = model.ClanName;
                    newClan.description        = model.Description;
                    newClan.shieldLogoLocation = model.Shield;

                    ClanManager.Insert(newClan);
                    ClanUser clanUser = HttpContext.GetCurrentLoginInformation();

                    if (clanUser != null)
                    {
                        clanUser.clanId     = newClan.id;
                        clanUser.userRoleId = (int)ClanRole.Leader;
                        ClanUserManager.Update(clanUser);
                    }
                    else
                    {
                        return(View(new RegisterClanViewModel()));
                    }
                }
            }
            catch
            {
                return(View(new RegisterClanViewModel()));
            }

            return(RedirectToAction("Index", "ClanInfo"));
        }
Beispiel #4
0
 public static void ChangeName(virtualUser User, string oldName, string newName)
 {
     string[] GetCheck = DB.runReadRow("SELECT * FROM clans WHERE clanname='" + newName + "'");
     if (GetCheck.Length == 0) // Prevent double clan name!
     {
         if (User.Cash - 5000 >= 0)
         {
             if (User.ClanRank == 5) // Check if user is master
             {
                 User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> You've changed clan name for 5,000 cash!", User.SessionID, User.Nickname));
                 foreach (virtualUser ClanUser in getClanUsers(User.ClanID))
                 {
                     ClanUser.ClanName = newName;
                     ClanUser.send(new PACKET_CHAT("ClanSystem", PACKET_CHAT.ChatType.Clan, "ClanSystem >> Clan name was changed from: " + oldName + " to: " + newName, ClanUser.ClanID, ClanUser.Nickname));
                 }
                 User.Cash -= 5000;
                 DB.runQuery("UPDATE users SET cash=cash-2500 WHERE id='" + User.UserID + "'");
                 DB.runQuery("UPDATE clans SET clanname='" + newName + "' WHERE id='" + User.ClanID + "'");
             }
             else
             {
                 User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> You cannot change the clan name because you're not the master!", User.SessionID, User.Nickname));
             }
         }
         else
         {
             User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> Not enough cash!", User.SessionID, User.Nickname));
         }
     }
     else
     {
         User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> This clan name is already in use!", User.SessionID, User.Nickname));
     }
 }
        public ActionResult Create(UpsertBlacklistUserViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    UserBlackList newBlacklistUser = new UserBlackList();

                    newBlacklistUser.clanUserId = model.ClanUserId;
                    newBlacklistUser.clanId     = (int)ClanManager.GetClanId(User.Identity.GetUserId());
                    newBlacklistUser.note       = model.Notes;

                    BlacklistManager.Insert(newBlacklistUser);

                    ClanUser blUser = ClanUserManager.SelectByClanUserId(model.ClanUserId);
                    blUser.clanId = null;
                    ClanUserManager.Update(blUser);
                }
            }
            catch
            {
                return(View(new UpsertBlacklistUserViewModel()));
            }

            return(RedirectToAction("EditMode", "Members"));
        }
Beispiel #6
0
        private void handleClanRanks(Player player, Packet packet)
        {
            int  rank = packet.readByteA();
            long name = packet.readLong();

            if (name < 0 || (rank < 0 || rank > 6))
            {
                return;
            }
            Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());

            if (clan != null)
            {
                ClanUser user = clan.getUserByName(Misc.longToPlayerName(name));
                if (user != null)
                {
                    user.setClanRights((Clan.ClanRank)rank);
                    Server.getClanManager().updateClan(clan);
                }
                Clan.ClanRank userExists;
                if (clan.getUsersWithRank().TryGetValue(Misc.longToPlayerName(name), out userExists))
                {
                    clan.getUsersWithRank()[Misc.longToPlayerName(name)] = (Clan.ClanRank)rank;  //Exists already, so altar.
                }
                else
                {
                    clan.getUsersWithRank().Add(Misc.longToPlayerName(name), (Clan.ClanRank)rank); //Not existed yet. so add
                }
            }
        }
 /// <summary>
 /// Inserts a new Clan User record
 /// </summary>
 public static void Insert(ClanUser clanUser)
 {
     using (var dbContext = new HouseOfClansEntities())
     {
         clanUser.addedOn = DateTime.Now;
         dbContext.ClanUsers.Add(clanUser);
         dbContext.SaveChanges();
     }
 }
        //
        // GET: Delete
        // Removes a clan member
        public ActionResult Remove(int memberId)
        {
            ClanUser removeUser = ClanUserManager.SelectByClanUserId(memberId);

            removeUser.clanId = null;
            ClanUserManager.Update(removeUser);

            return(RedirectToAction("EditMode"));
        }
        // GET: ClanWar
        public ActionResult Index()
        {
            ClanUser clanUser = HttpContext.GetCurrentLoginInformation();
            int      clanId   = clanUser.clanId != null ? (int)clanUser.clanId : 0;

            ClanWarViewModel clanWarsInfo = new ClanWarViewModel(clanId);

            return(View(clanWarsInfo));
        }
        public ActionResult Create(int memberId)
        {
            ClanUser blUser = ClanUserManager.SelectByClanUserId(memberId);

            UpsertBlacklistUserViewModel model = new UpsertBlacklistUserViewModel();

            model.ClanUserId = memberId;

            return(View(model));
        }
        public ActionResult Details(int id)
        {
            ClanUser clanUser = HttpContext.GetCurrentLoginInformation();

            int clanId = clanUser.clanId != null ? (int)clanUser.clanId : 0;

            ClanWarViewModel warInfo = new ClanWarViewModel(id, clanId);

            return(View(warInfo));
        }
        /// <summary>
        /// Gets the clan user information based on the clan user id
        /// </summary>
        /// <param name="clanUserId">ClanUser Id</param>
        public static ClanUser SelectByClanUserId(int userId)
        {
            ClanUser clanUser = new ClanUser();

            using (var dbContext = new HouseOfClansEntities())
            {
                clanUser = dbContext.ClanUsers.Where(p => p.id == userId).Select(user => user).FirstOrDefault();
            }

            return(clanUser);
        }
        /// <summary>
        /// Gets the Clan Leader based on the clan id
        /// </summary>
        /// <param name="clanId">Clan Id</param>
        public static ClanUser SelectClanLeaderByClanId(int clanId)
        {
            ClanUser clanLeader = new ClanUser();

            using (var dbContext = new HouseOfClansEntities())
            {
                clanLeader = dbContext.ClanUsers.Where(p => p.clanId == clanId && (ClanRole)p.userRoleId == ClanRole.Leader).Select(user => user).FirstOrDefault();
            }

            return(clanLeader);
        }
        public ActionResult Edit(ClanWarUpsertViewModel clanWar)
        {
            ActionResult result = View();

            try
            {
                ClanUser clanUser  = HttpContext.GetCurrentLoginInformation();
                int      clanWarId = ClanWarManager.Upsert(clanWar, clanUser.id);

                if (clanWarId > 0)
                {
                    //Insert member picks
                    //vv List<WarRanking> rankings = new List<WarRanking>();
                    List <ClanWarPickViewModel> picks       = new List <ClanWarPickViewModel>();
                    List <ClanUser>             clanMembers = ClanUserManager.SelectAllByClanId(clanWar.ClanId);
                    short i = 1;

                    foreach (ClanUser member in clanMembers)
                    {
                        WarRanking ranking = new WarRanking()
                        {
                            clanUserId = member.id,
                            clanWarId  = clanWarId
                        };

                        //vv rankings.Add(ranking);

                        ClanWarPickViewModel pick = new ClanWarPickViewModel()
                        {
                            ClanUserId            = member.id,
                            ClanMemberWarPosition = i,
                            ClanWarId             = clanWarId,
                            PickVS = i
                        };

                        picks.Add(pick);
                        i++;
                    }

                    //vv RankingsManager.Upsert(rankings);
                    ClanWarPicksManager.Upsert(picks);
                }
                //TODO //vv an Else here should display a message stating that the war was not inserted (and no exception apparently)

                result = RedirectToAction("Index");
            }
            catch
            {
                result = View(clanWar);
            }

            return(result);
        }
        /// <summary>
        /// Updates the current Clan User
        /// </summary>
        public static void Update(ClanUser updatedClanUser)
        {
            ClanUser clanUser = ClanUserManager.SelectByClanUserId(updatedClanUser.id);

            using (var dbContext = new HouseOfClansEntities())
            {
                updatedClanUser.updatedOn = DateTime.Now;
                dbContext.ClanUsers.Attach(clanUser);
                dbContext.Entry(clanUser).CurrentValues.SetValues(updatedClanUser);
                dbContext.SaveChanges();
            }
        }
        public ActionResult Create()
        {
            ClanUser clanUser = HttpContext.GetCurrentLoginInformation();
            int      clanId   = clanUser.clanId != null ? (int)clanUser.clanId : 0;

            ClanWarUpsertViewModel clanWar = new ClanWarUpsertViewModel();

            clanWar.ClanId       = clanId;
            clanWar.WarStartedOn = DateTime.Now.AddDays(1);

            return(View("Edit", clanWar));
        }
        public ActionResult Details(int id, string warNote)
        {
            ActionResult           result      = View();
            ClanUser               clanUser    = HttpContext.GetCurrentLoginInformation();
            ClanWarUpsertViewModel clanWarInfo = ClanWarUpsertViewModel.Get(id);

            //The only updatable field when war started is the war notes.
            clanWarInfo.WarNote = warNote;
            ClanWarManager.Upsert(clanWarInfo, clanUser.id);
            result = RedirectToAction("Index");

            return(result);
        }
Beispiel #18
0
        public string GetName(string aspnetId)
        {
            ClanUser user = ClanUserManager.SelectByAspNetUserId(aspnetId);

            if (user != null)
            {
                return(user.name);
            }
            else
            {
                return("No Name");
            }
        }
        /// <summary>
        /// Deletes the current Clan User
        /// </summary>
        public static bool Delete(int clanUserId)
        {
            bool     isDeleted      = false;
            ClanUser deleteCLanUser = ClanUserManager.SelectByClanUserId(clanUserId);

            using (var dbContext = new HouseOfClansEntities())
            {
                dbContext.ClanUsers.Attach(deleteCLanUser);
                dbContext.ClanUsers.Remove(deleteCLanUser);
                isDeleted = dbContext.SaveChanges() > 0;
            }

            return(isDeleted);
        }
		public static ClanUser GetCurrentLoginInformation(this HttpContextBase context)
		{
			ClanUser clanUser = new ClanUser();

			if (context.Session[_sessionMemberInfo] != null)
			{
				clanUser = context.Session[_sessionMemberInfo] as ClanUser;
			}
			else
			{
				clanUser = ClanUserManager.SelectByAspNetUserId(context.User.Identity.GetUserId());
				context.Session.Add(_sessionMemberInfo, clanUser);
			}

			return clanUser;
		}
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser()
                {
                    UserName = model.Email, Email = model.Email
                };
                IdentityResult result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //TODO //vv I think here is where we add the system Role, and all new should be 'normal' user, we need to find a place to change this role in the near future
                    //ref: http://stackoverflow.com/questions/19689183/add-user-to-role-asp-net-identity
                    var currentUser = UserManager.FindByName(user.UserName);

                    CheckAspRoles();

                    var userRoleResult = UserManager.AddToRole(currentUser.Id, "Normal");

                    await SignInAsync(user, isPersistent : false);

                    ClanUser newClanUser = new ClanUser();

                    newClanUser.name         = model.VillageName;
                    newClanUser.userRoleId   = (short)ClanRole.Member;
                    newClanUser.aspnetUserId = currentUser.Id;

                    ClanUserManager.Insert(newClanUser);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    AddErrors(result);
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Beispiel #22
0
        public ActionResult Edit(int id)
        {
            ActionResult result   = View();
            ClanUser     clanUser = HttpContext.GetCurrentLoginInformation();

            //TODO //vv If current user was able to get to this point then it belongs to a Clan, but should it be checked still?

            int clanId = (int)clanUser.clanId;

            ViewBag.WarId          = id;
            ViewBag.IsWarFinalized = ClanWarManager.SelectByClanWarId(id).isFinalized;
            RankingsUpsertViewModel rankings = new RankingsUpsertViewModel(id, clanId);

            result = View(rankings);

            return(result);
        }
Beispiel #23
0
        public ActionResult Create(CreateGroupViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ClanGroup newGroup = new ClanGroup();

                    int leaderId = 0;
                    int.TryParse(model.GroupLeaderId, out leaderId);

                    newGroup.name          = model.GroupName;
                    newGroup.groupLeaderId = leaderId;
                    newGroup.clanId        = model.ClanId;

                    ClanGroupManager.Insert(newGroup);

                    ClanUser groupLeader = ClanUserManager.SelectByClanUserId(leaderId);
                    groupLeader.clanGroupId = newGroup.id;

                    ClanUserManager.Update(groupLeader);

                    if (model.GroupMemberIds != null && model.GroupMemberIds.Count > 0)
                    {
                        foreach (var memberId in model.GroupMemberIds)
                        {
                            int id = 0;
                            int.TryParse(memberId, out id);

                            ClanUser member = ClanUserManager.SelectByClanUserId(id);
                            member.clanGroupId = newGroup.id;

                            ClanUserManager.Update(member);
                        }
                    }
                }
            }
            catch
            {
                int?clanId = ClanManager.GetClanId(User.Identity.GetUserId());

                return(View(new CreateGroupViewModel((int)clanId)));
            }

            return(RedirectToAction("EditMode"));
        }
        //
        // GET: Promote
        // Promotes a clan member
        public ActionResult Promote(int memberId)
        {
            ClanUser promoteUser = ClanUserManager.SelectByClanUserId(memberId);

            if (promoteUser.userRoleId == (short)ClanRole.Member)
            {
                promoteUser.userRoleId = (short)ClanRole.Elder;
            }
            else if (promoteUser.userRoleId == (short)ClanRole.Elder)
            {
                promoteUser.userRoleId = (short)ClanRole.CoLeader;
            }

            ClanUserManager.Update(promoteUser);

            return(RedirectToAction("EditMode"));
        }
Beispiel #25
0
        public ActionResult Index(bool isOverall)
        {
            ActionResult result = View();

            ClanUser clanUser = HttpContext.GetCurrentLoginInformation();

            //TODO //vv If current user was able to get to this point then it belongs to a Clan, but should it be checked still?

            int clanId       = (int)clanUser.clanId;
            int currentWarId = ClanWarManager.SelectClanWarsByClanId(clanId).OrderByDescending(p => p.id).First().id;

            RankingsUpsertViewModel rankings = new RankingsUpsertViewModel(currentWarId, clanId, isOverall);

            ViewBag.IsOverall = isOverall;
            result            = View(rankings);

            return(result);
        }
        //
        // GET: Accept
        // Accepts a clan member
        public ActionResult AcceptMember(int reqId, int clanId)
        {
            Request req = RequestManager.SelectById(reqId);

            req.accepted  = true;
            req.processed = true;

            RequestManager.Update(req);

            ClanUser user = ClanUserManager.SelectByAspNetUserId(req.aspnetUserId);

            user.clanId     = clanId;
            user.userRoleId = (int)ClanRole.Member;

            ClanUserManager.Update(user);

            return(RedirectToAction("EditMode"));
        }
Beispiel #27
0
        public ActionResult Move(MoveMemberViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    int newGroupId = 0;
                    int.TryParse(model.NewGroupId, out newGroupId);

                    ClanUser moveMember = ClanUserManager.SelectByClanUserId(model.MoveMemberId);
                    moveMember.clanGroupId = newGroupId;

                    ClanUserManager.Update(moveMember);
                }
            }
            catch
            {
                return(View());
            }

            return(RedirectToAction("EditMode"));
        }
        public ActionResult Create(CreateMemberViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ClanUser newMember = new ClanUser();

                    newMember.name       = model.Name;
                    newMember.userRoleId = (short)ClanRole.Member;
                    newMember.clanId     = ClanManager.GetClanId(User.Identity.GetUserId());

                    ClanUserManager.Insert(newMember);
                }
            }
            catch
            {
                return(View(new CreateMemberViewModel()));
            }

            return(RedirectToAction("EditMode"));
        }
Beispiel #29
0
        private void handleClanKick(Player player, Packet packet)
        {
            long name = packet.readLong();

            if (name < 0)
            {
                return;
            }
            Clan clan = Server.getClanManager().getClanByPlayer(player);

            if (clan != null)
            {
                ClanUser user = clan.getUserByName(player.getLoginDetails().getUsername());
                if (user != null)
                {
                    if (user.getClanRights() < clan.getKickRights())
                    {
                        player.getPackets().sendMessage("You do not have a high enough rank to kick users from this clan chat.");
                        return;
                    }
                    clan.kickUser(name);
                }
            }
        }
Beispiel #30
0
        public ClanUser GetGroupLeader(int groupLeaderId)
        {
            ClanUser leader = ClanUserManager.SelectByClanUserId(groupLeaderId);

            return(leader);
        }