public override void Execute(Player player)
        {
            // These four lines of code here are why Board.Move() exists and putting this
            // logic here feels bad.  However, Board.Move() ends by called the
            // Space.LandedOnBy() method, which just does too much FOR THIS ONE INSTANCE.
            // So do I ruin some really nice, elegant code for this one divergence, or
            // do I live with shit like this?
            List <Property> properties = BoardReference.GetPropertiesInGroup("Railroads");
            int             distance   = BoardReference.FindDistanceToNearestProperty(player.Position, properties);

            player.Position += distance;
            player.Position  = player.Position % BoardReference.NumSpaces;

            if (player.Position - distance < 0)
            {
                player.Bank += 200;
            }

            Railroad railroad = (Railroad)BoardReference.GetSpace(player.Position);

            if (!railroad.IsOwned)
            {
                railroad.SellTo(player);
            }

            else if (railroad.Owner != player)
            {
                int rent = railroad.CalculateRent();
                player.Bank         -= (rent * 2);
                railroad.Owner.Bank += (rent * 2);
            }
        }
예제 #2
0
 /// <summary>
 /// Установить дополнительную информацию.
 /// </summary>
 /// <param name="extended">Дополнительная информация.</param>
 /// <param name="reference">Ссылка.</param>
 /// <param name="serializationService">Сервис сериализации ссылок.</param>
 public static void SetExtendedInfoFor(BoardExtendedInfo extended, BoardReference reference, ILinkSerializationService serializationService)
 {
     if (reference == null)
     {
         throw new ArgumentNullException(nameof(reference));
     }
     if (serializationService == null)
     {
         throw new ArgumentNullException(nameof(serializationService));
     }
     if (extended == null)
     {
         reference.LikesEnabled        = false;
         reference.Icons               = null;
         reference.PostingCapabilities = null;
         reference.SageEnabled         = false;
         reference.ThreadTagsEnabled   = false;
         reference.TripCodesEnabled    = false;
     }
     else
     {
         reference.LikesEnabled      = extended.LikesEnabled;
         reference.SageEnabled       = extended.SageEnabled;
         reference.ThreadTagsEnabled = extended.ThreadTagsEnabled;
         reference.TripCodesEnabled  = extended.TripCodesEnabled;
         reference.Icons             = extended.Icons?.Select(i => new BoardIcon()
         {
             Id        = i?.Id,
             Name      = i?.Name,
             MediaLink = i?.MediaLink != null ? serializationService.Deserialize(i.MediaLink) : null
         })?.OfType <IBoardIcon>()?.ToList();
         if (extended.PostingCapabilities != null)
         {
             foreach (var c in extended.PostingCapabilities.OfType <BoardPostingIconCapability>())
             {
                 c.UpdateInterface();
             }
         }
         reference.PostingCapabilities = extended.PostingCapabilities?.OfType <IPostingCapability>()?.ToList();
     }
 }
        public override void Execute(Player player)
        {
            // These four lines of code here are why Board.Move() exists and putting this
            // logic here feels bad.  However, Board.Move() ends by called the
            // Space.LandedOnBy() method, which just does too much FOR THIS ONE INSTANCE.
            // So do I ruin some really nice, elegant code for this one divergence, or
            // do I live with shit like this?
            List <Property> properties = BoardReference.GetPropertiesInGroup("Utilities");
            int             distance   = BoardReference.FindDistanceToNearestProperty(player.Position, properties);

            player.Position += distance;
            player.Position  = player.Position % BoardReference.NumSpaces;

            if (player.Position - distance < 0)
            {
                player.Bank += 200;
            }

            Utility util = (Utility)BoardReference.GetSpace(player.Position);

            if (!util.IsOwned)
            {
                util.SellTo(player);
            }

            else if (util.Owner != player)
            {
                Dice dice = new Dice();
                int  roll1;
                int  roll2;
                (roll1, roll2) = dice.Roll();
                int rent = (roll1 + roll2) * 10;
                player.Bank     -= rent;
                util.Owner.Bank += rent;
            }
        }
예제 #4
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="boardReference">Ссылка на борду.</param>
 public SummaryBoardInfo(BoardReference boardReference)
 {
     if (boardReference == null) throw new ArgumentNullException(nameof(boardReference));
     this.boardReference = boardReference;
     if (boardReference.Extensions != null)
     {
         var makaba = boardReference.Extensions.OfType<MakabaBoardReferenceExtension>().FirstOrDefault();
         if (makaba != null)
         {
             MakabaInfo = new MakabaBoardInfo(makaba, boardReference.Link?.Engine);
         }
         var posting = boardReference.Extensions.OfType<BoardReferencePostingExtension>().FirstOrDefault();
         if (posting != null)
         {
             Posting = new PostingBoardInfo(posting);
         }
     }
     var engines = ServiceLocator.Current.GetServiceOrThrow<INetworkEngines>();
     if (boardReference.Link?.Engine != null)
     {
         if (engines.ListEngines().Any(e => StringComparer.OrdinalIgnoreCase.Equals(e, boardReference.Link.Engine)))
         {
             var engine = engines.GetEngineById(boardReference.Link.Engine);
             if ((engine.Capability & EngineCapability.PartialThreadRequest) != 0)
             {
                 EngineCapabilities.Add(new BoardInfoString("Загрузка только новых сообщений в треде при обновлении"));
             }
             if ((engine.Capability & EngineCapability.ThreadStatusRequest) != 0)
             {
                 EngineCapabilities.Add(new BoardInfoString("Получение количества постов и даты обновления без загрузки треда"));
             }
             if ((engine.Capability & EngineCapability.BoardsListRequest) != 0)
             {
                 EngineCapabilities.Add(new BoardInfoString("Получение списка досок"));
             }
             if ((engine.Capability & EngineCapability.SearchRequest) != 0)
             {
                 EngineCapabilities.Add(new BoardInfoString("Поиск по доске"));
             }
             if ((engine.Capability & EngineCapability.TopPostsRequest) != 0)
             {
                 EngineCapabilities.Add(new BoardInfoString("Топ тредов на доске"));
             }
             if ((engine.Capability & EngineCapability.Catalog) != 0)
             {
                 EngineCapabilities.Add(new BoardInfoString("Каталог тредов на доске"));
             }
             if ((engine.Capability & EngineCapability.LastModifiedRequest) != 0)
             {
                 EngineCapabilities.Add(new BoardInfoString("Быстрая проверка изменений в треде"));
             }
             if ((engine.Capability & EngineCapability.NoCaptcha) != 0)
             {
                 EngineCapabilities.Add(new BoardInfoString("Отправка сообщений в тред без ввода капчи"));
             }
             if ((engine.Capability & EngineCapability.Catalog) != 0)
             {
                 EngineCapabilities.Add(new BoardInfoString("Каталог тредов"));
             }
         }
     }
 }
 /// <summary>
 /// Парсить информацию о борде.
 /// </summary>
 /// <param name="category">Категория.</param>
 /// <param name="b">Информация.</param>
 /// <returns>Ссылка на борду.</returns>
 public BoardReference Parse(string category, MobileBoardInfo b)
 {
     var board = new BoardReference()
     {
         Category = category,
         DisplayName = b.Name,
         Link = new BoardLink() {Engine = CoreConstants.Engine.Makaba, Board = b.Id},
         ShortName = b.Id,
         Extensions = new List<BoardReferenceExtension>(),
         IsAdult = "Взрослым".Equals(category) || CoreConstants.Makaba.AdultBoards.Contains(b.Id)
     };
     var makabaExtension = new MakabaBoardReferenceExtension()
     {
         Bumplimit = b.BumpLimit,
         DefaultName = b.DefaultName,
         Icons = (b.Icons ?? new BoardIcon2[0]).Select(i => new MakabaIconReference()
         {
             Name = i.Name,
             Number = i.NumberInt,
             Url = i.Url
         }).ToList(),
         Pages = b.Pages,
         MaxComment = null,
         Sage = b.Sage != 0,
         Tripcodes = b.Tripcodes != 0,
         EnableLikes = b.EnableLikes != 0,
         EnableTags = b.EnableThreadTags != 0,
     };
     board.Extensions.Add(makabaExtension);
     var postingExtension = new BoardReferencePostingExtension()
     {
         Capabilities = new List<PostingCapability>()
     };
     foreach (var cr in CommonRoles)
     {
         switch (cr)
         {
             case PostingFieldSemanticRole.Comment:
                 postingExtension.Capabilities.Add(new PostingCommentCapability()
                 {
                     MaxLength = null,
                     MarkupType = PostingMarkupType.Makaba,
                     Role = PostingFieldSemanticRole.Comment
                 });
                 break;
             case PostingFieldSemanticRole.Captcha:
                 postingExtension.Capabilities.Add(new PostingCaptchaCapability()
                 {
                     Role = PostingFieldSemanticRole.Captcha,
                     CaptchaTypes = CaptchaTypes.DvachCaptcha
                 });
                 break;
             case PostingFieldSemanticRole.Icon:
                 if (makabaExtension.Icons.Count > 0)
                 {
                     postingExtension.Capabilities.Add(new PostingIconCapability()
                     {
                         Icons = makabaExtension.Icons.Select(i => new PostingCapabilityIcon()
                         {
                             Name = i.Name,
                             Number = i.Number
                         }).ToList(),
                         Role = PostingFieldSemanticRole.Icon
                     });
                 }
                 break;
             case PostingFieldSemanticRole.MediaFile:
                 postingExtension.Capabilities.Add(new PostingMediaFileCapability()
                 {
                     MaxFileCount = 4,
                     Role = PostingFieldSemanticRole.MediaFile
                 });
                 break;
             case PostingFieldSemanticRole.Title:
                 if (!"b".Equals(b.Id, StringComparison.OrdinalIgnoreCase))
                 {
                     postingExtension.Capabilities.Add(new PostingCapability()
                     {
                         Role = cr
                     });                            
                 }
                 break;
             case PostingFieldSemanticRole.ThreadTag:
                 if (b.EnableThreadTags != 0)
                 {
                     postingExtension.Capabilities.Add(new PostingCapability()
                     {
                         Role = cr
                     });
                 }
                 break;
             /*
             case PostingFieldSemanticRole.SageFlag:
                 if (makabaExtension.Sage)
                 {
                     postingExtension.Capabilities.Add(new PostingCapability()
                     {
                         Role = PostingFieldSemanticRole.SageFlag
                     });
                 }
                 break;*/
             default:
                 postingExtension.Capabilities.Add(new PostingCapability()
                 {
                     Role = cr
                 });
                 break;
         }
     }
     board.Extensions.Add(postingExtension);
     return board;
 }
        private BoardReference Parse(string category, MobileBoardInfo b)
        {
            var board = new BoardReference()
            {
                Category    = category ?? "",
                DisplayName = b.Name,
                BoardLink   = new BoardLink()
                {
                    Engine = MakabaEngineId, Board = b.Id
                },
                ShortName   = b.Id ?? "",
                IsAdult     = "Взрослым".Equals(category) || AdultBoards.Contains(b.Id),
                BumpLimit   = b.BumpLimit,
                DefaultName = b.DefaultName,
                Icons       = (b.Icons ?? new BoardIcon2[0]).Where(i => i != null).Select(i => new BoardIcon()
                {
                    Name      = i.Name,
                    Id        = i.Number,
                    MediaLink = new EngineMediaLink()
                    {
                        Engine = MakabaEngineId, Uri = i.Url
                    }
                }).OfType <IBoardIcon>().ToList(),
                Pages               = b.Pages,
                SageEnabled         = b.Sage != 0,
                TripCodesEnabled    = b.Tripcodes != 0,
                LikesEnabled        = b.EnableLikes != 0,
                ThreadTagsEnabled   = b.EnableThreadTags != 0,
                PostingCapabilities = new List <IPostingCapability>()
            };

            foreach (var cr in CommonRoles)
            {
                if (cr == PostingFieldSemanticRole.Comment)
                {
                    board.PostingCapabilities.Add(new PostingCommentCapability()
                    {
                        MaxLength  = null,
                        MarkupType = MarkupTypes.Makaba,
                        Role       = PostingFieldSemanticRole.Comment
                    });
                }
                else if (cr == PostingFieldSemanticRole.Captcha)
                {
                    board.PostingCapabilities.Add(new PostingCaptchaCapability()
                    {
                        Role         = PostingFieldSemanticRole.Captcha,
                        CaptchaTypes = new List <Guid>()
                        {
                            CaptchaTypes.DvachCaptcha
                        }
                    });
                }
                else if (cr == PostingFieldSemanticRole.Icon)
                {
                    if (board.Icons.Count > 0)
                    {
                        board.PostingCapabilities.Add(new PostingIconCapability()
                        {
                            Role  = PostingFieldSemanticRole.Icon,
                            Icons = board.Icons.Select(i => new PostingCapabilityIcon()
                            {
                                Name = i.Name,
                                Id   = i.Id
                            }).OfType <IPostingCapabilityIcon>().ToList()
                        });
                    }
                }
                else if (cr == PostingFieldSemanticRole.MediaFile)
                {
                    if (!BoardsWithoutMedia.Contains(b.Id))
                    {
                        board.PostingCapabilities.Add(new PostingMediaFileCapability()
                        {
                            Role         = PostingFieldSemanticRole.MediaFile,
                            MaxFileCount = 4
                        });
                    }
                }
                else if (cr == PostingFieldSemanticRole.Title)
                {
                    if (!BoardsWithoutTitle.Contains(b.Id))
                    {
                        board.PostingCapabilities.Add(new PostingCapability()
                        {
                            Role = PostingFieldSemanticRole.Title,
                        });
                    }
                }
                else if (cr == PostingFieldSemanticRole.ThreadTag)
                {
                    if (b.EnableThreadTags != 0)
                    {
                        board.PostingCapabilities.Add(new PostingCapability()
                        {
                            Role = PostingFieldSemanticRole.ThreadTag,
                        });
                    }
                }
                else
                {
                    board.PostingCapabilities.Add(new PostingCapability()
                    {
                        Role = cr,
                    });
                }
            }
            return(board);
        }
 public override void Execute(Player player)
 {
     BoardReference.MoveToSpaceNamed(player, "Illinois Avenue");
 }
예제 #8
0
 public override void Execute(Player player)
 {
     BoardReference.MoveToSpaceNamed(player, "Reading Railroad");
 }
예제 #9
0
 /// <summary>
 /// Десериализовать дополнительную ифнмормацию.
 /// </summary>
 /// <param name="extended">Дополнительная информация.</param>
 /// <param name="result">Результат.</param>
 protected virtual void SetExtendedInfo(byte[] extended, BoardReference result)
 {
     BoardExtendedInfo.SetExtendedInfoFor(DeserializeDataContract <BoardExtendedInfo>(extended), result, LinkSerialization);
 }
 public override void Execute(Player player)
 {
     BoardReference.MoveToSpaceNamed(player, "St. Charles Place");
 }
예제 #11
0
 public override void Execute(Player player)
 {
     BoardReference.MoveToSpaceNamed(player, "Go");
 }
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="boardRef">Ссылка на борду.</param>
 public BoardListBoardViewModel(BoardReference boardRef)
 {
     if (boardRef == null) throw new ArgumentNullException(nameof(boardRef));
     this.boardRef = boardRef;
 }