Exemple #1
0
 public override void Activate(Player p, Card c)
 {
     while (true)
     {
         GameEventArgs args = new GameEventArgs();
         args.Source = null;
         args.Targets = new List<Player>() { p };
         args.Card = c;
         args.ReadonlyCard = new ReadOnlyCard(c);
         try
         {
             Game.CurrentGame.Emit(GameEvent.CardUsageBeforeEffected, args);
         }
         catch (TriggerResultException e)
         {
             Trace.Assert(e.Status == TriggerResult.End);
             break;
         }
         ReadOnlyCard result = Game.CurrentGame.Judge(p, null, c, (judgeResultCard) => { return judgeResultCard.Suit != SuitType.Heart; });
         if (result.Suit != SuitType.Heart)
         {
             Game.CurrentGame.PhasesSkipped.Add(TurnPhase.Play);
         }
         break;
     }
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>();
     move.Cards.Add(c);
     move.To = new DeckPlace(null, DeckType.Discard);
     move.Helper.IsFakedMove = true;
     Game.CurrentGame.MoveCards(move, false, Core.Utils.GameDelays.None);
 }
Exemple #2
0
        /// <summary>
        /// 给某个玩家穿装备
        /// </summary>
        /// <param name="p"></param>
        /// <param name="card"></param>
        public void Install(Player p, Card card)
        {
            ParentCard = card;
            CardsMovement attachMove = new CardsMovement();
            attachMove.Cards = new List<Card>();
            attachMove.Cards.Add(card);
            attachMove.To = new DeckPlace(p, DeckType.Equipment);
            foreach (Card c in Game.CurrentGame.Decks[p, DeckType.Equipment])
            {
                if (CardCategoryManager.IsCardCategory(c.Type.Category, this.Category))
                {
                    Equipment e = (Equipment)c.Type;
                    Trace.Assert(e != null);
                    Game.CurrentGame.EnterAtomicContext();
                    Game.CurrentGame.PlayerLostCard(p, new List<Card>() { card });
                    Game.CurrentGame.HandleCardDiscard(p, new List<Card> () {c});
                    Game.CurrentGame.MoveCards(attachMove);
                    Game.CurrentGame.ExitAtomicContext();
                    return;
                }
            }

            Game.CurrentGame.MoveCards(attachMove);
            Game.CurrentGame.PlayerLostCard(p, new List<Card>() {card});
            return;
        }
Exemple #3
0
        public void RevealResult(Card card1, Card card2)
        {
            cardLeft.DataContext = new CardViewModel()
            {
                Card = card1,
                Footnote = LogFormatter.Translate(_player1),
                IsFootnoteVisible = true
            };
            cardRight.DataContext = new CardViewModel()
            {
                Card = card2,
                Footnote = LogFormatter.Translate(_player2),
                IsFootnoteVisible = true
            };
            AnimationBase anim;
            if (card1.Rank > card2.Rank)
            {
                anim = new PinDianWinAnimation();
            }
            else
            {
                anim = new PinDianLoseAnimation();
            }

            anim.SetValue(Canvas.LeftProperty, animationCenter.ActualWidth / 2 - anim.Width / 2);
            anim.SetValue(Canvas.TopProperty, animationCenter.ActualHeight / 2 - anim.Height / 2);

            animationCenter.Children.Add(anim);
            anim.Completed += new EventHandler(anim_Completed);
            anim.Start();
        }
Exemple #4
0
 void _FilterCard(Player p, Card card)
 {
     GameEventArgs args = new GameEventArgs();
     args.Source = p;
     args.Card = card;
     Emit(GameEvent.EnforcedCardTransform, args);
 }
Exemple #5
0
 public override void Activate(Player p, Card c)
 {
     while (true)
     {
         GameEventArgs args = new GameEventArgs();
         args.Source = null;
         args.Targets = new List<Player>() { p };
         args.Card = c;
         args.ReadonlyCard = new ReadOnlyCard(c);
         try
         {
             Game.CurrentGame.Emit(GameEvent.CardUsageBeforeEffected, args);
         }
         catch (TriggerResultException e)
         {
             Trace.Assert(e.Status == TriggerResult.End);
             break;
         }
         ReadOnlyCard result = Game.CurrentGame.Judge(p, null, c, (judgeResultCard) => { return judgeResultCard.Suit != SuitType.Heart; });
         if (result.Suit != SuitType.Heart)
         {
             var theTrigger = new LeBuSiShuTrigger() { Priority = int.MaxValue };
             theTrigger.Owner = p;
             Game.CurrentGame.RegisterTrigger(GameEvent.PhaseOutEvents[TurnPhase.Draw], theTrigger);
         }
         break;
     }
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>();
     move.Cards.Add(c);
     move.To = new DeckPlace(null, DeckType.Discard);
     Game.CurrentGame.MoveCards(move);
 }
Exemple #6
0
        /// <summary>
        /// 给某个玩家穿装备
        /// </summary>
        /// <param name="p"></param>
        /// <param name="card"></param>
        public void Install(Player p, Card card, Player installedBy)
        {
            ParentCard = card;
            CardsMovement attachMove = new CardsMovement();
            attachMove.Cards = new List<Card>();
            attachMove.Cards.Add(card);
            attachMove.To = new DeckPlace(p, DeckType.Equipment);
            foreach (Card c in Game.CurrentGame.Decks[p, DeckType.Equipment])
            {
                if (CardCategoryManager.IsCardCategory(c.Type.Category, this.Category))
                {
                    Equipment e = (Equipment)c.Type;
                    Trace.Assert(e != null);
                    Game.CurrentGame.EnterAtomicContext();
                    if (installedBy != null) Game.CurrentGame.PlayerLostCard(installedBy, new List<Card>() { card });
                    if (installedBy != p) Game.CurrentGame.PlayerAcquiredCard(p, new List<Card>() { card });
                    c.Log.GameAction = GameAction.PlaceIntoDiscard;
                    c.Log.Source = p;
                    Game.CurrentGame.PlaceIntoDiscard(p, new List<Card>() { c });
                    Game.CurrentGame.MoveCards(attachMove);
                    Game.CurrentGame.ExitAtomicContext();
                    return;
                }
            }

            Game.CurrentGame.MoveCards(attachMove);
            if (installedBy != null) Game.CurrentGame.PlayerLostCard(installedBy, new List<Card>() { card });
            if (installedBy != p) Game.CurrentGame.PlayerAcquiredCard(p, new List<Card>() { card });
            return;
        }
Exemple #7
0
 public override void Process(Player source, List<Player> dests, ICard card, ReadOnlyCard readonlyCard)
 {
     DeckType wuguDeck = new DeckType("WuGu");
     DeckType wuguFakeDeck = new DeckType("WuGuFake");
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>();
     for (int i = 0; i < dests.Count; i++)
     {
         Game.CurrentGame.SyncImmutableCardAll(Game.CurrentGame.PeekCard(0));
         Card c = Game.CurrentGame.DrawCard();
         move.Cards.Add(c);
     }
     move.To = new DeckPlace(null, wuguDeck);
     Game.CurrentGame.MoveCards(move);
     fakeMapping = new Dictionary<Card, Card>();
     Game.CurrentGame.Decks[null, wuguFakeDeck].Clear();
     foreach (var c in Game.CurrentGame.Decks[null, wuguDeck])
     {
         var faked = new Card(c);
         faked.Place = new DeckPlace(null, wuguFakeDeck);
         Game.CurrentGame.Decks[null, wuguFakeDeck].Add(faked);
         fakeMapping.Add(faked, c);
     }
     Game.CurrentGame.NotificationProxy.NotifyWuGuStart(new DeckPlace(null, wuguFakeDeck));
     base.Process(source, dests, card, readonlyCard);
     Game.CurrentGame.NotificationProxy.NotifyWuGuEnd();
     Game.CurrentGame.Decks[null, wuguFakeDeck].Clear();
     if (Game.CurrentGame.Decks[null, wuguDeck].Count > 0)
     {
         move = new CardsMovement();
         move.Cards = new List<Card>(Game.CurrentGame.Decks[null, wuguDeck]);
         move.To = new DeckPlace(null, DeckType.Discard);
         Game.CurrentGame.MoveCards(move);
     }
 }
Exemple #8
0
 public override void Activate(Player p, Card c)
 {
     while (true)
     {
         GameEventArgs args = new GameEventArgs();
         args.Source = null;
         args.Targets = new List<Player>() { p };
         args.Card = c;
         args.ReadonlyCard = new ReadOnlyCard(c);
         try
         {
             Game.CurrentGame.Emit(GameEvent.CardUsageBeforeEffected, args);
         }
         catch (TriggerResultException e)
         {
             Trace.Assert(e.Status == TriggerResult.End);
             break;
         }
         ReadOnlyCard result = Game.CurrentGame.Judge(p, null, c, (judgeResultCard) => { return judgeResultCard.Suit == SuitType.Spade && judgeResultCard.Rank >= 2 && judgeResultCard.Rank <= 9; });
         if (result.Suit == SuitType.Spade && result.Rank >= 2 && result.Rank <= 9)
         {
             var roc = new ReadOnlyCard(c);
             CardsMovement move = new CardsMovement();
             move.Cards = new List<Card>();
             move.Cards.Add(c);
             move.To = new DeckPlace(null, DeckType.Discard);
             Game.CurrentGame.MoveCards(move);
             Game.CurrentGame.DoDamage(null, p, 3, DamageElement.Lightning, c, roc);
             return;
         }
         break;
     }
     RecursiveShanDianDriver(p, p, c);
 }
Exemple #9
0
 public BiFaGiveCardVerifier(Card card)
 {
     MaxPlayers = 0;
     MaxCards = 1;
     MinCards = 1;
     this.theCard = card;
     Helper.OtherDecksUsed.Add(BiFaDeck);
 }
Exemple #10
0
 void _ResetCard(Card card)
 {
     if (card.Id > 0)
     {
         card.Type = GameEngine.CardSet[card.Id].Type;
         card.Suit = GameEngine.CardSet[card.Id].Suit;
         card.Rank = GameEngine.CardSet[card.Id].Rank;
     }
 }
Exemple #11
0
 public Card(Card c)
 {
     Suit = c.Suit;
     Rank = c.Rank;
     Type = c.Type;
     RevealOnce = false;
     Place = c.Place;
     Id = c.Id;
     Attributes = c.Attributes;
     Log = new UI.ActionLog();
 }
Exemple #12
0
 public void ReplaceJudgementCard(Player player, Player judgePlayer, Card card)
 {
     Game.CurrentGame.EnterAtomicContext();
     List<Card> toDiscard = new List<Card>(Game.CurrentGame.Decks[judgePlayer, DeckType.JudgeResult]);
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>() {card};
     move.To = new DeckPlace(judgePlayer, DeckType.JudgeResult);
     Game.CurrentGame.MoveCards(move);
     Game.CurrentGame.PlayerLostCard(player, new List<Card>() {card});
     Game.CurrentGame.HandleCardDiscard(judgePlayer, toDiscard, DiscardReason.Judge);
     Game.CurrentGame.ExitAtomicContext();
 }
Exemple #13
0
 public static IList<Inline> RichTranslate(Card c, bool useUiCard = true)
 {
     IList<Inline> list = new List<Inline>();
     if (c.Id < 0) return list;
     CardViewModel card = new CardViewModel() { Card = c };
     string typeString = Application.Current.TryFindResource(string.Format("Card.{0}.Name", useUiCard ? card.TypeString : c.Type.CardType)) as string;
     if (typeString != null)
     {
         list.Add(new Run("【" + typeString) { Foreground = new SolidColorBrush(Colors.Yellow) });
         Run run = new Run();
         run.Foreground = Application.Current.Resources[string.Format("Card.Suit.{0}.SuitBrush", useUiCard ? card.Suit : c.Suit)] as Brush;
         run.Text = string.Format("{0}{1}", Application.Current.Resources[string.Format("Card.Suit.{0}.SuitText", useUiCard ? card.Suit : c.Suit)], card.RankString);
         list.Add(run);
         list.Add(new Run("】") { Foreground = new SolidColorBrush(Colors.Yellow) });
     }
     return list;
 }
Exemple #14
0
 public void ReplaceJudgementCard(Player player, Player judgePlayer, Card card, ISkill skill)
 {
     card.Log = new ActionLog();
     card.Log.Source = player;
     card.Log.SkillAction = skill;
     card.Log.GameAction = GameAction.ReplaceJudge;
     Game.CurrentGame.EnterAtomicContext();
     var judgeDeck = Game.CurrentGame.Decks[judgePlayer, DeckType.JudgeResult];
     List<Card> toDiscard = new List<Card>() {judgeDeck.Last()};
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>() {card};
     move.To = new DeckPlace(judgePlayer, DeckType.JudgeResult);
     Game.CurrentGame.MoveCards(move);
     Game.CurrentGame.PlayerLostCard(card.Place.Player, new List<Card>() {card});
     Game.CurrentGame.HandleCardDiscard(judgePlayer, toDiscard, DiscardReason.Judge);
     Game.CurrentGame.ExitAtomicContext();
 }
Exemple #15
0
 public override void Process(GameEventArgs handlerArgs)
 {
     var source = handlerArgs.Source;
     var dests = handlerArgs.Targets;
     var readonlyCard = handlerArgs.ReadonlyCard;
     var inResponseTo = handlerArgs.InResponseTo;
     var card = handlerArgs.Card;
     DeckType wuguDeck = new DeckType("WuGu");
     DeckType wuguFakeDeck = new DeckType("WuGuFake");
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>();
     for (int i = 0; i < dests.Count; i++)
     {
         Game.CurrentGame.SyncImmutableCardAll(Game.CurrentGame.PeekCard(0));
         Card c = Game.CurrentGame.DrawCard();
         move.Cards.Add(c);
     }
     move.To = new DeckPlace(null, wuguDeck);
     Game.CurrentGame.MoveCards(move);
     fakeMapping = new Dictionary<Card, Card>();
     Game.CurrentGame.Decks[null, wuguFakeDeck].Clear();
     foreach (var c in Game.CurrentGame.Decks[null, wuguDeck])
     {
         var faked = new Card(c);
         faked.Place = new DeckPlace(null, wuguFakeDeck);
         Game.CurrentGame.Decks[null, wuguFakeDeck].Add(faked);
         fakeMapping.Add(faked, c);
     }
     Game.CurrentGame.NotificationProxy.NotifyWuGuStart(new CardChoicePrompt("WuGuFengDeng.Init"), new DeckPlace(null, wuguFakeDeck));
     base.Process(handlerArgs);
     Game.CurrentGame.NotificationProxy.NotifyWuGuEnd();
     Game.CurrentGame.Decks[null, wuguFakeDeck].Clear();
     if (Game.CurrentGame.Decks[null, wuguDeck].Count > 0)
     {
         move = new CardsMovement();
         move.Cards = new List<Card>(Game.CurrentGame.Decks[null, wuguDeck]);
         move.To = new DeckPlace(null, DeckType.Discard);
         Game.CurrentGame.MoveCards(move);
     }
 }
Exemple #16
0
 bool RecursiveShanDianDriver(Player start, Player current, Card c)
 {
     //todo: drive chain ShanDian cards
     List<Player> toProcess = new List<Player>(Game.CurrentGame.AlivePlayers);
     toProcess.Remove(current);
     Game.CurrentGame.SortByOrderOfComputation(current, toProcess);
     foreach (var next in toProcess)
     {
         List<Player> targets = new List<Player>();
         targets.Add(next);
         if (Game.CurrentGame.PlayerCanBeTargeted(null, targets, c))
         {
             if (DelayedToolConflicting(next))
             {
                 Card nextCard = null;
                 foreach (var card in Game.CurrentGame.Decks[next, DeckType.DelayedTools])
                 {
                     if (card.Type is ShanDian)
                     {
                         nextCard = card;
                         break;
                     }
                 }
                 Trace.Assert(nextCard != null);
                 if (!RecursiveShanDianDriver(start, next, nextCard))
                 {
                     return false;
                 }
             }
             CardsMovement move = new CardsMovement();
             move.Cards = new List<Card>();
             move.Cards.Add(c);
             move.To = new DeckPlace(next, DeckType.DelayedTools);
             Game.CurrentGame.MoveCards(move);
             return true;
         }
         if (next == start) return false;
     }
     return false;
 }
Exemple #17
0
 public override void Run(GameEvent gameEvent, GameEventArgs eventArgs)
 {
     var card = eventArgs.Card;
     if (!(card.Type is WuGuFengDeng)) return;
     var wugu = card.Type as WuGuFengDeng;
     var dests = eventArgs.Targets;
     DeckType wuguDeck = new DeckType("WuGu");
     DeckType wuguFakeDeck = new DeckType("WuGuFake");
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>();
     for (int i = 0; i < dests.Count; i++)
     {
         Game.CurrentGame.SyncImmutableCardAll(Game.CurrentGame.PeekCard(0));
         Card c = Game.CurrentGame.DrawCard();
         move.Cards.Add(c);
     }
     move.To = new DeckPlace(null, wuguDeck);
     Game.CurrentGame.MoveCards(move, false, Core.Utils.GameDelayTypes.None);
     wugu.FakeMapping = new Dictionary<Card, Card>();
     Game.CurrentGame.Decks[null, wuguFakeDeck].Clear();
     foreach (var c in Game.CurrentGame.Decks[null, wuguDeck])
     {
         var faked = new Card(c);
         faked.Place = new DeckPlace(null, wuguFakeDeck);
         Game.CurrentGame.Decks[null, wuguFakeDeck].Add(faked);
         wugu.FakeMapping.Add(faked, c);
     }
     Game.CurrentGame.NotificationProxy.NotifyWuGuStart(new CardChoicePrompt("WuGuFengDeng.Init"), new DeckPlace(null, wuguFakeDeck));
 }
Exemple #18
0
 protected override bool VerifyCard(Player source, Card card)
 {
     return true;
 }
Exemple #19
0
        public void NotifyShowCard(Player p, Card card)
        {
            Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
            {
                if (p == null)
                {
                    var cardView = CardView.CreateCard(card);
                    GlobalCanvas.Children.Add(cardView);
                    cardView.CardModel.Footnote = LogFormatter.TranslateCardFootnote(card.Log);
                    discardDeck.AppendCards(new List<CardView>() { cardView });
                    return;
                }

                Trace.Assert(card.Place.Player == p);
                var cards = playersMap[p].RemoveCards(card.Place.DeckType, new List<Card>() { card }, true);
                Trace.Assert(cards.Count == 1);
                cards[0].CardModel.Footnote = LogFormatter.TranslateCardFootnote(new ActionLog() { Source = p, GameAction = GameAction.Show });
                discardDeck.AddCards(DeckType.Discard, cards, false, false);
                gameLogs.AppendShowCardsLog(p, new List<Card>() { card });
                rtbLog.ScrollToEnd();
            });
        }
Exemple #20
0
 public void NotifyPinDianEnd(Card c1, Card c2)
 {
     Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
     {
         pinDianBox.RevealResult(c1, c2);
     });
 }
Exemple #21
0
        public void NotifyJudge(Player p, Card card, ActionLog log, bool? isSuccess, bool isFinalResult)
        {
            Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
            {
                CardView cardView = discardDeck.Cards.FirstOrDefault(c => c.Card.Id == card.Id);

                if (cardView == null) return;
                gameLogs.AppendJudgeResultLog(p, card, log, isSuccess, isFinalResult);
                rtbLog.ScrollToEnd();

                if (!isFinalResult || isSuccess == null) return;
                _AppendKeyEventLog(LogFormatter.RichTranslateJudgeResultEffectiveness(p, log, isSuccess == true));

                if (isSuccess == true)
                {
                    cardView.PlayAnimation(new TickAnimation(), new Point(0, 0));
                }
                else
                {
                    cardView.PlayAnimation(new CrossAnimation(), new Point(0, 0));
                }
            });
        }
Exemple #22
0
 void ctrlGetCard_OnCardSelected(Card card)
 {
     var gameModel = (gameView.DataContext as GameViewModel);
     gameModel.MainPlayerModel.CheatGetCard(card);
 }
Exemple #23
0
 public abstract void Activate(Player p, Card c);
Exemple #24
0
 protected override bool VerifyCard(Player source, Card card)
 {
     return card.Place.DeckType == QiXing.QiXingDeck;
 }
Exemple #25
0
 protected override bool VerifyCard(Player source, Card card)
 {
     return QiXingCards.Contains(card);
 }
Exemple #26
0
 protected override CardView RemoveRoleCard(Card card)
 {
     CardView result = CardView.CreateCard(card);
     ParentGameView.GlobalCanvas.Children.Add(result);
     result.Opacity = 0;
     result.SetCurrentPosition(ComputeCardCenterPos(result, cbRoleBox));
     return result;
 }
Exemple #27
0
        protected override CardView RemoveEquipment(Card card, bool isCopy)
        {
            Trace.Assert(card.Id >= 0, "Cannot remove unknown card from equip area.");
            Equipment equip = GameEngine.CardSet[card.Id].Type as Equipment;

            if (equip == null)
            {
                throw new ArgumentException("Cannot add non-equip to equip area.");
            }

            Canvas targetArea = null;
            switch (equip.Category)
            {
                case CardCategory.Weapon:
                    targetArea = weaponArea;
                    break;
                case CardCategory.Armor:
                    targetArea = armorArea;
                    break;
                case CardCategory.DefensiveHorse:
                    targetArea = horse1Area;
                    break;
                case CardCategory.OffensiveHorse:
                    targetArea = horse2Area;
                    break;
                default:
                    throw new ArgumentException("Cannot install non-equips to equip area.");
            }

            if (targetArea.Children.Count == 0)
            {
                throw new ArgumentException("No equip is found.");
            }

            SmallEquipView equipLabel = targetArea.Children[0] as SmallEquipView;
            if (!isCopy) targetArea.Children.Clear();

            CardView result = CardView.CreateCard(card);
            ParentGameView.GlobalCanvas.Children.Add(result);
            result.Opacity = 0;
            result.SetCurrentPosition(ComputeCardCenterPos(result, targetArea));
            return result;
        }
Exemple #28
0
        protected override CardView RemoveDelayedTool(Card card, bool isCopy)
        {
            SmallDelayedToolView dtv = null;
            foreach (var tmpDtv in delayedToolsDock.Children)
            {
                dtv = tmpDtv as SmallDelayedToolView;
                Trace.Assert(dtv != null);
                CardViewModel model = dtv.DataContext as CardViewModel;
                Trace.Assert(model != null);
                if (model.Card == card) break;
                dtv = null;
            }

            Trace.Assert(dtv != null);

            Point dest = dtv.TranslatePoint(new Point(0, 0),
                                            ParentGameView.GlobalCanvas);
            if (!isCopy) delayedToolsDock.Children.Remove(dtv);

            CardView result = CardView.CreateCard(card);
            ParentGameView.GlobalCanvas.Children.Add(result);
            result.Opacity = 0;
            result.SetCurrentPosition(dest);

            return result;
        }
Exemple #29
0
 protected override bool VerifyCard(Player source, Card card)
 {
     return card.SuitColor == SuitColorType.Black;
 }
Exemple #30
0
 public override bool VerifyInput(Card card, object arg)
 {
     return card.SuitColor != color;
 }