Пример #1
0
        public string Execute(MafiaBotV2.Network.NetUser fromUser, MafiaBotV2.Network.NetObject source, string[] args)
        {
            string result = null;

            IEnumerable<string> commands;
            if (source is NetUser) {
                commands = from ICommand c in fromUser.Commands where c != this select c.Name;
            }
            else {
                //HACK: Need a better way to handle shoot
                commands = from ICommand c in fromUser.Commands
                           where c != this && c.AllowedInPublic && c.Name != "shoot"
                           select c.Name;
            }

            if (commands.Count() > 0) {
                result = "Your commands: " + new ListFormatter<string>(commands).Format() + ".";
            }
            else {
                result = "You have no commands right now.";
            }

            if(source is NetChannel) {
                IEnumerable<string> channelCommands = from ICommand c in source.Commands select c.Name;
                if (channelCommands.Count() > 0) {
                    result += " Channel commands: " + new ListFormatter<string>(channelCommands).Format() + ".";
                }
            }

            return result;
        }
Пример #2
0
 public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
 {
     if(args.Length == 0) {
         return "Syntax: ##vote <name>";
     }
     return game.Vote(from, from.Master.GetUser(args[0]));
 }
Пример #3
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            Debug.Assert(game.Mapper[from] == member);

            if(this.AllowedInPublic && !(source is NetChannel)) {
                return "You have to issue this command in the channel.";
            }
            if(!this.AllowedInPublic && source is NetChannel) {
                return null;
            }

            VillageMember target = FindTarget(args);
            if (target != null && target.State == MemberState.Dead) {
                return args[0] + " is dead.";
            }

            string message = null;
            try {
                message = member.UsePower(power, target).ResultMessage;
            }
            catch (MafiaException ex) {
                return ex.Message;
            }

            if (source is NetChannel) {
                return null;
            }
            else {
                return message;
            }
        }
Пример #4
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            game.RemoveUser(from);
            from.Commands.Add(new JoinCommand(game));
            from.Commands.Remove(this);

            return "You have been removed from the game. To rejoin, use the ##join command.";
        }
Пример #5
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            game.VoiceEveryone(state);

            from.Commands.Remove(this);
            from.Commands.Add(new VoiceCommand(game, !state));

            return null;
        }
Пример #6
0
 public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
 {
     if (bot.Games.Games.Count == 0) {
         return "There are no games going on right now.";
     }
     else {
         return "Current games: " + new Util.ListFormatter<IGame>(bot.Games.Games);
     }
 }
Пример #7
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            if(args.Length == 0) {
                return "Syntax: ##add <name>";
            }

            game.AddUser(from.Master.GetUser(args[0]));
            return args[0] + " has been added to the game.";
        }
Пример #8
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            if(args.Length == 0) {
                return "Syntax: ##kill <name>";
            }

            NetUser user = from.Master.GetUser(args[0]);
            game.Kill(user);
            return null;
        }
Пример #9
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            if(game.MaxPlayers != -1 && game.Players.Count < game.MaxPlayers) {
                return "Need another " + (game.MaxPlayers - game.Players.Count) + " players to start the game.";
            }

            game.Start();
            from.Commands.Remove(this);
            return null;
        }
Пример #10
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            if (args.Length == 0) {
                return "Syntax: ##skip <powername>";
            }

            VillageMember member = game.Mapper[from];
            member.Skip(args[0]);
            return "Action " + args[0] + " skipped.";
        }
Пример #11
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            if (game == null) {
                return "Game does not exist.";
            }
            else if (game.Creator != from && !from.IsOpInChannel(game.Channel.Name)) {
                return "You are not the creator.";
            }

            games.Destroy(game);
            return "Game destroyed.";
        }
Пример #12
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            if(args.Length<1) {
                return "Syntax: ##variant <name>";
            }

            List<string> argList = args.ToList();
            argList.RemoveAt(0);

            game.SetVariant(args[0], argList);
            return null;
        }
Пример #13
0
        public override void Load(MafiaBotV2.MafiaLib.Village village)
        {
            base.Load(village);

            Faction town = village.Factions.First(v => v.Name == "Town");
            Faction mafia = village.Factions.First(v => v.Name == "Mafia");
            for (int i = 0; i < numTown; i++) {
                town.CreateMember("Town" + i);
            }
            for (int i = 0; i < numScum; i++) {
                mafia.CreateMember("Mafia");
            }
        }
Пример #14
0
 public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
 {
     if(args.Length < 1) {
         return "Syntax: ##opdestroy <name>";
     }
     if(!from.IsOpInChannel(bot.MainChannel)) {
         return "You must be an op to use this command.";
     }
     if(bot.Games.GetGame(args[0]) == null) {
         return "Game doesn't exist.";
     }
     bot.Games.Destroy(args[0]);
     return "Game destroyed.";
 }
Пример #15
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            if(args.Length < 1) {
                return "Syntax: ##create <name>";
            }

            string gameType = "mafia";
            if(args.Length>1) {
                gameType = args[1];
            }

            IGame game = bot.Games.CreateGame(from, args[0], gameType);
            return "Game created! To join the game, go to channel " + game.Channel.Name + " .";
        }
Пример #16
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            if(args.Length == 0) {
                return "Syntax: ##deadline <seconds>";
            }

            if(from != game.Creator) {
                return "Only the creator can set deadlines.";
            }

            DateTime executionTime = DateTime.Now.AddSeconds(Int32.Parse(args[0]));
            game.SetDeadline(executionTime);
            return null;
        }
Пример #17
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            if(args.Length == 0) {
                return "Syntax: ##modkill <target>";
            }

            NetUser target = game.Players.Find(p => p.Name.ToLower() == args[0].ToLower());
            if(target != null) {
                game.Mapper[target].Kill();
                return args[0] + " has been modkilled.";
            }
            else {
                return "Unknown user " + args[0];
            }
        }
Пример #18
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            Debug.Assert(game.Mapper[from] == member);

            VillageMember target = null;
            if(args.Length > 0) {
                NetUser targetUser = game.Players.Find(p => p.Name.ToLower() == args[0].ToLower());
                if(targetUser != null) {
                    target = game.Mapper[targetUser];
                }
            }

            member.Faction.UsePower(power, member, target);

            return "Action submitted";
        }
Пример #19
0
        public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
        {
            if(args.Length < 2) {
                return "Syntax: ##replace <old> <new>";
            }

            NetUser oldUser = game.Players.Find(p => p.Name.ToLower() == args[0].ToLower());
            if(oldUser == null) {
                return "Player " + args[0] + " is not in this game.";
            }
            NetUser newUser = game.Channel.Users.Find(p => p.Name.ToLower() == args[1].ToLower());
            if(newUser == null) {
                return "User " + args[1] + " is not in the game channel.";
            }

            game.Replace(oldUser, newUser);

            return args[0] + " has been replaced by " + args[1];
        }
Пример #20
0
 public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
 {
     (game.Mapper[from].Outside as MafiaUser).SendRoleInfo();
     return null;
 }
Пример #21
0
 public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
 {
     game.AddUser(from);
     from.Commands.Remove(this);
     return "You have been added to the game. To leave again, use the ##leave command.";
 }
Пример #22
0
 public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
 {
     return game.Village.Phase.Votes.GetVoteCount(true);
 }
Пример #23
0
 public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
 {
     return "You can find help on how to use this bot on http://mafiawiki.four-horsemen.com/index.php/MafiaBot";
 }
Пример #24
0
 public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
 {
     return game.Unvote(from);
 }
Пример #25
0
 public string Execute(MafiaBotV2.Network.NetUser from, MafiaBotV2.Network.NetObject source, string[] args)
 {
     return game.GetVoteCount();
 }