public void TestCreateGameNoStartingChips() { object objUser = db.getUserByName("test0"); Assert.IsInstanceOfType(objUser, typeof(SystemUser)); SystemUser user = (SystemUser)objUser; object objGame = sl.createGame(user.id, "Pot_Limit", 1000, 100, null, 120, 4, 8, true, false); Assert.IsInstanceOfType(objGame, typeof(TexasHoldemGame)); TexasHoldemGame game = (TexasHoldemGame)objGame; Assert.IsFalse(game.gamePreferences.isContain(new MustPreferences(new StartingAmountChipsCedPref(0, null), true))); object objUser1 = db.getUserByName("test1"); Assert.IsInstanceOfType(objUser, typeof(SystemUser)); SystemUser user1 = (SystemUser)objUser; int user1Tokens = -1; game.joinGame(user1, 3); for (int i = 0; i < game.players.Length; i++) { if (game.players[i] != null && game.players[i].systemUserID == user1.id) { user1Tokens = game.players[i].Tokens; } } Assert.AreEqual(1000, user1Tokens); }
public void GamePrefLessMinimalBet() { object objUser = db.getUserByName("test0"); Assert.IsInstanceOfType(objUser, typeof(SystemUser)); SystemUser user = (SystemUser)objUser; object objGame = sl.createGame(user.id, "Pot_Limit", 1000, 100, 0, 120, 4, 8, true, false); Assert.IsInstanceOfType(objGame, typeof(TexasHoldemGame)); TexasHoldemGame game = (TexasHoldemGame)objGame; Assert.IsTrue(game.gamePreferences.isContain(new MustPreferences(new StartingAmountChipsCedPref(0, null), true))); StartingAmountChipsCedPref startingChipsPref = (StartingAmountChipsCedPref)game.gamePreferences.getOptionalPref(new StartingAmountChipsCedPref(0, null)); Assert.AreEqual(0, startingChipsPref.startingChipsPolicy); object objUser1 = db.getUserByName("test1"); Assert.IsInstanceOfType(objUser, typeof(SystemUser)); SystemUser user1 = (SystemUser)objUser; ReturnMessage m = null; game.joinGame(user1, 3); for (int i = 0; i < game.players.Length; i++) { if (game.players[i] != null && game.players[i].systemUserID == user1.id) { m = game.bet(game.players[i], 100); } } Assert.IsFalse(m.success); }
public void TestCreateGameWithPotLimitFail() { object objUser = db.getUserByName("test0"); Assert.IsInstanceOfType(objUser, typeof(SystemUser)); SystemUser user = (SystemUser)objUser; object objGame = sl.createGame(user.id, "Pot_Limit", 1000, 100, 15000, 120, 4, 8, true, false); Assert.IsInstanceOfType(objGame, typeof(TexasHoldemGame)); TexasHoldemGame game = (TexasHoldemGame)objGame; Assert.IsTrue(game.gamePreferences.isContain(new MustPreferences(new GamePolicyDecPref(GameTypePolicy.Pot_Limit, 1000, null), true))); object objUser1 = db.getUserByName("test1"); Assert.IsInstanceOfType(objUser, typeof(SystemUser)); SystemUser user1 = (SystemUser)objUser; ReturnMessage m = null; game.joinGame(user1, 3); game.pot = 1000; for (int i = 0; i < game.players.Length; i++) { if (game.players[i] != null && game.players[i].systemUserID == user1.id) { m = game.bet(game.players[i], 1500); break; } } Assert.IsFalse(m.success); }
public object joinGame(int userId, int gameID, int seatIndex) { TexasHoldemGame game = gameCenter.getGameById(gameID); SystemUser user = gameCenter.getUserById(userId); if (game == null || user == null) { return(null); } var response = game.joinGame(user, seatIndex); if (response.success) { return(game); } else { Console.WriteLine(response.description); return(null); } }