Ejemplo n.º 1
0
        /// <summary>
        /// 与另一个玩家交换所有卡牌
        /// </summary>
        /// <param name="target"></param>
        internal void ExchangeCards(SimpleGamePlayer target)
        {
            DealCards();
            target.DealCards();

            var cards = target._cards;

            target._cards = cards;
            _cards        = cards;

            PlayerHost.WriteMessage("卡牌已经交换");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 实现卡牌被盗窃的方法
        /// </summary>
        /// <param name="user">盗窃者</param>
        /// <param name="token">取消标识</param>
        /// <returns>用于等待的 Task 对象</returns>
        internal async Task StealCardBy(SimpleGamePlayer user, CancellationToken token)
        {
            DealCards();

            var options = Cards.Select(item => Option.Create(item, item.Name, item.Description)).ToArray();

            var card = await user.PlayerHost.Console.Choose("请选择要盗取的卡牌:", options, null, token);

            if (card == null)
            {
                throw new TimeoutException();
            }

            CardCollection.RemoveCard(card);
            WriteSecretMessage(GameMessage.Warning($"一天深夜,你回到家,发现被你藏在绝密地方的 {card.Name} 卡牌被人偷走了。"));
            user.CardCollection.AddCard(card);
            user.PlayerHost.WriteMessage($"您偷到了一张 {card.Name} 卡牌");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 尝试附加一种诅咒效果
        /// </summary>
        /// <param name="curseEffect">诅咒效果</param>
        /// <returns></returns>
        internal bool Curse(SimpleGamePlayer player, CurseEffect curseEffect)
        {
            if (Effects.OfType <ShieldEffect>().FirstOrDefault(item => item.Element == Element.水) != null)
            {
                return(false);
            }

            if (Effects.OfType <BlessEffect>().FirstOrDefault(item => item.Element == Element.水) != null)
            {
                if (player != null)
                {
                    player.Curse(null, curseEffect);
                }
                return(false);
            }

            SetEffect(curseEffect);
            return(true);
        }
Ejemplo n.º 4
0
        protected SimpleGamePlayer[] GetTargets(SimpleGamePlayer player)
        {
            if (this is IOtherPlayerTarget)
            {
                return(player.Game.Players.Where(item => item != player).ToArray());
            }

            else if (this is IAnyPlayerTarget)
            {
                return(player.Game.Players);
            }

            else if (this is ISelfTarget)
            {
                return new[] { player }
            }
            ;

            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
        protected virtual async Task <SimpleGamePlayer> CherryTarget(SimpleGamePlayer player, CancellationToken token)
        {
            var targets = GetTargets(player);

            if (targets == null || targets.Any() == false)
            {
                return(null);
            }

            if (targets.Length == 1)
            {
                return(targets[0]);
            }

            var result = await player.PlayerHost.Console.Choose("请选择使用对象:", targets.Select( item => Option.Create(item)).ToArray(), null, token);

            if (result == null)
            {
                throw new TimeoutException();
            }

            return(result);
        }
Ejemplo n.º 6
0
 internal virtual bool AvailablesWithElement(SimpleGamePlayer player)
 {
     return(Availables(player));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 获取卡牌当前是否可用
 /// </summary>
 /// <param name="player">使用卡牌的玩家</param>
 /// <returns>是否可用</returns>
 public virtual bool Availables(SimpleGamePlayer player)
 {
     return(player.ActionPoint >= ActionPoint);
 }
Ejemplo n.º 8
0
 protected void AnnounceSpecialCardUsed(SimpleGamePlayer user)
 {
     user.Game.AnnounceMessage("{0} 使用了一张特殊卡牌", user.PlayerName);
 }