Пример #1
0
        public bool Kick(ulong ownerUserId, string userName, out ClubInfo club)
        {
            using (var uow = _db.UnitOfWork)
            {
                club = uow.Clubs.GetByOwnerOrAdmin(ownerUserId);
                if (club == null)
                {
                    return(false);
                }

                var usr = club.Users.FirstOrDefault(x => x.ToString().ToLowerInvariant() == userName.ToLowerInvariant());
                if (usr == null)
                {
                    return(false);
                }

                if (club.OwnerId == usr.Id)
                {
                    return(false);
                }

                club.Users.Remove(usr);
                var app = club.Applicants.FirstOrDefault(x => x.UserId == usr.Id);
                if (app != null)
                {
                    club.Applicants.Remove(app);
                }
                uow.Complete();
            }

            return(true);
        }
Пример #2
0
        public bool CreateClub(IUser user, string clubName, out ClubInfo club)
        {
            //must be lvl 5 and must not be in a club already

            club = null;
            using (var uow = _db.UnitOfWork)
            {
                var du = uow.DiscordUsers.GetOrCreate(user);
                uow._context.SaveChanges();
                var xp = new LevelStats(uow.Xp.GetTotalUserXp(user.Id));

                if (xp.Level >= 5 && du.Club == null)
                {
                    du.Club = new ClubInfo()
                    {
                        Name    = clubName,
                        Discrim = uow.Clubs.GetNextDiscrim(clubName),
                        Owner   = du,
                    };
                    uow.Clubs.Add(du.Club);
                    uow._context.SaveChanges();
                }
                else
                {
                    return(false);
                }

                uow._context.Set <ClubApplicants>()
                .RemoveRange(uow._context.Set <ClubApplicants>().Where(x => x.UserId == du.Id));
                club = du.Club;
                uow.Complete();
            }

            return(true);
        }
Пример #3
0
    void showClubs()
    {
        for (int i = 0; i < mClubs.Count; i++)
        {
            ClubInfo  club = mClubs[i];
            Transform item = getItem(i);

            setText(item, "name", club.name);
            setText(item, "desc", club.desc);
            setText(item, "id", "ID:" + club.id);
            setActive(item, "admin", club.is_admin);
            setText(item, "hc", club.member_num + " / " + club.max_member_num);
            setIcon(item, "bghead/icon", club.logo);

            UIButton btn = item.GetComponent <UIButton>();
            Color    cl  = club.is_admin ? new Color(0.26f, 0.26f, 0.26f) : new Color(0.06f, 0.06f, 0.06f);
            item.GetComponent <UISprite> ().color = cl;
            btn.hover   = cl;
            btn.pressed = cl;

            PUtils.onClick(item, () => {
                onBtnClub(club);
            });
        }

        updateItems(mClubs.Count);
    }
Пример #4
0
    void onBtnClub(ClubInfo club)
    {
        ClubDetail cd = GameObject.Find("PClubDetail").GetComponent <ClubDetail>();

        cd.UpdateEvents += refresh;
        cd.enter(club.id, club.is_admin);
    }
Пример #5
0
        public bool Kick(ulong kickerId, string userName, out ClubInfo club)
        {
            using (var uow = _db.GetDbContext())
            {
                club = uow.Clubs.GetByOwnerOrAdmin(kickerId);
                if (club == null)
                {
                    return(false);
                }

                var usr = club.Users.FirstOrDefault(x => x.ToString().ToUpperInvariant() == userName.ToUpperInvariant());
                if (usr == null)
                {
                    return(false);
                }

                if (club.OwnerId == usr.Id || (usr.IsClubAdmin && club.Owner.UserId != kickerId))
                {
                    return(false);
                }

                club.Users.Remove(usr);
                var app = club.Applicants.FirstOrDefault(x => x.UserId == usr.Id);
                if (app != null)
                {
                    club.Applicants.Remove(app);
                }
                uow.SaveChanges();
            }

            return(true);
        }
Пример #6
0
        public bool GetClubByName(string clubName, out ClubInfo club)
        {
            club = null;
            var arr = clubName.Split('#');

            if (arr.Length < 2 || !int.TryParse(arr[arr.Length - 1], out var discrim))
            {
                return(false);
            }

            //incase club has # in it
            var name = string.Concat(arr.Except(new[] { arr[arr.Length - 1] }));

            if (string.IsNullOrWhiteSpace(name))
            {
                return(false);
            }

            using (var uow = _db.UnitOfWork)
            {
                club = uow.Clubs.GetByName(name, discrim);
                if (club == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
Пример #7
0
        public async Task <ClubInfo> ClubReqHandler(string formattedId)
        {
            var clubResponse = new ClubInfo()
            {
                Source = "brand new scrape"
            };
            var cachedClub = GetClubById(formattedId);

            if (cachedClub != null)
            {
                clubResponse.Info   = cachedClub;
                clubResponse.Source = GetDataSourceName();

                if (cachedClub.Exists)
                {
                    bool tmiExpired     = _dateHelpers.IsExpired(cachedClub.TMIExpiration);
                    bool historyExpired = _dateHelpers.IsExpired(cachedClub.HistoryExpiration);

                    clubResponse.Source = GetDataSourceName(tmiExpired, historyExpired);
                    cachedClub          = await UpdateCachedClubData(cachedClub, tmiExpired, historyExpired);

                    return(clubResponse);
                }
                else
                {
                    return(clubResponse);
                }
            }
            else
            {
                clubResponse.Info = await NewClubRequest(formattedId);

                return(clubResponse);
            }
        }
Пример #8
0
        public bool Ban(ulong bannerId, DiscordUser usr, out ClubInfo club)
        {
            using (var uow = _db.UnitOfWork)
            {
                club = uow.Clubs.GetByOwnerOrAdmin(bannerId);
                if (club == null)
                {
                    return(false);
                }

                club.Bans.Add(new ClubBans
                {
                    Club = club,
                    User = usr,
                });
                club.Users.Remove(usr);

                var app = club.Applicants.FirstOrDefault(x => x.UserId == usr.Id);
                if (app != null)
                {
                    club.Applicants.Remove(app);
                }

                uow.Complete();
            }

            return(true);
        }
Пример #9
0
        public bool ApplyToClub(IUser user, ClubInfo club)
        {
            using (var uow = _db.UnitOfWork)
            {
                var du = uow.DiscordUsers.GetOrCreate(user);
                uow._context.SaveChanges();

                if (du.Club != null ||
                    new LevelStats(du.TotalXp).Level < club.MinimumLevelReq ||
                    club.Bans.Any(x => x.UserId == du.Id) ||
                    club.Applicants.Any(x => x.UserId == du.Id))
                {
                    //user banned or a member of a club, or already applied,
                    // or doesn't min minumum level requirement, can't apply
                    return(false);
                }

                var app = new ClubApplicants
                {
                    ClubId = club.Id,
                    UserId = du.Id,
                };

                uow._context.Set <ClubApplicants>().Add(app);

                uow.Complete();
            }
            return(true);
        }
Пример #10
0
        public bool Decline(ulong declinerId, DiscordUser usr, out ClubInfo club)
        {
            using (var uow = _db.UnitOfWork)
            {
                club = uow.Clubs.GetByOwnerOrAdmin(declinerId);
                if (club == null)
                {
                    return(false);
                }

                var app = club.Applicants.FirstOrDefault(x => x.UserId == usr.Id);
                if (app != null)
                {
                    club.Applicants.Remove(app);
                }
                else
                {
                    return(false);
                }

                uow.Complete();
            }

            return(true);
        }
Пример #11
0
        private void OnTicketReceived(Club.ClubTicketReceivedEvent ticketEvent)
        {
            ClubErrorType clubErrorType;
            ClubInfo?     clubInfo;
            bool          flag;

            Club.GetLastTicketResponse(ticketEvent.Ticket, ref clubErrorType, ref clubInfo, ref flag);
            if (clubErrorType == null)
            {
                if (clubInfo != null)
                {
                    ClubInfo value = clubInfo.Value;
                    if (value.clubType != 1)
                    {
                        this.ShowErrorText("COMMUNITIES_WRONG_COMMUNITY");
                        return;
                    }
                    this.m_nextButton.interactable = true;
                    this.m_communityText.text      = value.name;
                    this.m_communityIcon.sprite    = GeneralHelpers.LoadIconAsset(AssetBundleType.Icons, (int)((value.avatarId != 0u) ? value.avatarId : ((uint)StaticDB.communityIconDB.GetRecord(1).IconFileID)));
                    this.m_validTicketKey          = ticketEvent.Ticket;
                    this.m_validClubInfo           = value;
                }
            }
            else
            {
                this.ShowErrorText("COMMUNITIES_INVALID_LINK");
            }
        }
Пример #12
0
        private void addItem(ClubInfo club, int tableId)
        {
            GComponent table = Tables.AddItemFromPool().asCom;
            var        info  = table.GetChild("info").asRichTextField;

            for (var i = 1; i <= 10; i++)
            {
                var desk = table.GetChild("desk" + i);
                desk.data = tableId;
                desk.onClick.Set(onDeskClick);
            }

            Dictionary <string, string> vars = new Dictionary <string, string>();

            vars["id"]        = tableId + "";
            vars["current"]   = "0";
            vars["count"]     = club.count + "";
            vars["score"]     = scores[club.score];
            info.templateVars = vars;
            Tables.AddChild(table);

            var btnEditRoom = table.GetChild("btnEditRoom");

            btnEditRoom.data = tableId;
            btnEditRoom.onClick.Set(editRoom);
        }
Пример #13
0
 private ClubInfo DataInfo;//数据
 /// <summary>
 /// 设置数据
 /// </summary>
 public void SetValue(ClubInfo info)
 {
     this.DataInfo         = info;
     ClubNameLable.text    = info.ClubName;
     CreatorLable.text     = "管理员:" + info.CreatorName;
     PlayerCountLable.text = "人数:" + info.PlayerCount;
     IdLable.text          = "ID:" + info.Id;
 }
Пример #14
0
 private void AddCommunity(ClubInfo community)
 {
     if (!CommunityData.m_communityDictionary.ContainsKey(community.clubId))
     {
         Community community2 = new Community(community);
         CommunityData.m_communityDictionary.Add(community2.ClubId, community2);
         community2.RefreshStreams();
     }
 }
Пример #15
0
        public void HandleClubUpdatedEvent(Club.ClubUpdatedEvent updateEvent)
        {
            ClubInfo?clubInfo = Club.GetClubInfo(updateEvent.ClubID);

            if (clubInfo.HasValue)
            {
                this.m_clubInfo = clubInfo.Value;
            }
        }
Пример #16
0
        /// <summary>
        /// 计算需要的速度
        /// </summary>
        /// <param name="club">所用的球杆</param>
        /// <param name="ball">所使用的球</param>
        /// <param name="startPos">发球点</param>
        /// <param name="RingPos">五环的位置,第一个反弹点</param>
        /// <returns></returns>
        public Vector3 CalcNeedSpeed(ClubInfo club, BallInfo ball, Vector3 startPosition, Vector3 endPosition, float hookAngle = 0)
        {
            float sinElevationRad = 0;
            float cosElevationRad = 0;

            GetClubElevationRad(club.Type, out sinElevationRad, out cosElevationRad);
            //位移
            Vector3 deltaPosition = endPosition - startPosition;

            //角
            if (deltaPosition.z == 0)
            {
                return(Vector3.zero);
            }
            float HorizonRad    = Mathf.Atan(deltaPosition.x / deltaPosition.z);
            float CosHorizonRad = Mathf.Cos(HorizonRad);
            float SinHorizonRad = Mathf.Sin(HorizonRad);

            //公式算出初速度
            float divisor = (2 * deltaPosition.y * cosElevationRad * cosElevationRad * CosHorizonRad * CosHorizonRad
                             - 2 * deltaPosition.z * sinElevationRad * cosElevationRad * CosHorizonRad);

            if (divisor == 0)
            {
                return(Vector3.zero);
            }
            float squareV = (deltaPosition.z * deltaPosition.z * LogicConstantData.Gravity) / divisor;
            float v       = Mathf.Sqrt(Mathf.Abs(squareV));

            //初速度分量
            float vx = v * cosElevationRad * SinHorizonRad;
            float vy = v * sinElevationRad;
            float vz = v * cosElevationRad * CosHorizonRad;

            //反向时的处理
            Vector3 dir = deltaPosition.normalized;

            if (dir.z < 0)
            {
                vz        = -vz;
                vx        = -vx;
                hookAngle = -hookAngle;
            }

            //计算曲球初速度和加速度
            //CalcHook(vy, vz, deltaPosition.z, hookAngle);

            //计算精准度风切校正
            //CalcAccuracyRevise(vx, vz);

            //最终初速度
            Vector3 velocity = new Vector3(vx, vy, vz);

            return(velocity);
        }
Пример #17
0
        public byte[] GetClubData()
        {
            PlayerItemData ClubInfo;

            ClubInfo = ItemWarehouse.GetItem(this.ClubSetIndex);
            if ((ClubInfo == null))
            {
                return(new byte[28]);
            }
            return(ClubInfo.GetClubInfo());
        }
 protected MainController()
 {
     db       = new AdminConnectEntities();
     User     = db.Users.FirstOrDefault();
     ClubInfo = db.ClubInfoes.FirstOrDefault();
     Package  = db.Packages.FirstOrDefault();
     Room     = db.Rooms.FirstOrDefault();
     Trainer  = db.Trainers.FirstOrDefault();
     Day      = db.Days.FirstOrDefault();
     Course   = db.Courses.FirstOrDefault();
     Schedule = db.Schedules.FirstOrDefault();
 }
Пример #19
0
        public bool Disband(ClubInfo club)
        {
            using (var uow = _db.UnitOfWork)
            {
                if (club == null)
                {
                    return(false);
                }

                uow.Clubs.Remove(club);
                uow.Complete();
            }
            return(true);
        }
Пример #20
0
        internal static string MakeLeaveClubMessage(string UserID, int QID, int OID, string clubID)
        {
            ClubInfo        clubInfo  = new ClubInfo(UserID, clubID, "");
            List <ClubInfo> clubInfos = clubInfo.SelectByUseridandClubID();

            if (clubInfos.Count > 0)
            {
                return($"已經離開:\n{clubInfos[0].ClubName}");
            }
            else
            {
                return("系統錯誤!");
            }
        }
Пример #21
0
        public bool Disband(ulong userId, out ClubInfo club)
        {
            using (var uow = _db.GetDbContext())
            {
                club = uow.Clubs.GetByOwner(userId);
                if (club == null)
                {
                    return(false);
                }

                uow.Clubs.Remove(club);
                uow.SaveChanges();
            }
            return(true);
        }
Пример #22
0
        public ClubInfo GetClubInfo(int id)
        {
            ClubInfo message = null;
            var      clas    = new Class1();

            using (var session = clas.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    message = session.QueryOver <ClubInfo>().Where(u => (u.Id == id)).List().FirstOrDefault();
                    transaction.Commit();
                }
            }
            return(message);
        }
Пример #23
0
    public void SetData(ClubInfo data)
    {
        mData = data;
        //俱乐部id
        mClubId.text = data.clubId.ToString();
        //人数
        mPlayerNum.text = data.people.ToString();
        //设置仓库金币数
        SetWarehouseNum();
        mWinNum.text = data.winGold.ToString();
        //刷新列表
        int count = ClubModel.Inst.ClubPlayerInfoData == null ? 0 : ClubModel.Inst.ClubPlayerInfoData.Count;

        mScroll.SetData(count);
    }
Пример #24
0
        public bool Disband(ulong userId, out ClubInfo club)
        {
            using (var uow = _db.UnitOfWork)
            {
                club = uow.Clubs.GetByOwner(userId);
                if (club == null)
                {
                    return(false);
                }

                uow.Clubs.Remove(club);
                uow.Complete();
            }
            return(true);
        }
Пример #25
0
        public ActionResult ChangePhoto(HttpPostedFileBase Photo, int id)
        {
            string image = "";

            if (Photo != null)
            {
                string photoName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + Photo.FileName;
                image = Path.Combine(Server.MapPath("~/Uploads"), photoName);
                Photo.SaveAs(image);
                ClubInfo ci = db.ClubInfoes.Find(id);
                ci.Photo = photoName;
                db.SaveChanges();
            }

            return(RedirectToAction("ClubInfo"));
        }
Пример #26
0
    void onBtnClub(ClubInfo club)
    {
        bool admin = club.is_admin;

        Debug.Log("onBtnClub");

        if (admin)
        {
            GameObject padmin = GameObject.Find("PAdmin");
            padmin.GetComponent <LuaListBase>().enter(club.id);
        }
        else
        {
            GameObject hall = GameObject.Find("PHall");
            hall.GetComponent <Hall>().enter(club.id);
        }
    }
Пример #27
0
    public void ReadData(UMessage msg)
    {
        //nMessageType = msg.ReadUInt();
        clubNumber = msg.ReadUInt();
        clubs.Clear();
        for (uint index = 0; index < clubNumber; index++)
        {
            ClubInfo info = new ClubInfo();
            info.clubid       = msg.ReadUInt();
            info.clubName     = msg.ReadString();
            info.memberNumber = msg.ReadUInt();
            info.maxMember    = msg.ReadUInt();
            info.clubLevel    = msg.ReadUInt();
            info.content      = msg.ReadString();
            info.condition    = msg.ReadChar();

            clubs.Add(info);
        }
    }
Пример #28
0
        public bool Ban(ulong ownerUserId, string userName, out ClubInfo club)
        {
            using (var uow = _db.UnitOfWork)
            {
                club = uow.Clubs.GetByOwner(ownerUserId,
                                            set => set.Include(x => x.Applicants)
                                            .ThenInclude(x => x.User));
                if (club == null)
                {
                    return(false);
                }

                var usr = club.Users.FirstOrDefault(x => x.ToString().ToLowerInvariant() == userName.ToLowerInvariant())
                          ?? club.Applicants.FirstOrDefault(x => x.User.ToString().ToLowerInvariant() == userName.ToLowerInvariant())?.User;
                if (usr == null)
                {
                    return(false);
                }

                if (club.OwnerId == usr.Id) // can't ban the owner kek, whew
                {
                    return(false);
                }

                club.Bans.Add(new ClubBans
                {
                    Club = club,
                    User = usr,
                });
                club.Users.Remove(usr);

                var app = club.Applicants.FirstOrDefault(x => x.UserId == usr.Id);
                if (app != null)
                {
                    club.Applicants.Remove(app);
                }

                uow.Complete();
            }

            return(true);
        }
 private void OnTicketReceived(Club.ClubTicketReceivedEvent ticketEvent)
 {
     if (ticketEvent.Error != ClubErrorType.ERROR_COMMUNITIES_NONE)
     {
         this.ShowErrorText("COMMUNITIES_INVALID_LINK");
     }
     else if (ticketEvent.Info.HasValue)
     {
         ClubInfo value = ticketEvent.Info.Value;
         if (value.clubType != ClubType.Character)
         {
             this.ShowErrorText("COMMUNITIES_WRONG_COMMUNITY");
             return;
         }
         this.m_nextButton.interactable = true;
         this.m_communityText.text      = value.name.ToUpper();
         this.m_validTicketKey          = ticketEvent.Ticket;
         this.m_validClubInfo           = value;
     }
 }
    /// <summary>
    /// 俱乐部列表返回
    /// </summary>
    /// <param name="message"></param>
    private void onClubListBack(NetworkMessage message)
    {
        GameData.ClubInfoList = new List <ClubInfo>();
        int count = message.readInt32();

        for (int i = 0; i < count; i++)
        {
            ClubInfo info = new ClubInfo();
            info.Id          = (int)message.readUInt32(); //俱乐部id
            info.ClubName    = message.readString();      //俱乐部名称
            info.CreatorName = message.readString();      //俱乐部管理人
            info.PlayerCount = message.readInt32();       //俱乐部人数

            GameData.ClubInfoList.Add(info);
        }
        UIManager.Instance.ShowUiPanel(UIPaths.ClubListPanel, OpenPanelType.MinToMax);
        if (ClubListPanelControl.Instance != null)
        {
            ClubListPanelControl.Instance.InitData();
        }
    }