Ejemplo n.º 1
0
        private CostReference CreateDropinFee(Pool pool, DateTime gameDate, String playerId)
        {
            Player player = Manager.FindPlayerById(playerId);

            //No cost if clust member mode and the player is the registered member
            if (Manager.ClubMemberMode && player.IsRegisterdMember)
            {
                return(new CostReference(CostType.CLUB_MEMBER, null));
            }
            //No fee created and remove one transfer for the dropin player who is the member with cancelled spot in another pool on same day.
            foreach (Pool thePool in Manager.Pools)
            {
                if (thePool.Name != thePool.Name && thePool.DayOfWeek == thePool.DayOfWeek && thePool.Members.Exists(playerId))
                {
                    player.RemoveTransferByGameDate(gameDate);
                    return(new CostReference(CostType.TRANSFER, null));
                }
            }
            //Check to see if the player has free of charge of dropin
            if (player.FreeDropin > 0)
            {
                player.FreeDropin--;

                /*Fee fee = new Fee(0);
                *  fee.Date = gameDate;
                *  fee.FeeType = "Free -" + String.Format(Fee.FEETYPE_DROPIN, pool.Name);
                *  fee.IsPaid = false;
                *  player.Fees.Add(fee);*/
                return(new CostReference(CostType.FREE, null));
            }
            //Check to see if the player has paid total amount that reaches the membership fee
            if (ReachMaxDropinFeePaid(player))
            {
                return(new CostReference(CostType.REACH_MAX, null));
            }
            if (player.TransferUsed < Manager.MaxTransfers)
            {
                Transfer transfer = player.GetAvailableTransfer(gameDate);
                if (transfer != null)
                {
                    transfer.IsUsed        = true;
                    transfer.ApplyGameDate = gameDate;
                    return(new CostReference(CostType.TRANSFER, transfer.TransferId));
                }
            }
            //Deduct from prepaid balance if it is enough
            if (player.PrePaidBalance >= Manager.DropinFee)
            {
                player.PrePaidBalance -= Manager.DropinFee;
                return(new CostReference(CostType.PRE_PAID, null));
            }
            //last case is to create dropin fee
            Fee fee = new Fee(Manager.DropinFee);

            fee.Date    = gameDate;
            fee.FeeType = FeeTypeEnum.Dropin.ToString();
            fee.FeeDesc = String.Format(Fee.FEETYPE_DROPIN, pool.Name);
            player.Fees.Add(fee);
            //Send wechat reminder if dropin fee reaches the max allow
            if (!player.IsRegisterdMember && IsDropinOwesExceedMax(player))
            {
                String message = "[System Info] Hi, " + player.Name + ". According to our records, the total amount you unpaid dropin fee reaches the maximum ($" + Manager.MaxDropinFeeOwe + "). Please make the payment ASAP, in order to continue making reservation in the future.";
                Manager.WechatNotifier.AddNotifyWechatMessage(player, message);
            }
            return(new CostReference(CostType.FEE, fee.FeeId));
        }