Inheritance: IGameLog
Beispiel #1
0
 void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     var args = eventArgs as DiscardCardEventArgs;
     if (args.Source == null || args.Source == Owner || args.Reason != DiscardReason.Use)
     {
         return;
     }
     List<Card> cardsToProcess = new List<Card>(eventArgs.Cards);
     foreach (Card c in cardsToProcess)
     {
         if (c.Type is NanManRuQin)
         {
             ActionLog log = new ActionLog();
             log.GameAction = GameAction.None;
             log.SkillAction = this;
             log.Source = Owner;
             log.CardAction = c;
             Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
             List<Card> cc = new List<Card>();
             cc.Add(c);
             Game.CurrentGame.HandleCardTransferToHand(null, Owner, cc);
             eventArgs.Cards.Remove(c);
         }
     }
 }
Beispiel #2
0
 public void NotifySkillUse(List<Player> targets)
 {
     ActionLog log = new ActionLog();
     log.GameAction = GameAction.None;
     log.SkillAction = this;
     log.Source = Owner;
     log.Targets = targets;
     Games.Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
 }
Beispiel #3
0
 public void NotifySkillUse(List<Player> targets)
 {
     ActionLog log = new ActionLog();
     log.GameAction = GameAction.None;
     log.SkillAction = this;
     log.Source = Owner;
     log.Targets = targets;
     log.SpecialEffectHint = GenerateSpecialEffectHintIndex(Owner, targets);
     Games.Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
 }
Beispiel #4
0
 public override void NotifyAction(Player source, List<Player> targets, CompositeCard card)
 {
     if (withoutNotify) return;
     ActionLog log = new ActionLog();
     log.GameAction = GameAction.None;
     log.CardAction = card;
     log.Source = source;
     log.SpecialEffectHint = GenerateSpecialEffectHintIndex(source, targets, card);
     Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
 }
Beispiel #5
0
 public void NotifySkillUse(List<Player> targets)
 {
     ActionLog log = new ActionLog();
     log.GameAction = GameAction.None;
     log.SkillAction = this;
     log.Source = Owner;
     log.Targets = targets;
     log.SpecialEffectHint = GenerateSpecialEffectHintIndex(Owner, targets);
     Games.Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
     if (IsSingleUse || IsAwakening) Core.Utils.GameDelays.Delay(Utils.GameDelayTypes.Awaken);
 }
Beispiel #6
0
 public override void NotifyAction(Player source, List<Player> targets, CompositeCard card)
 {
     ActionLog log = new ActionLog();
     log.GameAction = GameAction.None;
     log.CardAction = card;
     log.SkillAction = this;
     log.Source = source;
     log.Targets = targets;
     log.ShowCueLine = true;
     log.SpecialEffectHint = GenerateSpecialEffectHintIndex(source, targets, card);
     Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
 }
Beispiel #7
0
 protected void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     ReadOnlyCard c = Game.CurrentGame.Judge(Owner, null, new Card() { Type = new BaGuaZhen() }, (judgeResultCard) => { return judgeResultCard.SuitColor == SuitColorType.Red; });
     if (c.SuitColor == SuitColorType.Red)
     {
         eventArgs.Cards = new List<Card>();
         ActionLog log = new ActionLog();
         log.Source = Owner;
         log.SkillAction = this;
         log.GameAction = GameAction.None;
         Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
         throw new TriggerResultException(TriggerResult.Success);
     }
 }
Beispiel #8
0
 void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     var args = eventArgs as DiscardCardEventArgs;
     if (args.Source == null || args.Source == Owner || (args.Reason != DiscardReason.Discard && args.Reason != DiscardReason.Judge))
     {
         return;
     }
     int answer = 0;
     List<Card> cardsToProcess = new List<Card>(eventArgs.Cards);
     foreach (Card c in cardsToProcess)
     {
         if (c.Suit == SuitType.Club)
         {
             CardsMovement temp = new CardsMovement();
             temp.Cards = new List<Card>(cardsToProcess);
             temp.To = new DeckPlace(null, DeckType.Discard);
             Game.CurrentGame.NotificationProxy.NotifyCardMovement(new List<CardsMovement>() { temp });
             foreach (Card cc in cardsToProcess)
             {
                 cc.PlaceOverride = new DeckPlace(null, DeckType.Discard);
             }
             break;
         }
     }
     foreach (Card c in cardsToProcess)
     {
         var prompt = new MultipleChoicePrompt("LuoYing", c);
         if (c.Suit == SuitType.Club &&
             Game.CurrentGame.UiProxies[Owner].AskForMultipleChoice(prompt, Prompt.YesNoChoices, out answer) && answer == 0)
         {
             ActionLog log = new ActionLog();
             log.GameAction = GameAction.None;
             log.SkillAction = this;
             log.Source = Owner;
             log.CardAction = c;
             Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
             List<Card> cc = new List<Card>();
             cc.Add(c);
             Game.CurrentGame.HandleCardTransferToHand(null, Owner, cc);
             eventArgs.Cards.Remove(c);
         }
     }
 }
Beispiel #9
0
 public void NotifyAction(Players.Player source, List<Players.Player> targets, List<Card> cards)
 {
     ActionLog log = new ActionLog();
     log.GameAction = GameAction.None;
     log.CardAction = null;
     log.SkillAction = this;
     log.Source = source;
     List<Players.Player> ft, st;
     TargetsSplit(targets, out ft, out st);
     log.Targets = ft;
     log.SecondaryTargets = st;
     foreach (Card c in cards)
     {
         if (c.Log == null)
         {
             c.Log = new ActionLog();
         }
         c.Log.SkillAction = this;
     }
     Games.Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
 }
Beispiel #10
0
 public override void NotifyAction(Player source, List<Player> targets, List<Card> cards)
 {
     ActionLog log = new ActionLog();
     log.GameAction = GameAction.None;
     log.CardAction = null;
     log.SkillAction = this;
     log.Source = source;
     log.Targets = targets;
     foreach (Card c in cards)
     {
         if (c.Log == null)
         {
             c.Log = new ActionLog();
         }
         c.Log.SkillAction = this;
     }
     int index = GenerateSpecialEffectHintIndex(source, targets, cards);
     log.SpecialEffectHint = index;
     log.SkillSoundOnly = index == 1 ? true : false;
     Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
 }
Beispiel #11
0
 protected void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     NotifySkillUse(new List<Player>());
     int answer;
     if (Game.CurrentGame.UiProxies[Owner].AskForMultipleChoice(
             new MultipleChoicePrompt(Prompt.SkillUseYewNoPrompt, new BaGuaZhen.BaGuaZhenSkill()), Prompt.YesNoChoices, out answer)
             && answer == 0)
     {
         ReadOnlyCard c = Game.CurrentGame.Judge(Owner, null, new Card() { Type = new BaGuaZhen() }, (judgeResultCard) => { return judgeResultCard.SuitColor == SuitColorType.Red; });
         if (c.SuitColor == SuitColorType.Red)
         {
             eventArgs.Cards = new List<Card>();
             ActionLog log = new ActionLog();
             log.Source = Owner;
             log.SkillAction = new BaGuaZhen().EquipmentSkill;
             log.GameAction = GameAction.None;
             Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
             throw new TriggerResultException(TriggerResult.Success);
         }
     }
 }
Beispiel #12
0
 public void NotifyCardUse(Player source, List<Player> dests, List<Player> secondary, ICard card, GameAction action)
 {
     List<Player> logTargets = ActualTargets(source, dests, card);
     ActionLog log = new ActionLog();
     log.Source = source;
     log.Targets = logTargets;
     log.SecondaryTargets = secondary;
     log.SkillAction = null;
     log.GameAction = action;
     log.CardAction = card;
     Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
     if (card is Card)
     {
         Card terminalCard = card as Card;
         if (terminalCard.Log == null)
         {
             terminalCard.Log = new ActionLog();
         }
         terminalCard.Log.Source = source;
         terminalCard.Log.Targets = dests;
         terminalCard.Log.SecondaryTargets = secondary;
         terminalCard.Log.CardAction = card;
         terminalCard.Log.GameAction = action;
     }
     else if (card is CompositeCard)
     {
         foreach (var s in (card as CompositeCard).Subcards)
         {
             if (s.Log == null)
             {
                 s.Log = new ActionLog();
             }
             s.Log.Source = source;
             s.Log.Targets = dests;
             s.Log.SecondaryTargets = secondary;
             s.Log.CardAction = card;
             s.Log.GameAction = action;
         }
     }
 }
 public void NotifyJudge(Player p, Card card, ActionLog log, bool? isSuccess, bool f)
 {
 }
        public void NotifySkillUse(ActionLog log)
        {
            if (ViewModelBase.IsDetached) return;
            Trace.Assert(log.Source != null);
            PlayerViewBase player = playersMap[log.Source];
            bool soundPlayed = false;
            if (log.SkillAction != null)
            {
                string key1 = string.Format("{0}.Animation", log.SkillAction.GetType().Name);
                string key2 = key1 + ".Offset";
                bool animPlayed = false;
                lock (equipAnimationResources)
                {
                    if (equipAnimationResources.Contains(key1))
                    {
                        AnimationBase animation = null;
                        Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
                        {
                            animation = equipAnimationResources[key1] as AnimationBase;
                        });
                        if (animation != null && animation.Parent == null)
                        {
                            Point offset = new Point(0, 0);
                            if (equipAnimationResources.Contains(key2))
                            {
                                offset = (Point)equipAnimationResources[key2];
                            }
                            player.PlayAnimationAsync(animation, 0, offset);
                            animPlayed = true;
                        }
                    }
                }
                if (log.SkillAction.IsSingleUse || log.SkillAction.IsAwakening)
                {
                    Application.Current.Dispatcher.BeginInvoke((ThreadStart)delegate()
                    {
                        ExcitingSkillAnimation anim = new ExcitingSkillAnimation();
                        anim.SkillName = log.SkillAction.GetType().Name;
                        anim.HeroName = log.SkillAction.HeroTag.Name;
                        gridRoot.Children.Add(anim);
                        anim.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                        anim.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
                        anim.Start();
                    });
                    animPlayed = true;
                }
                if (!animPlayed && player != mainPlayerPanel)
                {
                    string s = LogFormatter.Translate(log.SkillAction);
                    if (s != string.Empty)
                    {
                        RegularSkillAnimation anim = null;
                        Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
                        {
                            anim = new RegularSkillAnimation() { Text = s };
                        });
                        Trace.Assert(anim != null);
                        player.PlayAnimationAsync(anim, 1, new Point(0, 0));
                        animPlayed = true;
                    }
                }
                string soundKey = log.SkillAction.GetType().Name;
                Uri uri = GameSoundLocator.GetSkillSound(soundKey, log.SpecialEffectHint);
                GameSoundPlayer.PlaySoundEffect(uri);
                soundPlayed = uri != null;
            }
            else if (log.GameAction == GameAction.None)
            {
                bool? isMale = null;
                if (log.Source != null) isMale = !log.Source.IsFemale;
                Uri cardSoundUri = GameSoundLocator.GetCardSound(log.CardAction.Type.Name, isMale);
                GameSoundPlayer.PlaySoundEffect(cardSoundUri);
                soundPlayed = cardSoundUri != null;
            }
            if (log.CardAction != null && log.GameAction != GameAction.None)
            {
                if (log.CardAction.Type is TieSuoLianHuan)
                {
                    foreach (var p in log.Targets)
                    {
                        Application.Current.Dispatcher.BeginInvoke((ThreadStart)delegate()
                        {
                            playersMap[p].PlayIronShackleAnimation();
                        });
                    }
                }
                else
                {
                    ICard c = log.CardAction;
                    string key1;
                    key1 = string.Format("{0}.{1}.Animation", c.Type.GetType().Name, c.SuitColor == SuitColorType.Red ? "Red" : "Black");
                    if (!baseCardAnimationResources.Contains(key1))
                    {
                        key1 = string.Format("{0}.Animation", c.Type.GetType().Name);
                    }
                    string key2 = key1 + ".Offset";
                    lock (baseCardAnimationResources)
                    {
                        if (baseCardAnimationResources.Contains(key1))
                        {
                            AnimationBase animation = null;
                            Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
                            {
                                animation = baseCardAnimationResources[key1] as AnimationBase;
                            });
                            if (animation != null && animation.Parent == null)
                            {
                                Point offset = new Point(0, 0);
                                if (baseCardAnimationResources.Contains(key2))
                                {
                                    offset = (Point)baseCardAnimationResources[key2];
                                }
                                player.PlayAnimationAsync(animation, 0, offset);
                            }
                        }
                    }
                }

                bool? isMale = null;
                if (log.Source != null) isMale = !log.Source.IsFemale;
                Uri cardSoundUri = GameSoundLocator.GetCardSound(log.CardAction.Type.Name, isMale);
                var card = log.CardAction as Card;
                if (card != null)
                {
                    bool play = true;
                    if (card.Log != null && card.Log.SkillAction is IEquipmentSkill)
                    {
                        Uri uri = GameSoundLocator.GetSkillSound(card.Log.SkillAction.GetType().Name);
                        if (uri != null) play = false;
                    }
                    if (play && !soundPlayed) GameSoundPlayer.PlaySoundEffect(cardSoundUri);
                }
            }

            if (log.GameAction != GameAction.None || log.SkillAction != null && log.CardAction == null || log.ShowCueLine)
            {
                if (log.Targets.Count > 0)
                {
                    _LineUp(log.Source, log.Targets);
                    foreach (var target in log.Targets)
                    {
                        target.IsTargeted = true;
                    }
                }

                if (log.Targets.Count == 1 && log.SecondaryTargets != null && log.SecondaryTargets.Count > 0)
                {
                    _LineUp(log.Targets[0], log.SecondaryTargets);
                    foreach (var target in log.SecondaryTargets)
                    {
                        target.IsTargeted = true;
                    }
                }
            }

            if (!log.SkillSoundOnly)
            {
                Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
                {
                    gameLogs.AppendLog(log);
                    rtbLog.ScrollToEnd();
                });

                Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
                {
                    _AppendKeyEventLog(log);
                });
            }
        }
Beispiel #15
0
        public ReadOnlyCard Judge(Player player, ISkill skill = null, ICard handler = null, JudgementResultSucceed del = null)
        {
            CardsMovement move = new CardsMovement();
            Card c;
            if (decks[player, DeckType.JudgeResult].Count != 0)
            {
                c = decks[player, DeckType.JudgeResult][0];
                move = new CardsMovement();
                move.Cards = new List<Card>();
                List<Card> backup = new List<Card>(move.Cards);
                move.Cards.Add(c);
                move.To = new DeckPlace(null, DeckType.Discard);
                PlayerAboutToDiscardCard(player, move.Cards, DiscardReason.Judge);
                MoveCards(move);
                PlayerDiscardedCard(player, backup, DiscardReason.Judge);
            }
            SyncImmutableCardAll(PeekCard(0));
            c = Game.CurrentGame.DrawCard();
            move = new CardsMovement();
            move.Cards = new List<Card>();
            move.Cards.Add(c);
            move.To = new DeckPlace(player, DeckType.JudgeResult);
            MoveCards(move);
            GameEventArgs args = new GameEventArgs();
            args.Source = player;
            Game.CurrentGame.Emit(GameEvent.PlayerJudgeBegin, args);
            c = Game.CurrentGame.Decks[player, DeckType.JudgeResult][0];
            args.Card = new ReadOnlyCard(c);
            args.Cards = new List<Card>() { c };
            Game.CurrentGame.Emit(GameEvent.PlayerJudgeDone, args);
            Trace.Assert(args.Source == player);
            Trace.Assert(args.Card is ReadOnlyCard);

            ActionLog log = new ActionLog();
            log.SkillAction = skill;
            log.CardAction = handler;
            log.Source = player;
            bool? succeed = null;
            if (del != null)
            {
                succeed = del(args.Card);
            }

            Card uiCard = new Card(args.Card);
            uiCard.Id = (args.Card as ReadOnlyCard).Id;
            Game.CurrentGame.NotificationProxy.NotifyJudge(player, uiCard, log, succeed);

            if (decks[player, DeckType.JudgeResult].Count != 0)
            {
                c = decks[player, DeckType.JudgeResult][0];
                move = new CardsMovement();
                move.Cards = new List<Card>();
                List<Card> backup = new List<Card>(move.Cards);
                move.Cards.Add(c);
                move.To = new DeckPlace(null, DeckType.Discard);
                move.Helper = new MovementHelper();
                PlayerAboutToDiscardCard(player, move.Cards, DiscardReason.Judge);
                MoveCards(move);
                PlayerDiscardedCard(player, backup, DiscardReason.Judge);
            }
            return args.Card as ReadOnlyCard;
        }
Beispiel #16
0
 internal static Paragraph RichTranslateJudgeResultEffectiveness(Player p, ActionLog log, bool isSuccess)
 {
     Paragraph para = new Paragraph();
     para.Inlines.Add(Translate(p) + "的");
     if (log.CardAction != null)
     {
         para.Inlines.AddRange(RichTranslate(log.CardAction.Type));
     }
     else if (log.SkillAction != null)
     {
         para.Inlines.AddRange(RichTranslate(log.SkillAction));
     }
     para.Inlines.Add(isSuccess ? "生效" : "失效");
     return para;
 }
Beispiel #17
0
 internal static Paragraph RichTranslateJudgeResult(Player p, Card card, ActionLog log, bool isFinalResult)
 {
     Paragraph para = new Paragraph();
     para.Inlines.Add(Translate(p) + "的");
     if (log.CardAction != null)
     {
         para.Inlines.AddRange(RichTranslate(log.CardAction.Type));
     }
     else if (log.SkillAction != null)
     {
         para.Inlines.AddRange(RichTranslate(log.SkillAction));
     }
     para.Inlines.Add("判定结果为");
     para.Inlines.AddRange(RichTranslate(card, false));
     return para;
 }
Beispiel #18
0
 public static string TranslateCardFootnote(ActionLog log)
 {
     string source = Translate(log.Source);
     string dest = string.Empty;
     Trace.Assert(log.Targets != null);
     if (log.Targets != null && log.Targets.Count == 1)
     {
         dest = "对" + Translate(log.Targets[0]);
     }
     string skill = Translate(log.SkillAction);
     switch (log.GameAction)
     {
         case GameAction.None:
             return string.Concat(source, skill);
         case GameAction.Use:
             return string.Concat(source, dest, skill);
         case GameAction.Play:
             return string.Concat(source, skill, dest, "打出");
         case GameAction.PlaceIntoDiscard:
             return string.Concat(source, skill, "置入弃牌堆");
         case GameAction.Discard:
             return string.Concat(source, skill, "弃置");
         case GameAction.Show:
             return string.Concat(source, "展示");
         case GameAction.Judge:
             {
                 string card = Translate(log.CardAction as Card);
                 return string.Concat(source, skill, card, "判定");
             }
         case GameAction.ReplaceJudge:
             return string.Concat(source, skill, "改判");
         case GameAction.Reforge:
             return string.Concat(source, skill, "重铸");
     }
     return string.Empty;
 }
Beispiel #19
0
            public override void Run(GameEvent gameEvent, GameEventArgs eventArgs)
            {
                if (eventArgs.Source != Owner) return;
                if (Game.CurrentGame.Decks[Owner, BiFaDeck].Count == 1)
                {
                    Card theCard = Game.CurrentGame.Decks[Owner, BiFaDeck][0];
                    Player ChenLin = theCard.HistoryPlace1.Player;
                    Game.CurrentGame.SyncImmutableCardAll(theCard);
                    CardsMovement move = new CardsMovement();
                    move.Cards = new List<Card>() { theCard };
                    move.To = new DeckPlace(Owner, BiFaDeck);
                    move.Helper = new MovementHelper();
                    move.Helper.IsFakedMove = true;
                    Game.CurrentGame.MoveCards(move);

                    ActionLog log = new ActionLog();
                    log.GameAction = GameAction.None;
                    log.SkillAction = bifa;
                    log.Source = ChenLin;
                    log.SkillSoundOnly = true;

                    ISkill skill;
                    List<Card> cards;
                    List<Player> players;
                    if (!ChenLin.IsDead && Owner.AskForCardUsage(new CardUsagePrompt("BiFaGiveCard", ChenLin), new BiFaGiveCardVerifier(theCard), out skill, out cards, out players))
                    {
                        log.SpecialEffectHint = 2;
                        Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
                        Game.CurrentGame.NotificationProxy.NotifyLogEvent(new LogEvent("BiFa", Owner, bifa, LogEventArg.Fail), new List<Player>() { Owner });
                        Game.CurrentGame.HandleCardTransferToHand(Owner, ChenLin, cards);
                        Game.CurrentGame.HandleCardTransferToHand(Owner, Owner, new List<Card>() { theCard });
                    }
                    else
                    {
                        log.SpecialEffectHint = 1;
                        Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
                        Game.CurrentGame.NotificationProxy.NotifyLogEvent(new LogEvent("BiFa", Owner, bifa, LogEventArg.Success), new List<Player>() { Owner });
                        theCard.Log = new ActionLog();
                        theCard.Log.SkillAction = bifa;
                        theCard.Log.GameAction = GameAction.PlaceIntoDiscard;
                        Game.CurrentGame.PlaceIntoDiscard(null, new List<Card>() { theCard });
                        Game.CurrentGame.LoseHealth(Owner, 1);
                    }
                }
                Game.CurrentGame.UnregisterTrigger(GameEvent.PhaseBeginEvents[TurnPhase.Start], this);
            }
Beispiel #20
0
        public static Paragraph RichTranslateKeyLog(ActionLog log)
        {
            Paragraph paragraph = new Paragraph();
            string source = Translate(log.Source);
            string dests = Translate(log.Targets);

            IList<Inline> skillInline = RichTranslate(log.SkillAction);
            string formatter = source;
            switch (log.GameAction)
            {
                case GameAction.None:
                    if (log.SkillAction != null)
                    {
                        ISkill skill = log.SkillAction;
                        if (skill is ActiveSkill)
                        {
                            if (!string.IsNullOrEmpty(dests))
                            {
                                dests = "对" + dests;
                            }
                            if (log.SkillAction is IEquipmentSkill)
                            {
                                IEquipmentSkill equipSkill = log.SkillAction as IEquipmentSkill;
                                if (equipSkill.ParentEquipment is Weapon)
                                {
                                    paragraph.Inlines.Add(string.Format("{0}{1}发动了", source, dests));
                                    paragraph.Inlines.AddRange(RichTranslate(equipSkill.ParentEquipment));
                                    paragraph.Inlines.Add("的武器特效");
                                }
                            }
                            else
                            {
                                paragraph.Inlines.Add(string.Format("{0}{1}发动了武将技能", source, dests));
                                paragraph.Inlines.AddRange(RichTranslate(log.SkillAction));
                            }
                        }
                        else if (skill is TriggerSkill)
                        {
                            if (skill is IEquipmentSkill)
                            {
                                IEquipmentSkill equipSkill = log.SkillAction as IEquipmentSkill;
                                if (equipSkill.ParentEquipment is Weapon)
                                {
                                    paragraph.Inlines.Add(string.Format("{0}发动了武器特效", source));
                                    paragraph.Inlines.AddRange(RichTranslate(equipSkill.ParentEquipment));
                                }
                                else if (equipSkill.ParentEquipment is Armor)
                                {
                                    paragraph.Inlines.Add(string.Format("{0}的", source));
                                    paragraph.Inlines.AddRange(RichTranslate(equipSkill.ParentEquipment));
                                    paragraph.Inlines.Add(string.Format("效果被触发", source));
                                }
                            }
                            else
                            {
                                paragraph.Inlines.Add(string.Format("{0}的武将技能", source));
                                paragraph.Inlines.AddRange(RichTranslate(log.SkillAction));
                                paragraph.Inlines.Add(string.Format("被触发"));
                            }
                        }
                    }
                    break;
                case GameAction.Use:
                    if (log.CardAction.GetType().Name == "WuXieKeJi" && log.SkillAction == null)
                    {
                        paragraph.Inlines.Add(string.Format("{0}使用了卡牌", source));
                        paragraph.Inlines.AddRange(RichTranslate(log.CardAction));
                    }
                    break;
                case GameAction.PlaceIntoDiscard:
                    // return string.Format("{0}{1}置入弃牌堆", source, skill);
                    break;
                case GameAction.Discard:
                    //return string.Format("{0}{1}弃置", source, skill);
                    break;
            }
            paragraph.TextAlignment = TextAlignment.Center;
            return paragraph;
        }
Beispiel #21
0
 public void NotifyJudge(Player p, Card card, ActionLog log, bool?isSuccess, bool f)
 {
 }
Beispiel #22
0
 public void NotifySkillUse(ActionLog log)
 {
 }
Beispiel #23
0
        public void NotifySkillUse(ActionLog log)
        {
            Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
            {
                Trace.Assert(log.Source != null);
                PlayerViewBase player = playersMap[log.Source];
                if (log.SkillAction != null)
                {
                    string key1 = string.Format("{0}.Animation", log.SkillAction.GetType().Name);
                    string key2 = key1 + ".Offset";
                    bool animPlayed = false;
                    lock (equipAnimationResources)
                    {
                        if (equipAnimationResources.Contains(key1))
                        {
                            AnimationBase animation = equipAnimationResources[key1] as AnimationBase;
                            if (animation != null && animation.Parent == null)
                            {
                                Point offset = new Point(0, 0);
                                if (equipAnimationResources.Contains(key2))
                                {
                                    offset = (Point)equipAnimationResources[key2];
                                }
                                player.PlayAnimation(animation, 0, offset);
                                animPlayed = true;
                            }
                        }
                    }
                    if (log.SkillAction.IsSingleUse || log.SkillAction.IsAwakening)
                    {
                        ExcitingSkillAnimation anim = new ExcitingSkillAnimation();
                        anim.SkillName = log.SkillAction.GetType().Name;
                        anim.HeroName = log.Source.Hero.Name;
                        gridRoot.Children.Add(anim);
                        anim.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                        anim.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
                        anim.Start();
                        animPlayed = true;
                    }
                    if (!animPlayed && player != mainPlayerPanel)
                    {
                        string s = LogFormatter.Translate(log.SkillAction);
                        if (s != string.Empty)
                        {

                            ZoomTextAnimation anim = new ZoomTextAnimation() { Text = s };
                            player.PlayAnimation(anim, 1, new Point(0, 0));
                            animPlayed = true;
                        }
                    }
                    string soundKey = log.SkillAction.GetType().Name;
                    Uri uri = GameSoundLocator.GetSkillSound(soundKey, log.SpecialEffectHint);
                    GameSoundPlayer.PlaySoundEffect(uri);
                }
                if (log.CardAction != null)
                {
                    if (log.CardAction.Type is Shan)
                    {
                        player.PlayAnimation(new ShanAnimation(), 0, new Point(0, 0));
                    }
                    else if (log.CardAction.Type is RegularSha)
                    {
                        AnimationBase sha;
                        if (log.CardAction.SuitColor == SuitColorType.Red)
                        {
                            sha = new ShaAnimation();
                        }
                        else
                        {
                            sha = new ShaAnimation2();
                        }
                        player.PlayAnimation(sha, 0, new Point(0, 0));
                    }
                    else if (log.CardAction.Type is TieSuoLianHuan)
                    {
                        foreach (var p in log.Targets)
                        {
                            playersMap[p].PlayIronShackleAnimation();
                        }
                    }

                    bool? isMale = null;
                    if (log.Source != null) isMale = !log.Source.IsFemale;
                    Uri cardSoundUri = GameSoundLocator.GetCardSound(log.CardAction.Type.CardType, isMale);
                    var card = log.CardAction as Card;
                    if (card != null)
                    {
                        bool play = true;
                        if (card.Log != null && card.Log.SkillAction is IEquipmentSkill)
                        {
                            Uri uri = GameSoundLocator.GetSkillSound(card.Log.SkillAction.GetType().Name);
                            if (uri != null) play = false;
                        }
                        if (play) GameSoundPlayer.PlaySoundEffect(cardSoundUri);
                    }
                }

                if (log.Targets.Count > 0)
                {
                    _LineUp(log.Source, log.Targets);
                    foreach (var target in log.Targets)
                    {
                        target.IsTargeted = true;
                    }
                }

                gameLogs.AppendLog(log);
                rtbLog.ScrollToEnd();

                _AppendKeyEventLog(log);
            });
        }
Beispiel #24
0
 protected virtual void NotifyAction(Players.Player source, List<Players.Player> targets, CompositeCard card)
 {
     ActionLog log = new ActionLog();
     log.GameAction = GameAction.None;
     log.CardAction = card;
     log.SkillAction = this;
     log.Source = source;
     log.Targets = targets;
     Games.Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
     if (card.Subcards != null)
     {
         foreach (Card c in card.Subcards)
         {
             if (c.Log == null)
             {
                 c.Log = new ActionLog();
             }
             c.Log.SkillAction = this;
         }
     }
 }
 public void NotifySkillUse(ActionLog log)
 {
 }
Beispiel #26
0
        public static Paragraph RichTranslateMainLog(ActionLog log)
        {
            Paragraph paragraph = new Paragraph();
            string source = Translate(log.Source);
            string dests = Translate(log.Targets);
            string secDests = Translate(log.SecondaryTargets);

            IList<Inline> skillInline = RichTranslate(log.SkillAction);
            string formatter = source;
            switch (log.GameAction)
            {
                case GameAction.None:
                    if (log.SkillAction != null)
                    {
                        ISkill skill = log.SkillAction;
                        if (skill is ActiveSkill)
                        {
                            IEquipmentSkill equipSkill = log.SkillAction as IEquipmentSkill;
                            if (equipSkill != null && equipSkill.ParentEquipment is Weapon)
                            {
                                paragraph.Inlines.Add(string.Format("{0}{1}发动了", source, dests));
                                paragraph.Inlines.AddRange(RichTranslate(equipSkill.ParentEquipment));
                                paragraph.Inlines.Add("的武器特效");
                            }
                            else
                            {
                                paragraph.Inlines.Add(string.Format("{0}发动了技能", source));
                                paragraph.Inlines.AddRange(RichTranslate(log.SkillAction));
                                if (dests != string.Empty)
                                {
                                    paragraph.Inlines.Add(",目标是" + dests);
                                }
                                if (secDests != string.Empty)
                                {
                                    paragraph.Inlines.Add("," + secDests);
                                }
                            }
                        }
                        else if (skill is TriggerSkill)
                        {
                            if (skill is IEquipmentSkill)
                            {
                                IEquipmentSkill equipSkill = log.SkillAction as IEquipmentSkill;
                                if (equipSkill.ParentEquipment is Weapon)
                                {
                                    paragraph.Inlines.Add(string.Format("{0}发动了武器特效", source));
                                    paragraph.Inlines.AddRange(RichTranslate(equipSkill.ParentEquipment));
                                }
                                else if (equipSkill.ParentEquipment is Armor)
                                {
                                    paragraph.Inlines.Add(string.Format("{0}的", source));
                                    paragraph.Inlines.AddRange(RichTranslate(equipSkill.ParentEquipment));
                                    paragraph.Inlines.Add(string.Format("效果被触发", source));
                                }
                            }
                            else
                            {
                                paragraph.Inlines.Add(string.Format("{0}的武将技能", source));
                                paragraph.Inlines.AddRange(RichTranslate(log.SkillAction));
                                paragraph.Inlines.Add(string.Format("被触发"));
                            }
                            if (dests != string.Empty)
                            {
                                paragraph.Inlines.Add(",目标是" + dests);
                            }
                        }
                        else if (skill is CardTransformSkill)
                        {
                            CompositeCard card = log.CardAction as CompositeCard;
                            Trace.Assert(card != null);
                            paragraph.Inlines.Add(string.Format("{0}发动了技能", source));
                            paragraph.Inlines.AddRange(RichTranslate(log.SkillAction));
                            if (card.Subcards.Count > 0)
                            {
                                paragraph.Inlines.Add(",将");
                                paragraph.Inlines.AddRange(RichTranslate(card.Subcards));
                                paragraph.Inlines.Add("当作一张");
                                paragraph.Inlines.AddRange(RichTranslate(card.Type));
                            }
                            if (dests != string.Empty) paragraph.Inlines.Add(string.Format(",目标是" + dests));
                        }
                    }
                    break;
                case GameAction.Use:
                    string toDests = (dests == string.Empty) ? string.Empty : ("对" + dests);
                    paragraph.Inlines.Add(string.Format("{0}{1}使用了", source, toDests));
                    paragraph.Inlines.AddRange(RichTranslate(log.CardAction, false));
                    if (secDests != string.Empty) paragraph.Inlines.Add(string.Format("目标是" + secDests));
                    break;
                case GameAction.Play:
                    paragraph.Inlines.Add(string.Format("{0}打出了", source));
                    paragraph.Inlines.AddRange(RichTranslate(log.CardAction, false));
                    break;
                case GameAction.PlaceIntoDiscard:
                    // return string.Format("{0}{1}置入弃牌堆", source, skill);
                    break;
                case GameAction.Discard:
                    //return string.Format("{0}{1}弃置", source, skill);
                    break;
            }
            return paragraph;
        }
Beispiel #27
0
 public void NotifyIntermediateJudgeResults(Player player, ActionLog log, JudgementResultSucceed intermDel)
 {
     Trace.Assert(Game.CurrentGame.Decks[player, DeckType.JudgeResult].Count > 0);
     Card c = Game.CurrentGame.Decks[player, DeckType.JudgeResult][0];
     bool? succeed = null;
     if (intermDel != null)
     {
         succeed = intermDel(c);
     }
     Game.CurrentGame.NotificationProxy.NotifyJudge(player, c, log, succeed, false);
 }
Beispiel #28
0
        public ReadOnlyCard Judge(Player player, ISkill skill = null, ICard handler = null, JudgementResultSucceed del = null)
        {
            ActionLog log = new ActionLog();
            log.SkillAction = skill;
            log.CardAction = handler;
            log.Source = player;
            CardsMovement move = new CardsMovement();
            Card c;
            int initCount = decks[player, DeckType.JudgeResult].Count;
            SyncImmutableCardAll(PeekCard(0));
            c = DrawCard();
            move = new CardsMovement();
            move.Cards = new List<Card>();
            move.Cards.Add(c);
            move.To = new DeckPlace(player, DeckType.JudgeResult);
            MoveCards(move);
            GameEventArgs args = new GameEventArgs();
            args.Source = player;
            if (triggers.ContainsKey(GameEvent.PlayerJudgeBegin) && triggers[GameEvent.PlayerJudgeBegin].Count > 0)
            {
                NotifyIntermediateJudgeResults(player, log, del);
            }
            Emit(GameEvent.PlayerJudgeBegin, args);
            c = Decks[player, DeckType.JudgeResult].Last();
            args.ReadonlyCard = new ReadOnlyCard(c);
            args.Cards = new List<Card>() { c };
            args.Skill = skill;
            args.Card = handler;
            Emit(GameEvent.PlayerJudgeDone, args);
            Trace.Assert(args.Source == player);
            Trace.Assert(args.ReadonlyCard is ReadOnlyCard);

            bool? succeed = null;
            if (del != null)
            {
                succeed = del(args.ReadonlyCard);
            }

            Card uiCard = new Card(args.ReadonlyCard);
            uiCard.Id = (args.ReadonlyCard as ReadOnlyCard).Id;
            if (uiCard.Log == null)
            {
                uiCard.Log = new ActionLog();
            }
            uiCard.Log.Source = player;
            uiCard.Log.CardAction = handler;
            uiCard.Log.SkillAction = skill;
            uiCard.Log.GameAction = GameAction.Judge;
            NotificationProxy.NotifyJudge(player, uiCard, log, succeed);

            if (decks[player, DeckType.JudgeResult].Count > initCount)
            {
                c = decks[player, DeckType.JudgeResult].Last();
                move = new CardsMovement();
                move.Cards = new List<Card>();
                List<Card> backup = new List<Card>(move.Cards);
                move.Cards.Add(c);
                move.To = new DeckPlace(null, DeckType.Discard);
                move.Helper = new MovementHelper();
                PlayerAboutToDiscardCard(player, move.Cards, DiscardReason.Judge);
                MoveCards(move);
                PlayerDiscardedCard(player, backup, DiscardReason.Judge);
            }
            GameDelays.Delay(GameDelayTypes.JudgeEnd);
            return args.ReadonlyCard as ReadOnlyCard;
        }
Beispiel #29
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));
                }
            });
        }
Beispiel #30
0
        public void AppendLog(ActionLog log)
        {
            var docs = (from pair in Logs
                        where (log.Targets.Contains(pair.Key) || log.Source == pair.Key)
                        select pair.Value).Concat(new List<FlowDocument>() { GlobalLog });

            foreach (var doc in docs)
            {
                var paragraph = LogFormatter.RichTranslateMainLog(log);
                if (paragraph != null && paragraph.Inlines.Count > 0)
                {
                    doc.Blocks.Add(paragraph);
                }
            }
        }
Beispiel #31
0
 private void _AppendKeyEventLog(ActionLog log)
 {
     _AppendKeyEventLog(LogFormatter.RichTranslateKeyLog(log));
 }
Beispiel #32
0
        internal void AppendJudgeResultLog(Player p, Card card, ActionLog log, bool? isSuccess, bool isFinalResult)
        {
            List<FlowDocument> docs = new List<FlowDocument>() { Logs[p], GlobalLog };
            foreach (var doc in docs)
            {
                Paragraph para = LogFormatter.RichTranslateJudgeResult(p, card, log, isFinalResult);

                if (para != null)
                {
                    doc.Blocks.Add(para);
                }
                if (isSuccess != null)
                {
                    para = LogFormatter.RichTranslateJudgeResultEffectiveness(p, log, isSuccess == true);

                    if (para != null)
                    {
                        doc.Blocks.Add(para);
                    }
                }
            }
        }