示例#1
0
        /// <summary>
        /// 添加卡牌操作按钮到操作面板中
        /// </summary>
        void AddCardOperationButtonToOperationPanel(CardOperation cardOperation)
        {
            GameObject gameObject = Instantiate(GameManager.GetCardOperationButtonPrefab(), operationPanelTransform);
            CardOperationButtonScript cardOperationButtonScript = gameObject.GetComponent <CardOperationButtonScript>();

            cardOperationButtonScript.SetInfo(this, cardOperation);
        }
示例#2
0
        public ContentResult DestroyCard()
        {
            Response.ContentType = "application/json";
            ResultInfo <Card> result;

            try
            {
                if (Request.Cookies["CardId"] == null)
                {
                    throw new Exception("没有公交卡可供销毁");
                }

                HttpCookie cookie = new HttpCookie("CardId")
                {
                    Expires = DateTime.Now.AddDays(-2)
                };
                Response.Cookies.Add(cookie);

                CardOperation.DestroyCard(Request.Cookies["CardId"].Value);
                result = new ResultInfo <Card>(ResultInfoEnum.OK, "访问成功", Request.Url.ToString(), null);


                return(Content(JsonConvert.SerializeObject(result)));
            }
            catch (Exception e)
            {
                HttpCookie cookie = new HttpCookie("CardId")
                {
                    Expires = DateTime.Now.AddDays(-2)
                };
                Response.Cookies.Add(cookie);
                result = result = new ResultInfo <Card>(ResultInfoEnum.ERROR, e.Message, Request.Url.ToString(), null);
                return(Content(JsonConvert.SerializeObject(result)));
            }
        }
示例#3
0
        public ContentResult CreatCard()
        {
            Response.ContentType = "application/json";
            ResultInfo <Card> result;

            try
            {
                if (Request.Cookies["CardId"] != null)
                {
                    throw new Exception("已有公交卡,不可重复创建,请先删除现有公交卡");
                }
                Card card = CardOperation.CreatCard();
                result = new ResultInfo <Card>(ResultInfoEnum.OK, "访问成功", Request.Url.ToString(), card);

                HttpCookie cookie = new HttpCookie("CardId")
                {
                    Value   = card.CardId,
                    Expires = DateTime.MaxValue
                };
                Response.Cookies.Add(cookie);

                return(Content(JsonConvert.SerializeObject(result)));
            }
            catch (Exception e)
            {
                result = result = new ResultInfo <Card>(ResultInfoEnum.ERROR, e.Message, Request.Url.ToString(), null);
                return(Content(JsonConvert.SerializeObject(result)));
            }
        }
示例#4
0
        public Task <CardOperation> AddNewOperation(CardOperation newCardOperation)
        {
            newCardOperation.Id = Guid.NewGuid();
            operations.Add(newCardOperation);

            return(Task.FromResult(newCardOperation));
        }
示例#5
0
        static void Main(string[] args)
        {
            // 入力 N/M, Card の取得
            var inputsNM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n        = inputsNM[0];
            var m        = inputsNM[1];

            var cards = Console.ReadLine().Split().Select(long.Parse).ToArray();

            // 操作一覧の取得
            var operations = new CardOperation[m];

            for (var i = 0; i < m; i++)
            {
                var inputsBC = Console.ReadLine().Split().ToArray();
                var b        = int.Parse(inputsBC[0]);
                var c        = long.Parse(inputsBC[1]);
                operations[i] = new CardOperation(b, c);
            }

            // 操作をカードの値の降順に並び替える
            Array.Sort(operations);
            Array.Reverse(operations);

            // 操作によって手に入るN枚までのカード
            var opCards = operations.SelectMany(op => Enumerable.Repeat(op.Number, op.Count)).Take(n).ToArray();

            // 初期カードと操作のカードを合わせて、大きいものからN枚を合計する
            var sum = cards.Concat(opCards).OrderByDescending(x => x).Take(n).Sum();

            // 解答の出力
            Console.WriteLine(sum);
        }
示例#6
0
    public void AddNewElement(Item item)
    {
        /*if (!item.isDefaultItem)
         * {
         *  inventory.Add(item);
         * }*/

        if (item is Card)
        {
            Card addCardInList = (Card)item;
            cardList.Add(addCardInList);
        }
        else
        {
            if (item is CardOperation)
            {
                CardOperation addCardInList = (CardOperation)item;
                cardOperationList.Add(addCardInList);
            }
            else
            {
                inventory.Add(item);
            }
        }
    }
示例#7
0
    /// <summary>
    /// 设置信息
    /// </summary>
    /// <param name="duelCardScript"></param>
    /// <param name="cardOperation"></param>
    public void SetInfo(DuelCardScript duelCardScript, CardOperation cardOperation)
    {
        this.duelCardScript = duelCardScript;
        this.cardOperation  = cardOperation;
        CardOperationConfig cardOperationConfig = ConfigManager.GetConfigByName("CardOperation") as CardOperationConfig;

        buttonText.text = cardOperationConfig.GetRecordById((int)cardOperation).value;
    }
示例#8
0
        public void RPC_PlayerWantsToUseCard(int cardInst, int photonId, CardOperation operation)
        {
            if (!NetworkManager.isMaster)
            {
                return;
            }

            bool hasCard = PlayerHasCard(cardInst, photonId);

            if (hasCard)
            {
                photonView.RPC("RPC_PlayerUsesCard", PhotonTargets.All, cardInst, photonId, operation);
            }
        }
        private void GetBlockedOperations(List <CardOperation> operations, string csvStringToImportFrom)
        {
            // Get string blocks from csv string that contain operations info
            var operationLineBlockRegex   = new Regex(@"Заблокированные суммы по.*\n((.*\n)*)");
            var operationLineBlockMatches = operationLineBlockRegex.Matches(csvStringToImportFrom);

            if (operationLineBlockMatches.Count != 0)
            {
                // Process each data block
                foreach (Match operationBlockMatch in operationLineBlockMatches)
                {
                    var headerRowsToSkip         = 1;
                    var operationLinesGroupIndex = 2;
                    var operationLines           = operationBlockMatch
                                                   .Groups[operationLinesGroupIndex].Captures
                                                   .Cast <Capture>()
                                                   .Skip(headerRowsToSkip)
                                                   .Select(capture => capture.ToString())
                                                   .Where(l => !string.IsNullOrWhiteSpace(l));

                    // Single operation line regex
                    var operationLineRegex = new Regex("(.*;){8}");

                    // Populate result array with CardOperation objects created based on captured string lines
                    foreach (var operationLine in operationLines)
                    {
                        int cellGroupIndex = 1;
                        var cells          = operationLineRegex.Match(operationLine)
                                             .Groups[cellGroupIndex].Captures
                                             .Cast <Capture>()
                                             .Select(capt => capt.ToString().Replace(";", ""))
                                             .ToArray();

                        // Parse data
                        var newCardOperation = new CardOperation();
                        newCardOperation.DateTime     = DateTime.ParseExact(cells[0], "dd.MM.yyyy HH:mm:ss", null, DateTimeStyles.AssumeLocal);
                        newCardOperation.OriginalName = cells[1];
                        newCardOperation.Amount       = -ParseDecimal(cells[2]);
                        newCardOperation.Currency     = (Currency)Enum.Parse(typeof(Currency), cells[3]);

                        operations.Add(newCardOperation);
                    }
                }
            }
        }
示例#10
0
        private void CardInfomation_timer_Tick(object sender, EventArgs e)
        {
            CardInfomation_timer.Enabled = false;
            Thread thread = new Thread()
                            if (AllParmetersIsNotNull())
            {
                #region get card infomation and send it

                var card = new CardOperation(_config.DbConnectString);
                var dt   = card.GetCardInfo();
                foreach (DataRow row in dt.Rows)
                {
                    card.SendParameters(_config.SyncPassword, row["oldcardid"].ToString(), row["newcardid"].ToString());
                }

                #endregion
            }
            CardInfomation_timer.Enabled = true;
        }
示例#11
0
        // GET: Card
        public ActionResult Index()
        {
            CardViewModel model = null;;
            Card          card  = null;

            if (Request.Cookies["CardId"] != null)
            {
                card = CardOperation.GetCard(Request.Cookies["CardId"].Value);

                if (card != null)
                {
                    model = new CardViewModel(card);
                }
                else
                {
                    model = null;
                }
            }
            return(View(model));
        }
示例#12
0
 public void AddNewElement(Item item)
 {
     if (item is Card)
     {
         Card addCardInList = (Card)item;
         cardList.Add(addCardInList);
     }
     else
     {
         if (item is CardOperation)
         {
             CardOperation addCardInList = (CardOperation)item;
             cardOperationList.Add(addCardInList);
         }
         else
         {
             inventory.Add(item);
         }
     }
 }
示例#13
0
 public void PlayerWantsToUseCard(int cardInst, int photonId, CardOperation operation)
 {
     photonView.RPC("RPC_PlayerWantsToUseCard", PhotonTargets.MasterClient, cardInst, photonId, operation);
 }
示例#14
0
        /// <summary>
        /// 对卡牌进行操作
        /// </summary>
        /// <param name="cardOperation"></param>
        public void Operation(CardOperation cardOperation)
        {
            switch (cardOperation)
            {
            case CardOperation.NormalCall:
            case CardOperation.SacrificCall:
                if (ownerPlayer.CanCallMonster())
                {
                    if (CanCall())
                    {
                        ownerPlayer.CallMonster(card);
                    }
                }
                break;

            case CardOperation.BackPlaceToMonsterArea:
                if (ownerPlayer.CanCallMonster())
                {
                    if (CanCall())
                    {
                        ownerPlayer.CallMonster(card, CardGameState.Back);
                    }
                }
                break;

            case CardOperation.FlipCall:
                if (CanFlipCall())
                {
                    ownerPlayer.CallMonster(card);
                }
                break;

            case CardOperation.ChangeAttack:
                if (CanChangeToFrontAttack())
                {
                    ChangeAttackDefenseEffectProcess changeAttackDefenseEffectProcess = new ChangeAttackDefenseEffectProcess(card, CardGameState.FrontAttack, ownerPlayer);
                    ownerPlayer.AddEffectProcess(changeAttackDefenseEffectProcess);
                }
                break;

            case CardOperation.ChangeDefense:
                if (CanChangeToFrontDefense())
                {
                    ChangeAttackDefenseEffectProcess changeAttackDefenseEffectProcess = new ChangeAttackDefenseEffectProcess(card, CardGameState.FrontDefense, ownerPlayer);
                    ownerPlayer.AddEffectProcess(changeAttackDefenseEffectProcess);
                }
                break;

            case CardOperation.BackPlaceToMagicTrapArea:
                if (CanBackPlaceToMagicTrapArea())
                {
                    ownerPlayer.BackPlaceMagicOrTrap(card);
                }
                break;

            case CardOperation.LaunchEffect:
                if (CanLaunchEffect())
                {
                    ownerPlayer.LaunchEffect(card);
                }
                break;

            default:
                Debug.LogError("未知操作命令:" + cardOperation);
                break;
            }
            GameManager.CleanPanelContent(operationPanelTransform);
        }
        public async Task <IActionResult> Post([FromBody] CardOperation cardOperation)
        {
            await _cardOperationStorage.Add(cardOperation);

            return(Created(cardOperation));
        }
示例#16
0
 private void Start()
 {
     //遍历落牌位置链表给元素赋值
     for (int i = 0; i < FallCardPosList.Length; i++)
     {
         string        pos = "fallcardpos" + i;
         RectTransform rt  = XUIUtils.GetCompmentT <RectTransform>(transform, "FallCardPos/" + pos);
         FallCardPosList[i] = rt;
     }
     //提前在对象池复制出预设物
     for (int i = 0; i < 15; i++)
     {
         GameObject go = Instantiate(cardBack) as GameObject;
         go.transform.position = DealCardPos.localPosition;
         go.transform.SetParent(parentT, false);
         go.SetActive(false);
         CardOperation cardAnimation = go.GetComponent <CardOperation>();
         if (cardAnimation == null)
         {
             go.AddComponent <CardOperation>();
         }
         cardBackList.Add(go);
     }
     //获取到牌的正面图片存进字典中
     for (int i = 1; i <= 52; i++)
     {
         Sprite sprite = GameTools.Instance.GetSpriteAtlas("Sprite/card/CardAtlas", i.ToString());
         cardDict[i] = sprite;
     }
     //初始化一个图片链表字典
     showCache = new Dictionary <int, List <Image> >();
     for (int i = 0; i < 5; i++)
     {
         showCache[i] = new List <Image>();
     }
     //获取下注倒计时
     CountDown = XUIUtils.GetCompmentT <Transform>(transform, "CountDown");
     //获取红包随机生成位置
     Tag = XUIUtils.GetCompmentT <Transform>(transform, "Tag");
     //获取发红包按钮绑定事件
     redpagBtn = XUIUtils.GetCompmentT <Button>(transform, "Button/RedPagBtn");
     XUIUtils.ListenerBtn(redpagBtn, RedPagBtnOnclick);
     //获取红包页面
     redpagPanel = XUIUtils.GetCompmentT <Transform>(transform, "RedPagPanel");
     //获取红包页面返回按钮绑定事件
     redPagBackBtn = redpagPanel.GetChild(2).GetComponent <Button>();
     XUIUtils.ListenerBtn(redPagBackBtn, redpagBackOnclick);
     //获取红包排行预设物
     RankQueue = Resources.Load <GameObject>("Prefabs/Game/WanRenChang/rankqueue");
     //获取红包预设物生成页面
     rankShow = XUIUtils.GetCompmentT <Transform>(transform, "RedPagPanel/RedRank/rankbg/rankshow");
     //遍历红包预设物文件夹
     for (int i = 0; i < Resources.LoadAll <GameObject>("Prefabs/Game/WanRenChang/redpag").Length; i++)
     {
         //存进红包预设物链表
         RedpagList.Add(Resources.Load <GameObject>("Prefabs/Game/WanRenChang/redpag/reapag" + i));
     }
     //红包选择按钮链表添加事件
     for (int i = 0; i < 3; i++)
     {
         RedpagselectList.Add(redpagPanel.GetChild(0).GetChild(i).GetComponent <Button>());
         int j = i;
         RedpagselectList[j].onClick.AddListener(delegate() { RedPagselectBtn(j); });
     }
     //获取红包按钮
     SendredpagBtn = redpagPanel.GetChild(0).GetChild(4).GetComponent <Button>();
     XUIUtils.ListenerBtn(SendredpagBtn, SendRedpagOnclick);
 }
        public async Task <CardOperation> AddNewOperation(CardOperation newCardOperation)
        {
            await _cardOperationStorage.Add(newCardOperation);

            return(newCardOperation);
        }
示例#18
0
        public void RPC_PlayerUsesCard(int instId, int photonId, CardOperation operation)
        {
            NetworkPrint p    = GetPlayer(photonId);
            Card         card = p.GetCard(instId);

            switch (operation)
            {
            case CardOperation.dropStableType:
                Debug.Log("Online Player placing stable down");
                Settings.DropCard(card.cardPhysicalInst.transform, p.playerHolder.currentHolder.stableAreaGrid.value, card.cardPhysicalInst);
                card.cardPhysicalInst.currentLogic = dataHolder.cardDownLogic;
                card.cardPhysicalInst.gameObject.SetActive(true);
                break;

            case CardOperation.dropStableTypeEnemy:
                Debug.Log("Online Player placing enemy stable down");
                Settings.DropCard(card.cardPhysicalInst.transform, p.playerHolder.currentHolder.enemyStableAreaGrid.value, card.cardPhysicalInst);
                card.cardPhysicalInst.currentLogic = dataHolder.cardDownLogic;
                card.cardPhysicalInst.gameObject.SetActive(true);
                break;

            case CardOperation.dropMagicalUnicornType:
                Debug.Log("Online Player placing unicorn down");
                Settings.DropCard(card.cardPhysicalInst.transform, p.playerHolder.currentHolder.unicornAreaGrid.value, card.cardPhysicalInst);
                card.cardPhysicalInst.currentLogic = dataHolder.cardDownLogic;
                card.cardPhysicalInst.gameObject.SetActive(true);
                break;

            case CardOperation.dropMagicalUnicornTypeEnemy:
                Debug.Log("Online Player placing enemy unicorn down");
                Settings.DropCard(card.cardPhysicalInst.transform, p.playerHolder.currentHolder.enemyUnicornAreaGrid.value, card.cardPhysicalInst);
                card.cardPhysicalInst.currentLogic = dataHolder.cardDownLogic;
                card.cardPhysicalInst.gameObject.SetActive(true);
                break;

            case CardOperation.pickCardFromDeck:
                GameObject go = Instantiate(dataHolder.cardPrefab) as GameObject;
                CardViz    v  = go.GetComponent <CardViz>();
                v.LoadCard(card);
                card.cardPhysicalInst = go.GetComponent <CardInstance>();
                card.cardPhysicalInst.currentLogic = dataHolder.handLogic;
                Settings.SetParentForCard(go.transform, p.playerHolder.currentHolder.handGrid.value);
                p.playerHolder.handCards.Add(card.cardPhysicalInst);
                break;

            case CardOperation.syncDeck:
                // Debug.Log("player" + photonId + "drew" + instId);
                foreach (NetworkPrint player in players)
                {
                    if (player.photonId != photonId)
                    {
                        // Debug.Log("removing" + instId + "for player" + player.photonId);
                        player.deckCards.RemoveAt(0);
                    }
                }
                break;

            default:
                break;
            }
        }
        public void ImportTest()
        {
            CardOperation[] expectedData = new CardOperation[]
            {
                new CardOperation
                {
                    Amount       = 0.37m,
                    Currency     = Currency.BYN,
                    DateTime     = new DateTime(2019, 6, 20),
                    OriginalName = "Поступление на контракт клиента 749103-00081-044753  "
                },
                new CardOperation
                {
                    Amount       = 100m,
                    Currency     = Currency.BYN,
                    DateTime     = new DateTime(2019, 6, 20),
                    OriginalName = "Поступление на контракт клиента 749103-00081-044753  "
                },
                new CardOperation
                {
                    Amount       = -2m,
                    Currency     = Currency.BYN,
                    DateTime     = new DateTime(2019, 6, 20),
                    OriginalName = "Retail BLR GRODNO PT MINI KAFE TVISTER  "
                },
                new CardOperation
                {
                    Amount       = -33.6m,
                    Currency     = Currency.BYN,
                    DateTime     = new DateTime(2019, 6, 20),
                    OriginalName = "Retail BLR GRODNO AZS N 46  "
                },
                new CardOperation
                {
                    Amount       = -4.80m,
                    Currency     = Currency.BYN,
                    DateTime     = new DateTime(2019, 6, 20, 20, 31, 20),
                    OriginalName = "Retail NLD AMSTERDAM YANDEX.TAXI"
                },
                new CardOperation
                {
                    Amount       = -2.70m,
                    Currency     = Currency.BYN,
                    DateTime     = new DateTime(2019, 6, 20, 0, 59, 27),
                    OriginalName = "Retail NLD AMSTERDAM YANDEX.TAXI"
                },
            };

            CardOperation[] actualData = _parser.Parse(_csvString);

            Func <CardOperation, CardOperation, bool> cardOperationComparer = (op1, op2) =>
            {
                if (op1.Amount != op2.Amount)
                {
                    return(false);
                }
                if (op1.Currency != op2.Currency)
                {
                    return(false);
                }
                if (op1.DateTime != op2.DateTime)
                {
                    return(false);
                }
                if (op1.UserDefinedName != op2.UserDefinedName)
                {
                    return(false);
                }
                if (op1.OriginalName != op2.OriginalName)
                {
                    return(false);
                }

                return(true);
            };

            Assert.That(actualData, Is.EquivalentTo(expectedData).Using(cardOperationComparer));
        }