void Log(CardModel card)
 {
     string playerName = Receiver.GetPlayerByKey(Invoker).Info.NickName;
       string commandName = string.Empty;
       switch(card.Visibility.Value)
       {
     case CardVisibility.Visible: commandName = COMMANDCODE_VISIBLE; break;
     case CardVisibility.Private: commandName = COMMANDCODE_PRIVATE; break;
     case CardVisibility.Hidden: commandName = COMMANDCODE_HIDDEN; break;
       }
       commandName = Receiver.GetCommandByKey(commandName).Data.Name;
       MessageContent logContent = new MessageContent(string.Concat("[", playerName, "] ", commandName, " "));
       logContent.Add(CardLogger.EncodeCardSmartName(card));
       Receiver.Console.WriteLog(logContent);
 }
 void Log(CardModel card)
 {
     string playerName = Receiver.GetPlayerByKey(Invoker).Info.NickName;
       string commandName = Receiver.GetCommandByKey(COMMANDCODE).Data.Name;
       MessageContent logContent = new MessageContent(string.Concat("[", playerName, "] ", commandName, " "));
       logContent.Add(CardLogger.EncodeCardSmartName(card));
       Receiver.Console.WriteLog(logContent);
 }
Example #3
0
        public static void LogMovement(GameModel game, string executorPlayerKey, CardModel card, SectorModel fromSector, 
            SectorModel toSector, int fromIndex, int toIndex, CardVisibility? toCardVisibility, bool verbose)
        {
            if(fromSector.Key == toSector.Key && fromSector.Data.Behavior != SectorBehavior.Simple)
            return;

              IEnumerable<SectorModel> sectors = game.Players.Cast<PlayerModel>().SelectMany(e => e.Sectors).Cast<SectorModel>();
              SectorCardsVisibility fromSectorVisibility = sectors.First(e => e.Data.Code == fromSector.Data.Code).Data.CardsVisibility;
              SectorCardsVisibility toSectorVisibility = sectors.First(e => e.Data.Code == toSector.Data.Code).Data.CardsVisibility;

              PlayerModel fromPlayer = (PlayerModel)fromSector.Parent;
              PlayerModel toPlayer = (PlayerModel)toSector.Parent;
              PlayerModel executorPlayer = game.GetPlayerByKey(executorPlayerKey);

              MessageContent logContent = new MessageContent();
              StringBuilder logText = new StringBuilder(200);

              if(verbose)
              {
            logText.Append("[").Append(executorPlayer.Info.NickName).Append("] ");
            logText.Append(game.GetCommandByKey(MoveCardsCommand.COMMANDCODE_SINGLE).Data.Name).Append(" ");
              }

              bool fromVisible = fromSectorVisibility == SectorCardsVisibility.Visibile ||
            (fromSectorVisibility == SectorCardsVisibility.Private && fromPlayer.Key == game.ActivePlayer.Key);
              if(fromVisible)
              {
            fromVisible = (card.Visibility.Value == CardVisibility.Visible ||
              (card.Visibility.Value == CardVisibility.Private && fromPlayer.Key == game.ActivePlayer.Key));
              }
              bool toVisible = toSectorVisibility == SectorCardsVisibility.Visibile ||
            (toSectorVisibility == SectorCardsVisibility.Private && toPlayer.Key == game.ActivePlayer.Key);
              if(toVisible)
              {
            if(toCardVisibility.HasValue)
              toVisible = (toCardVisibility.Value == CardVisibility.Visible ||
            (toCardVisibility.Value == CardVisibility.Private && toPlayer.Key == game.ActivePlayer.Key));
            else
              toVisible = (card.Visibility.Value == CardVisibility.Visible ||
            (card.Visibility.Value == CardVisibility.Private && toPlayer.Key == game.ActivePlayer.Key));
              }
              logContent.Add(logText.ToString());
              logText.Length = 0;
              logContent.Add(EncodeCardSmartName(card, fromVisible || toVisible));
              if(verbose)
              {
            logText.Append(" (");
            if(fromPlayer.Key != executorPlayerKey)
              logText.Append(fromPlayer.Info.NickName).Append("-");
            logText.Append(fromSector.Data.Name);
            if(fromSector.Data.Behavior == SectorBehavior.Simple)
              logText.Append("[").Append(fromIndex + 1).Append("]");
            logText.Append(">");
            if(toPlayer.Key != executorPlayerKey)
              logText.Append(toPlayer.Info.NickName).Append("-");
            logText.Append(toSector.Data.Name);
            if(toSector.Data.Behavior == SectorBehavior.Simple)
              logText.Append("[").Append(toIndex + 1).Append("]");
            logText.Append(")");
              }
              else
              {
            if(fromSector.Data.Behavior == SectorBehavior.Simple)
              logText.Append("[").Append(fromIndex + 1).Append("]");
            if(toSector.Data.Behavior == SectorBehavior.Simple)
              logText.Append("[").Append(toIndex + 1).Append("]");
              }
              logContent.Add(logText.ToString());
              game.Console.WriteLog(logContent);
        }