Esempio n. 1
0
            public override async Task Add()
            {
                Location location = new Location();

                location.name = await AsyncAsk("What is the name of the location?");

                await AsyncAskListBasic("Provide a description for the location.", 1, location.descriptions.Add);

                await AsyncAddConnections(location);

                await AsyncAskList("Name the ExploreSet.", 0, async name =>
                {
                    ExploreSet set = ExploreSet.Find(name);

                    if (set == null)
                    {
                        await ReplyMentionAsync($"An ExploreSet of the name '{name}' could not be found.");

                        return(true);
                    }
                    else
                    {
                        location.exploreSet = set;

                        return(false);
                    }
                });

                ChatCraft.Instance.State.locations.Add(location);

                ChatCraft.Instance.Save();

                await ReplyMentionAsync($"Finished adding {location.name}.");
            }
Esempio n. 2
0
            public override async Task Edit(Location target)
            {
                await AsyncAskList("What should the name change to?", 0, name =>
                {
                    target.name = name;
                    return(Task.FromResult(false));
                });

                string message = "These are the current descriptions:";

                foreach (string description in target.descriptions)
                {
                    message += '\n' + description;
                }

                await ReplyMentionAsync(message);

                await AsyncRemove("Which descriptions should be removed?", target.descriptions, text => text, (start, full) => full.ToLower().StartsWith(start.ToLower()), removing => target.descriptions.Remove(removing));

                await AsyncAskListBasic("Provide a description for the location.", 1, target.descriptions.Add);

                await AsyncRemove("Which connections should be removed?", target.connections, Location.Find, (location, connection) => connection.locationA == location || connection.locationB == location, removing =>
                {
                    removing.locationA.connections.Remove(removing);
                    removing.locationB.connections.Remove(removing);

                    target.connections.Remove(removing);
                });

                await ReplyMentionAsync($"Finished editing {target.name}.");

                await AsyncAddConnections(target);

                await AsyncAskList("Name the new ExploreSet.", 0, async name =>
                {
                    if (name == ".")
                    {
                        target.exploreSet = null;
                    }

                    ExploreSet set = ExploreSet.Find(name);

                    if (set == null)
                    {
                        await ReplyMentionAsync($"An ExploreSet of the name '{name}' could not be found.");

                        return(true);
                    }
                    else
                    {
                        target.exploreSet = set;

                        return(false);
                    }
                });
            }