Beispiel #1
0
        public void GetNewGameInstance()
        {
            IPlayerPair players = new PlayerPair(new Player(new User("Alessandro"), PlayerColor.WHITE),
                                                 new Player(new User("Stefano"), PlayerColor.BLACK));

            Assert.AreEqual(GameType.CLASSIC.GetNewGameInstance(players).Type, GameType.CLASSIC);
            Assert.AreEqual(GameType.PAWN_HORDE.GetNewGameInstance(players).Type, GameType.PAWN_HORDE);
        }
Beispiel #2
0
        public void IndexerReturnsCorrectPlayers()
        {
            var black   = new HumanPlayerBuilder(StoneColor.Black).Build();
            var white   = new HumanPlayerBuilder(StoneColor.White).Build();
            var players = new PlayerPair(black, white);

            Assert.AreEqual(black, players[StoneColor.Black]);
            Assert.AreEqual(white, players[StoneColor.White]);
        }
Beispiel #3
0
        public void RightColorTest()
        {
            IPlayer whitePlayer = new Player(this._firstUser, PlayerColor.WHITE);
            IPlayer blackPlayer = new Player(this._secondUser, PlayerColor.BLACK);

            Assert.Throws <System.ArgumentException>(() =>
            {
                IPlayerPair playerPair = new PlayerPair(blackPlayer, whitePlayer);
            });
        }
Beispiel #4
0
        public void PlayersAreSetProperlyToTheRightColors()
        {
            var black              = new HumanPlayerBuilder(StoneColor.Black).Build();
            var white              = new HumanPlayerBuilder(StoneColor.White).Build();
            var firstOrderPlayers  = new PlayerPair(black, white);
            var secondOrderPlayers = new PlayerPair(white, black);

            Assert.AreEqual(black, firstOrderPlayers.Black);
            Assert.AreEqual(black, secondOrderPlayers.Black);
            Assert.AreEqual(white, firstOrderPlayers.White);
            Assert.AreEqual(white, secondOrderPlayers.White);
        }
Beispiel #5
0
        public async Task Start(CommandContext ctx)
        {
            var player = await _playerService.GetOrCreatePlayer(ctx.User.Id, ctx.Guild.Id);

            if (player.isBanned)
            {
                await ctx.Channel.SendMessageAsync(":clown:");

                return;
            }
            var startEmbed = new DiscordEmbedBuilder
            {
                Title        = "New Game",
                ThumbnailUrl = ctx.Client.CurrentUser.AvatarUrl,
                Description  = "Waiting for player 2\n React to this message with :wave: to join!",
                Color        = DiscordColor.Cyan
            };

            var message = await ctx.Channel.SendMessageAsync(embed : startEmbed);

            var waveEmoji = DiscordEmoji.FromName(ctx.Client, ":wave:");

            await message.CreateReactionAsync(waveEmoji);

            var interactivity = ctx.Client.GetInteractivityModule();

            bool gotReaction = false;

            while (!gotReaction)
            {
                var reactionResult = await interactivity.WaitForReactionAsync(x => x == waveEmoji);

                if (reactionResult == null)
                {
                    await ctx.Channel.SendMessageAsync("No one responded, closing the game");

                    return;
                }
                else if (reactionResult.Emoji == waveEmoji && reactionResult.User != ctx.Client.CurrentUser && reactionResult.User != ctx.User)
                {
                    gotReaction = true;
                    var pair = new PlayerPair(ctx.User.Id, reactionResult.User.Id);
                    if (games.ContainsKey(pair))
                    {
                        var errorMessage = await ctx.Channel.SendMessageAsync("Either user is already playing a game, get him to finish that one first!");

                        return;
                    }
                    await PlayGame(ctx, reactionResult.User, pair);
                }
            }
        }
Beispiel #6
0
 public KgsGameController(
     KgsGameInfo kgsGameInfo,
     IRuleset ruleset,
     PlayerPair players,
     KgsConnection serverConnection) :
     base(kgsGameInfo, ruleset, players, serverConnection)
 {
     Info         = kgsGameInfo;
     KgsConnector = new KgsConnector(this, serverConnection);
     Chat         = new ChatService(KgsConnector);
     Server       = serverConnection;
     RegisterConnector(KgsConnector);
     KgsConnector.GameEndedByServer += KgsConnector_GameEndedByServer;
 }
Beispiel #7
0
        /// <summary>
        /// Creates IGS game controller
        /// </summary>
        /// <param name="gameInfo">Game info</param>
        /// <param name="ruleset">Ruleset</param>
        /// <param name="players">Players</param>
        /// <param name="serverConnection">Connection to IGS server</param>
        public IgsGameController(
            IgsGameInfo gameInfo,
            IRuleset ruleset,
            PlayerPair players,
            IgsConnection serverConnection) :
            base(gameInfo, ruleset, players, serverConnection)
        {
            Info = gameInfo;

            //create and register connector
            IgsConnector = new IgsConnector(this, serverConnection);
            Chat         = new ChatService(IgsConnector);
            RegisterConnector(IgsConnector);
            Server = serverConnection;
            InitializeServer(serverConnection);
        }
 /// <summary>
 ///     Creates the game controller.
 /// </summary>
 /// <param name="gameInfo">Game info</param>
 /// <param name="ruleset">Ruleset</param>
 /// <param name="players">Players</param>
 public GameController(GameInfo gameInfo, IRuleset ruleset, PlayerPair players)
 {
     if (gameInfo == null)
     {
         throw new ArgumentNullException(nameof(gameInfo));
     }
     if (ruleset == null)
     {
         throw new ArgumentNullException(nameof(ruleset));
     }
     if (players == null)
     {
         throw new ArgumentNullException(nameof(players));
     }
     this.Info    = gameInfo;
     this.Ruleset = ruleset;
     this.Players = players;
     AssignPlayers();
     this.GameTree = new GameTree(ruleset, this.Info.BoardSize);
     InitGameTree();
 }
    private void InsertRandomPlayer()
    {
        SqlTransaction transaction = dbService.getConnection().BeginTransaction();

        try
        {
            using (SqlCommand comm = new SqlCommand("Register", dbService.getConnection(), transaction))
            {
                comm.CommandType = System.Data.CommandType.StoredProcedure;
                //SqlParameter returnValue = comm.Parameters.Add("@returnValue", System.Data.SqlDbType.Int);
                //returnValue.Direction = System.Data.ParameterDirection.ReturnValue;
                SqlParameter usernameStr = comm.Parameters.Add("@Username", System.Data.SqlDbType.VarChar);
                SqlParameter passSalt    = comm.Parameters.Add("@Salt", System.Data.SqlDbType.VarChar);
                SqlParameter passHash    = comm.Parameters.Add("@PassHash", System.Data.SqlDbType.VarChar);
                for (int i = 0; i < 3200; i++)
                {
                    byte[] salt = new byte[32];
                    dbService.getRandomizer().GetNonZeroBytes(salt);

                    string saltStr = Encoding.ASCII.GetString(salt);
                    passSalt.Value    = saltStr;
                    usernameStr.Value = names[i];
                    passHash.Value    = dbService.HashPassword(saltStr, RandomPassword());
                    comm.ExecuteNonQuery();
                }
            }
            print("User Registered");
            List <List <PlayerPair> > nameByServer  = new List <List <PlayerPair> >();
            List <string[]>           guildByServer = new List <string[]>();
            for (int i = 0; i < 16; i++)
            {
                string[] tempguild = GuildNames.GetRange(i * 5, 5).ToArray();
                guildByServer.Add(tempguild);

                string[]          tempname = names.GetRange(i * 200, 200).ToArray();
                List <PlayerPair> tempPair = new List <PlayerPair>();
                for (int j = 0; j < 200; j++)
                {
                    if (j < 50)
                    {
                        tempPair.Add(new PlayerPair(tempname[j], "Saber"));
                    }
                    else if (j < 100)
                    {
                        tempPair.Add(new PlayerPair(tempname[j], "Archer"));
                    }
                    else if (j < 150)
                    {
                        tempPair.Add(new PlayerPair(tempname[j], "Lancer"));
                    }
                    else
                    {
                        tempPair.Add(new PlayerPair(tempname[j], "Ruler"));
                    }
                }
                tempPair = ShuffleList <PlayerPair>(tempPair);
                nameByServer.Add(tempPair);
            }
            print("Name distributed & Shuffled");
            using (SqlCommand comm = new SqlCommand("Insert_Guild", dbService.getConnection(), transaction))
            {
                comm.CommandType = System.Data.CommandType.StoredProcedure;
                SqlParameter nameStr       = comm.Parameters.Add("@Name", System.Data.SqlDbType.VarChar);
                SqlParameter serverNameStr = comm.Parameters.Add("@ServerName", System.Data.SqlDbType.VarChar);
                for (int i = 0; i < 16; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        nameStr.Value       = guildByServer[i][j];
                        serverNameStr.Value = serverNames[i];
                        comm.ExecuteNonQuery();
                    }
                }
                print("Insert Guild Complete");
            }
            using (SqlCommand comm = new SqlCommand("new_Player", dbService.getConnection(), transaction))
            {
                comm.CommandType = System.Data.CommandType.StoredProcedure;
                SqlParameter usernameStr   = comm.Parameters.Add("@username", System.Data.SqlDbType.VarChar);
                SqlParameter classStr      = comm.Parameters.Add("@Class", System.Data.SqlDbType.VarChar);
                SqlParameter serverNameStr = comm.Parameters.Add("@ServerName", System.Data.SqlDbType.VarChar);

                for (int i = 0; i < 16; i++)
                {
                    for (int j = 0; j < 200; j++)
                    {
                        PlayerPair temp = nameByServer[i][j];
                        usernameStr.Value   = temp.name;
                        classStr.Value      = temp.className;
                        serverNameStr.Value = serverNames[i];
                        comm.ExecuteNonQuery();
                    }
                    nameByServer[i] = ShuffleList <PlayerPair>(nameByServer[i]);
                }
            }
            print("Create Player Complete");
            using (SqlCommand join = new SqlCommand("join_Guild", dbService.getConnection(), transaction))
            {
                join.CommandType = System.Data.CommandType.StoredProcedure;
                SqlParameter usernameStrJoin  = join.Parameters.Add("@username", System.Data.SqlDbType.VarChar);
                SqlParameter guildNameStrJoin = join.Parameters.Add("@GuildName", System.Data.SqlDbType.VarChar);
                SqlParameter returnValue      = join.Parameters.Add("@returnValue", System.Data.SqlDbType.Int);
                returnValue.Direction = System.Data.ParameterDirection.ReturnValue;
                for (int i = 0; i < 16; i++)
                {
                    for (int j = 0; j < 150; j++)
                    {
                        PlayerPair temp = nameByServer[i][j];
                        usernameStrJoin.Value = temp.name;
                        if (j < 50)
                        {
                            guildNameStrJoin.Value = guildByServer[i][0];
                        }
                        else if (j < 90)
                        {
                            guildNameStrJoin.Value = guildByServer[i][1];
                        }
                        else if (j < 120)
                        {
                            guildNameStrJoin.Value = guildByServer[i][2];
                        }
                        else if (j < 140)
                        {
                            guildNameStrJoin.Value = guildByServer[i][3];
                        }
                        else if (j < 150)
                        {
                            guildNameStrJoin.Value = guildByServer[i][4];
                        }
                        join.ExecuteNonQuery();
                        if ((int)returnValue.Value != 0)
                        {
                            print(returnValue.Value.ToString());
                            SqlCommand    tempComm = new SqlCommand("Select Name from Player p join GameServer g on g.ServerId = p.ServerID where Username = '******'", dbService.getConnection(), transaction);
                            SqlDataReader reader   = tempComm.ExecuteReader();
                            if (reader.Read())
                            {
                                print(reader["Name"].ToString());
                            }
                            reader.Close();
                            tempComm = new SqlCommand("select gs.Name from Guild g join GameServer gs on g.ServerID = gs.ServerID where GuildName = '" + guildNameStrJoin.Value.ToString() + "'", dbService.getConnection(), transaction);
                            reader   = tempComm.ExecuteReader();
                            if (reader.Read())
                            {
                                print(reader["Name"].ToString());
                            }
                            print(guildNameStrJoin.Value.ToString());
                            transaction.Rollback();
                            return;
                        }
                    }
                    nameByServer[i] = ShuffleList <PlayerPair>(nameByServer[i]);
                }
            }
            print("Assign Guild Complete");
            using (SqlCommand comm = new SqlCommand("update Player set Lvl = @level where Username = @name", dbService.getConnection(), transaction))
            {
                SqlParameter level       = comm.Parameters.Add("@level", System.Data.SqlDbType.Int);
                SqlParameter usernameStr = comm.Parameters.Add("@name", System.Data.SqlDbType.VarChar);
                for (int i = 0; i < 16; i++)
                {
                    for (int j = 0; j < 200; j++)
                    {
                        int levelvalue = 1;
                        if (j < 100)
                        {
                            levelvalue  = (int)(random.NextDouble() * 10 + 30);
                            level.Value = levelvalue;
                        }
                        else if (j < 170)
                        {
                            levelvalue  = (int)(random.NextDouble() * 10 + 50);
                            level.Value = levelvalue;
                        }
                        else
                        {
                            levelvalue  = (int)(random.NextDouble() * 10 + 100);
                            level.Value = levelvalue;
                        }
                        usernameStr.Value = nameByServer[i][j].name;
                        comm.ExecuteNonQuery();
                    }
                }
            }
            print("Player level assigned");
            using (SqlCommand comm = new SqlCommand("add_Owns", dbService.getConnection(), transaction))
            {
                string[] parts  = new string[] { "Weapon", "Helmet", "Armor" };
                string[] rarity = new string[] { "Common", "Rare", "Legendary", "Exotic" };
                comm.CommandType = System.Data.CommandType.StoredProcedure;
                SqlParameter usernameStr      = comm.Parameters.Add("@Username", System.Data.SqlDbType.VarChar);
                SqlParameter equipmentNameStr = comm.Parameters.Add("@EquipmentName", System.Data.SqlDbType.VarChar);
                SqlParameter rarityStr        = comm.Parameters.Add("@Rarity", System.Data.SqlDbType.VarChar);
                SqlParameter returnValue      = comm.Parameters.Add("@returnValue", System.Data.SqlDbType.Int);
                returnValue.Direction = System.Data.ParameterDirection.ReturnValue;
                for (int i = 0; i < 16; i++)
                {
                    for (int j = 0; j < 200; j++)
                    {
                        PlayerPair temp = nameByServer[i][j];
                        usernameStr.Value = temp.name;
                        int pool = 0;
                        if (j < 100)
                        {
                            pool = (int)(random.NextDouble() * 1);
                        }
                        else if (j < 170)
                        {
                            pool = (int)(random.NextDouble() * 1 + 1);
                        }
                        else
                        {
                            pool = (int)(random.NextDouble() * 1 + 2);
                        }
                        foreach (string part in parts)
                        {
                            List <string[]> tempEquipmentList = equipments[temp.className][part];
                            rarityStr.Value        = rarity[pool];
                            equipmentNameStr.Value = tempEquipmentList[pool][(int)(random.NextDouble() * (tempEquipmentList[pool].Length - 1))];
                            comm.ExecuteNonQuery();
                            if ((int)returnValue.Value != 0)
                            {
                                print(returnValue.Value.ToString());
                                transaction.Rollback();
                                return;
                            }
                        }
                    }
                }
                print("Equipment Assigned");
                transaction.Commit();
            }
        }
        catch (Exception ex)
        {
            print(ex.Message + ex.StackTrace);
            transaction.Rollback();
        }
    }
Beispiel #10
0
        private async Task PlayGame(CommandContext ctx, DiscordUser opponent, PlayerPair pair)
        {
            GameLogic game;

            if (games.ContainsKey(pair))
            {
                game = games[pair];
            }
            else
            {
                game = new GameLogic(pair.PlayerID1, pair.PlayerID2);
                games.Add(pair, game);
            }

            var    interactivity = ctx.Client.GetInteractivityModule();
            string info          = string.Empty;

            var currentState = GameState.MoveSuccessfull;

            var player1 = await _playerService.GetOrCreatePlayer(ctx.User.Id, ctx.Guild.Id);

            if (player1.isBanned)
            {
                currentState = GameState.Owin;
            }
            var player2 = await _playerService.GetOrCreatePlayer(opponent.Id, ctx.Guild.Id);

            if (player2.isBanned)
            {
                currentState = GameState.Xwin;
            }
            while (currentState == GameState.MoveSuccessfull || currentState == GameState.MoveFailed)
            {
                int currentPlayer = game.PController.CurrentPlayer;
                if (currentPlayer == 0)
                {
                    info = "Current turn: " + ctx.Member.Username + ", playing as :x:" + "\n Write a position in format X Y";
                }
                else if (currentPlayer == 1)
                {
                    info = "Current turn: " + opponent.Username + ", playing as :o:" + "\n Write a position in format X Y";
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }

                var boardEmbed = new DiscordEmbedBuilder
                {
                    Title       = ctx.Member.Username + " vs " + opponent.Username,
                    Description = game.TransformBoardToDiscord() + info,
                    Color       = DiscordColor.Gold
                };

                var gameMessage = await ctx.Channel.SendMessageAsync(embed : boardEmbed);

                var messageResult = await interactivity.WaitForMessageAsync(x => x.Author.Id == game.PController.CurrentPlayerID() &&
                                                                            x.Content.Length == 3 &&
                                                                            char.IsDigit(x.Content, 0) &&
                                                                            char.IsWhiteSpace(x.Content, 1) &&
                                                                            char.IsDigit(x.Content, 2),
                                                                            TimeSpan.FromMinutes(2));

                if (messageResult == null || messageResult.Message == null)
                {
                    if (game.PController.CurrentPlayer == 0)
                    {
                        currentState = GameState.OwinByDc;
                    }
                    else if (game.PController.CurrentPlayer == 1)
                    {
                        currentState = GameState.XwinByDc;
                    }
                    else
                    {
                        throw new ArgumentOutOfRangeException("Unknown player");
                    }
                    break;
                }

                currentState = game.Place(Convert.ToInt32(messageResult.Message.Content[0].ToString()), Convert.ToInt32(messageResult.Message.Content[2].ToString()));
                if (currentState == GameState.MoveFailed)
                {
                    await ctx.Channel.SendMessageAsync("Move failed, try again");
                }
                Console.WriteLine(currentState);
            }
            string winnerUrl = string.Empty;

            switch (currentState)
            {
            case GameState.Xwin:
                info      = "GG EZ for " + ctx.Member.Username + ":crown:";
                winnerUrl = ctx.Member.AvatarUrl;
                player1.Wins++;
                await _playerService.UpdatePlayer(player1);

                player2.Losses++;
                await _playerService.UpdatePlayer(player2);

                break;

            case GameState.Owin:
                info      = "GG EZ for " + opponent.Username + ":crown:";
                winnerUrl = opponent.AvatarUrl;
                player2.Wins++;
                await _playerService.UpdatePlayer(player2);

                player1.Losses++;
                await _playerService.UpdatePlayer(player1);

                break;

            case GameState.XwinByDc:
                info      = "GG EZ for " + ctx.Member.Username + ":crown: \n" + opponent.Username + " flew :man_running:";
                winnerUrl = ctx.Member.AvatarUrl;
                player1.Wins++;
                await _playerService.UpdatePlayer(player1);

                player2.Abandons++;
                await _playerService.UpdatePlayer(player2);

                break;

            case GameState.OwinByDc:
                info      = "GG EZ for " + opponent.Username + ":crown: \n" + ctx.User.Username + " flew :man_running:";
                winnerUrl = opponent.AvatarUrl;
                player2.Wins++;
                await _playerService.UpdatePlayer(player2);

                player1.Abandons++;
                await _playerService.UpdatePlayer(player1);

                break;

            case GameState.Tie:
                info = "It's a tie this time :necktie:";
                break;
            }

            games.Remove(pair);

            var finishEmbed = new DiscordEmbedBuilder
            {
                Title        = ctx.Member.Username + " vs " + opponent.Username,
                Description  = game.TransformBoardToDiscord() + info,
                ThumbnailUrl = winnerUrl,
                Color        = DiscordColor.Green
            };

            var endMessage = await ctx.Channel.SendMessageAsync(embed : finishEmbed);
        }
Beispiel #11
0
 /// <summary>
 /// Creates game cancellation
 /// </summary>
 /// <param name="players">Both players</param>
 /// <returns>Game end info</returns>
 public static GameEndInformation CreateCancellation(PlayerPair players) =>
 new GameEndInformation(GameEndReason.Cancellation, players);
Beispiel #12
0
 /// <summary>
 /// Creates a resignation
 /// </summary>
 /// <param name="whoResigned"></param>
 /// <param name="players"></param>
 /// <returns>Game end info</returns>
 public static GameEndInformation CreateResignation(GamePlayer whoResigned, PlayerPair players) =>
 new GameEndInformation(GameEndReason.Resignation, players, whoResigned.Info.Color.GetOpponentColor());
Beispiel #13
0
 /// <summary>
 /// Creates a timeout
 /// </summary>
 /// <param name="whoTimedOut">Who timed out</param>
 /// <param name="players">Player pair</param>
 /// <returns></returns>
 public static GameEndInformation CreateTimeout(GamePlayer whoTimedOut, PlayerPair players) =>
 new GameEndInformation(GameEndReason.Timeout, players, whoTimedOut.Info.Color.GetOpponentColor());
Beispiel #14
0
 /// <summary>
 /// Creates game end information
 /// </summary>
 /// <param name="reason">Reason why the game has ended</param>
 /// <param name="players">The player pair of the game controller.</param>
 /// <param name="winnerColor">The player who has won the game, or None if there is no winner.</param>
 private GameEndInformation(GameEndReason reason, PlayerPair players, StoneColor winnerColor = StoneColor.None)
 {
     Reason       = reason;
     Players      = players;
     _winnerColor = winnerColor;
 }
Beispiel #15
0
 public LocalGame(GameInfo info, IRuleset ruleset, PlayerPair players) : base(info)
 {
     Controller = new GameController(info, ruleset, players);
 }
Beispiel #16
0
 public void PlayerPairThrowsForNullSecondPlayer()
 {
     var players = new PlayerPair(null, new HumanPlayerBuilder(StoneColor.Black).Build());
 }
Beispiel #17
0
 public IgsGame(IgsGameInfo info, IRuleset ruleset, PlayerPair players, IgsConnection serverConnection) : base(info)
 {
     Controller = new IgsGameController(Info, ruleset, players, serverConnection);
 }
Beispiel #18
0
 /// <summary>
 /// Creates a remote game controller
 /// </summary>
 /// <param name="remoteGameInfo">Info about the remote game</param>
 /// <param name="ruleset">Ruleset that guides the game</param>
 /// <param name="players">Players playing the game</param>
 /// <param name="serverConnection">Server connection</param>
 protected RemoteGameController(RemoteGameInfo remoteGameInfo, IRuleset ruleset, PlayerPair players, IServerConnection serverConnection) : base(remoteGameInfo, ruleset, players)
 {
     Info   = remoteGameInfo;
     Server = serverConnection;
 }
Beispiel #19
0
        public async Task Duel(CommandContext ctx, [Description("Specify a user via @username")] DiscordMember opponent)
        {
            var player = await _playerService.GetOrCreatePlayer(ctx.User.Id, ctx.Guild.Id);

            if (player.isBanned)
            {
                await ctx.Channel.SendMessageAsync(":clown:");

                return;
            }

            var pair = new PlayerPair(ctx.User.Id, opponent.Id);

            if (games.ContainsKey(pair))
            {
                var message = await ctx.Channel.SendMessageAsync("Either user is already playing a game, get him to finish that one first!");

                return;
            }
            else if (opponent == ctx.User)
            {
                var message = await ctx.Channel.SendMessageAsync(ctx.User.Username + " tried to duel himself and destroyed the universe:exploding_head: ");

                return;
            }
            //Fix later just testing
            if (opponent != null)
            {
                if (opponent == ctx.Client.CurrentUser)
                {
                    await ctx.Channel.SendMessageAsync("You cannot duel me, mortal!");
                }
                else
                {
                    var startEmbed = new DiscordEmbedBuilder
                    {
                        Title        = "New Game",
                        ThumbnailUrl = opponent.AvatarUrl,
                        Description  = "Waiting for " + opponent.Username + "\n Answer y to accept",
                        Color        = DiscordColor.Cyan
                    };

                    var message = await ctx.Channel.SendMessageAsync(embed : startEmbed);

                    var interactivity = ctx.Client.GetInteractivityModule();

                    var messageResult = await interactivity.WaitForMessageAsync(x => x.Author == opponent, TimeSpan.FromMinutes(2));

                    if (messageResult != null && messageResult.Message != null && messageResult.Message.Content.ToLower() == "y")
                    {
                        await PlayGame(ctx, opponent, pair);
                    }
                    else
                    {
                        await ctx.Channel.SendMessageAsync(opponent.Username + " has declined a duel");
                    }
                }
            }
            else
            {
                await ctx.Channel.SendMessageAsync("User with this nickname does not exist");
            }
        }
Beispiel #20
0
 /// <summary>
 /// Creates disconnection
 /// </summary>
 /// <param name="whoDisconnected">Who has disconnected. In observed games, this may be null.</param>
 /// <param name="players">Both players</param>
 /// <returns>Game end info</returns>
 public static GameEndInformation CreateDisconnection(GamePlayer whoDisconnected, PlayerPair players) =>
 new GameEndInformation(GameEndReason.Disconnection, players, whoDisconnected?.Info.Color.GetOpponentColor() ?? StoneColor.None);
Beispiel #21
0
 /// <summary>
 /// Creates scored game end
 /// </summary>
 public static GameEndInformation CreateDraw(PlayerPair players, Scores scores) =>
 new GameEndInformation(GameEndReason.ScoringComplete, players)
 {
     Scores = scores
 };
Beispiel #22
0
 public void PlayerPairThrowsForSameColorPlayers()
 {
     var black       = new HumanPlayerBuilder(StoneColor.Black).Build();
     var secondBlack = new HumanPlayerBuilder(StoneColor.Black).Build();
     var players     = new PlayerPair(black, secondBlack);
 }
Beispiel #23
0
 public KgsGame(KgsGameInfo info, IRuleset ruleset, PlayerPair players, KgsConnection connection) : base(info)
 {
     Controller = new KgsGameController(info, ruleset, players, connection);
     Controller.Nodes.Add(0, new KgsSgfNode(0, 0, null));
 }