Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 4th, 2009  |  syntax: None  |  size: 36.14 KB  |  views: 94  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Index: debian/python-poker-network.links
  2. ===================================================================
  3. --- debian/python-poker-network.links   (révision 6259)
  4. +++ debian/python-poker-network.links   (copie de travail)
  5.  -1,4 +1,5 @@
  6.  usr/share/poker-network/schema.sql usr/share/dbconfig-common/data/python-poker-network/install/mysql
  7. +usr/share/poker-network/1.7.5-2.0.0.sql usr/share/dbconfig-common/data/python-poker-network/upgrade/mysql/2.0.0
  8.  usr/share/poker-network/1.7.4-1.7.5.sql usr/share/dbconfig-common/data/python-poker-network/upgrade/mysql/1.7.5
  9.  usr/share/poker-network/1.7.3-1.7.4.sql usr/share/dbconfig-common/data/python-poker-network/upgrade/mysql/1.7.4
  10.  usr/share/poker-network/1.6.0-1.7.0.sql usr/share/dbconfig-common/data/python-poker-network/upgrade/mysql/1.7.0
  11. Index: pokernetwork/pokerpackets.py
  12. ===================================================================
  13. --- pokernetwork/pokerpackets.py        (révision 6259)
  14. +++ pokernetwork/pokerpackets.py        (copie de travail)
  15.  -1732,6 +1732,7 @@
  16.  
  17.      format = "!I"
  18.      format_size = calcsize(format)
  19. +    TIME_BEFORE_YOU_CAN_REBUY_CODE = "1"
  20.  
  21.      def __init__(self, *args, **kwargs):
  22.          self.amount = kwargs.get("amount",0)
  23.  -1849,6 +1850,7 @@
  24.     info = PacketPokerId.info + ( ('name', 'noname', 's'),
  25.                                   ('outfit', 'random', 's'),
  26.                                   ('url', 'random', 's'),
  27. +                                  ('tables_max', -1, 'I'),
  28.                                   # FIXME_PokerPlayerInfoLocale:
  29.                                   # (see also sr #2262 )
  30.                                   # should "locale" be here?  It's
  31.  -1863,20 +1865,22 @@
  32.         self.name = kwargs.get('name', "noname")
  33.         self.url = kwargs.get('url', "random")
  34.         self.outfit = kwargs.get('outfit',"random")
  35. +       self.tables_max = kwargs.get('tables_max',-1)
  36.         PacketPokerId.__init__(self, *args, **kwargs)
  37.  
  38.     def pack(self):
  39. -       return PacketPokerId.pack(self) + self.packstring(self.name) + self.packstring(self.outfit) + self.packstring(self.url)
  40. +       return PacketPokerId.pack(self) + self.packstring(self.name) + self.packstring(self.outfit) + self.packstring(self.url) + pack(PacketPokerPlayerInfo.format, self.tables_max)
  41.  
  42.     def unpack(self, block):
  43.         block = PacketPokerId.unpack(self, block)
  44.         (block, self.name) = self.unpackstring(block)
  45.         (block, self.outfit) = self.unpackstring(block)
  46.         (block, self.url) = self.unpackstring(block)
  47. -       return block
  48. +       (self.tables_max,) = unpack(PacketPokerPlayerInfo.format, block[:PacketPokerPlayerInfo.format_size])
  49. +       return block[PacketPokerPlayerInfo.format_size:]
  50.  
  51.     def calcsize(self):
  52. -       return PacketPokerId.calcsize(self) + self.calcsizestring(self.name) + self.calcsizestring(self.outfit) + self.calcsizestring(self.url)
  53. +       return PacketPokerId.calcsize(self) + self.calcsizestring(self.name) + self.calcsizestring(self.outfit) + self.calcsizestring(self.url) + PacketPokerPlayerInfo.format_size
  54.  
  55.     def __str__(self):
  56.         return PacketPokerId.__str__(self) + " name = %s, url = %s, outfit = %s " % ( self.name , self.url, self.outfit )
  57. Index: pokernetwork/pokerservice.py
  58. ===================================================================
  59. --- pokernetwork/pokerservice.py        (révision 6259)
  60. +++ pokernetwork/pokerservice.py        (copie de travail)
  61.  -102,6 +102,7 @@
  62.  UPDATE_TOURNEYS_SCHEDULE_DELAY = 10 * 60
  63.  CHECK_TOURNEYS_SCHEDULE_DELAY = 60
  64.  DELETE_OLD_TOURNEYS_DELAY = 1 * 60 * 60
  65. +CLEANUP_SERIAL2LEAVETIME_DELAY = 1 * 60 * 60
  66.  
  67.  class IPokerService(Interface):
  68.  
  69.  -295,6 +296,7 @@
  70.              self.createTable(0, description)
  71.          self.cleanupTourneys()
  72.          self.updateTourneysSchedule()
  73. +        self.cleanupSerial2leavetimeTimer()
  74.          self.messageCheck()
  75.          self.poker_auth.SetLevel(PACKET_POKER_SEAT, User.REGULAR)
  76.          self.poker_auth.SetLevel(PACKET_POKER_GET_USER_INFO, User.REGULAR)
  77.  -304,6 +306,19 @@
  78.          self.poker_auth.SetLevel(PACKET_POKER_HAND_SELECT_ALL, User.ADMIN)
  79.          service.Service.startService(self)
  80.          self.down = False
  81. +        
  82. +    
  83. +    def cleanupSerial2leavetimeTimer(self):
  84. +        for table in self.tables.values():
  85. +                serialsToDelete = {}
  86. +                for (player_serial , leavetime ) in table.serial2leavetime.iteritems():
  87. +                    if (seconds() - leavetime[0]) > table.timeBeforeYouCanRebuyMin :
  88. +                        serialsToDelete[player_serial] = player_serial;                              
  89. +                for serial in serialsToDelete:
  90. +                    del table.serial2leavetime[serial]    
  91. +                              
  92. +        self.timer['cleanupSerial2leavetimeTimer'] = reactor.callLater(CLEANUP_SERIAL2LEAVETIME_DELAY, self.cleanupSerial2leavetimeTimer)
  93. +                                
  94.  
  95.      def message(self, string):
  96.          print "PokerService: " + str(string)
  97.  -449,6 +464,7 @@
  98.  
  99.      def shutdown(self):
  100.          self.shutting_down = True
  101. +        self.cancelTimer('cleanupSerial2leavetimeTimer')
  102.          self.cancelTimer('checkTourney')
  103.          self.cancelTimer('updateTourney')
  104.          self.cancelTimer('messages')
  105.  -1905,6 +1921,7 @@
  106.                                              name = "anonymous",
  107.                                              url= "random",
  108.                                              outfit = "random",
  109. +                                            tables_max = -1,
  110.                                              # FIXME_PokerPlayerInfoLocale:
  111.                                              # (see also sr #2262 )
  112.                                              # this sets locale but
  113.  -1920,19 +1937,20 @@
  114.              return placeholder
  115.  
  116.          cursor = self.db.cursor()
  117. -        sql = ( "select locale,name,skin_url,skin_outfit from users where serial = " + str(serial) )
  118. +        sql = ( "select locale,name,skin_url,skin_outfit,tables_max from users where serial = " + str(serial) )
  119.          cursor.execute(sql)
  120.          if cursor.rowcount != 1:
  121.              self.error("getPlayerInfo(%d) expected one row got %d" % ( serial, cursor.rowcount ))
  122.              return placeholder
  123. -        (locale,name,skin_url,skin_outfit) = cursor.fetchone()
  124. +        (locale,name,skin_url,skin_outfit,tables_max) = cursor.fetchone()
  125.          if skin_outfit == None:
  126.              skin_outfit = "random"
  127.          cursor.close()
  128.          packet = PacketPokerPlayerInfo(serial = serial,
  129.                                         name = name,
  130.                                         url = skin_url,
  131. -                                       outfit = skin_outfit)
  132. +                                       outfit = skin_outfit,
  133. +                                       tables_max = tables_max)
  134.          # pokerservice generally provides playerInfo() internally to
  135.          # methods like pokeravatar.(re)?login.  Since this is the central
  136.          # internal location where the query occurs, we hack in the locale
  137. Index: pokernetwork/pokeravatar.py
  138. ===================================================================
  139. --- pokernetwork/pokeravatar.py (révision 6259)
  140. +++ pokernetwork/pokeravatar.py (copie de travail)
  141.  -131,6 +131,7 @@
  142.          self.user.privilege = User.REGULAR
  143.          self.user.url = player_info.url
  144.          self.user.outfit = player_info.outfit
  145. +        self.user.tablesMax = player_info.tables_max
  146.          self._setDefaultLocale(player_info.locale)
  147.  
  148.          if self.explain:
  149.  -140,10 +141,11 @@
  150.          self.loginTableUpdates(serial)
  151.      
  152.      def login(self, info):
  153. -        (serial, name, privilege) = info
  154. +        (serial, name, privilege, tables_max) = info
  155.          self.user.serial = serial
  156.          self.user.name = name
  157.          self.user.privilege = privilege
  158. +        self.user.tablesMax = tables_max
  159.  
  160.          player_info = self.service.getPlayerInfo(serial)
  161.          self.user.url = player_info.url
  162.  -224,6 +226,9 @@
  163.      def getName(self):
  164.          return self.user.name
  165.  
  166. +    def getTablesMax(self):
  167. +        return self.user.tablesMax
  168. +
  169.      def getUrl(self):
  170.          return self.user.url
  171.  
  172.  -1061,7 +1066,8 @@
  173.              return PacketPokerPlayerInfo(serial = self.getSerial(),
  174.                                           name = self.getName(),
  175.                                           url = self.user.url,
  176. -                                         outfit = self.user.outfit)
  177. +                                         outfit = self.user.outfit,
  178. +                                         tables_max = self.user.tablesMax)
  179.          else:
  180.              return PacketError(code = PacketPokerGetPlayerInfo.NOT_LOGGED,
  181.                                 message = "Not logged in",
  182. Index: pokernetwork/pokertable.py
  183. ===================================================================
  184. --- pokernetwork/pokertable.py  (révision 6259)
  185. +++ pokernetwork/pokertable.py  (copie de travail)
  186.  -35,6 +35,7 @@
  187.  from types import *
  188.  from string import split, join
  189.  import time
  190. +import datetime
  191.  import traceback
  192.  
  193.  from pokerengine.pokergame import PokerGameServer, history2messages
  194.  -132,6 +133,14 @@
  195.          self.cache = self.createCache()
  196.          self.owner = 0
  197.          self.avatar_collection = PokerAvatarCollection("Table%d" % id, factory.verbose)
  198. +        self.timeBeforeYouCanRebuyMinProps = settings.headerGetProperties("/server/time-before-you-can-rebuy-min")
  199. +        self.isTimeBeforeYouCanRebuyMin= False                
  200. +        if len(self.timeBeforeYouCanRebuyMinProps) != 0:
  201. +            if self.timeBeforeYouCanRebuyMinProps[0].get("activate") == "yes":
  202. +                self.isTimeBeforeYouCanRebuyMin= True
  203. +                self.timeBeforeYouCanRebuyMin = int (self.timeBeforeYouCanRebuyMinProps[0].get("period", 1800))
  204. +            
  205. +        self.serial2leavetime = {} # key : serial ; value : [ time , money ]
  206.          self.timer_info = {
  207.              "playerTimeout": None,
  208.              "playerTimeoutSerial": 0,
  209.  -973,6 +982,9 @@
  210.              #
  211.              # If not on a closed table, stand up
  212.              #
  213. +            if(not self.game.isTournament() and self.isTimeBeforeYouCanRebuyMin and (self.game.minMoney() < self.game.serial2player[serial].money)):
  214. +                self.serial2leavetime[serial] = [ seconds() , self.game.serial2player[serial].money ]      
  215. +                      
  216.              if self.isOpen():
  217.                  if avatar.removePlayer(self, serial):
  218.                      self.seated2observer(avatar)
  219.  -1193,12 +1205,25 @@
  220.              return False
  221.  
  222.          # Next, test to see if joining this table will cause the avatar to
  223. -        # exceed the maximum permitted by the server.
  224. -        if len(avatar.tables) >= self.factory.simultaneous:
  225. +        # exceed the maximum permitted by the server
  226. +        clientTablesLen = len(avatar.tables)
  227. +        if clientTablesLen >= self.factory.simultaneous:        
  228.              if self.factory.verbose:
  229.                  self.error("joinPlayer: %d seated at %d tables (max %d)" % ( serial, len(avatar.tables), self.factory.simultaneous ))
  230. +            avatar.sendPacketVerbose(PacketPokerError(message = "You have reached the maximum number of tables available by the server (%d)" % (self.factory.simultaneous ),
  231. +                                                      code=100 ))                                
  232.              return False
  233. +        
  234. +        # Next, test to see if joining this table will cause the avatar to
  235. +        # exceed the maximum permitted by the maximum specified for him
  236. +        if avatar.getTablesMax() != -1 and clientTablesLen >= avatar.getTablesMax():      
  237. +            if self.factory.verbose:
  238. +                self.error("joinPlayer: %d seated at %d tables (specific user max %d)" % ( serial, len(avatar.tables), avatar.getTablesMax()))                                        
  239. +            avatar.sendPacketVerbose(PacketPokerError(message = "You have reached the maximum number of tables available with your access (%d)" % (avatar.getTablesMax() ),
  240. +                                                      code=101 ))                                                                        
  241. +            return False
  242.  
  243. +
  244.          #
  245.          # Player is now an observer, unless he is seated
  246.          # at the table.
  247.  -1335,6 +1360,18 @@
  248.              self.error("player %d already payed the buy-in" % avatar.getSerial())
  249.              return False
  250.  
  251. +        if self.isTimeBeforeYouCanRebuyMin and self.serial2leavetime.has_key(avatar.getSerial()):    
  252. +            diff = seconds() - self.serial2leavetime[avatar.getSerial()][0]
  253. +            if (  diff  < self.timeBeforeYouCanRebuyMin  ) and self.serial2leavetime[avatar.getSerial()][1] > amount :
  254. +                rest = self.timeBeforeYouCanRebuyMin - diff
  255. +                if self.factory.verbose:
  256. +                    self.error("player %d can't for the next %d secondes buyin less than %d " % (avatar.getSerial(), rest, self.serial2leavetime[avatar.getSerial()][1] ) )
  257. +                avatar.sendPacketVerbose(PacketPokerError(message = "You can't for the next %d secondes buyin less than %d " % (rest, self.serial2leavetime[avatar.getSerial()][1] ),
  258. +                                                          code=102 ))              
  259. +                return False
  260. +            else:
  261. +                del self.serial2leavetime[avatar.getSerial()]
  262. +                
  263.          amount = self.factory.buyInPlayer(avatar.getSerial(), game.id, self.currency_serial, max(amount, game.buyIn()))
  264.          return avatar.setMoney(self, amount)
  265.          
  266. Index: pokernetwork/pokerauth.py
  267. ===================================================================
  268. --- pokernetwork/pokerauth.py   (révision 6259)
  269. +++ pokernetwork/pokerauth.py   (copie de travail)
  270.  -52,11 +52,12 @@
  271.  
  272.      def auth(self, name, password):
  273.          cursor = self.db.cursor()
  274. -        cursor.execute("SELECT serial, password, privilege FROM users "
  275. +        cursor.execute("SELECT serial, password, privilege, tables_max FROM users "
  276.                         "WHERE name = '%s'" % name)
  277.          numrows = int(cursor.rowcount)
  278.          serial = 0
  279.          privilege = User.REGULAR
  280. +        tables_max = -1
  281.          if numrows <= 0:
  282.              if self.auto_create_account:
  283.                  if self.verbose > 1:
  284.  -73,13 +74,13 @@
  285.              cursor.close()
  286.              return ( False, "Invalid login or password" )
  287.          else:
  288. -            (serial, password_sql, privilege) = cursor.fetchone()
  289. +            (serial, password_sql, privilege, tables_max) = cursor.fetchone()
  290.              cursor.close()
  291.              if password_sql != password:
  292.                  self.message("password mismatch for %s" % name)
  293.                  return ( False, "Invalid login or password" )
  294.  
  295. -        return ( (serial, name, privilege), None )
  296. +        return ( (serial, name, privilege, tables_max), None )
  297.  
  298.      def userCreate(self, name, password):
  299.          if self.verbose:
  300. Index: pokernetwork/user.py
  301. ===================================================================
  302. --- pokernetwork/user.py        (révision 6259)
  303. +++ pokernetwork/user.py        (copie de travail)
  304.  -73,6 +73,7 @@
  305.          self.url = "random"
  306.          self.outfit = "random"
  307.          self.privilege = None
  308. +        self.tablesMax = -1
  309.  
  310.      def logout(self):
  311.          self.serial = 0
  312.  -80,6 +81,7 @@
  313.          self.url = "random"
  314.          self.outfit = "random"
  315.          self.privilege = None
  316. +        self.tablesMax = -1
  317.          
  318.      def isLogged(self):
  319.          return not self.serial == 0
  320. Index: tests/test-pokeravatar.py.in
  321. ===================================================================
  322. --- tests/test-pokeravatar.py.in        (révision 6259)
  323. +++ tests/test-pokeravatar.py.in        (copie de travail)
  324.  -1170,7 +1170,7 @@
  325.      def playerInfoUnpriv(self, (client, packet)):
  326.          return self.pingThenExpectPrivilegeFailure((client, packet),
  327.              PacketPokerPlayerInfo(serial= client.getSerial(), name = "The Naked Guy",
  328. -                                  outfit = "Naked", url = "http://example.org"))
  329. +                                  outfit = "Naked", url = "http://example.org", tables_max = -1))
  330.      # -------------------------------------------------------------------------
  331.      def test17_4_tourneyTourneyRegisterUnpriv(self):
  332.          self.createClients(1)
  333.  -1206,7 +1206,7 @@
  334.                                'packet':
  335.                                PacketPokerPlayerInfo(serial = someoneElseSerial,
  336.                                        name = "YOU_BEEN_CRACKED",
  337. -                                      url = "http://example.com/myhack", outfit = "Naked") },
  338. +                                      url = "http://example.com/myhack", outfit = "Naked", tables_max = -1) },
  339.              'player_image' : { 'output' :
  340.                                 "%sattempt to set player image%s" \
  341.                                     % (messageStart, forPlayerByPlayer),
  342.  -1789,7 +1789,8 @@
  343.          avatar.handlePacketLogic(PacketPokerPlayerInfo(serial= client.getSerial(),
  344.                                                         name = "The Naked Guy",
  345.                                                         outfit = "Naked",
  346. -                                                       url = "http://example.org"))
  347. +                                                       url = "http://example.org",
  348. +                                                       tables_max = -1))
  349.          found = False
  350.          for packet in avatar.resetPacketsQueue():
  351.              if packet.type == PACKET_POKER_PLAYER_INFO:
  352.  -1821,7 +1822,8 @@
  353.          avatar.handlePacketLogic(PacketPokerPlayerInfo(serial= client.getSerial(),
  354.                                                         name = "The Naked Guy",
  355.                                                         outfit = "Naked",
  356. -                                                       url = "http://example.org"))
  357. +                                                       url = "http://example.org",
  358. +                                                       tables_max = -1))
  359.          found = False
  360.          for packet in avatar.resetPacketsQueue():
  361.              if packet.type == PACKET_ERROR:
  362.  -2240,7 +2242,7 @@
  363.          avatar0 = self.service.avatars[0]
  364.          avatar0.logout()
  365.          table.observers.append(avatar0)
  366. -        avatar0.login((4, "user0", 32767))
  367. +        avatar0.login((4, "user0", 32767, -1))
  368.          avatar0.queuePackets()
  369.          count = 0
  370.          for packet in avatar0.resetPacketsQueue():
  371.  -2295,7 +2297,7 @@
  372.          avatar0 = self.service.avatars[0]
  373.          avatar0.logout()
  374.          table.observers.append(avatar0)
  375. -        avatar0.login((4, "user0", 32767))
  376. +        avatar0.login((4, "user0", 32767,-1))
  377.          avatar0.queuePackets()
  378.          count = 0
  379.          for packet in avatar0.resetPacketsQueue():
  380.  -4036,6 +4038,7 @@
  381.              mpiSelf.outfit = "naked"
  382.              mpiSelf.locale = 'mylocale'
  383.              mpiSelf.name = 'Doyle Brunson'
  384. +            mpiSelf.tables_max = -1
  385.      class MockService:
  386.          def __init__(msSelf):
  387.              msSelf.verbose = 6
  388. Index: tests/test-pokerclient.py.in
  389. ===================================================================
  390. --- tests/test-pokerclient.py.in        (révision 6259)
  391. +++ tests/test-pokerclient.py.in        (copie de travail)
  392.  -1097,7 +1097,8 @@
  393.          client.handlePlayerInfo(PacketPokerPlayerInfo(name = "test",
  394.                                                    url = "http://thatisone/",
  395.                                                    outfit = "Stablize",
  396. -                                                  serial = client.getSerial()))
  397. +                                                  serial = client.getSerial(),
  398. +                                                  tables_max = -1))
  399.          if forceCrash:
  400.              self.assertEquals(get_messages(),
  401.                                ['ERROR *CRITICAL*: PACKET_POKER_PLAYER_INFO: may enter loop packet.url = http://thatisone/\n url = http://thatistwo\n url_check = http://thatisthree\npacket.outfit = Stablize\n outfit = Stablize\n outfit_check = Stablize'])
  402.  -1141,7 +1142,8 @@
  403.          client.handlePlayerInfo(PacketPokerPlayerInfo(name = "test",
  404.                                                    url = "http://stable/",
  405.                                                    outfit = "OutfitOne",
  406. -                                                  serial = client.getSerial()))
  407. +                                                  serial = client.getSerial(),
  408. +                                                  tables_max = -1))
  409.          if forceCrash:
  410.              self.assertEquals(get_messages(),
  411.                                ['ERROR *CRITICAL*: PACKET_POKER_PLAYER_INFO: may enter loop packet.url = http://stable/\n url = http://stable/\n url_check = http://stable/\npacket.outfit = OutfitOne\n outfit = OutfitTwo\n outfit_check = OutfitThree'])
  412. Index: tests/conf/poker.server.xml.in
  413. ===================================================================
  414. --- tests/conf/poker.server.xml.in      (révision 6259)
  415. +++ tests/conf/poker.server.xml.in      (copie de travail)
  416.  -8,6 +8,8 @@
  417.         chat="yes" >
  418.  
  419.    <delays autodeal="3" round="2" position="1" showdown="5" finish="3" />
  420. +    <!-- remaining buy-in -->
  421. +  <remaining-buy-in activate="yes" period="1800" />
  422.    
  423.    <table name="One"    variant="holdem" betting_structure="2-4-limit" seats="10" timeout="60" custom_money="0" />
  424.    <table name="Two"    variant="holdem" betting_structure="10-15-limit" seats="10" timeout="60" custom_money="0" />
  425. Index: tests/test-pokertable.py.in
  426. ===================================================================
  427. --- tests/test-pokertable.py.in (révision 6259)
  428. +++ tests/test-pokertable.py.in (copie de travail)
  429.  -62,6 +62,8 @@
  430.  <server verbose="4" autodeal="yes" max_missed_round="5">
  431.    <delays autodeal_tournament_min="2" autodeal="2" autodeal_max="2" autodeal_check="0" round="0" position="0" showdown="0" finish="0" />
  432.  
  433. +  <time-before-you-can-rebuy-min activate="yes" period="1" />
  434. +  
  435.    <path>@POKER_ENGINE_PKGSYSCONFDIR@ @POKER_NETWORK_PKGSYSCONFDIR@</path>
  436.    <users temporary="BOT"/>
  437.  </server>
  438.  -70,6 +72,8 @@
  439.  <server verbose="4" autodeal="no" >
  440.    <delays autodeal_tournament_min="2" autodeal="2" autodeal_max="2" autodeal_check="0" round="0" position="0" showdown="0" finish="0" />
  441.  
  442. +  <time-before-you-can-rebuy-min activate="yes" period="1" />
  443. +  
  444.    <decks>
  445.      <deck>9c 9d 9h Ts Tc Td Th Ts Jc Jd Jh Js Qc Qd Qh Qs Kc Kd Kh Ks Ac Ad Ah As</deck>
  446.    </decks>
  447.  -152,6 +156,9 @@
  448.          self.joined_max = 1000
  449.          self.chat_messages = []
  450.  
  451. +    def setSimultaneous(self, tables_max):
  452. +        self.simultaneous = tables_max
  453. +        
  454.      def getMissedRoundMax(self):
  455.          return 5  # if you change this, change it in settings_xml above
  456.  
  457.  -330,6 +337,7 @@
  458.          self.user = MockClient.User()
  459.          self.testObject = testObject
  460.          self.reasonExpected = expectedReason
  461. +        self.tables_max = -1
  462.  
  463.      def __str__(self):
  464.          return "MockClient of Player%d" % self.serial
  465.  -414,7 +422,15 @@
  466.                  self.name = self.player.getName()
  467.                  self.url = "http://fake"
  468.                  self.outfit = None
  469. +                self.tables_max = -1
  470.          return MockPlayerInfo(self)
  471. +                
  472. +    def getTablesMax(self):
  473. +        return self.tables_max  
  474. +        
  475. +    def setTablesMax(self, table_max):
  476. +        self.tables_max = table_max        
  477. +            
  478.  
  479.  if verbose < 0: redirect_messages(MockClient)
  480.  
  481.  -654,9 +670,18 @@
  482.  
  483.          self.assertEqual(True, self.table.rebuyPlayerRequest(player[5], \
  484.                                                self.table.game.maxBuyIn()))
  485. -        # finally, player5 tries to join table 2, which isn't permitted since
  486. +        # now, player5 tries to join table 2, which isn't permitted since
  487.          # we've set MockService.simultaneous to 1
  488.          self.assertEqual(False, self.table2.joinPlayer(player[5], 5))
  489. +        
  490. +        # finally, apply simultaneous = 2, player5 tries to join table 2, which isn't permitted since
  491. +        # we've set tablesMax for specific user to 1      
  492. +        self.service.setSimultaneous(2)
  493. +        player[5].setTablesMax(1)
  494. +        self.assertEqual(False, self.table2.joinPlayer(player[5], 5))  
  495. +        player[5].setTablesMax(2)  
  496. +        self.assertEqual(True, self.table2.joinPlayer(player[5], 5))    
  497. +        
  498.      # -------------------------------------------------------------------
  499.      def test08_2_brokenSeatFactory(self):
  500.          player = self.createPlayer(1, False)
  501.  -1427,6 +1452,17 @@
  502.          self.tableSave = self.table
  503.  
  504.          return deferredMustBeCalledBackForSuccess
  505. +    # -------------------------------------------------------------------    
  506. +    def test47_timeBeforeYouCanRebuyMin(self):
  507. +        # note : createPlayer apply maxBuyIn
  508. +        p = self.createPlayer(1)
  509. +        self.table.quitPlayer(p, 1)
  510. +        self.table.joinPlayer(p, p.serial)
  511. +        self.table.seatPlayer(p, p.serial, -1)
  512. +        if self.table.game.isTournament() == False:
  513. +            self.assertEqual(False,self.table.buyInPlayer(p, self.table.game.minMoney()))
  514. +            self.assertEqual(True,self.table.buyInPlayer(p, self.table.game.maxBuyIn()))
  515. +                    
  516.  # -------------------------------------------------------------------
  517.  
  518.  # I seriously considered not having *all* the same tests run with
  519.  -1846,6 +1882,11 @@
  520.          """SKIP THIS TEST IN THIS SUBCLASS
  521.          """
  522.          return True
  523. +    # -------------------------------------------------------------------    
  524. +    def test47_timeBeforeYouCanRebuyMin(self):
  525. +        """SKIP THIS TEST IN THIS SUBCLASS
  526. +        """
  527. +        return True          
  528.  # --------------------------------------------------------------------------------
  529.  class MockServiceWithUserStats(MockService):
  530.      def __init__(self, settings):
  531. Index: tests/test-pokerservice.py.in
  532. ===================================================================
  533. --- tests/test-pokerservice.py.in       (révision 6259)
  534. +++ tests/test-pokerservice.py.in       (copie de travail)
  535.  -68,6 +68,7 @@
  536.  from pokernetwork.pokertable  import PokerAvatarCollection
  537.  from MySQLdb.cursors import DictCursor
  538.  
  539. +from twisted.python.runtime import seconds
  540.  
  541.  class ConstantDeckShuffler:
  542.      def shuffle(self, what):
  543.  -221,9 +222,9 @@
  544.              cursor.execute("INSERT INTO users (name, password, created) VALUES ('user%d', 'password%d', 0)" % ( user_number, user_number ))
  545.              self.assertEqual(1, cursor.rowcount)
  546.  
  547. -        ( (self.user1_serial, name, privilege), message ) = self.service.auth("user1", "password1", "role1")
  548. -        ( (self.user2_serial, name, privilege), message ) = self.service.auth("user2", "password2", "role1")
  549. -        ( (self.user3_serial, name, privilege), message ) = self.service.auth("user3", "password3", "role1")
  550. +        ( (self.user1_serial, name, privilege, tables_max), message ) = self.service.auth("user1", "password1", "role1")
  551. +        ( (self.user2_serial, name, privilege, tables_max), message ) = self.service.auth("user2", "password2", "role1")
  552. +        ( (self.user3_serial, name, privilege, tables_max), message ) = self.service.auth("user3", "password3", "role1")
  553.  
  554.          for user_number in (self.user1_serial, self.user2_serial, self.user3_serial):
  555.              if self.default_money > 0 and user_number == self.user3_serial:
  556.  -1321,7 +1322,7 @@
  557.      # ----------------------------------------------------------------
  558.      def test01_auth(self):
  559.          self.service.startService()
  560. -        ( (serial, name, privilege), message ) = self.service.auth("user1", "password1", "role1")
  561. +        ( (serial, name, privilege, tables_max), message ) = self.service.auth("user1", "password1", "role1")
  562.          self.assertEquals(None, message)
  563.          self.assertEquals(4, serial)
  564.          self.assertEquals("user1", name)
  565.  -1344,9 +1345,9 @@
  566.                  return "user1"
  567.  
  568.          self.service.startService()
  569. -        ( (serial, name, privilege), message ) = self.service.auth("user1", "password1", sets.Set('role1'))
  570. +        ( (serial, name, privilege, tables_max), message ) = self.service.auth("user1", "password1", sets.Set('role1'))
  571.          self.service.avatar_collection.add(serial, Client())
  572. -        ( (serial, name, privilege), message ) = self.service.auth("user1", "password1", sets.Set('role1'))
  573. +        ( (serial, name, privilege, tables_max), message ) = self.service.auth("user1", "password1", sets.Set('role1'))
  574.          self.assertEquals(None, message)
  575.          self.assertEquals("user1", name)
  576.  
  577.  -1984,7 +1985,7 @@
  578.      def test_refill(self):
  579.          self.service.startService()
  580.          refill = 10000
  581. -        ( (serial, name, privilege), message ) = self.service.auth("user1", "password1", "role1")
  582. +        ( (serial, name, privilege, tables_max), message ) = self.service.auth("user1", "password1", "role1")
  583.          self.assertEquals(0, self.service.autorefill(serial))
  584.          table_money = 1000
  585.          table_serial = 200
  586.  -4497,7 +4498,7 @@
  587.                          found = True
  588.                          break
  589.                  cursorSelf.rowcount = 1
  590. -                cursorSelf.row = ('ourlocal','ourname','ourskinurl',None)
  591. +                cursorSelf.row = ('ourlocal','ourname','ourskinurl',None,-1)
  592.                  self.failUnless(found)
  593.                  return cursorSelf.rowcount
  594.              def fetchone(cursorSelf): return cursorSelf.row
  595.  -4519,6 +4520,7 @@
  596.          self.assertEquals(pack.name, 'ourname')
  597.          self.assertEquals(pack.url, 'ourskinurl')
  598.          self.assertEquals(pack.outfit, 'random')
  599. +        self.assertEquals(pack.tables_max, -1)
  600.  
  601.          self.service.db = oldDb
  602.      # ----------------------------------------------------------------
  603.  -5324,6 +5326,7 @@
  604.          self.assertEquals(packet.name, "anonymous")
  605.          self.assertEquals(packet.url, "random")
  606.          self.assertEquals(packet.outfit, "random")
  607. +        self.assertEquals(packet.tables_max, -1)
  608.          # FIXME_PokerPlayerInfoLocale: (see also sr #2262 )
  609.          # PokerService.getPlayerInfo() sends locale argument when creating
  610.          # the PokerPlayerInfo() packet, but that argument is not used.
  611.  -5339,7 +5342,7 @@
  612.                  self.failUnless(sql.find("serial = 235") > 0, "serial wrong")
  613.              def __init__(cursorSelf):
  614.                  MockCursorBase.__init__(cursorSelf, self,
  615. -                                      ["select locale,name,skin_url,skin_outfit from users"])
  616. +                                      ["select locale,name,skin_url,skin_outfit,tables_max from users"])
  617.          self.service = pokerservice.PokerService(self.settings)
  618.  
  619.          oldDb = self.service.db
  620.  -5354,6 +5357,7 @@
  621.          self.assertEquals(packet.name, "anonymous")
  622.          self.assertEquals(packet.url, "random")
  623.          self.assertEquals(packet.outfit, "random")
  624. +        self.assertEquals(packet.tables_max, -1)
  625.          # FIXME_PokerPlayerInfoLocale: (see also sr #2262 )
  626.          # PokerService.getPlayerInfo() sends locale argument when creating
  627.          # the PokerPlayerInfo() packet, but that argument is not used.
  628.  -6231,7 +6235,31 @@
  629.          self.assertEquals(get_messages(), [])
  630.  
  631.          clear_all_messages()
  632. -        return deferredMessageCheck
  633. +        return deferredMessageCheck        
  634. +    # ----------------------------------------------------------------    
  635. +    def test69_cleanupSerial2leavetimeTimer(self):
  636. +        pokerservice.CLEANUP_SERIAL2LEAVETIME_DELAY = 0
  637. +        self.service = pokerservice.PokerService(self.settings)        
  638. +
  639. +        class MockTable:
  640. +            def __init__(mgSelf):
  641. +                mgSelf.id = 7775
  642. +                mgSelf.timeBeforeYouCanRebuyMin = 0
  643. +                mgSelf.serial2leavetime = {100: {0:seconds()} }                
  644. +
  645. +        ourTable  = MockTable()
  646. +        class MockGame:
  647. +            def __init__(mgSelf):
  648. +                mgSelf.id = 7775
  649. +
  650. +        ourTable.game = MockGame()
  651. +        self.service.tables = { 7775: ourTable }
  652. +        
  653. +        self.assertEquals(len(self.service.tables[7775].serial2leavetime),1)  
  654. +        self.service.cleanupSerial2leavetimeTimer()  
  655. +        self.assertEquals(len(self.service.tables[7775].serial2leavetime),0)      
  656. +        
  657. +        self.service.cancelTimer('cleanupSerial2leavetimeTimer')                
  658.  ##############################################################################
  659.  class SSLContextFactoryCoverage(unittest.TestCase):
  660.      # ----------------------------------------------------------------
  661. Index: tests/poker.server.xml
  662. ===================================================================
  663. --- tests/poker.server.xml      (révision 6259)
  664. +++ tests/poker.server.xml      (copie de travail)
  665.  -6,6 +6,8 @@
  666.      verbose="3"
  667.      chat="yes" >
  668.  
  669. +  <time-before-you-can-rebuy-min activate="yes" period="1800" />
  670. +
  671.    <delays autodeal="3" round="2" position="1" showdown="7" finish="3" />
  672.    
  673.    <table name="Fourty" variant="7stud" betting_structure="ante-5-10-limit" seats="8" player_timeout="60" custom_money="0" />
  674. Index: tests/test-tourneytablebalance.py.in
  675. ===================================================================
  676. --- tests/test-tourneytablebalance.py.in        (révision 6259)
  677. +++ tests/test-tourneytablebalance.py.in        (copie de travail)
  678.  -121,6 +121,7 @@
  679.                  miSelf.name =  "PLAYER INFO: %d" % self.serial
  680.                  miSelf.url  = "http://example.org"
  681.                  miSelf.outfit  = "naked"
  682. +                miSelf.tables_max = -1
  683.          return MockInfo()
  684.  
  685.      def sendPacket(self, packet):
  686. Index: tests/test-pokerauth.py.in
  687. ===================================================================
  688. --- tests/test-pokerauth.py.in  (révision 6259)
  689. +++ tests/test-pokerauth.py.in  (copie de travail)
  690.  -149,7 +149,7 @@
  691.          auth = pokerauth.get_auth_instance(db, settings)
  692.  
  693.          clear_all_messages()
  694. -        self.assertEquals(auth.auth('joe_schmoe', 'foo'), ((4, 'joe_schmoe', 1), None))
  695. +        self.assertEquals(auth.auth('joe_schmoe', 'foo'), ((4, 'joe_schmoe', 1, -1), None))
  696.          self.assertEquals(get_messages(), ['user joe_schmoe does not exist, create it',
  697.                                         'creating user joe_schmoe', 'create user with serial 4'])
  698.          self.failUnless(len(self.checkIfUserExistsInDB('joe_schmoe')) == 1)
  699.  -174,6 +174,7 @@
  700.          cursor.execute("""CREATE TABLE users (
  701.             serial int unsigned not null auto_increment,
  702.             name varchar(32), password varchar(32), privilege int default 1,
  703. +           tables_max int default -1,     
  704.              primary key (serial))""")
  705.          for ii in [ 1 , 2 ]:
  706.              cursor.execute("INSERT INTO users (name, password) values ('%s', '%s')" %
  707.  -198,7 +199,7 @@
  708.          auth = pokerauth.get_auth_instance(self.db, self.settings)
  709.  
  710.          clear_all_messages()
  711. -        self.assertEquals(auth.auth('dan_harrington', 'bar'), ((4L, 'dan_harrington', 1L), None))
  712. +        self.assertEquals(auth.auth('dan_harrington', 'bar'), ((4L, 'dan_harrington', 1L, -1), None))
  713.          self.assertEquals(get_messages(), [])
  714.  
  715.          clear_all_messages()
  716. Index: database/1.7.5-2.0.0.sql
  717. ===================================================================
  718. --- database/1.7.5-2.0.0.sql    (révision 6259)
  719. +++ database/1.7.5-2.0.0.sql    (copie de travail)
  720.  -1,3 +1,11 @@
  721. +UPDATE server SET version = '2.0.0';
  722. +
  723.  -- resthost must persist
  724.  ALTER table resthost ENGINE=MyIsam;
  725.  ALTER table route ENGINE=MyIsam;
  726. +
  727. +
  728. +-- max tables allowed , no check if -1
  729. +ALTER TABLE `users` ADD `tables_max` INT DEFAULT '-1';
  730. +
  731. +
  732. Index: database/schema.sql.in
  733. ===================================================================
  734. --- database/schema.sql.in      (révision 6259)
  735. +++ database/schema.sql.in      (copie de travail)
  736.  -60,13 +60,15 @@
  737.    password VARCHAR(32),
  738.    -- 1 is a regular player, 0 is an observer and cannot play, 2 is admin
  739.    privilege INT DEFAULT 1,
  740. +  -- max tables allowed , no check if -1
  741. +  tables_max INT DEFAULT -1,    
  742.    -- locale
  743.    locale VARCHAR(32) DEFAULT "en_US",
  744.  
  745.    rating INT DEFAULT 1000,
  746.    future_rating FLOAT DEFAULT 1000,
  747.    games_count INT DEFAULT 0,
  748. -  
  749. +    
  750.    PRIMARY KEY (serial),
  751.    KEY name_idx (name),
  752.    UNIQUE KEY email_idx (email)