Пример #1
0
        internal void BroadcastSkillEffect_LogUpdate(PlayerIndicator player, List <CardModel> targets, CardSkill skill)
        {
#if UNITY_EDITOR || DEVELOPMENT_BUILD
            if (skill == null)
            {
                throw new ArgumentNullException("skill", "Skill argument cannot be null in this context.");
            }
#endif

            if (targets == null || targets.Count == 0)
            {
                return;
            }

            // a bit of a hack
            CardModel dummy = new CardModel(0, PlayerIndicator.Bot);
            skill.Effect(dummy);                                              // see what this spell does to a dummy
            bool heals       = dummy.CurrentStrength > dummy.DefaultStrength; // true - heals, false - damages
            int  howPowerful = Math.Abs(dummy.DefaultStrength - dummy.CurrentStrength);

            string lastExecutedCommand = $"<b>{CurrentPlayer.ToString()} Player's</b> card ";
            lastExecutedCommand += targets.Count == 1
                ? $"{HealsOrDamages()} <color=yellow>{DB[targets[0].CardId].Title}</color> for {howPowerful} point(s)"
                : $"{HealsOrDamages()} following cards: " + string.Join(", ", targets) // many targets
                                   + $" for total of {howPowerful * targets.Count} point(s)";

            string HealsOrDamages() => heals ? "<color=green>heals</color>" : "<color=red>damages</color>";

            GameLogicLogUpdateEventHandler?.Invoke(
                this,
                new GameLogicLogUpdateEventArgs(
                    player, GetCurrentStatus(), lastExecutedCommand, TopTotalStrength, BotTotalStrength));
        }
Пример #2
0
        internal void BroadcastGameOver_StatusUpdate()
        {
            _gameOver = true; // after this moment all return calls will be ignored

            int    top = TopTotalStrength, bot = BotTotalStrength;
            string msg = top > bot
                ? $"Top wins {top} to {bot}"
                : top < bot
                    ? $"Bot wins {bot} to {top}"
                    : $"Draw {top} - {bot}";

            // broadcast game log last message
            GameLogicLogUpdateEventHandler?.Invoke(
                this,
                new GameLogicLogUpdateEventArgs(PlayerIndicator.Top, null, $"\n{msg}\n === GAME OVER ===", top, bot));

            if (GameLogicStatusChangedEventHandler == null)
            {
                ReturnControl(); // interface not attached - immediately return control
            }
            else
            {
                GameLogicStatusChangedEventHandler.Invoke(
                    this,
                    new GameLogicStatusChangedEventArgs(GameLogicMessageType.GameOver, CurrentPlayer)
                {
                    TopTotalStrength = TopTotalStrength,
                    BotTotalStrength = BotTotalStrength,
                });
            }
        }
Пример #3
0
        internal void BroadcastCardMove_LogUpdate(PlayerIndicator player, MoveData move)
        {
#if UNITY_EDITOR || DEVELOPMENT_BUILD
            if (move == null)
            {
                throw new ArgumentNullException("move", "Move argument cannot be null in this context.");
            }
#endif

            string cardTitle           = DB[move.Card.CardId].Title;
            string lastExecutedCommand =
                $"<b>Player {player.ToString()}</b> moved card <color=yellow>{cardTitle}</color> "
                + $"from <b>{move.FromLine.ToString()}</b> slot <b>{move.FromSlotNumber}</b> "
                + $"to <b>{move.TargetLine.ToString()}</b> slot <b>{move.TargetSlotNumber}</b>";

            GameLogicLogUpdateEventHandler?.Invoke(
                this,
                new GameLogicLogUpdateEventArgs(
                    player, GetCurrentStatus(), lastExecutedCommand, TopTotalStrength, BotTotalStrength));
        }
Пример #4
0
 internal void BroadcastInitialData_LogUpdate()
 => GameLogicLogUpdateEventHandler?.Invoke(
     this,
     new GameLogicLogUpdateEventArgs(PlayerIndicator.Top, GetCurrentStatus(), null, TopTotalStrength, BotTotalStrength));