コード例 #1
0
        static void GetPost(Bastion bastion)
        {
            string id = ConsolePrompt(ConsoleColor.White, "ID");
            Post   p  = bastion.GetPost(id);

            ConsoleWriteLine(ConsoleColor.Gray, JsonConvert.SerializeObject(p, Formatting.Indented));
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var repoDir = new DirectoryInfo(args[0]);

            ConsoleWriteLine(ConsoleColor.Yellow, "Using Bastion {0}", repoDir);
            var bastion = new Bastion(repoDir);

            if (!repoDir.Exists)
            {
                Init(bastion);
            }

            string c = null;

            while (c != "0")
            {
                c = ConsolePrompt(ConsoleColor.White, "1: Post, 2: List, 3: Get, 4: Vote");

                switch (c)
                {
                case "1": NewPost(bastion); break;

                case "2": ListPosts(bastion); break;

                case "3": GetPost(bastion); break;

                case "4": PostVote(bastion); break;
                }
            }
        }
コード例 #3
0
    public bool Evaluate(Bastion bastion)
    {
        if (bastion.Emptied)
        {
            return(false);
        }

        return(IsMet(bastion));
    }
コード例 #4
0
 static void ListPosts(Bastion bastion)
 {
     foreach (var post in bastion.ListPosts())
     {
         ConsoleWrite(ConsoleColor.White, post.Id);
         ConsoleWrite(ConsoleColor.Green, " {0}", post.Title);
         ConsoleWriteLine(ConsoleColor.Yellow, " {0} <{1}>", post.Author.Name, post.Author.Identifier);
     }
 }
コード例 #5
0
 public void Evaluate(Bastion bastion)
 {
     foreach (var thought in _thoughts)
     {
         var isMet = thought.Evaluate(bastion);
         if (thought.Evaluate(bastion))
         {
             _iconTarget.sprite = thought.Icon;
             _target.SetActive(true);
         }
     }
 }
コード例 #6
0
        static void PostVote(Bastion bastion)
        {
            string   id    = ConsolePrompt(ConsoleColor.White, "ID");
            Post     p     = bastion.GetPost(id);
            VoteType v     = ConsolePrompt(ConsoleColor.White, "U/D") == "U" ? VoteType.Upvote : VoteType.Downvote;
            string   name  = ConsolePrompt(ConsoleColor.White, "Post author");
            Identity voter = new Identity
            {
                Name       = name,
                Identifier = IdentifierForName(name).ToString()
            };

            bastion.Vote(p, voter, v);
        }
コード例 #7
0
        static void Init(Bastion bastion)
        {
            string name      = ConsolePrompt(ConsoleColor.White, "Bastion name");
            string ownerName = ConsolePrompt(ConsoleColor.White, "Owner's name");

            bastion.Init(new DeclarationOfExistence
            {
                Name  = "The Bastion about Bastion",
                Owner = new Identity
                {
                    Name       = name,
                    Identifier = IdentifierForName(name).ToString()
                }
            });
        }
コード例 #8
0
        static void NewPost(Bastion bastion)
        {
            string title  = ConsolePrompt(ConsoleColor.White, "Post title");
            string text   = ConsolePrompt(ConsoleColor.White, "Post text");
            string link   = ConsolePrompt(ConsoleColor.White, "Post link");
            string author = ConsolePrompt(ConsoleColor.White, "Post author");

            bastion.NewPost(new Post
            {
                Title  = title,
                Text   = text,
                Link   = string.IsNullOrWhiteSpace(link) ? null : new Uri(link),
                Author = new Identity
                {
                    Name       = author,
                    Identifier = IdentifierForName(author).ToString()
                },
                Timestamp = DateTimeOffset.UtcNow
            });
        }
コード例 #9
0
 protected override bool IsMet(Bastion bastion)
 {
     return(bastion.HasFamily && bastion.HasLight && bastion.FinalHome);
 }
コード例 #10
0
 protected override bool IsMet(Bastion bastion)
 {
     return(bastion.HasFamily && bastion.HasLight && !bastion.FinalHome && _newHome.Value != null);
 }
コード例 #11
0
 protected override bool IsMet(Bastion bastion)
 {
     return(!bastion.HasFamily && !bastion.HasLight);
 }
コード例 #12
0
 abstract protected bool IsMet(Bastion bastion);
コード例 #13
0
 protected override bool IsMet(Bastion bastion)
 {
     return(!bastion.HasFamily && bastion.HasLight && bastion.AllowFamily);
 }
コード例 #14
0
    }

    private void OnGetNearbyBastions(JsonData data)
    {