fox9        04/11/06 22:37:43

  Modified:    module/gostop ai.py gostop.py
  Log:
  ΰ - ¦ ´ и  
  
  Revision  Changes    Path
  1.2       +24 -2     siminserver/module/gostop/ai.py
  
  Index: ai.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/module/gostop/ai.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ai.py	2 Nov 2004 17:56:41 -0000	1.1
  +++ ai.py	6 Nov 2004 13:37:42 -0000	1.2
  @@ -11,8 +11,30 @@
   
   	def do_turn(self):
   
  -		data = self.game.users.get_cardlist(self.game.currentuser)
  -		card = int(data[0])
  +		# ʽ ī尡   ϴ 
  +		flag = False
  +		cardlist = self.game.users.get_cardlist(self.game.currentuser)
  +		card = cardlist[0]
  +		
  +		for tempcard in cardlist:
  +			if self.game.cards.get_special(tempcard) == self.game.cards.SPECIAL_BONUS:
  +				card = tempcard
  +				flag = True
  +				break
  +
  +		if not flag:
  +			# ʽ ī尡 ٸ  ¦ ´ ī带 ã´
  +			for tempcard in cardlist:
  +				cardgroup = self.game.cards.get_group(tempcard)
  +				for temptablecard in self.game.tablecard:
  +					if cardgroup == self.game.cards.get_group(temptablecard):
  +						flag = True
  +						card = tempcard
  +						break
  +
  +				if flag:
  +					break
  +					
   
   		if self.game.mode == self.game.MODE_NORMAL:
   			# ź ˻
  
  
  
  1.5       +1 -0      siminserver/module/gostop/gostop.py
  
  Index: gostop.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/module/gostop/gostop.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- gostop.py	5 Nov 2004 14:09:26 -0000	1.4
  +++ gostop.py	6 Nov 2004 13:37:42 -0000	1.5
  @@ -590,6 +590,7 @@
   
   		self.send_all(self.CODE_BONUS, struct.pack("B", card))
   		self.send(user, self.CODE_BONUSGET, struct.pack("B", dummy))
  +		self.send(user, self.CODE_TURN, "")
   		
   		if self.is_chongtong(user):
   			print ""
  
  
  


exman       04/11/07 14:13:30

  Modified:    .        run.py
  Log:
  ClientList Ŭ (ClientItem ) ʱ ڵ
  ClientItem Ŭ ( ó  IO) ʱ ڵ
  Select   ӿ ʱ ڵ
  
  Revision  Changes    Path
  1.2       +100 -0    siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- run.py	2 Nov 2004 17:56:41 -0000	1.1
  +++ run.py	7 Nov 2004 05:13:29 -0000	1.2
  @@ -4,14 +4,114 @@
   
   
   # daemonrize
  +"""
   from lib.daemonrize import run
   run()
   
   # logsetting
   from lib.logset import run
   run()
  +"""
   
   # read config
   # config parse -> fork
   # load moduloe
   
  +from socket import *
  +import select
  +
  +s = socket(AF_INET, SOCK_STREAM)
  +s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) 
  +s.bind(('', 1234))
  +s.listen(5)
  +
  +
  +import struct
  +class ClientItem:
  +    """
  +Ŷ  ()
  +MajorCode(UChar)-MinorCode(UChar)-Length(UShort)-Data(until recv Length)
  +    """
  +    def __init__(self, fd):
  +        self.fd = fd
  +        # Ŷ 
  +        self.buffer = ''
  +        #   Ŷ ޴ ƴ... 
  +        self.gettingPacket = False
  +    def buffer(self):
  +        return self.buffer
  +    def getProtocolList(self):
  +        self.ret = []
  +        if self.gettingPacket==False:
  +            while  True:
  +                if len(self.buffer)==0:
  +                    break
  +                if len(self.buffer)>=4:
  +                    major, minor, length = struct.unpack('BBH', self.buffer[:4])
  +                    if len(self.buffer[4:])>=length:
  +                        data = self.buffer[4:4+length]
  +                        self.ret.append((major, minor, length, data))
  +                        self.buffer = self.buffer[4+length:]
  +                        continue
  +                    else:
  +                        self.gettingPacket = True
  +                        break
  +                else:
  +                    self.gettingPacket = True
  +                    break
  +        return self.ret
  +
  +    def buffer(self):
  +            return None
  +    def addBuffer(self, buf):
  +        self.buffer=self.buffer+buf
  +        if len(self.buffer)>=4:
  +            major, minor, length = struct.unpack('BBH', self.buffer[:4])
  +            if len(self.buffer[4:])>=length:
  +                self.gettingPacket = False
  +
  +    
  +class ClientList:
  +    def __init__(self):
  +        self.list = {} 
  +    def addClient(self, fd):
  +        self.list[fd] = ClientItem(fd)
  +    def fdList(self):
  +        return self.list.keys()
  +    def removeClient(self, fd):
  +        del self.list[fd]
  +    def client(self, fd):
  +        return self.list[fd]
  +
  +
  +# Server fd  
  +SERVERFDS = [s.fileno()]
  +CLIENTS = ClientList()
  +
  +
  +while 1:
  +    r, w, o =  select.select(SERVERFDS, [], [], 0.1)
  +    if r: #  Ŭ̾Ʈ 
  +        c, a = s.accept()
  +        CLIENTS.addClient(c.fileno())
  +        continue
  +
  +    # Ŭ̾Ʈ IO ó
  +    r, w, o =  select.select(CLIENTS.fdList(), [], [], 0.1)
  +    for fd in r:
  +        buf = os.read(fd, 4096)
  +        if len(buf)==0: # client  
  +            # Ŭ̾Ʈ 
  +            CLIENTS.removeClient(fd)
  +            continue
  +
  +        client = CLIENTS.client(fd)
  +        client.addBuffer(buf)
  +        for major, minor, length, data in client.getProtocolList():
  +            print major, minor, length
  +            if major==0x01: # login
  +                pass
  +            elif major==0x02: # lobby
  +                pass
  +            elif major==0x03: # gostop
  +                pass
  
  
  


exman       04/11/07 14:13:30

  Modified:    lib      logset.py
  Removed:     lib      __init__.pyc logset.pyc
  Log:
  ClientList Ŭ (ClientItem ) ʱ ڵ
  ClientItem Ŭ ( ó  IO) ʱ ڵ
  Select   ӿ ʱ ڵ
  
  Revision  Changes    Path
  1.2       +3 -3      siminserver/lib/logset.py
  
  Index: logset.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/logset.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- logset.py	2 Nov 2004 17:56:41 -0000	1.1
  +++ logset.py	7 Nov 2004 05:13:30 -0000	1.2
  @@ -4,6 +4,6 @@
   
   
   def run():
  -	fp = open('log/stdout.err.log','a')
  -	sys.stdout = fp
  -	sys.stderr = fp
  +    fp = open('log/stdout.err.log','a')
  +    sys.stdout = fp
  +    sys.stderr = fp
  
  
  


fox9        04/11/08 19:51:53

  Modified:    module/gostop ai.py gostop.py test.py
  Log:
  .  Ǿ  ߰
  . ׽Ʈ α׷ /   ߰
  . ׽Ʈ α׷     ߰
  .ai ī  ó  
  
  Revision  Changes    Path
  1.3       +3 -0      siminserver/module/gostop/ai.py
  
  Index: ai.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/module/gostop/ai.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ai.py	6 Nov 2004 13:37:42 -0000	1.2
  +++ ai.py	8 Nov 2004 10:51:53 -0000	1.3
  @@ -14,6 +14,9 @@
   		# ʽ ī尡   ϴ 
   		flag = False
   		cardlist = self.game.users.get_cardlist(self.game.currentuser)
  +		if len(cardlist) == 0:
  +			return
  +		
   		card = cardlist[0]
   		
   		for tempcard in cardlist:
  
  
  
  1.6       +7 -0      siminserver/module/gostop/gostop.py
  
  Index: gostop.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/module/gostop/gostop.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- gostop.py	6 Nov 2004 13:37:42 -0000	1.5
  +++ gostop.py	8 Nov 2004 10:51:53 -0000	1.6
  @@ -45,6 +45,7 @@
   		self.MODE_NORMAL = 0
   		self.MODE_SELECT = 1
   		self.MODE_GOSTOP = 2
  +		self.MODE_END    = 3
   		self.mode = self.MODE_NORMAL
   
   		# ׼  (Ϲ, , ź)
  @@ -73,6 +74,7 @@
   		self.CODE_BONUSGET = 5
   		self.CODE_CARD  = 6
   		self.CODE_SELECT = 7
  +		self.CODE_GOSTOP = 8
   
   		# ޼ 
   		self.msgaction = 0
  @@ -369,6 +371,7 @@
   		if self.get_currentpoint(user) >= self.GOSTOP_POINT:
   			# SEND / 
   			self.mode = self.MODE_GOSTOP
  +			self.send(user, self.CODE_GOSTOP, "")
   			return
   		
   		self.set_nextuser()
  @@ -782,6 +785,10 @@
   			#  
   
   			# Ÿ  
  +
  +		# Ǿ ߰
  +		if len(self.tablecard) == 0:
  +			self.get_othercard(user, 1)
   			
   		self.completion_turn(user) #  Ų
   
  
  
  
  1.4       +35 -5     siminserver/module/gostop/test.py
  
  Index: test.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/module/gostop/test.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- test.py	5 Nov 2004 14:09:26 -0000	1.3
  +++ test.py	8 Nov 2004 10:51:53 -0000	1.4
  @@ -36,6 +36,8 @@
   			self.client.mode = self.game.MODE_NORMAL
   			self.process_start(data)
   		elif minor == self.game.CODE_END:
  +			print "  "
  +			self.client.mode = self.game.MODE_END
   			#self.client.draw_end()
   			pass
   		elif minor == self.game.CODE_TURN:
  @@ -55,6 +57,11 @@
   			self.client.mode = self.game.MODE_NORMAL
   			self.process_card(data)
   			self.client.oldtablecard = self.game.tablecard
  +		elif minor == self.game.CODE_GOSTOP: #    
  +			self.client.mode = self.game.MODE_GOSTOP
  +			if self.type == "com": # ǻ 
  +				print " "
  +				self.game.ai.do_turn()
   		else:
   			print "Ÿ "
   
  @@ -250,6 +257,11 @@
   		self.draw_text("2", 330, 180)
   
   		self.draw_text("Select Card", 200, 280)
  +
  +	def draw_gostop(self):
  +		self.screen.fill(self.yellow, [150, 170, 260, 160])
  +
  +		self.draw_text("1 = Go, 2 = Stop", 200, 300)
   		
   	def draw_askbomb(self):
   		self.screen.fill(self.yellow, [150, 170, 260, 160])
  @@ -268,7 +280,10 @@
   			self.draw_text("1 = Shake, 2 = Bomb, 0 = Normal", 200, 300)
   		
   	def draw_end(self):
  -		self.draw_modalress("Game Over!!!!", [300, 300, 200, 200], 50, 50)
  +		self.screen.fill(self.yellow, [150, 170, 260, 160])
  +
  +		self.draw_text("Game Over!!!!", 200, 300)
  +		#self.draw_modalress("Game Over!!!!", [300, 300, 200, 200], 50, 50)
   		
   	def draw_backcard(self, x, y):
   		img_rect = self.img_back.get_rect()
  @@ -379,6 +394,9 @@
   		if self.askbomb != 0:
   			self.draw_askbomb()
   
  +		if self.mode == self.game.MODE_GOSTOP:
  +			self.draw_gostop()
  +
   		if self.game.status == self.game.STATUS_END:
   			self.draw_end()
   			
  @@ -398,14 +416,16 @@
   				if event.type == pygame.QUIT:
   					sys.exit(0)
   				elif event.type == pygame.KEYDOWN:
  +					print "Ű "
  +					if event.key == pygame.K_ESCAPE:
  +						sys.exit(0)
  +							
   					if self.game.status != self.game.STATUS_GAME:
  -						self.game.do_process(self.user1, self.game.ACTION_START)
  +						self.game.do_process(self.game.currentuser, self.game.ACTION_START)
   				
   					else:
  -						if event.key == pygame.K_ESCAPE:
  -							sys.exit(0)
  -
   						if self.game.currentuser == self.user1:
  +							
   							if self.game.mode == self.game.MODE_NORMAL:
   								if self.askbomb != 0:
   									data = -1
  @@ -453,6 +473,16 @@
   
   								if data > -1:
   									self.game.do_process(self.user1, self.game.ACTION_NORMAL, self.matchcard[data])
  +							elif self.game.mode == self.game.MODE_GOSTOP:
  +								data = -1
  +								if event.key == pygame.K_1:
  +									data = self.game.ACTION_GO
  +								elif event.key == pygame.K_2:
  +									data = self.game.ACTION_STOP
  +
  +								if data > -1:
  +									self.game.do_process(self.user1, data)
  +
   
   			self.update()
   			pygame.display.flip()
  
  
  


exman       04/11/09 20:22:19

  Modified:    .        run.py
  Log:
  ClientList/ClientItem 
  
  Revision  Changes    Path
  1.3       +83 -7     siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- run.py	7 Nov 2004 05:13:29 -0000	1.2
  +++ run.py	9 Nov 2004 11:22:19 -0000	1.3
  @@ -12,7 +12,6 @@
   from lib.logset import run
   run()
   """
  -
   # read config
   # config parse -> fork
   # load moduloe
  @@ -20,6 +19,9 @@
   from socket import *
   import select
   
  +sys.path.append("lib")
  +sys.path.append("module")
  +
   s = socket(AF_INET, SOCK_STREAM)
   s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) 
   s.bind(('', 1234))
  @@ -38,6 +40,59 @@
           self.buffer = ''
           #   Ŷ ޴ ƴ... 
           self.gettingPacket = False
  +
  +        #  
  +        self.auth = False
  +        # info
  +        self.id = ""
  +        self.nick = ""
  +        self.name = ""
  +        self.email = ""
  +        self.money = 0
  +		self.version = ""
  +		# handler
  +		self.handler = None
  +	def id(self):
  +		return self.id
  +	def setId(self, id):
  +		self.id = id
  +	def nick(self):
  +		return self.nick
  +	def setNick(self, nick):
  +		self.nick = nick 
  +	def name(self):
  +		return self.name
  +	def setName(self, name):
  +		self.name = name
  +	def email(self):
  +		return self.email
  +	def setEmail(self, email):
  +		self.email = email
  +	def money(self):
  +		return self.money
  +	def setMoney(self, money):
  +		self.money = money
  +	def version(self):
  +		return self.money
  +	def setVersion(self, version):
  +		self.version = version
  +
  +    def setAuth(self):
  +        self.auth = True
  +    def isAuth(self):
  +        return self.auth
  +
  +	def handler(self):
  +		return self.handler
  +	def setHandler(self, handler):
  +		self.handler = handler
  +
  +	def event(self, major, minor, length, data):
  +		if self.handler!=None:
  +			self.handler.event(major, minor, length, data)
  +		else:
  +			raise "Not assigned client handler"
  +
       def buffer(self):
           return self.buffer
       def getProtocolList(self):
  @@ -52,6 +107,7 @@
                           data = self.buffer[4:4+length]
                           self.ret.append((major, minor, length, data))
                           self.buffer = self.buffer[4+length:]
  +                        print "buffer 缳"
                           continue
                       else:
                           self.gettingPacket = True
  @@ -59,6 +115,7 @@
                   else:
                       self.gettingPacket = True
                       break
  +        print "after getProtocolList"; print self.hexdump()
           return self.ret
   
       def buffer(self):
  @@ -69,6 +126,22 @@
               major, minor, length = struct.unpack('BBH', self.buffer[:4])
               if len(self.buffer[4:])>=length:
                   self.gettingPacket = False
  +        print "after addBuffer"
  +        print self.gettingPacket
  +        print self.hexdump()
  +    def hexdump(self):
  +        i=0
  +        ret = ""
  +        for x in self.buffer:
  +            ret = ret + "%02X " % ord(x)
  +            i += 1
  +            if i%4==0:
  +                ret = ret+" "
  +            if i%16==0:
  +                ret = ret+"\n"
  +        return ret
  +
  +            
   
       
   class ClientList:
  @@ -93,6 +166,7 @@
       r, w, o =  select.select(SERVERFDS, [], [], 0.1)
       if r: #  Ŭ̾Ʈ 
           c, a = s.accept()
  +        print "add Client"
           CLIENTS.addClient(c.fileno())
           continue
   
  @@ -102,6 +176,7 @@
           buf = os.read(fd, 4096)
           if len(buf)==0: # client  
               # Ŭ̾Ʈ 
  +            print "remove Client"
               CLIENTS.removeClient(fd)
               continue
   
  @@ -109,9 +184,10 @@
           client.addBuffer(buf)
           for major, minor, length, data in client.getProtocolList():
               print major, minor, length
  -            if major==0x01: # login
  -                pass
  -            elif major==0x02: # lobby
  -                pass
  -            elif major==0x03: # gostop
  -                pass
  +            if client.handler() == None:
  +                if major==0x02: # gostop
  +                    import gostop
  +                    client.setHandler(gostop.createHandler())
  +                elif major==0x03: # another game
  +                    pass
  +            client.event(major, minor, length, data)
  
  
  


exman       04/11/10 01:07:44

  Log:
  Directory /cvsroot/simin/siminserver/test added to the repository


exman       04/11/10 01:18:55

  Modified:    .        run.py
  Log:
  Lobby   - login 
  
  Revision  Changes    Path
  1.4       +87 -58    siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- run.py	9 Nov 2004 11:22:19 -0000	1.3
  +++ run.py	9 Nov 2004 16:18:55 -0000	1.4
  @@ -29,6 +29,8 @@
   
   
   import struct
  +import xmlrpclib
  +
   class ClientItem:
       """
   Ŷ  ()
  @@ -43,55 +45,69 @@
   
           #  
           self.auth = False
  +        self.auth_try = 0
           # info
           self.id = ""
           self.nick = ""
           self.name = ""
           self.email = ""
           self.money = 0
  -		self.version = ""
  -		# handler
  -		self.handler = None
  -	def id(self):
  -		return self.id
  -	def setId(self, id):
  -		self.id = id
  -	def nick(self):
  -		return self.nick
  -	def setNick(self, nick):
  -		self.nick = nick 
  -	def name(self):
  -		return self.name
  -	def setName(self, name):
  -		self.name = name
  -	def email(self):
  -		return self.email
  -	def setEmail(self, email):
  -		self.email = email
  -	def money(self):
  -		return self.money
  -	def setMoney(self, money):
  -		self.money = money
  -	def version(self):
  -		return self.money
  -	def setVersion(self, version):
  -		self.version = version
  +        self.version = ""
  +
  +    def fileno(self):
  +        return self.fd
  +    def write(self, major, minor, data):
  +        self._write(struct.pack("B", major))
  +        self._write(struct.pack("B", minor))
  +        self._write(struct.pack("H", len(data)))
  +        self._write(data)
  +    def _write(self, buffer):
  +        return os.write(self.fd, buffer)
  +
  +    def id(self):
  +        return self.id
  +    def setId(self, id):
  +        self.id = id
  +    def nick(self):
  +        return self.nick
  +    def setNick(self, nick):
  +        self.nick = nick 
  +    def name(self):
  +        return self.name
  +    def setName(self, name):
  +        self.name = name
  +    def email(self):
  +        return self.email
  +    def setEmail(self, email):
  +        self.email = email
  +    def money(self):
  +        return self.money
  +    def setMoney(self, money):
  +        self.money = money
  +    def version(self):
  +        return self.money
  +    def setVersion(self, version):
  +        self.version = version
   
  -    def setAuth(self):
  -        self.auth = True
       def isAuth(self):
           return self.auth
  -
  -	def handler(self):
  -		return self.handler
  -	def setHandler(self, handler):
  -		self.handler = handler
  -
  -	def event(self, major, minor, length, data):
  -		if self.handler!=None:
  -			self.handler.event(major, minor, length, data)
  -		else:
  -			raise "Not assigned client handler"
  +    def login(self, id, password):
  +        """
  +        RETURN:
  +            0x00 
  +            0x01 
  +            0x02 : 3̻  н
  +        """
  +        if self.auth_try>=3:
  +            return 0x02
  +        s = xmlrpclib.Server("http://simin.h-9.net/RPC/")
  +        ret = s.auth.login(id, password)
  +        if ret['code']=='00':
  +            self.auth = True
  +            return 0x00
  +        else: 
  +            self.auth_try += 1
  +            return 0x01
   
       def buffer(self):
           return self.buffer
  @@ -141,10 +157,7 @@
                   ret = ret+"\n"
           return ret
   
  -            
  -
  -    
  -class ClientList:
  +class Lobby:
       def __init__(self):
           self.list = {} 
       def addClient(self, fd):
  @@ -155,11 +168,33 @@
           del self.list[fd]
       def client(self, fd):
           return self.list[fd]
  +    def event(self, client):
  +        for major, minor, length, data in client.getProtocolList():
  +            print "Client Event %d %d %d" % (major, minor, length)
  +            if not client.isAuth():
  +                if major==0x01: # Lobby
  +                    if minor==0x00: # version check
  +                        pass
  +                    elif minor==0x01: # login
  +                        p = 0
  +                        l = struct.unpack("B", data[p])[0]; p+=1
  +                        id = data[p:p+l]; p+=l
  +                        l = struct.unpack("B", data[p])[0]; p+=1
  +                        password = data[p:p+l]; p+=l
  +                        print id, password
  +                        if client.login(id, password)==0x00: # success
  +                            print "success"
  +                            client.write(0x01, 0xA1, struct.pack("B", 0x00))
  +                        else:                   # fail
  +                            print "fail"
  +                            client.write(0x01, 0xA1, struct.pack("B", 0x01))
  +            else:
  +                pass
   
   
   # Server fd  
   SERVERFDS = [s.fileno()]
  -CLIENTS = ClientList()
  +LOBBY = Lobby()
   
   
   while 1:
  @@ -167,27 +202,21 @@
       if r: #  Ŭ̾Ʈ 
           c, a = s.accept()
           print "add Client"
  -        CLIENTS.addClient(c.fileno())
  +        LOBBY.addClient(c.fileno())
           continue
   
       # Ŭ̾Ʈ IO ó
  -    r, w, o =  select.select(CLIENTS.fdList(), [], [], 0.1)
  +    r, w, o =  select.select(LOBBY.fdList(), [], [], 0.1)
       for fd in r:
           buf = os.read(fd, 4096)
           if len(buf)==0: # client  
               # Ŭ̾Ʈ 
               print "remove Client"
  -            CLIENTS.removeClient(fd)
  +            LOBBY.removeClient(fd)
               continue
   
  -        client = CLIENTS.client(fd)
  +        client = LOBBY.client(fd)
           client.addBuffer(buf)
  -        for major, minor, length, data in client.getProtocolList():
  -            print major, minor, length
  -            if client.handler() == None:
  -                if major==0x02: # gostop
  -                    import gostop
  -                    client.setHandler(gostop.createHandler())
  -                elif major==0x03: # another game
  -                    pass
  -            client.event(major, minor, length, data)
  +
  +        # event
  +        LOBBY.event(client)
  
  
  


exman       04/11/10 01:18:55

  Added:       test     logintest.py
  Log:
  Lobby   - login 
  
  Revision  Changes    Path
  1.1                  siminserver/test/logintest.py
  
  Index: logintest.py
  ===================================================================
  from socket import *
  import struct
  import md5
  id="exman"
  password=md5.md5("1234").hexdigest()
  print id
  print password
  
  s=socket(AF_INET, SOCK_STREAM); s.connect(('',1234))
  s.send(struct.pack("<BBH", 1, 1, len(id)+len(password)+2))
  s.send(struct.pack("<B", len(id)))
  s.send(id)
  s.send(struct.pack("<B", len(password)))
  s.send(password)
  
  print s.recv(1024)
  
  
  
  


exman       04/11/10 22:45:13

  Modified:    .        run.py
  Log:
   Ȳ ߻ Ŭ̾Ʈ   ̺Ʈ  ϵ Ʈ
  
  Revision  Changes    Path
  1.5       +46 -30    siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- run.py	9 Nov 2004 16:18:55 -0000	1.4
  +++ run.py	10 Nov 2004 13:45:13 -0000	1.5
  @@ -36,15 +36,16 @@
   Ŷ  ()
   MajorCode(UChar)-MinorCode(UChar)-Length(UShort)-Data(until recv Length)
       """
  -    def __init__(self, fd):
  +    def __init__(self, lobby, fd):
           self.fd = fd
  +        self.lobby = lobby
           # Ŷ 
           self.buffer = ''
           #   Ŷ ޴ ƴ... 
           self.gettingPacket = False
   
           #  
  -        self.auth = False
  +        self.isAuth = False
           self.auth_try = 0
           # info
           self.id = ""
  @@ -57,12 +58,27 @@
       def fileno(self):
           return self.fd
       def write(self, major, minor, data):
  -        self._write(struct.pack("B", major))
  -        self._write(struct.pack("B", minor))
  -        self._write(struct.pack("H", len(data)))
  -        self._write(data)
  +        length = len(data)
  +        sendsize = 0
  +        packet = struct.pack("BBH", major, minor, length)
  +        while sendsize<3:
  +            ret = self._write(packet[sendsize:])
  +            if ret<0: return -1
  +            sendsize += ret
  +        sendsize = 0
  +        while sendsize<length:
  +            ret = self._write(data[sendsize:])
  +            if ret<0: return -1
  +            sendsize += ret
  +
       def _write(self, buffer):
  -        return os.write(self.fd, buffer)
  +        ret = -1
  +        try:
  +            ret = os.write(self.fd, buffer)
  +        except OSError, v:
  +            print "Client Closed: ", v
  +            self.lobby.addErrorOccurredClient(self.fd)
  +        return ret
   
       def id(self):
           return self.id
  @@ -89,25 +105,10 @@
       def setVersion(self, version):
           self.version = version
   
  -    def isAuth(self):
  -        return self.auth
  -    def login(self, id, password):
  -        """
  -        RETURN:
  -            0x00 
  -            0x01 
  -            0x02 : 3̻  н
  -        """
  -        if self.auth_try>=3:
  -            return 0x02
  -        s = xmlrpclib.Server("http://simin.h-9.net/RPC/")
  -        ret = s.auth.login(id, password)
  -        if ret['code']=='00':
  -            self.auth = True
  -            return 0x00
  -        else: 
  -            self.auth_try += 1
  -            return 0x01
  +    def auth(self):
  +        return self.isAuth
  +    def setAuth(self):
  +        self.isAuth = True
   
       def buffer(self):
           return self.buffer
  @@ -160,18 +161,27 @@
   class Lobby:
       def __init__(self):
           self.list = {} 
  +        self.rpc = xmlrpclib.Server("http://simin.h-9.net/RPC/")
  +        self.errorClientList = []
       def addClient(self, fd):
  -        self.list[fd] = ClientItem(fd)
  +        self.list[fd] = ClientItem(self, fd)
       def fdList(self):
           return self.list.keys()
       def removeClient(self, fd):
  +        if fd in self.errorClientList:
  +            self.errorClientList.remove(fd)
           del self.list[fd]
       def client(self, fd):
           return self.list[fd]
  +    def addErrorOccurredClient(self, fd):
  +        if fd not in self.errorClientList:
  +            self.errorClientList.append(fd)
  +    def errorOccurredClients(self):
  +        return self.errorClientList
       def event(self, client):
           for major, minor, length, data in client.getProtocolList():
               print "Client Event %d %d %d" % (major, minor, length)
  -            if not client.isAuth():
  +            if not client.auth():
                   if major==0x01: # Lobby
                       if minor==0x00: # version check
                           pass
  @@ -182,10 +192,12 @@
                           l = struct.unpack("B", data[p])[0]; p+=1
                           password = data[p:p+l]; p+=l
                           print id, password
  -                        if client.login(id, password)==0x00: # success
  +
  +                        ret = self.rpc.auth.login(id, password)
  +                        if ret['code']=='00': # success
                               print "success"
                               client.write(0x01, 0xA1, struct.pack("B", 0x00))
  -                        else:                   # fail
  +                        else: 
                               print "fail"
                               client.write(0x01, 0xA1, struct.pack("B", 0x01))
               else:
  @@ -198,6 +210,10 @@
   
   
   while 1:
  +    for fd in LOBBY.errorOccurredClients():
  +        print "remove Client by errorOccurredClient list", fd
  +        LOBBY.removeClient(fd)
  +
       r, w, o =  select.select(SERVERFDS, [], [], 0.1)
       if r: #  Ŭ̾Ʈ 
           c, a = s.accept()
  
  
  


exman       04/11/10 22:45:13

  Modified:    test     logintest.py
  Log:
   Ȳ ߻ Ŭ̾Ʈ   ̺Ʈ  ϵ Ʈ
  
  Revision  Changes    Path
  1.2       +35 -11    siminserver/test/logintest.py
  
  Index: logintest.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/logintest.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- logintest.py	9 Nov 2004 16:18:55 -0000	1.1
  +++ logintest.py	10 Nov 2004 13:45:13 -0000	1.2
  @@ -1,17 +1,41 @@
   from socket import *
   import struct
   import md5
  -id="exman"
  -password=md5.md5("1234").hexdigest()
  -print id
  -print password
   
  -s=socket(AF_INET, SOCK_STREAM); s.connect(('',1234))
  -s.send(struct.pack("<BBH", 1, 1, len(id)+len(password)+2))
  -s.send(struct.pack("<B", len(id)))
  -s.send(id)
  -s.send(struct.pack("<B", len(password)))
  -s.send(password)
  +def hexdump(buffer):
  +    i=0
  +    ret = ""
  +    for x in buffer:
  +        ret = ret + "%02X " % ord(x)
  +        i += 1
  +        if i%4==0:
  +            ret = ret+" "
  +        if i%16==0:
  +            ret = ret+"\n"
  +    print ret
  +
   
  -print s.recv(1024)
  +def login(s, id, password):
  +    password=md5.md5(password).hexdigest()
  +    print id
  +    print password
  +    s.send(struct.pack("<BBH", 1, 1, len(id)+len(password)+2))
  +    s.send(struct.pack("<B", len(id)))
  +    s.send(id)
  +    s.send(struct.pack("<B", len(password)))
  +    s.send(password)
  +    packet = ""
  +    while True:
  +        packet = packet + s.recv(1)
  +        if len(packet)>=4:
  +            m, n, l = struct.unpack('BBH', packet[:4])
  +            for x in range(l):
  +                packet = packet + s.recv(1)
  +            break
  +    hexdump(packet)
  +    m,n,l,d = struct.unpack("<BBHB", packet)
  +    print d
   
  +s=socket(AF_INET, SOCK_STREAM); s.connect(('',1234))
  +while True:
  +    login(s, "exman", "a")
  
  
  


exman       04/11/10 22:51:23

  Modified:    test     logintest.py
  Log:
  
  
  Revision  Changes    Path
  1.3       +1 -1      siminserver/test/logintest.py
  
  Index: logintest.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/logintest.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- logintest.py	10 Nov 2004 13:45:13 -0000	1.2
  +++ logintest.py	10 Nov 2004 13:51:23 -0000	1.3
  @@ -38,4 +38,4 @@
   
   s=socket(AF_INET, SOCK_STREAM); s.connect(('',1234))
   while True:
  -    login(s, "exman", "a")
  +    login(s, "exman", "1234")
  
  
  


exman       04/11/10 23:57:59

  Modified:    .        run.py
  Log:
  lib/protocol.py  Major/Minor Code   
  
  Revision  Changes    Path
  1.6       +8 -5      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- run.py	10 Nov 2004 13:45:13 -0000	1.5
  +++ run.py	10 Nov 2004 14:57:59 -0000	1.6
  @@ -30,6 +30,7 @@
   
   import struct
   import xmlrpclib
  +from lib.protocol import *
   
   class ClientItem:
       """
  @@ -182,10 +183,10 @@
           for major, minor, length, data in client.getProtocolList():
               print "Client Event %d %d %d" % (major, minor, length)
               if not client.auth():
  -                if major==0x01: # Lobby
  -                    if minor==0x00: # version check
  +                if major==M_LOBBY: # Lobby
  +                    if minor==REQEST_LOBBY_VERSIONCHECK: # version check
                           pass
  -                    elif minor==0x01: # login
  +                    elif minor==REQEST_LOBBY_LOGIN: # login
                           p = 0
                           l = struct.unpack("B", data[p])[0]; p+=1
                           id = data[p:p+l]; p+=l
  @@ -196,10 +197,12 @@
                           ret = self.rpc.auth.login(id, password)
                           if ret['code']=='00': # success
                               print "success"
  -                            client.write(0x01, 0xA1, struct.pack("B", 0x00))
  +                            client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  +                                                    struct.pack("B", 0x00))
                           else: 
                               print "fail"
  -                            client.write(0x01, 0xA1, struct.pack("B", 0x01))
  +                            client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  +                                                    struct.pack("B", 0x01))
               else:
                   pass
   
  
  
  


exman       04/11/10 23:57:59

  Added:       lib      protocol.py
  Log:
  lib/protocol.py  Major/Minor Code   
  
  Revision  Changes    Path
  1.1                  siminserver/lib/protocol.py
  
  Index: protocol.py
  ===================================================================
  M_RESERVATION                               = 0x00
  M_LOBBY                                     = 0x01
  M_GAME_RESERVATION                          = 0x10
  M_GAME_GOSTOP                               = 0x11
  
  # Minor code in M_LOBBY
  # Request ========================================
  REQEST_LOBBY_VERSIONCHECK                   = 0x01
  REQEST_LOBBY_LOGIN                          = 0x02
  REQEST_LOBBY_CLIENTLIST                     = 0x03
  
  REQEST_LOBBY_CREATE_GAMEROOM                = 0x04
  REQEST_LOBBY_MODIFY_GAMEROOM                = 0x05
  REQEST_LOBBY_DELETE_GAMEROOM                = 0x06
  
  REQEST_LOBBY_JOIN_GAMEROOM                  = 0x07
  REQEST_LOBBY_PART_RESERVATION_GAMEROOM      = 0x08
  REQEST_LOBBY_PART_GAMEROOM                  = 0x09
  
  # Response =======================================
  RESPONSE_LOBBY_VERSIONCHECK                 = 0xA1
  RESPONSE_LOBBY_LOGIN                        = 0xA2
  RESPONSE_LOBBY_CLIENTLIST                   = 0xA3
  
  RESPONSE_LOBBY_CREATE_GAMEROOM              = 0xA4
  RESPONSE_LOBBY_MODIFY_GAMEROOM              = 0xA5
  RESPONSE_LOBBY_DELETE_GAMEROOM              = 0xA6
  
  RESPONSE_LOBBY_JOIN_GAMEROOM                = 0xA7
  RESPONSE_LOBBY_PART_RESERVATION_GAMEROOM    = 0xA8
  RESPONSE_LOBBY_PART_GAMEROOM                = 0xA9
  # Notificaton ====================================
  NOTIFY_LOBBY_JOIN_CLIENT                    = 0x51
  NOTIFY_LOBBY_PART_CLIENT                    = 0x52
  
  NOTIFY_LOBBY_ADD_GAMEROOM                   = 0x54
  NOTIFY_LOBBY_MOD_GAMEROOM                   = 0x55
  NOTIFY_LOBBY_DEL_GAMEROOM                   = 0x56
  
  NOTIFY_LOBBY_JOIN_GAMEROOM                  = 0x57
  NOTIFY_LOBBY_PART_RESERVATION_GAMEROOM      = 0x58
  NOTIFY_LOBBY_PART_GAMEROOM                  = 0x59
  
  
  


exman       04/11/10 23:57:59

  Modified:    test     logintest.py
  Log:
  lib/protocol.py  Major/Minor Code   
  
  Revision  Changes    Path
  1.4       +1 -1      siminserver/test/logintest.py
  
  Index: logintest.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/logintest.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- logintest.py	10 Nov 2004 13:51:23 -0000	1.3
  +++ logintest.py	10 Nov 2004 14:57:59 -0000	1.4
  @@ -19,7 +19,7 @@
       password=md5.md5(password).hexdigest()
       print id
       print password
  -    s.send(struct.pack("<BBH", 1, 1, len(id)+len(password)+2))
  +    s.send(struct.pack("<BBH", 0x01, 0x02, len(id)+len(password)+2))
       s.send(struct.pack("<B", len(id)))
       s.send(id)
       s.send(struct.pack("<B", len(password)))
  
  
  


exman       04/11/11 00:10:18

  Modified:    lib      protocol.py
  Log:
  protocol.py 
  
  Revision  Changes    Path
  1.2       +29 -24    siminserver/lib/protocol.py
  
  Index: protocol.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/protocol.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- protocol.py	10 Nov 2004 14:57:59 -0000	1.1
  +++ protocol.py	10 Nov 2004 15:10:18 -0000	1.2
  @@ -4,39 +4,44 @@
   M_GAME_GOSTOP                               = 0x11
   
   # Minor code in M_LOBBY
  -# Request ========================================
  +# Request (0x00~0x4F) ============================
   REQEST_LOBBY_VERSIONCHECK                   = 0x01
   REQEST_LOBBY_LOGIN                          = 0x02
   REQEST_LOBBY_CLIENTLIST                     = 0x03
   
  -REQEST_LOBBY_CREATE_GAMEROOM                = 0x04
  -REQEST_LOBBY_MODIFY_GAMEROOM                = 0x05
  -REQEST_LOBBY_DELETE_GAMEROOM                = 0x06
  -
  -REQEST_LOBBY_JOIN_GAMEROOM                  = 0x07
  -REQEST_LOBBY_PART_RESERVATION_GAMEROOM      = 0x08
  -REQEST_LOBBY_PART_GAMEROOM                  = 0x09
  +REQEST_LOBBY_CREATE_GAMEROOM                = 0x11
  +REQEST_LOBBY_MODIFY_GAMEROOM                = 0x12
  +REQEST_LOBBY_DELETE_GAMEROOM                = 0x13
   
  -# Response =======================================
  +REQEST_LOBBY_JOIN_GAMEROOM                  = 0x14
  +REQEST_LOBBY_PART_RESERVATION_GAMEROOM      = 0x15
  +REQEST_LOBBY_PART_GAMEROOM                  = 0x16
  +
  +REQEST_LOBBY_SENDMSG_CHAT                   = 0x21
  +
  +# Response (0xA0~0xFF) ===========================
   RESPONSE_LOBBY_VERSIONCHECK                 = 0xA1
   RESPONSE_LOBBY_LOGIN                        = 0xA2
   RESPONSE_LOBBY_CLIENTLIST                   = 0xA3
   
  -RESPONSE_LOBBY_CREATE_GAMEROOM              = 0xA4
  -RESPONSE_LOBBY_MODIFY_GAMEROOM              = 0xA5
  -RESPONSE_LOBBY_DELETE_GAMEROOM              = 0xA6
  -
  -RESPONSE_LOBBY_JOIN_GAMEROOM                = 0xA7
  -RESPONSE_LOBBY_PART_RESERVATION_GAMEROOM    = 0xA8
  -RESPONSE_LOBBY_PART_GAMEROOM                = 0xA9
  -# Notificaton ====================================
  +RESPONSE_LOBBY_CREATE_GAMEROOM              = 0xB1
  +RESPONSE_LOBBY_MODIFY_GAMEROOM              = 0xB2
  +RESPONSE_LOBBY_DELETE_GAMEROOM              = 0xB3
  +
  +RESPONSE_LOBBY_JOIN_GAMEROOM                = 0xB4
  +RESPONSE_LOBBY_PART_RESERVATION_GAMEROOM    = 0xB5
  +RESPONSE_LOBBY_PART_GAMEROOM                = 0xB6
  +
  +# Notificaton (0x50~0x9F) ========================
   NOTIFY_LOBBY_JOIN_CLIENT                    = 0x51
   NOTIFY_LOBBY_PART_CLIENT                    = 0x52
   
  -NOTIFY_LOBBY_ADD_GAMEROOM                   = 0x54
  -NOTIFY_LOBBY_MOD_GAMEROOM                   = 0x55
  -NOTIFY_LOBBY_DEL_GAMEROOM                   = 0x56
  -
  -NOTIFY_LOBBY_JOIN_GAMEROOM                  = 0x57
  -NOTIFY_LOBBY_PART_RESERVATION_GAMEROOM      = 0x58
  -NOTIFY_LOBBY_PART_GAMEROOM                  = 0x59
  +NOTIFY_LOBBY_ADD_GAMEROOM                   = 0x61
  +NOTIFY_LOBBY_MOD_GAMEROOM                   = 0x62
  +NOTIFY_LOBBY_DEL_GAMEROOM                   = 0x63
  +
  +NOTIFY_LOBBY_JOIN_GAMEROOM                  = 0x64
  +NOTIFY_LOBBY_PART_RESERVATION_GAMEROOM      = 0x65
  +NOTIFY_LOBBY_PART_GAMEROOM                  = 0x66
  +
  +NOTIFY_LOBBY_RECVMSG_CHAT                   = 0x21
  
  
  


exman       04/11/11 00:13:07

  Modified:    lib      protocol.py
  Log:
  protocol.py 
  
  Revision  Changes    Path
  1.3       +3 -1      siminserver/lib/protocol.py
  
  Index: protocol.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/protocol.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- protocol.py	10 Nov 2004 15:10:18 -0000	1.2
  +++ protocol.py	10 Nov 2004 15:13:07 -0000	1.3
  @@ -18,6 +18,7 @@
   REQEST_LOBBY_PART_GAMEROOM                  = 0x16
   
   REQEST_LOBBY_SENDMSG_CHAT                   = 0x21
  +REQEST_LOBBY_TOMSG_CHAT                     = 0x22
   
   # Response (0xA0~0xFF) ===========================
   RESPONSE_LOBBY_VERSIONCHECK                 = 0xA1
  @@ -44,4 +45,5 @@
   NOTIFY_LOBBY_PART_RESERVATION_GAMEROOM      = 0x65
   NOTIFY_LOBBY_PART_GAMEROOM                  = 0x66
   
  -NOTIFY_LOBBY_RECVMSG_CHAT                   = 0x21
  +NOTIFY_LOBBY_RECVMSG_CHAT                   = 0x71
  +REQEST_LOBBY_FROMMSG_CHAT                   = 0x72
  
  
  


exman       04/11/12 02:02:56

  Modified:    .        run.py
  Log:
  client list request/response, client join notification 
  
  Revision  Changes    Path
  1.7       +57 -25    siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- run.py	10 Nov 2004 14:57:59 -0000	1.6
  +++ run.py	11 Nov 2004 17:02:55 -0000	1.7
  @@ -32,6 +32,10 @@
   import xmlrpclib
   from lib.protocol import *
   
  +IN_OUTDOOR  = 0
  +IN_LOBBY    = 1
  +IN_GAMEROOM = 2
  +
   class ClientItem:
       """
   Ŷ  ()
  @@ -40,6 +44,7 @@
       def __init__(self, lobby, fd):
           self.fd = fd
           self.lobby = lobby
  +        self.whereis = IN_OUTDOOR
           # Ŷ 
           self.buffer = ''
           #   Ŷ ޴ ƴ... 
  @@ -60,26 +65,23 @@
           return self.fd
       def write(self, major, minor, data):
           length = len(data)
  -        sendsize = 0
           packet = struct.pack("BBH", major, minor, length)
  -        while sendsize<3:
  -            ret = self._write(packet[sendsize:])
  -            if ret<0: return -1
  -            sendsize += ret
  -        sendsize = 0
  -        while sendsize<length:
  -            ret = self._write(data[sendsize:])
  -            if ret<0: return -1
  -            sendsize += ret
  +        if self._write(packet)>0:
  +            self._write(data)
   
       def _write(self, buffer):
           ret = -1
  -        try:
  -            ret = os.write(self.fd, buffer)
  -        except OSError, v:
  -            print "Client Closed: ", v
  -            self.lobby.addErrorOccurredClient(self.fd)
  -        return ret
  +        sendsize = 0
  +        length = len(buffer)
  +        while sendsize<length:
  +            try:
  +                ret = os.write(self.fd, buffer)
  +                sendsize += ret
  +            except OSError, v:
  +                print "Client Closed: ", v
  +                self.lobby.addErrorOccurredClient(self.fd)
  +                return -1
  +        return sendsize
   
       def id(self):
           return self.id
  @@ -110,6 +112,10 @@
           return self.isAuth
       def setAuth(self):
           self.isAuth = True
  +    def moveTo(self, where):
  +        self.whereis = where
  +    def whereis(self):
  +        return self.whereis
   
       def buffer(self):
           return self.buffer
  @@ -125,7 +131,7 @@
                           data = self.buffer[4:4+length]
                           self.ret.append((major, minor, length, data))
                           self.buffer = self.buffer[4+length:]
  -                        print "buffer 缳"
  +                        #print "buffer 缳"
                           continue
                       else:
                           self.gettingPacket = True
  @@ -133,7 +139,7 @@
                   else:
                       self.gettingPacket = True
                       break
  -        print "after getProtocolList"; print self.hexdump()
  +        #print "after getProtocolList"; print self.hexdump()
           return self.ret
   
       def buffer(self):
  @@ -144,9 +150,9 @@
               major, minor, length = struct.unpack('BBH', self.buffer[:4])
               if len(self.buffer[4:])>=length:
                   self.gettingPacket = False
  -        print "after addBuffer"
  -        print self.gettingPacket
  -        print self.hexdump()
  +        #print "after addBuffer"
  +        #print self.gettingPacket
  +        #print self.hexdump()
       def hexdump(self):
           i=0
           ret = ""
  @@ -179,6 +185,10 @@
               self.errorClientList.append(fd)
       def errorOccurredClients(self):
           return self.errorClientList
  +    def notify(self, minor, data):
  +        for c in self.list.values():
  +            if c.whereis()==IN_LOBBY:
  +                client.write(M_LOBBY, minor, data)
       def event(self, client):
           for major, minor, length, data in client.getProtocolList():
               print "Client Event %d %d %d" % (major, minor, length)
  @@ -192,17 +202,31 @@
                           id = data[p:p+l]; p+=l
                           l = struct.unpack("B", data[p])[0]; p+=1
                           password = data[p:p+l]; p+=l
  -                        print id, password
   
                           ret = self.rpc.auth.login(id, password)
                           if ret['code']=='00': # success
  -                            print "success"
  +                            print "%s login successed" % id
  +                            client.moveTo(IN_LOBBY)
                               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                                       struct.pack("B", 0x00))
  +                            # NOTIFY_LOBBY_JOIN_CLIENT
  +                            packet += struct.pack("B", len(client.id()))
  +                            packet += client.id()
  +                            self.notify(NOTIFY_LOBBY_JOIN_CLIENT, packet)
                           else: 
  -                            print "fail"
  +                            print "%s login failed" % id
                               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                                       struct.pack("B", 0x01))
  +                    elif minor==REQEST_LOBBY_CLIENTLIST: 
  +                        packet = ""
  +                        count = 0
  +                        for c in self.list.values():
  +                            if c.whereis()==IN_LOBBY:
  +                                packet += struct.pack("B", len(c.id()))
  +                                packet += c.id()
  +                                count += 1
  +                        packet = struct.pack("H", count) + packet
  +                        client.write(M_LOBBY, RESPONSE_LOBBY_CLIENTLIST, packet)
               else:
                   pass
   
  @@ -225,9 +249,17 @@
           continue
   
       # Ŭ̾Ʈ IO ó
  +    if len(LOBBY.fdList())>0:
  +        print LOBBY.fdList()
       r, w, o =  select.select(LOBBY.fdList(), [], [], 0.1)
       for fd in r:
  -        buf = os.read(fd, 4096)
  +        try:
  +            buf = os.read(fd, 4096)
  +        except OSError:
  +            print "remove Client (reset by peer)"
  +            LOBBY.removeClient(fd)
  +            continue
  +            
           if len(buf)==0: # client  
               # Ŭ̾Ʈ 
               print "remove Client"
  
  
  


exman       04/11/12 02:07:35

  Modified:    .        run.py
  Log:
  client info ϴ κ...ϴ ӽ÷ (ģ  ʿ)
  
  Revision  Changes    Path
  1.8       +9 -0      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- run.py	11 Nov 2004 17:02:55 -0000	1.7
  +++ run.py	11 Nov 2004 17:07:35 -0000	1.8
  @@ -185,6 +185,13 @@
               self.errorClientList.append(fd)
       def errorOccurredClients(self):
           return self.errorClientList
  +    def setUserInfo(self, client, id):
  +        cliet.setId(id)
  +        cliet.setNick(id)
  +        cliet.setName(id)
  +        cliet.setEmail("")
  +        cliet.setMoney(30000)
  +        pass
       def notify(self, minor, data):
           for c in self.list.values():
               if c.whereis()==IN_LOBBY:
  @@ -195,6 +202,7 @@
               if not client.auth():
                   if major==M_LOBBY: # Lobby
                       if minor==REQEST_LOBBY_VERSIONCHECK: # version check
  +                        #client.setVersion(ver...)
                           pass
                       elif minor==REQEST_LOBBY_LOGIN: # login
                           p = 0
  @@ -207,6 +215,7 @@
                           if ret['code']=='00': # success
                               print "%s login successed" % id
                               client.moveTo(IN_LOBBY)
  +                            self.setUserInfo(client, id)
                               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                                       struct.pack("B", 0x00))
                               # NOTIFY_LOBBY_JOIN_CLIENT
  
  
  


exman       04/11/12 03:04:52

  Modified:    .        run.py
  Log:
  ׽Ʈ  ProxyClient ۼ
  
  Revision  Changes    Path
  1.9       +27 -27    siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- run.py	11 Nov 2004 17:07:35 -0000	1.8
  +++ run.py	11 Nov 2004 18:04:52 -0000	1.9
  @@ -44,7 +44,7 @@
       def __init__(self, lobby, fd):
           self.fd = fd
           self.lobby = lobby
  -        self.whereis = IN_OUTDOOR
  +        self._whereis = IN_OUTDOOR
           # Ŷ 
           self.buffer = ''
           #   Ŷ ޴ ƴ... 
  @@ -54,12 +54,12 @@
           self.isAuth = False
           self.auth_try = 0
           # info
  -        self.id = ""
  -        self.nick = ""
  -        self.name = ""
  -        self.email = ""
  -        self.money = 0
  -        self.version = ""
  +        self._id = ""
  +        self._nick = ""
  +        self._name = ""
  +        self._email = ""
  +        self._money = 0
  +        self._version = ""
   
       def fileno(self):
           return self.fd
  @@ -84,38 +84,38 @@
           return sendsize
   
       def id(self):
  -        return self.id
  +        return self._id
       def setId(self, id):
  -        self.id = id
  +        self._id = id
       def nick(self):
  -        return self.nick
  +        return self._nick
       def setNick(self, nick):
  -        self.nick = nick 
  +        self._nick = nick 
       def name(self):
  -        return self.name
  +        return self._name
       def setName(self, name):
  -        self.name = name
  +        self._name = name
       def email(self):
  -        return self.email
  +        return self._email
       def setEmail(self, email):
  -        self.email = email
  +        self._email = email
       def money(self):
  -        return self.money
  +        return self._money
       def setMoney(self, money):
  -        self.money = money
  +        self._money = money
       def version(self):
  -        return self.money
  +        return self._version
       def setVersion(self, version):
  -        self.version = version
  +        self._version = version
   
       def auth(self):
           return self.isAuth
       def setAuth(self):
           self.isAuth = True
       def moveTo(self, where):
  -        self.whereis = where
  +        self._whereis = where
       def whereis(self):
  -        return self.whereis
  +        return self._whereis
   
       def buffer(self):
           return self.buffer
  @@ -186,11 +186,11 @@
       def errorOccurredClients(self):
           return self.errorClientList
       def setUserInfo(self, client, id):
  -        cliet.setId(id)
  -        cliet.setNick(id)
  -        cliet.setName(id)
  -        cliet.setEmail("")
  -        cliet.setMoney(30000)
  +        client.setId(id)
  +        client.setNick(id)
  +        client.setName(id)
  +        client.setEmail("")
  +        client.setMoney(30000)
           pass
       def notify(self, minor, data):
           for c in self.list.values():
  @@ -219,7 +219,7 @@
                               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                                       struct.pack("B", 0x00))
                               # NOTIFY_LOBBY_JOIN_CLIENT
  -                            packet += struct.pack("B", len(client.id()))
  +                            packet = struct.pack("B", len(client.id()))
                               packet += client.id()
                               self.notify(NOTIFY_LOBBY_JOIN_CLIENT, packet)
                           else: 
  
  
  


exman       04/11/12 03:04:52

  Added:       test     proxyclient.py
  Log:
  ׽Ʈ  ProxyClient ۼ
  
  Revision  Changes    Path
  1.1                  siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  #!/usr/bin/env python
  from socket import *
  import cmd, os, signal, sys
  import string, random, time
  import traceback
  from threading import *
  from errno import *
  import struct
  import random
  import md5
  import select
  import sys
  
  sys.path.append('..')
  from lib.protocol import *
  
  
  def hexdump(buffer):
      i=0
      ret = ""
      for x in buffer:
          ret = ret + "%02X " % ord(x)
          i += 1
          if i%4==0:
              ret = ret+" "
          if i%16==0:
              ret = ret+"\n"
      print ret
  
  class serverHandler(Thread):
      def __init__(self, cmd):
          Thread.__init__(self) 
          self.cmd = cmd
          self.sock=None
          self.stop = False
  
      def setSock(self, sock):
          self.sock = sock
      def event(self, major, minor, length, data):
          print major, minor, length
          if major==M_LOBBY:
              if minor==RESPONSE_LOBBY_LOGIN:
                  print "α : %d" % struct.unpack("B", data)
              elif minor==RESPONSE_LOBBY_CLIENTLIST:
                  count = struct.unpack("B", data[0])
                  print " Lobby  : %d" % count
              elif minor==NOTIFY_LOBBY_JOIN_CLIENT:
                  count = struct.unpack("B", data[0])
                  print "  "
          pass
  
      def run(self):
          while not self.stop:
              r, w, o = select.select([self.sock.fileno(),], [], [], 1)
              if not r:
                  continue
              buffer = self.sock.recv(1024)
              if buffer=="":
                  self.stop = True
                  print "   "
                  return
              hexdump(buffer)
              while True:
                  if len(buffer)>=4:
                      major, minor, length = \
                                      struct.unpack('BBH', buffer[:4])
                      if len(buffer[4:])>=length:
                          self.event(major, minor, length, \
                                                  buffer[4:4+length])
                          buffer = buffer[4+length:]
                      else:
                          break
                  else:
                      break
              
  
  class ProxyClient(cmd.Cmd):
      def __init__(self):
          cmd.Cmd.__init__(self)
          self.prompt = "Simin>>> "
          self.intro = """\
  =========================================================\r\n\
   ù ¥ Ŭ̾Ʈ.\r\n\
    ׽Ʈ غô!.\r\n\
  =========================================================\r\n\
  help ԷϽø    ֽϴ. \r\n""" 
          self.sock = None
          self.dir = os.getcwd()+'/'+os.path.dirname(sys.argv[0])
  
          self.do_EOF = self.do_exit
          self.do_bye = self.do_exit
          self.do_quit = self.do_exit
          self.serverHandler = None
      def setServerHandler(self, h):
          self.serverHandler = h
  
      def do_exit(self, arg):
          return True
      def do_login(self, arg):
          """
           & α
          """
          try:
              id, passwd = arg.split(" ")
          except:
              print "Usage: login id passwd"
              return
          if self.sock != None:
              print "̹ α ߽ϴ."
              return
          self.sock = socket(AF_INET, SOCK_STREAM)
          self.sock.connect(('',1234))
          self.serverHandler.setSock(self.sock)
          self.serverHandler.start()
          passwd=md5.md5(passwd).hexdigest()
          self.sock.send(struct.pack("<BBH", 0x01, 0x02, len(id)+len(passwd)+2))
          self.sock.send(struct.pack("<B", len(id)))
          self.sock.send(id)
          self.sock.send(struct.pack("<B", len(passwd)))
          self.sock.send(passwd)
  
  
  m = ProxyClient()
  th = serverHandler(m)
  m.setServerHandler(th)
  try:
      m.cmdloop()
  except:
      a,b,c = sys.exc_info()
      print a
      print b
      print c
  print "\nWait a minute\n"
  th.stop = True
  
  
  


exman       04/11/12 20:48:34

  Modified:    .        run.py
  Log:
  rpc.user.info 
  
  Revision  Changes    Path
  1.10      +2 -1      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- run.py	11 Nov 2004 18:04:52 -0000	1.9
  +++ run.py	12 Nov 2004 11:48:34 -0000	1.10
  @@ -168,7 +168,7 @@
   class Lobby:
       def __init__(self):
           self.list = {} 
  -        self.rpc = xmlrpclib.Server("http://simin.h-9.net/RPC/")
  +        self.rpc = xmlrpclib.Server("http://simin.h-9.net/RPC", verbose=1)
           self.errorClientList = []
       def addClient(self, fd):
           self.list[fd] = ClientItem(self, fd)
  @@ -219,6 +219,7 @@
                               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                                       struct.pack("B", 0x00))
                               # NOTIFY_LOBBY_JOIN_CLIENT
  +                            print self.rpc.user.info(id)
                               packet = struct.pack("B", len(client.id()))
                               packet += client.id()
                               self.notify(NOTIFY_LOBBY_JOIN_CLIENT, packet)
  
  
  


exman       04/11/13 21:03:42

  Modified:    .        run.py
  Log:
  ref count   client ӵǴ  fix
  
  Revision  Changes    Path
  1.11      +12 -8     siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- run.py	12 Nov 2004 11:48:34 -0000	1.10
  +++ run.py	13 Nov 2004 12:03:42 -0000	1.11
  @@ -41,8 +41,10 @@
   Ŷ  ()
   MajorCode(UChar)-MinorCode(UChar)-Length(UShort)-Data(until recv Length)
       """
  -    def __init__(self, lobby, fd):
  -        self.fd = fd
  +    def __init__(self, lobby, sock, addr):
  +        self.sock = sock
  +        self.addr = addr
  +        self.fd = sock.fileno()
           self.lobby = lobby
           self._whereis = IN_OUTDOOR
           # Ŷ 
  @@ -63,6 +65,7 @@
   
       def fileno(self):
           return self.fd
  +
       def write(self, major, minor, data):
           length = len(data)
           packet = struct.pack("BBH", major, minor, length)
  @@ -170,8 +173,9 @@
           self.list = {} 
           self.rpc = xmlrpclib.Server("http://simin.h-9.net/RPC", verbose=1)
           self.errorClientList = []
  -    def addClient(self, fd):
  -        self.list[fd] = ClientItem(self, fd)
  +    def addClient(self, sock, addr):
  +        fd = sock.fileno()
  +        self.list[fd] = ClientItem(self, sock, addr)
       def fdList(self):
           return self.list.keys()
       def removeClient(self, fd):
  @@ -254,13 +258,13 @@
       r, w, o =  select.select(SERVERFDS, [], [], 0.1)
       if r: #  Ŭ̾Ʈ 
           c, a = s.accept()
  -        print "add Client"
  -        LOBBY.addClient(c.fileno())
  +        print "add Client", c.fileno()
  +        LOBBY.addClient(c, a)
           continue
   
       # Ŭ̾Ʈ IO ó
  -    if len(LOBBY.fdList())>0:
  -        print LOBBY.fdList()
  +    if len(LOBBY.fdList())==0:
  +        continue
       r, w, o =  select.select(LOBBY.fdList(), [], [], 0.1)
       for fd in r:
           try:
  
  
  


exman       04/11/13 21:03:43

  Modified:    test     proxyclient.py
  Log:
  ref count   client ӵǴ  fix
  
  Revision  Changes    Path
  1.2       +9 -3      siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- proxyclient.py	11 Nov 2004 18:04:52 -0000	1.1
  +++ proxyclient.py	13 Nov 2004 12:03:42 -0000	1.2
  @@ -40,7 +40,12 @@
           print major, minor, length
           if major==M_LOBBY:
               if minor==RESPONSE_LOBBY_LOGIN:
  -                print "α : %d" % struct.unpack("B", data)
  +                ret = struct.unpack("B", data)
  +                if ret!=0x00:
  +                    self.sock.close()
  +                    self.sock = None
  +                    self.cmd.sock = None
  +                print "α : %d" % ret
               elif minor==RESPONSE_LOBBY_CLIENTLIST:
                   count = struct.unpack("B", data[0])
                   print " Lobby  : %d" % count
  @@ -50,7 +55,7 @@
           pass
   
       def run(self):
  -        while not self.stop:
  +        while not self.stop and self.sock != None:
               r, w, o = select.select([self.sock.fileno(),], [], [], 1)
               if not r:
                   continue
  @@ -111,7 +116,8 @@
           self.sock = socket(AF_INET, SOCK_STREAM)
           self.sock.connect(('',1234))
           self.serverHandler.setSock(self.sock)
  -        self.serverHandler.start()
  +        if not self.serverHandler.isAlive():
  +            self.serverHandler.start()
           passwd=md5.md5(passwd).hexdigest()
           self.sock.send(struct.pack("<BBH", 0x01, 0x02, len(id)+len(passwd)+2))
           self.sock.send(struct.pack("<B", len(id)))
  
  
  


exman       04/11/13 22:03:20

  Modified:    .        run.py
  Log:
  Client  Noti 
  
  Revision  Changes    Path
  1.12      +23 -8     siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- run.py	13 Nov 2004 12:03:42 -0000	1.11
  +++ run.py	13 Nov 2004 13:03:20 -0000	1.12
  @@ -181,6 +181,15 @@
       def removeClient(self, fd):
           if fd in self.errorClientList:
               self.errorClientList.remove(fd)
  +
  +        # NOTIFY_LOBBY__CLIENT
  +        client = self.client(fd)
  +        packet = struct.pack("B", len(client.id()))
  +        packet += client.id()
  +        if client.whereis()==IN_LOBBY:
  +            self.notify(NOTIFY_LOBBY_PART_CLIENT, packet, client)
  +        elif client.whereis()==IN_GAMEROOM:
  +            pass # FIXME
           del self.list[fd]
       def client(self, fd):
           return self.list[fd]
  @@ -190,16 +199,19 @@
       def errorOccurredClients(self):
           return self.errorClientList
       def setUserInfo(self, client, id):
  +        info = self.rpc.user.info(id)
  +        print info
           client.setId(id)
           client.setNick(id)
  -        client.setName(id)
  -        client.setEmail("")
  +        client.setName(info['name'])
  +        client.setEmail(info['email'])
           client.setMoney(30000)
           pass
  -    def notify(self, minor, data):
  +    def notify(self, minor, data, exceptClient=None):
           for c in self.list.values():
               if c.whereis()==IN_LOBBY:
  -                client.write(M_LOBBY, minor, data)
  +                if exceptClient!=c:
  +                    c.write(M_LOBBY, minor, data)
       def event(self, client):
           for major, minor, length, data in client.getProtocolList():
               print "Client Event %d %d %d" % (major, minor, length)
  @@ -219,29 +231,32 @@
                           if ret['code']=='00': # success
                               print "%s login successed" % id
                               client.moveTo(IN_LOBBY)
  +                            client.setAuth()
                               self.setUserInfo(client, id)
                               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                                       struct.pack("B", 0x00))
                               # NOTIFY_LOBBY_JOIN_CLIENT
  -                            print self.rpc.user.info(id)
                               packet = struct.pack("B", len(client.id()))
                               packet += client.id()
  -                            self.notify(NOTIFY_LOBBY_JOIN_CLIENT, packet)
  +                            self.notify(NOTIFY_LOBBY_JOIN_CLIENT, packet, client)
                           else: 
                               print "%s login failed" % id
                               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                                       struct.pack("B", 0x01))
  -                    elif minor==REQEST_LOBBY_CLIENTLIST: 
  +            else:
  +                if major==M_LOBBY: # Lobby
  +                    if minor==REQEST_LOBBY_CLIENTLIST: 
  +                        print "ha"
                           packet = ""
                           count = 0
                           for c in self.list.values():
                               if c.whereis()==IN_LOBBY:
  +                                print "id:", c.id()
                                   packet += struct.pack("B", len(c.id()))
                                   packet += c.id()
                                   count += 1
                           packet = struct.pack("H", count) + packet
                           client.write(M_LOBBY, RESPONSE_LOBBY_CLIENTLIST, packet)
  -            else:
                   pass
   
   
  
  
  


exman       04/11/13 22:03:20

  Modified:    test     proxyclient.py
  Log:
  Client  Noti 
  
  Revision  Changes    Path
  1.3       +33 -10    siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- proxyclient.py	13 Nov 2004 12:03:42 -0000	1.2
  +++ proxyclient.py	13 Nov 2004 13:03:20 -0000	1.3
  @@ -40,18 +40,29 @@
           print major, minor, length
           if major==M_LOBBY:
               if minor==RESPONSE_LOBBY_LOGIN:
  -                ret = struct.unpack("B", data)
  +                ret = struct.unpack("B", data)[0]
                   if ret!=0x00:
                       self.sock.close()
                       self.sock = None
                       self.cmd.sock = None
                   print "α : %d" % ret
               elif minor==RESPONSE_LOBBY_CLIENTLIST:
  -                count = struct.unpack("B", data[0])
  +                count = struct.unpack("H", data[:2])[0]
                   print " Lobby  : %d" % count
  +                p = 2
  +                for x in range(count):
  +                    l = struct.unpack("B", data[p])[0]; p+=1
  +                    id = data[p:p+l]; p+=l
  +                    print "\t", id
  +
               elif minor==NOTIFY_LOBBY_JOIN_CLIENT:
  -                count = struct.unpack("B", data[0])
  -                print "  "
  +                l = struct.unpack("B", data[0])[0]
  +                id = data[1:1+l]
  +                print " κ  :", id
  +            elif minor==NOTIFY_LOBBY_PART_CLIENT:
  +                l = struct.unpack("B", data[0])[0]
  +                id = data[1:1+l]
  +                print "κ ִٰ   :", id
           pass
   
       def run(self):
  @@ -62,6 +73,8 @@
               buffer = self.sock.recv(1024)
               if buffer=="":
                   self.stop = True
  +                self.sock = None
  +                self.cmd.sock = None
                   print "   "
                   return
               hexdump(buffer)
  @@ -114,17 +127,30 @@
               print "̹ α ߽ϴ."
               return
           self.sock = socket(AF_INET, SOCK_STREAM)
  -        self.sock.connect(('',1234))
  +        try:
  +            self.sock.connect(('',1234))
  +        except:
  +            print " Ҽ ϴ."
  +            return
           self.serverHandler.setSock(self.sock)
           if not self.serverHandler.isAlive():
               self.serverHandler.start()
           passwd=md5.md5(passwd).hexdigest()
  -        self.sock.send(struct.pack("<BBH", 0x01, 0x02, len(id)+len(passwd)+2))
  +        self.sock.send(struct.pack("<BBH", M_LOBBY, REQEST_LOBBY_LOGIN, len(id)+len(passwd)+2))
           self.sock.send(struct.pack("<B", len(id)))
           self.sock.send(id)
           self.sock.send(struct.pack("<B", len(passwd)))
           self.sock.send(passwd)
   
  +    def do_clientList(self, arg):
  +        """
  +        κ    û
  +        """
  +        if self.sock == None:
  +            print "α Ͻʽÿ"
  +            return
  +        self.sock.send(struct.pack("<BBH", M_LOBBY, REQEST_LOBBY_CLIENTLIST, 0))
  +
   
   m = ProxyClient()
   th = serverHandler(m)
  @@ -132,9 +158,6 @@
   try:
       m.cmdloop()
   except:
  -    a,b,c = sys.exc_info()
  -    print a
  -    print b
  -    print c
  +    traceback.print_exc()
   print "\nWait a minute\n"
   th.stop = True
  
  
  


exman       04/11/13 23:26:11

  Modified:    .        run.py
  Log:
  ߺα Ұϵ...
  
  Revision  Changes    Path
  1.13      +15 -8     siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- run.py	13 Nov 2004 13:03:20 -0000	1.12
  +++ run.py	13 Nov 2004 14:26:11 -0000	1.13
  @@ -178,7 +178,8 @@
           self.list[fd] = ClientItem(self, sock, addr)
       def fdList(self):
           return self.list.keys()
  -    def removeClient(self, fd):
  +    def removeClient(self, fd, reason = None):
  +        print "removeClient", reason
           if fd in self.errorClientList:
               self.errorClientList.remove(fd)
   
  @@ -199,7 +200,7 @@
       def errorOccurredClients(self):
           return self.errorClientList
       def setUserInfo(self, client, id):
  -        info = self.rpc.user.info(id)
  +        info = self.rpc.user.info(id) 
           print info
           client.setId(id)
           client.setNick(id)
  @@ -227,6 +228,15 @@
                           l = struct.unpack("B", data[p])[0]; p+=1
                           password = data[p:p+l]; p+=l
   
  +                        # ̹ α  ִ...
  +                        for c in self.list.values():
  +                            if c.id()==id:
  +                                # ̹ α̶ RESPONSE  
  +                                client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  +                                                        struct.pack("B", 0x02))
  +                                self.removeClient(client.fileno(), "already login")
  +                                return
  +
                           ret = self.rpc.auth.login(id, password)
                           if ret['code']=='00': # success
                               print "%s login successed" % id
  @@ -267,8 +277,7 @@
   
   while 1:
       for fd in LOBBY.errorOccurredClients():
  -        print "remove Client by errorOccurredClient list", fd
  -        LOBBY.removeClient(fd)
  +        LOBBY.removeClient(fd, "error Occurred")
   
       r, w, o =  select.select(SERVERFDS, [], [], 0.1)
       if r: #  Ŭ̾Ʈ 
  @@ -285,14 +294,12 @@
           try:
               buf = os.read(fd, 4096)
           except OSError:
  -            print "remove Client (reset by peer)"
  -            LOBBY.removeClient(fd)
  +            LOBBY.removeClient(fd, "reset by peer")
               continue
               
           if len(buf)==0: # client  
               # Ŭ̾Ʈ 
  -            print "remove Client"
  -            LOBBY.removeClient(fd)
  +            LOBBY.removeClient(fd, "closed from client")
               continue
   
           client = LOBBY.client(fd)
  
  
  


exman       04/11/13 23:26:11

  Modified:    test     proxyclient.py
  Log:
  ߺα Ұϵ...
  
  Revision  Changes    Path
  1.4       +4 -1      siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- proxyclient.py	13 Nov 2004 13:03:20 -0000	1.3
  +++ proxyclient.py	13 Nov 2004 14:26:11 -0000	1.4
  @@ -66,7 +66,10 @@
           pass
   
       def run(self):
  -        while not self.stop and self.sock != None:
  +        while not self.stop:
  +            if self.sock==None:
  +                time.sleep(1)
  +                continue
               r, w, o = select.select([self.sock.fileno(),], [], [], 1)
               if not r:
                   continue
  
  
  


exman       04/11/14 03:24:49

  Modified:    .        run.py
  Log:
  JOIN/PART  ܼȭ/äñ
  
  Revision  Changes    Path
  1.14      +21 -29    siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- run.py	13 Nov 2004 14:26:11 -0000	1.13
  +++ run.py	13 Nov 2004 18:24:49 -0000	1.14
  @@ -32,6 +32,19 @@
   import xmlrpclib
   from lib.protocol import *
   
  +def hexdump(buffer):
  +    i=0
  +    ret = ""
  +    for x in buffer:
  +        ret = ret + "%02X " % ord(x)
  +        i += 1
  +        if i%4==0:
  +            ret = ret+" "
  +        if i%16==0:
  +            ret = ret+"\n"
  +    print ret
  +
  +
   IN_OUTDOOR  = 0
   IN_LOBBY    = 1
   IN_GAMEROOM = 2
  @@ -57,7 +70,6 @@
           self.auth_try = 0
           # info
           self._id = ""
  -        self._nick = ""
           self._name = ""
           self._email = ""
           self._money = 0
  @@ -90,10 +102,6 @@
           return self._id
       def setId(self, id):
           self._id = id
  -    def nick(self):
  -        return self._nick
  -    def setNick(self, nick):
  -        self._nick = nick 
       def name(self):
           return self._name
       def setName(self, name):
  @@ -142,7 +150,6 @@
                   else:
                       self.gettingPacket = True
                       break
  -        #print "after getProtocolList"; print self.hexdump()
           return self.ret
   
       def buffer(self):
  @@ -153,21 +160,6 @@
               major, minor, length = struct.unpack('BBH', self.buffer[:4])
               if len(self.buffer[4:])>=length:
                   self.gettingPacket = False
  -        #print "after addBuffer"
  -        #print self.gettingPacket
  -        #print self.hexdump()
  -    def hexdump(self):
  -        i=0
  -        ret = ""
  -        for x in self.buffer:
  -            ret = ret + "%02X " % ord(x)
  -            i += 1
  -            if i%4==0:
  -                ret = ret+" "
  -            if i%16==0:
  -                ret = ret+"\n"
  -        return ret
  -
   class Lobby:
       def __init__(self):
           self.list = {} 
  @@ -185,10 +177,8 @@
   
           # NOTIFY_LOBBY__CLIENT
           client = self.client(fd)
  -        packet = struct.pack("B", len(client.id()))
  -        packet += client.id()
           if client.whereis()==IN_LOBBY:
  -            self.notify(NOTIFY_LOBBY_PART_CLIENT, packet, client)
  +            self.notify(NOTIFY_LOBBY_PART_CLIENT, client.id(), client)
           elif client.whereis()==IN_GAMEROOM:
               pass # FIXME
           del self.list[fd]
  @@ -203,7 +193,6 @@
           info = self.rpc.user.info(id) 
           print info
           client.setId(id)
  -        client.setNick(id)
           client.setName(info['name'])
           client.setEmail(info['email'])
           client.setMoney(30000)
  @@ -246,9 +235,7 @@
                               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                                       struct.pack("B", 0x00))
                               # NOTIFY_LOBBY_JOIN_CLIENT
  -                            packet = struct.pack("B", len(client.id()))
  -                            packet += client.id()
  -                            self.notify(NOTIFY_LOBBY_JOIN_CLIENT, packet, client)
  +                            self.notify(NOTIFY_LOBBY_JOIN_CLIENT, client.id(), client)
                           else: 
                               print "%s login failed" % id
                               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  @@ -256,7 +243,6 @@
               else:
                   if major==M_LOBBY: # Lobby
                       if minor==REQEST_LOBBY_CLIENTLIST: 
  -                        print "ha"
                           packet = ""
                           count = 0
                           for c in self.list.values():
  @@ -267,6 +253,12 @@
                                   count += 1
                           packet = struct.pack("H", count) + packet
                           client.write(M_LOBBY, RESPONSE_LOBBY_CLIENTLIST, packet)
  +                    if minor==REQEST_LOBBY_SENDMSG_CHAT: 
  +                        packet = struct.pack("B", len(client.id()))
  +                        packet += client.id()
  +                        packet += struct.pack("B", len(data))
  +                        packet += data
  +                        self.notify(NOTIFY_LOBBY_RECVMSG_CHAT, packet, client)
                   pass
   
   
  
  
  


exman       04/11/14 03:24:49

  Modified:    test     proxyclient.py
  Log:
  JOIN/PART  ܼȭ/äñ
  
  Revision  Changes    Path
  1.5       +17 -6     siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- proxyclient.py	13 Nov 2004 14:26:11 -0000	1.4
  +++ proxyclient.py	13 Nov 2004 18:24:49 -0000	1.5
  @@ -56,13 +56,16 @@
                       print "\t", id
   
               elif minor==NOTIFY_LOBBY_JOIN_CLIENT:
  -                l = struct.unpack("B", data[0])[0]
  -                id = data[1:1+l]
  -                print " κ  :", id
  +                print " κ  :", data
               elif minor==NOTIFY_LOBBY_PART_CLIENT:
  -                l = struct.unpack("B", data[0])[0]
  -                id = data[1:1+l]
  -                print "κ ִٰ   :", id
  +                print "κ ִٰ   :", data
  +            elif minor==NOTIFY_LOBBY_RECVMSG_CHAT:
  +                p = 0
  +                l = struct.unpack("B", data[p])[0]; p+=1
  +                id = data[p:p+l]; p+=l
  +                l = struct.unpack("B", data[p])[0]; p+=1
  +                msg = data[p:p+l]; p+=l
  +                print "%s Ϳ ޽: %s" % (id, msg)
           pass
   
       def run(self):
  @@ -154,6 +157,14 @@
               return
           self.sock.send(struct.pack("<BBH", M_LOBBY, REQEST_LOBBY_CLIENTLIST, 0))
   
  +    def do_chat(self, arg):
  +        """
  +        äø޽ 
  +        """
  +        if len(arg)>255:
  +            arg = arg[:255]
  +        self.sock.send(struct.pack("<BBH", M_LOBBY, REQEST_LOBBY_SENDMSG_CHAT, len(arg)))
  +        self.sock.send(arg)
   
   m = ProxyClient()
   th = serverHandler(m)
  
  
  


exman       04/11/14 03:48:34

  Modified:    .        run.py
  Log:
  ä/ӼӸ 
  
  Revision  Changes    Path
  1.15      +23 -4     siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- run.py	13 Nov 2004 18:24:49 -0000	1.14
  +++ run.py	13 Nov 2004 18:48:34 -0000	1.15
  @@ -176,14 +176,19 @@
               self.errorClientList.remove(fd)
   
           # NOTIFY_LOBBY__CLIENT
  -        client = self.client(fd)
  +        client = self.clientbyfd(fd)
           if client.whereis()==IN_LOBBY:
               self.notify(NOTIFY_LOBBY_PART_CLIENT, client.id(), client)
           elif client.whereis()==IN_GAMEROOM:
               pass # FIXME
           del self.list[fd]
  -    def client(self, fd):
  +    def clientbyfd(self, fd):
           return self.list[fd]
  +    def clientbyid(self, id):
  +        for c in self.list.values():
  +            if c.id()==id:
  +                return c
  +        return None
       def addErrorOccurredClient(self, fd):
           if fd not in self.errorClientList:
               self.errorClientList.append(fd)
  @@ -253,12 +258,26 @@
                                   count += 1
                           packet = struct.pack("H", count) + packet
                           client.write(M_LOBBY, RESPONSE_LOBBY_CLIENTLIST, packet)
  -                    if minor==REQEST_LOBBY_SENDMSG_CHAT: 
  +                    elif minor==REQEST_LOBBY_SENDMSG_CHAT: 
                           packet = struct.pack("B", len(client.id()))
                           packet += client.id()
                           packet += struct.pack("B", len(data))
                           packet += data
                           self.notify(NOTIFY_LOBBY_RECVMSG_CHAT, packet, client)
  +                    elif minor==REQEST_LOBBY_TOMSG_CHAT: 
  +                        p = 0
  +                        l = struct.unpack("B", data[p])[0]; p+=1
  +                        to = data[p:p+l]; p+=l
  +                        l = struct.unpack("B", data[p])[0]; p+=1
  +                        msg = data[p:p+l]; p+=l
  +
  +                        packet = struct.pack("B", len(client.id()))
  +                        packet += client.id()
  +                        packet += struct.pack("B", len(msg))
  +                        packet += msg
  +                        toclient = self.clientbyid(to)
  +                        if toclient != None and toclient.id()!=client.id():
  +                            toclient.write(M_LOBBY, NOTIFY_LOBBY_FROMMSG_CHAT, packet)
                   pass
   
   
  @@ -294,7 +313,7 @@
               LOBBY.removeClient(fd, "closed from client")
               continue
   
  -        client = LOBBY.client(fd)
  +        client = LOBBY.clientbyfd(fd)
           client.addBuffer(buf)
   
           # event
  
  
  


exman       04/11/14 03:48:34

  Modified:    lib      protocol.py
  Log:
  ä/ӼӸ 
  
  Revision  Changes    Path
  1.4       +1 -1      siminserver/lib/protocol.py
  
  Index: protocol.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/protocol.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- protocol.py	10 Nov 2004 15:13:07 -0000	1.3
  +++ protocol.py	13 Nov 2004 18:48:34 -0000	1.4
  @@ -46,4 +46,4 @@
   NOTIFY_LOBBY_PART_GAMEROOM                  = 0x66
   
   NOTIFY_LOBBY_RECVMSG_CHAT                   = 0x71
  -REQEST_LOBBY_FROMMSG_CHAT                   = 0x72
  +NOTIFY_LOBBY_FROMMSG_CHAT                   = 0x72
  
  
  


exman       04/11/14 03:48:34

  Modified:    test     proxyclient.py
  Log:
  ä/ӼӸ 
  
  Revision  Changes    Path
  1.6       +31 -0     siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- proxyclient.py	13 Nov 2004 18:24:49 -0000	1.5
  +++ proxyclient.py	13 Nov 2004 18:48:34 -0000	1.6
  @@ -66,6 +66,13 @@
                   l = struct.unpack("B", data[p])[0]; p+=1
                   msg = data[p:p+l]; p+=l
                   print "%s Ϳ ޽: %s" % (id, msg)
  +            elif minor==NOTIFY_LOBBY_FROMMSG_CHAT:
  +                p = 0
  +                l = struct.unpack("B", data[p])[0]; p+=1
  +                id = data[p:p+l]; p+=l
  +                l = struct.unpack("B", data[p])[0]; p+=1
  +                msg = data[p:p+l]; p+=l
  +                print "%s Ϳ ӼӸ: %s" % (id, msg)
           pass
   
       def run(self):
  @@ -161,10 +168,34 @@
           """
           äø޽ 
           """
  +        if self.sock == None:
  +            print "α Ͻʽÿ"
  +            return
           if len(arg)>255:
               arg = arg[:255]
           self.sock.send(struct.pack("<BBH", M_LOBBY, REQEST_LOBBY_SENDMSG_CHAT, len(arg)))
           self.sock.send(arg)
  +    def do_to(self, arg):
  +        """
  +        ӼӸ 
  +        """
  +        if self.sock == None:
  +            print "α Ͻʽÿ"
  +            return
  +        if len(arg.split(" "))<2:
  +            print "Usage: to id msg"
  +            return
  +        to = arg.split(" ")[0]
  +        msg = arg[len(to)+1:]
  +
  +        if msg>255:
  +            msg = msg[:255]
  +        packet = struct.pack("B", len(to))
  +        packet += to
  +        packet += struct.pack("B", len(msg))
  +        packet += msg
  +        self.sock.send(struct.pack("<BBH", M_LOBBY, REQEST_LOBBY_TOMSG_CHAT, len(packet)))
  +        self.sock.send(packet)
   
   m = ProxyClient()
   th = serverHandler(m)
  
  
  


exman       04/11/16 01:01:54

  Modified:    test     proxyclient.py
  Log:
  
  
  Revision  Changes    Path
  1.7       +1 -1      siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- proxyclient.py	13 Nov 2004 18:48:34 -0000	1.6
  +++ proxyclient.py	15 Nov 2004 16:01:54 -0000	1.7
  @@ -141,7 +141,7 @@
               return
           self.sock = socket(AF_INET, SOCK_STREAM)
           try:
  -            self.sock.connect(('',1234))
  +            self.sock.connect(('simin.h-9.net',1234))
           except:
               print " Ҽ ϴ."
               return
  
  
  


exman       04/11/16 01:39:16

  Modified:    test     proxyclient.py
  Log:
  proxyclient bug fix
  
  Revision  Changes    Path
  1.8       +9 -6      siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- proxyclient.py	15 Nov 2004 16:01:54 -0000	1.7
  +++ proxyclient.py	15 Nov 2004 16:39:16 -0000	1.8
  @@ -33,6 +33,7 @@
           self.cmd = cmd
           self.sock=None
           self.stop = False
  +        self.buffer = ""
   
       def setSock(self, sock):
           self.sock = sock
  @@ -42,6 +43,7 @@
               if minor==RESPONSE_LOBBY_LOGIN:
                   ret = struct.unpack("B", data)[0]
                   if ret!=0x00:
  +                    print " ", ret
                       self.sock.close()
                       self.sock = None
                       self.cmd.sock = None
  @@ -90,15 +92,16 @@
                   self.cmd.sock = None
                   print "   "
                   return
  -            hexdump(buffer)
  +            self.buffer += buffer
  +            hexdump(self.buffer)
               while True:
  -                if len(buffer)>=4:
  +                if len(self.buffer)>=4:
                       major, minor, length = \
  -                                    struct.unpack('BBH', buffer[:4])
  -                    if len(buffer[4:])>=length:
  +                                    struct.unpack('BBH', self.buffer[:4])
  +                    if len(self.buffer[4:])>=length:
                           self.event(major, minor, length, \
  -                                                buffer[4:4+length])
  -                        buffer = buffer[4+length:]
  +                                                self.buffer[4:4+length])
  +                        self.buffer = self.buffer[4+length:]
                       else:
                           break
                   else:
  
  
  


exman       04/11/16 02:24:05

  Modified:    test     proxyclient.py
  Log:
  default  ê 
  
  Revision  Changes    Path
  1.9       +2 -0      siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- proxyclient.py	15 Nov 2004 16:39:16 -0000	1.8
  +++ proxyclient.py	15 Nov 2004 17:24:05 -0000	1.9
  @@ -199,6 +199,8 @@
           packet += msg
           self.sock.send(struct.pack("<BBH", M_LOBBY, REQEST_LOBBY_TOMSG_CHAT, len(packet)))
           self.sock.send(packet)
  +    def default(self, line):
  +        self.do_chat(line)
   
   m = ProxyClient()
   th = serverHandler(m)
  
  
  


exman       04/11/23 02:20:34

  Modified:    .        run.py
  Log:
  Network byte order ٲ
  
  Revision  Changes    Path
  1.16      +7 -5      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- run.py	13 Nov 2004 18:48:34 -0000	1.15
  +++ run.py	22 Nov 2004 17:20:34 -0000	1.16
  @@ -3,8 +3,10 @@
   import sys , os
   
   
  -# daemonrize
   """
  +# daemonrize
  +from lib.daemonrize import run
  +run()
   from lib.daemonrize import run
   run()
   
  @@ -80,7 +82,7 @@
   
       def write(self, major, minor, data):
           length = len(data)
  -        packet = struct.pack("BBH", major, minor, length)
  +        packet = struct.pack("!BBH", major, minor, length)
           if self._write(packet)>0:
               self._write(data)
   
  @@ -137,7 +139,7 @@
                   if len(self.buffer)==0:
                       break
                   if len(self.buffer)>=4:
  -                    major, minor, length = struct.unpack('BBH', self.buffer[:4])
  +                    major, minor, length = struct.unpack('!BBH', self.buffer[:4])
                       if len(self.buffer[4:])>=length:
                           data = self.buffer[4:4+length]
                           self.ret.append((major, minor, length, data))
  @@ -157,7 +159,7 @@
       def addBuffer(self, buf):
           self.buffer=self.buffer+buf
           if len(self.buffer)>=4:
  -            major, minor, length = struct.unpack('BBH', self.buffer[:4])
  +            major, minor, length = struct.unpack('!BBH', self.buffer[:4])
               if len(self.buffer[4:])>=length:
                   self.gettingPacket = False
   class Lobby:
  @@ -256,7 +258,7 @@
                                   packet += struct.pack("B", len(c.id()))
                                   packet += c.id()
                                   count += 1
  -                        packet = struct.pack("H", count) + packet
  +                        packet = struct.pack("!H", count) + packet
                           client.write(M_LOBBY, RESPONSE_LOBBY_CLIENTLIST, packet)
                       elif minor==REQEST_LOBBY_SENDMSG_CHAT: 
                           packet = struct.pack("B", len(client.id()))
  
  
  


exman       04/11/23 02:20:34

  Removed:     lib      daemonrize.pyc
  Log:
  Network byte order ٲ


exman       04/11/23 02:21:03

  Modified:    test     proxyclient.py
  Log:
  little-endian->network byte order 
  
  Revision  Changes    Path
  1.10      +8 -8      siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- proxyclient.py	15 Nov 2004 17:24:05 -0000	1.9
  +++ proxyclient.py	22 Nov 2004 17:21:03 -0000	1.10
  @@ -49,7 +49,7 @@
                       self.cmd.sock = None
                   print "α : %d" % ret
               elif minor==RESPONSE_LOBBY_CLIENTLIST:
  -                count = struct.unpack("H", data[:2])[0]
  +                count = struct.unpack("!H", data[:2])[0]
                   print " Lobby  : %d" % count
                   p = 2
                   for x in range(count):
  @@ -97,7 +97,7 @@
               while True:
                   if len(self.buffer)>=4:
                       major, minor, length = \
  -                                    struct.unpack('BBH', self.buffer[:4])
  +                                    struct.unpack('!BBH', self.buffer[:4])
                       if len(self.buffer[4:])>=length:
                           self.event(major, minor, length, \
                                                   self.buffer[4:4+length])
  @@ -152,10 +152,10 @@
           if not self.serverHandler.isAlive():
               self.serverHandler.start()
           passwd=md5.md5(passwd).hexdigest()
  -        self.sock.send(struct.pack("<BBH", M_LOBBY, REQEST_LOBBY_LOGIN, len(id)+len(passwd)+2))
  -        self.sock.send(struct.pack("<B", len(id)))
  +        self.sock.send(struct.pack("!BBH", M_LOBBY, REQEST_LOBBY_LOGIN, len(id)+len(passwd)+2))
  +        self.sock.send(struct.pack("B", len(id)))
           self.sock.send(id)
  -        self.sock.send(struct.pack("<B", len(passwd)))
  +        self.sock.send(struct.pack("B", len(passwd)))
           self.sock.send(passwd)
   
       def do_clientList(self, arg):
  @@ -165,7 +165,7 @@
           if self.sock == None:
               print "α Ͻʽÿ"
               return
  -        self.sock.send(struct.pack("<BBH", M_LOBBY, REQEST_LOBBY_CLIENTLIST, 0))
  +        self.sock.send(struct.pack("!BBH", M_LOBBY, REQEST_LOBBY_CLIENTLIST, 0))
   
       def do_chat(self, arg):
           """
  @@ -176,7 +176,7 @@
               return
           if len(arg)>255:
               arg = arg[:255]
  -        self.sock.send(struct.pack("<BBH", M_LOBBY, REQEST_LOBBY_SENDMSG_CHAT, len(arg)))
  +        self.sock.send(struct.pack("!BBH", M_LOBBY, REQEST_LOBBY_SENDMSG_CHAT, len(arg)))
           self.sock.send(arg)
       def do_to(self, arg):
           """
  @@ -197,7 +197,7 @@
           packet += to
           packet += struct.pack("B", len(msg))
           packet += msg
  -        self.sock.send(struct.pack("<BBH", M_LOBBY, REQEST_LOBBY_TOMSG_CHAT, len(packet)))
  +        self.sock.send(struct.pack("!BBH", M_LOBBY, REQEST_LOBBY_TOMSG_CHAT, len(packet)))
           self.sock.send(packet)
       def default(self, line):
           self.do_chat(line)
  
  
  


exman       04/11/23 03:26:18

  Modified:    .        run.py
  Log:
  CREATE GAME ROOM 
  
  Revision  Changes    Path
  1.17      +65 -11    siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- run.py	22 Nov 2004 17:20:34 -0000	1.16
  +++ run.py	22 Nov 2004 18:26:18 -0000	1.17
  @@ -47,13 +47,41 @@
       print ret
   
   
  +class GameRoom:
  +    """
  +ӷ ӱ   ӿ 踦 Ѵ.
  +    """
  +    def __init__(self, gametype, title, roomMaster):
  +        self.gametype  = gametype
  +        self.title = title # utf-8 ̴.
  +        self.member = [roomMaster, ] #  , self.member[0] ̴.
  +    def find(self, id):
  +        for c in self.member:
  +            if c.id()==id:
  +                return True
  +        return False
  +    def title(self):
  +        return self.title
  +    def setTitle(self, title):
  +        self.title = title
  +    def addUser(self, client):
  +        self.member.append(client)
  +    def removeUser(self, id):
  +        pass
  +    def event(self, major, minor, length, data):
  +        pass
  +
  +
   IN_OUTDOOR  = 0
   IN_LOBBY    = 1
   IN_GAMEROOM = 2
   
   class ClientItem:
       """
  -Ŷ  ()
  +Ŭ̾Ʈ  - Ŭ̾Ʈ  Ŷ   ݴ 
  + ̺Ʈ ó Ҽ ִ. ̺Ʈ Lobby Ŭ νϽ Ѵ.
  +
  +: Ŷ  ()
   MajorCode(UChar)-MinorCode(UChar)-Length(UShort)-Data(until recv Length)
       """
       def __init__(self, lobby, sock, addr):
  @@ -61,6 +89,7 @@
           self.addr = addr
           self.fd = sock.fileno()
           self.lobby = lobby
  +        self.room = None # ҼӵǾ ִ ӷ
           self._whereis = IN_OUTDOOR
           # Ŷ 
           self.buffer = ''
  @@ -154,6 +183,11 @@
                       break
           return self.ret
   
  +    def setGameRoom(self, room): # ҼӵǾ ִ ӷ 
  +        self.room = room
  +    def gameRoom(self): # ҼӵǾִ ӷ 
  +        return self.room
  +
       def buffer(self):
               return None
       def addBuffer(self, buf):
  @@ -164,14 +198,15 @@
                   self.gettingPacket = False
   class Lobby:
       def __init__(self):
  -        self.list = {} 
  +        self.clientDict = {} 
  +        self.roomList = []
           self.rpc = xmlrpclib.Server("http://simin.h-9.net/RPC", verbose=1)
           self.errorClientList = []
       def addClient(self, sock, addr):
           fd = sock.fileno()
  -        self.list[fd] = ClientItem(self, sock, addr)
  +        self.clientDict[fd] = ClientItem(self, sock, addr)
       def fdList(self):
  -        return self.list.keys()
  +        return self.clientDict.keys()
       def removeClient(self, fd, reason = None):
           print "removeClient", reason
           if fd in self.errorClientList:
  @@ -183,11 +218,11 @@
               self.notify(NOTIFY_LOBBY_PART_CLIENT, client.id(), client)
           elif client.whereis()==IN_GAMEROOM:
               pass # FIXME
  -        del self.list[fd]
  +        del self.clientDict[fd]
       def clientbyfd(self, fd):
  -        return self.list[fd]
  +        return self.clientDict[fd]
       def clientbyid(self, id):
  -        for c in self.list.values():
  +        for c in self.clientDict.values():
               if c.id()==id:
                   return c
           return None
  @@ -205,7 +240,7 @@
           client.setMoney(30000)
           pass
       def notify(self, minor, data, exceptClient=None):
  -        for c in self.list.values():
  +        for c in self.clientDict.values():
               if c.whereis()==IN_LOBBY:
                   if exceptClient!=c:
                       c.write(M_LOBBY, minor, data)
  @@ -225,7 +260,7 @@
                           password = data[p:p+l]; p+=l
   
                           # ̹ α  ִ...
  -                        for c in self.list.values():
  +                        for c in self.clientDict.values():
                               if c.id()==id:
                                   # ̹ α̶ RESPONSE  
                                   client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  @@ -252,7 +287,7 @@
                       if minor==REQEST_LOBBY_CLIENTLIST: 
                           packet = ""
                           count = 0
  -                        for c in self.list.values():
  +                        for c in self.clientDict.values():
                               if c.whereis()==IN_LOBBY:
                                   print "id:", c.id()
                                   packet += struct.pack("B", len(c.id()))
  @@ -280,7 +315,26 @@
                           toclient = self.clientbyid(to)
                           if toclient != None and toclient.id()!=client.id():
                               toclient.write(M_LOBBY, NOTIFY_LOBBY_FROMMSG_CHAT, packet)
  -                pass
  +                    elif minor==REQEST_LOBBY_CREATE_GAMEROOM:
  +                        p = 0
  +                        gametype = struct.unpack("B", data[p])[0]; p+=1
  +                        l = struct.unpack("B", data[p])[0]; p+=1
  +                        title = data[p:p+l]; p+=l
  +                        print gametype, title
  +                        id = client.id()
  +                        ret = 0x00
  +                        for room in self.roomList:
  +                            # ̹ ٸӷ뿡 ̴...
  +                            # ع 
  +                            if room.find(id):
  +                                ret = 0x01 # д
  +                        if ret==0x00:
  +                            room = GameRoom(gametype, title, client)
  +                            self.roomList.append(room)
  +                            client.moveTo(IN_GAMEROOM)
  +                            client.setGameRoom(room)
  +                        client.write(M_LOBBY, RESPONSE_LOBBY_CREATE_GAMEROOM, \
  +                                                    struct.pack("B", ret))
   
   
   # Server fd  
  
  
  


exman       04/11/23 03:27:05

  Modified:    test     proxyclient.py
  Log:
  create game room ׽Ʈ̽ ߰
  
  Revision  Changes    Path
  1.11      +47 -0     siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- proxyclient.py	22 Nov 2004 17:21:03 -0000	1.10
  +++ proxyclient.py	22 Nov 2004 18:27:05 -0000	1.11
  @@ -14,6 +14,15 @@
   sys.path.append('..')
   from lib.protocol import *
   
  +if os.getenv("LANG").find("eucKR")>=0 or sys.platform.find("win")>=0:
  +    def chatenc(str):
  +        return str.decode('euc-kr').encode('utf-8')
  +elif os.getenv("LANG").find("UTF-8")>=0:
  +    def chatenc(str):
  +        return str.decode('euc-kr').encode('utf-8')
  +else:
  +    print " ÷ Ͻʴϱ? =3=33"
  +    sys.exit(1)
   
   def hexdump(buffer):
       i=0
  @@ -75,6 +84,13 @@
                   l = struct.unpack("B", data[p])[0]; p+=1
                   msg = data[p:p+l]; p+=l
                   print "%s Ϳ ӼӸ: %s" % (id, msg)
  +            if minor==RESPONSE_LOBBY_CREATE_GAMEROOM:
  +                ret = struct.unpack("B", data)[0]
  +                if ret!=0x00:
  +                    print "ӷ   ", ret
  +                else:
  +                    print "ӷ   ", ret
  +                    print "  ӷ ȿ ֽϴ."
           pass
   
       def run(self):
  @@ -201,6 +217,37 @@
           self.sock.send(packet)
       def default(self, line):
           self.do_chat(line)
  +    def do_createroom(self, arg):
  +        """
  +        ӷ 
  +        """
  +        if self.sock == None:
  +            print "α Ͻʽÿ"
  +            return
  +        if len(arg.split(" "))<2:
  +            print "Usage: gametype title"
  +            print "gametype: 0=>°, 1=>()"
  +            return
  +        try:
  +            type = arg.split(" ")[0]
  +            title = arg[len(type)+1:]
  +            type = int(type)
  +        except:
  +            print "Usage: gametype title"
  +            print "gametype: 0=>°, 1=>()"
  +            return
  +        if type!=0:
  +            print "Usage: gametype title"
  +            print "gametype: 0=>°, 1=>()"
  +            return
  +
  +        if title>255:
  +            title = title[:255]
  +        packet = struct.pack("B", type)
  +        packet += struct.pack("B", len(title))
  +        packet += title
  +        self.sock.send(struct.pack("!BBH", M_LOBBY, REQEST_LOBBY_CREATE_GAMEROOM, len(packet)))
  +        self.sock.send(packet)
   
   m = ProxyClient()
   th = serverHandler(m)
  
  
  


nohmad      04/11/26 20:28:31

  Modified:    .        run.py
  Log:
  Fix typo. s/REQEST/REQUEST/
  
  Revision  Changes    Path
  1.18      +6 -6      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- run.py	22 Nov 2004 18:26:18 -0000	1.17
  +++ run.py	26 Nov 2004 11:28:30 -0000	1.18
  @@ -249,10 +249,10 @@
               print "Client Event %d %d %d" % (major, minor, length)
               if not client.auth():
                   if major==M_LOBBY: # Lobby
  -                    if minor==REQEST_LOBBY_VERSIONCHECK: # version check
  +                    if minor==REQUEST_LOBBY_VERSIONCHECK: # version check
                           #client.setVersion(ver...)
                           pass
  -                    elif minor==REQEST_LOBBY_LOGIN: # login
  +                    elif minor==REQUEST_LOBBY_LOGIN: # login
                           p = 0
                           l = struct.unpack("B", data[p])[0]; p+=1
                           id = data[p:p+l]; p+=l
  @@ -284,7 +284,7 @@
                                                       struct.pack("B", 0x01))
               else:
                   if major==M_LOBBY: # Lobby
  -                    if minor==REQEST_LOBBY_CLIENTLIST: 
  +                    if minor==REQUEST_LOBBY_CLIENTLIST: 
                           packet = ""
                           count = 0
                           for c in self.clientDict.values():
  @@ -295,13 +295,13 @@
                                   count += 1
                           packet = struct.pack("!H", count) + packet
                           client.write(M_LOBBY, RESPONSE_LOBBY_CLIENTLIST, packet)
  -                    elif minor==REQEST_LOBBY_SENDMSG_CHAT: 
  +                    elif minor==REQUEST_LOBBY_SENDMSG_CHAT: 
                           packet = struct.pack("B", len(client.id()))
                           packet += client.id()
                           packet += struct.pack("B", len(data))
                           packet += data
                           self.notify(NOTIFY_LOBBY_RECVMSG_CHAT, packet, client)
  -                    elif minor==REQEST_LOBBY_TOMSG_CHAT: 
  +                    elif minor==REQUEST_LOBBY_TOMSG_CHAT: 
                           p = 0
                           l = struct.unpack("B", data[p])[0]; p+=1
                           to = data[p:p+l]; p+=l
  @@ -315,7 +315,7 @@
                           toclient = self.clientbyid(to)
                           if toclient != None and toclient.id()!=client.id():
                               toclient.write(M_LOBBY, NOTIFY_LOBBY_FROMMSG_CHAT, packet)
  -                    elif minor==REQEST_LOBBY_CREATE_GAMEROOM:
  +                    elif minor==REQUEST_LOBBY_CREATE_GAMEROOM:
                           p = 0
                           gametype = struct.unpack("B", data[p])[0]; p+=1
                           l = struct.unpack("B", data[p])[0]; p+=1
  
  
  


nohmad      04/11/26 20:28:31

  Modified:    lib      protocol.py
  Log:
  Fix typo. s/REQEST/REQUEST/
  
  Revision  Changes    Path
  1.5       +13 -13    siminserver/lib/protocol.py
  
  Index: protocol.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/protocol.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- protocol.py	13 Nov 2004 18:48:34 -0000	1.4
  +++ protocol.py	26 Nov 2004 11:28:31 -0000	1.5
  @@ -5,20 +5,20 @@
   
   # Minor code in M_LOBBY
   # Request (0x00~0x4F) ============================
  -REQEST_LOBBY_VERSIONCHECK                   = 0x01
  -REQEST_LOBBY_LOGIN                          = 0x02
  -REQEST_LOBBY_CLIENTLIST                     = 0x03
  -
  -REQEST_LOBBY_CREATE_GAMEROOM                = 0x11
  -REQEST_LOBBY_MODIFY_GAMEROOM                = 0x12
  -REQEST_LOBBY_DELETE_GAMEROOM                = 0x13
  -
  -REQEST_LOBBY_JOIN_GAMEROOM                  = 0x14
  -REQEST_LOBBY_PART_RESERVATION_GAMEROOM      = 0x15
  -REQEST_LOBBY_PART_GAMEROOM                  = 0x16
  +REQUEST_LOBBY_VERSIONCHECK                   = 0x01
  +REQUEST_LOBBY_LOGIN                          = 0x02
  +REQUEST_LOBBY_CLIENTLIST                     = 0x03
  +
  +REQUEST_LOBBY_CREATE_GAMEROOM                = 0x11
  +REQUEST_LOBBY_MODIFY_GAMEROOM                = 0x12
  +REQUEST_LOBBY_DELETE_GAMEROOM                = 0x13
  +
  +REQUEST_LOBBY_JOIN_GAMEROOM                  = 0x14
  +REQUEST_LOBBY_PART_RESERVATION_GAMEROOM      = 0x15
  +REQUEST_LOBBY_PART_GAMEROOM                  = 0x16
   
  -REQEST_LOBBY_SENDMSG_CHAT                   = 0x21
  -REQEST_LOBBY_TOMSG_CHAT                     = 0x22
  +REQUEST_LOBBY_SENDMSG_CHAT                   = 0x21
  +REQUEST_LOBBY_TOMSG_CHAT                     = 0x22
   
   # Response (0xA0~0xFF) ===========================
   RESPONSE_LOBBY_VERSIONCHECK                 = 0xA1
  
  
  


nohmad      04/11/26 20:28:31

  Modified:    test     proxyclient.py
  Log:
  Fix typo. s/REQEST/REQUEST/
  
  Revision  Changes    Path
  1.12      +5 -5      siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- proxyclient.py	22 Nov 2004 18:27:05 -0000	1.11
  +++ proxyclient.py	26 Nov 2004 11:28:31 -0000	1.12
  @@ -168,7 +168,7 @@
           if not self.serverHandler.isAlive():
               self.serverHandler.start()
           passwd=md5.md5(passwd).hexdigest()
  -        self.sock.send(struct.pack("!BBH", M_LOBBY, REQEST_LOBBY_LOGIN, len(id)+len(passwd)+2))
  +        self.sock.send(struct.pack("!BBH", M_LOBBY, REQUEST_LOBBY_LOGIN, len(id)+len(passwd)+2))
           self.sock.send(struct.pack("B", len(id)))
           self.sock.send(id)
           self.sock.send(struct.pack("B", len(passwd)))
  @@ -181,7 +181,7 @@
           if self.sock == None:
               print "α Ͻʽÿ"
               return
  -        self.sock.send(struct.pack("!BBH", M_LOBBY, REQEST_LOBBY_CLIENTLIST, 0))
  +        self.sock.send(struct.pack("!BBH", M_LOBBY, REQUEST_LOBBY_CLIENTLIST, 0))
   
       def do_chat(self, arg):
           """
  @@ -192,7 +192,7 @@
               return
           if len(arg)>255:
               arg = arg[:255]
  -        self.sock.send(struct.pack("!BBH", M_LOBBY, REQEST_LOBBY_SENDMSG_CHAT, len(arg)))
  +        self.sock.send(struct.pack("!BBH", M_LOBBY, REQUEST_LOBBY_SENDMSG_CHAT, len(arg)))
           self.sock.send(arg)
       def do_to(self, arg):
           """
  @@ -213,7 +213,7 @@
           packet += to
           packet += struct.pack("B", len(msg))
           packet += msg
  -        self.sock.send(struct.pack("!BBH", M_LOBBY, REQEST_LOBBY_TOMSG_CHAT, len(packet)))
  +        self.sock.send(struct.pack("!BBH", M_LOBBY, REQUEST_LOBBY_TOMSG_CHAT, len(packet)))
           self.sock.send(packet)
       def default(self, line):
           self.do_chat(line)
  @@ -246,7 +246,7 @@
           packet = struct.pack("B", type)
           packet += struct.pack("B", len(title))
           packet += title
  -        self.sock.send(struct.pack("!BBH", M_LOBBY, REQEST_LOBBY_CREATE_GAMEROOM, len(packet)))
  +        self.sock.send(struct.pack("!BBH", M_LOBBY, REQUEST_LOBBY_CREATE_GAMEROOM, len(packet)))
           self.sock.send(packet)
   
   m = ProxyClient()
  
  
  


djb         04/12/04 19:49:09

  Modified:    test     proxyclient.py
  Log:
  added encoding :P

  
  Revision  Changes    Path
  1.13      +1 -1      siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- proxyclient.py	26 Nov 2004 11:28:31 -0000	1.12
  +++ proxyclient.py	4 Dec 2004 10:49:09 -0000	1.13
  @@ -160,7 +160,7 @@
               return
           self.sock = socket(AF_INET, SOCK_STREAM)
           try:
  -            self.sock.connect(('simin.h-9.net',1234))
  +            self.sock.connect(('127.0.0.1',1234))
           except:
               print " Ҽ ϴ."
               return
  
  
  


djb         04/12/04 19:49:09

  Modified:    .        run.py
  Log:
  added encoding :P

  
  Revision  Changes    Path
  1.19      +1 -0      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- run.py	26 Nov 2004 11:28:30 -0000	1.18
  +++ run.py	4 Dec 2004 10:49:09 -0000	1.19
  @@ -1,4 +1,5 @@
   #!/usr/bin/python
  +# -*- coding: utf_8 -*-
   
   import sys , os
   
  
  
  


djb         04/12/04 20:18:18

  Added:       .        .project
  Log:
  for server work , need to split source code so split run.py to lib.lobby_functios.py ( it dosent work now )
  
  Revision  Changes    Path
  1.1                  siminserver/.project
  
  Index: .project
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <projectDescription>
  	<name>siminserver</name>
  	<comment></comment>
  	<projects>
  	</projects>
  	<buildSpec>
  		<buildCommand>
  			<name>org.python.pydev.PyDevBuilder</name>
  			<arguments>
  			</arguments>
  		</buildCommand>
  	</buildSpec>
  	<natures>
  		<nature>org.python.pydev.pythonNature</nature>
  	</natures>
  </projectDescription>
  
  
  


djb         04/12/04 20:18:19

  Added:       lib      lobby_functions.py
  Log:
  for server work , need to split source code so split run.py to lib.lobby_functios.py ( it dosent work now )
  
  Revision  Changes    Path
  1.1                  siminserver/lib/lobby_functions.py
  
  Index: lobby_functions.py
  ===================================================================
  #!/usr/bin/python
  from protocol import *
  
  if minor==REQUEST_LOBBY_VERSIONCHECK: # version check
      #client.setVersion(ver...)
      pass
  elif minor==REQUEST_LOBBY_LOGIN: # login
      p = 0
      l = struct.unpack("B", data[p])[0]; p+=1
      id = data[p:p+l]; p+=l
      l = struct.unpack("B", data[p])[0]; p+=1
      password = data[p:p+l]; p+=l
  
      # ̹ α  ִ...
      for c in self.clientDict.values():
          if c.id()==id:
              # ̹ α̶ RESPONSE  
              client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                      struct.pack("B", 0x02))
              self.removeClient(client.fileno(), "already login")
              return
  
      ret = self.rpc.auth.login(id, password)
      if ret['code']=='00': # success
          print "%s login successed" % id
          client.moveTo(IN_LOBBY)
          client.setAuth()
          self.setUserInfo(client, id)
          client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                  struct.pack("B", 0x00))
          # NOTIFY_LOBBY_JOIN_CLIENT
          self.notify(NOTIFY_LOBBY_JOIN_CLIENT, client.id(), client)
      else: 
          print "%s login failed" % id
          client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                  struct.pack("B", 0x01))
  
  
  


djb         04/12/04 20:36:36

  Modified:    .        run.py
  Log:
  from run.py split lobby_functions
  
  Revision  Changes    Path
  1.20      +37 -33    siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- run.py	4 Dec 2004 10:49:09 -0000	1.19
  +++ run.py	4 Dec 2004 11:36:36 -0000	1.20
  @@ -197,6 +197,9 @@
               major, minor, length = struct.unpack('!BBH', self.buffer[:4])
               if len(self.buffer[4:])>=length:
                   self.gettingPacket = False
  +                
  +# import lobby_function by djb
  +from lib.lobby_functions import *
   class Lobby:
       def __init__(self):
           self.clientDict = {} 
  @@ -250,39 +253,40 @@
               print "Client Event %d %d %d" % (major, minor, length)
               if not client.auth():
                   if major==M_LOBBY: # Lobby
  -                    if minor==REQUEST_LOBBY_VERSIONCHECK: # version check
  -                        #client.setVersion(ver...)
  -                        pass
  -                    elif minor==REQUEST_LOBBY_LOGIN: # login
  -                        p = 0
  -                        l = struct.unpack("B", data[p])[0]; p+=1
  -                        id = data[p:p+l]; p+=l
  -                        l = struct.unpack("B", data[p])[0]; p+=1
  -                        password = data[p:p+l]; p+=l
  -
  -                        # ̹ α  ִ...
  -                        for c in self.clientDict.values():
  -                            if c.id()==id:
  -                                # ̹ α̶ RESPONSE  
  -                                client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  -                                                        struct.pack("B", 0x02))
  -                                self.removeClient(client.fileno(), "already login")
  -                                return
  -
  -                        ret = self.rpc.auth.login(id, password)
  -                        if ret['code']=='00': # success
  -                            print "%s login successed" % id
  -                            client.moveTo(IN_LOBBY)
  -                            client.setAuth()
  -                            self.setUserInfo(client, id)
  -                            client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  -                                                    struct.pack("B", 0x00))
  -                            # NOTIFY_LOBBY_JOIN_CLIENT
  -                            self.notify(NOTIFY_LOBBY_JOIN_CLIENT, client.id(), client)
  -                        else: 
  -                            print "%s login failed" % id
  -                            client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  -                                                    struct.pack("B", 0x01))
  +					eventNotAuthLobbyMinorFunction(minor,length,data,client,self)
  +#                    if minor==REQUEST_LOBBY_VERSIONCHECK: # version check
  +#                        #client.setVersion(ver...)
  +#                        pass
  +#                    elif minor==REQUEST_LOBBY_LOGIN: # login
  +#                        p = 0
  +#                        l = struct.unpack("B", data[p])[0]; p+=1
  +#                        id = data[p:p+l]; p+=l
  +#                        l = struct.unpack("B", data[p])[0]; p+=1
  +#                        password = data[p:p+l]; p+=l
  +#
  +#                        # ̹ α  ִ...
  +#                        for c in self.clientDict.values():
  +#                            if c.id()==id:
  +#                                # ̹ α̶ RESPONSE  
  +#                                client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  +#                                                        struct.pack("B", 0x02))
  +#                                self.removeClient(client.fileno(), "already login")
  +#                                return
  +#
  +#                        ret = self.rpc.auth.login(id, password)
  +#                        if ret['code']=='00': # success
  +#                            print "%s login successed" % id
  +#                            client.moveTo(IN_LOBBY)
  +#                            client.setAuth()
  +#                            self.setUserInfo(client, id)
  +#                            client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  +#                                                    struct.pack("B", 0x00))
  +#                            # NOTIFY_LOBBY_JOIN_CLIENT
  +#                            self.notify(NOTIFY_LOBBY_JOIN_CLIENT, client.id(), client)
  +#                        else: 
  +#                            print "%s login failed" % id
  +#                            client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  +#                                                    struct.pack("B", 0x01))
               else:
                   if major==M_LOBBY: # Lobby
                       if minor==REQUEST_LOBBY_CLIENTLIST: 
  
  
  


djb         04/12/04 20:36:36

  Modified:    lib      lobby_functions.py
  Log:
  from run.py split lobby_functions
  
  Revision  Changes    Path
  1.2       +32 -30    siminserver/lib/lobby_functions.py
  
  Index: lobby_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/lobby_functions.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- lobby_functions.py	4 Dec 2004 11:18:18 -0000	1.1
  +++ lobby_functions.py	4 Dec 2004 11:36:36 -0000	1.2
  @@ -1,36 +1,38 @@
   #!/usr/bin/python
   from protocol import *
  +import struct
   
  -if minor==REQUEST_LOBBY_VERSIONCHECK: # version check
  -    #client.setVersion(ver...)
  -    pass
  -elif minor==REQUEST_LOBBY_LOGIN: # login
  -    p = 0
  -    l = struct.unpack("B", data[p])[0]; p+=1
  -    id = data[p:p+l]; p+=l
  -    l = struct.unpack("B", data[p])[0]; p+=1
  -    password = data[p:p+l]; p+=l
  +def eventNotAuthLobbyMinorFunction(minor,length,data,client,self):
  +    if minor == REQUEST_LOBBY_VERSIONCHECK: # version check
  +        #client.setVersion(ver...)
  +        pass
  +    elif minor==REQUEST_LOBBY_LOGIN: # login
  +        p = 0
  +        l = struct.unpack("B", data[p])[0]; p+=1
  +        id = data[p:p+l]; p+=l
  +        l = struct.unpack("B", data[p])[0]; p+=1
  +        password = data[p:p+l]; p+=l
   
       # ̹ α  ִ...
  -    for c in self.clientDict.values():
  -        if c.id()==id:
  -            # ̹ α̶ RESPONSE  
  +        for c in self.clientDict.values():
  +            if c.id()==id:
  +                # ̹ α̶ RESPONSE  
  +                client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  +                                        struct.pack("B", 0x02))
  +                self.removeClient(client.fileno(), "already login")
  +                return
  +    
  +        ret = self.rpc.auth.login(id, password)
  +        if ret['code']=='00': # success
  +            print "%s login successed" % id
  +            client.moveTo(IN_LOBBY)
  +            client.setAuth()
  +            self.setUserInfo(client, id)
               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  -                                    struct.pack("B", 0x02))
  -            self.removeClient(client.fileno(), "already login")
  -            return
  -
  -    ret = self.rpc.auth.login(id, password)
  -    if ret['code']=='00': # success
  -        print "%s login successed" % id
  -        client.moveTo(IN_LOBBY)
  -        client.setAuth()
  -        self.setUserInfo(client, id)
  -        client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  -                                struct.pack("B", 0x00))
  -        # NOTIFY_LOBBY_JOIN_CLIENT
  -        self.notify(NOTIFY_LOBBY_JOIN_CLIENT, client.id(), client)
  -    else: 
  -        print "%s login failed" % id
  -        client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  -                                struct.pack("B", 0x01))
  +                                    struct.pack("B", 0x00))
  +            # NOTIFY_LOBBY_JOIN_CLIENT
  +            self.notify(NOTIFY_LOBBY_JOIN_CLIENT, client.id(), client)
  +        else: 
  +            print "%s login failed" % id
  +            client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  +                                    struct.pack("B", 0x01))
  
  
  


djb         04/12/04 20:50:51

  Modified:    .        run.py
  Log:
  split end
  
  Revision  Changes    Path
  1.21      +3 -85     siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- run.py	4 Dec 2004 11:36:36 -0000	1.20
  +++ run.py	4 Dec 2004 11:50:51 -0000	1.21
  @@ -253,94 +253,12 @@
               print "Client Event %d %d %d" % (major, minor, length)
               if not client.auth():
                   if major==M_LOBBY: # Lobby
  +                     # see lib/lobby_functions.py
   					eventNotAuthLobbyMinorFunction(minor,length,data,client,self)
  -#                    if minor==REQUEST_LOBBY_VERSIONCHECK: # version check
  -#                        #client.setVersion(ver...)
  -#                        pass
  -#                    elif minor==REQUEST_LOBBY_LOGIN: # login
  -#                        p = 0
  -#                        l = struct.unpack("B", data[p])[0]; p+=1
  -#                        id = data[p:p+l]; p+=l
  -#                        l = struct.unpack("B", data[p])[0]; p+=1
  -#                        password = data[p:p+l]; p+=l
  -#
  -#                        # ̹ α  ִ...
  -#                        for c in self.clientDict.values():
  -#                            if c.id()==id:
  -#                                # ̹ α̶ RESPONSE  
  -#                                client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  -#                                                        struct.pack("B", 0x02))
  -#                                self.removeClient(client.fileno(), "already login")
  -#                                return
  -#
  -#                        ret = self.rpc.auth.login(id, password)
  -#                        if ret['code']=='00': # success
  -#                            print "%s login successed" % id
  -#                            client.moveTo(IN_LOBBY)
  -#                            client.setAuth()
  -#                            self.setUserInfo(client, id)
  -#                            client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  -#                                                    struct.pack("B", 0x00))
  -#                            # NOTIFY_LOBBY_JOIN_CLIENT
  -#                            self.notify(NOTIFY_LOBBY_JOIN_CLIENT, client.id(), client)
  -#                        else: 
  -#                            print "%s login failed" % id
  -#                            client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  -#                                                    struct.pack("B", 0x01))
               else:
                   if major==M_LOBBY: # Lobby
  -                    if minor==REQUEST_LOBBY_CLIENTLIST: 
  -                        packet = ""
  -                        count = 0
  -                        for c in self.clientDict.values():
  -                            if c.whereis()==IN_LOBBY:
  -                                print "id:", c.id()
  -                                packet += struct.pack("B", len(c.id()))
  -                                packet += c.id()
  -                                count += 1
  -                        packet = struct.pack("!H", count) + packet
  -                        client.write(M_LOBBY, RESPONSE_LOBBY_CLIENTLIST, packet)
  -                    elif minor==REQUEST_LOBBY_SENDMSG_CHAT: 
  -                        packet = struct.pack("B", len(client.id()))
  -                        packet += client.id()
  -                        packet += struct.pack("B", len(data))
  -                        packet += data
  -                        self.notify(NOTIFY_LOBBY_RECVMSG_CHAT, packet, client)
  -                    elif minor==REQUEST_LOBBY_TOMSG_CHAT: 
  -                        p = 0
  -                        l = struct.unpack("B", data[p])[0]; p+=1
  -                        to = data[p:p+l]; p+=l
  -                        l = struct.unpack("B", data[p])[0]; p+=1
  -                        msg = data[p:p+l]; p+=l
  -
  -                        packet = struct.pack("B", len(client.id()))
  -                        packet += client.id()
  -                        packet += struct.pack("B", len(msg))
  -                        packet += msg
  -                        toclient = self.clientbyid(to)
  -                        if toclient != None and toclient.id()!=client.id():
  -                            toclient.write(M_LOBBY, NOTIFY_LOBBY_FROMMSG_CHAT, packet)
  -                    elif minor==REQUEST_LOBBY_CREATE_GAMEROOM:
  -                        p = 0
  -                        gametype = struct.unpack("B", data[p])[0]; p+=1
  -                        l = struct.unpack("B", data[p])[0]; p+=1
  -                        title = data[p:p+l]; p+=l
  -                        print gametype, title
  -                        id = client.id()
  -                        ret = 0x00
  -                        for room in self.roomList:
  -                            # ̹ ٸӷ뿡 ̴...
  -                            # ع 
  -                            if room.find(id):
  -                                ret = 0x01 # д
  -                        if ret==0x00:
  -                            room = GameRoom(gametype, title, client)
  -                            self.roomList.append(room)
  -                            client.moveTo(IN_GAMEROOM)
  -                            client.setGameRoom(room)
  -                        client.write(M_LOBBY, RESPONSE_LOBBY_CREATE_GAMEROOM, \
  -                                                    struct.pack("B", ret))
  -
  +                    # see lib/lobby_functions.py
  +                    eventAuthLobbyMinorFunction(minor,length,data,client,self)
   
   # Server fd  
   SERVERFDS = [s.fileno()]
  
  
  


djb         04/12/04 20:50:51

  Modified:    lib      lobby_functions.py
  Log:
  split end
  
  Revision  Changes    Path
  1.3       +54 -0     siminserver/lib/lobby_functions.py
  
  Index: lobby_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/lobby_functions.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- lobby_functions.py	4 Dec 2004 11:36:36 -0000	1.2
  +++ lobby_functions.py	4 Dec 2004 11:50:51 -0000	1.3
  @@ -36,3 +36,57 @@
               print "%s login failed" % id
               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                       struct.pack("B", 0x01))
  +                                    
  +def eventAuthLobbyMinorFunction(minor,length,data,client,self):
  +    if minor==REQUEST_LOBBY_CLIENTLIST: 
  +        packet = ""
  +        count = 0
  +        for c in self.clientDict.values():
  +            if c.whereis()==IN_LOBBY:
  +                print "id:", c.id()
  +                packet += struct.pack("B", len(c.id()))
  +                packet += c.id()
  +                count += 1
  +        packet = struct.pack("!H", count) + packet
  +        client.write(M_LOBBY, RESPONSE_LOBBY_CLIENTLIST, packet)
  +    elif minor==REQUEST_LOBBY_SENDMSG_CHAT: 
  +        packet = struct.pack("B", len(client.id()))
  +        packet += client.id()
  +        packet += struct.pack("B", len(data))
  +        packet += data
  +        self.notify(NOTIFY_LOBBY_RECVMSG_CHAT, packet, client)
  +    elif minor==REQUEST_LOBBY_TOMSG_CHAT: 
  +        p = 0
  +        l = struct.unpack("B", data[p])[0]; p+=1
  +        to = data[p:p+l]; p+=l
  +        l = struct.unpack("B", data[p])[0]; p+=1
  +        msg = data[p:p+l]; p+=l
  +    
  +        packet = struct.pack("B", len(client.id()))
  +        packet += client.id()
  +        packet += struct.pack("B", len(msg))
  +        packet += msg
  +        toclient = self.clientbyid(to)
  +        if toclient != None and toclient.id()!=client.id():
  +            toclient.write(M_LOBBY, NOTIFY_LOBBY_FROMMSG_CHAT, packet)
  +    elif minor==REQUEST_LOBBY_CREATE_GAMEROOM:
  +        p = 0
  +        gametype = struct.unpack("B", data[p])[0]; p+=1
  +        l = struct.unpack("B", data[p])[0]; p+=1
  +        title = data[p:p+l]; p+=l
  +        print gametype, title
  +        id = client.id()
  +        ret = 0x00
  +        for room in self.roomList:
  +            # ̹ ٸӷ뿡 ̴...
  +            # ع 
  +            if room.find(id):
  +                ret = 0x01 # д
  +        if ret==0x00:
  +            room = GameRoom(gametype, title, client)
  +            self.roomList.append(room)
  +            client.moveTo(IN_GAMEROOM)
  +            client.setGameRoom(room)
  +        client.write(M_LOBBY, RESPONSE_LOBBY_CREATE_GAMEROOM, \
  +                                    struct.pack("B", ret))
  +    
  
  
  


nohmad      04/12/05 00:08:15

  Modified:    module/gostop TODO ai.py cardlist.py gostop.py test.py
                        userlist.py
  Log:
  Reformat tab(ascii-0x9) to 4*space(ascii-0x20). => s/\t/    /g
  Don't blame me, see http://simin.h-9.net/wiki/wiki.php/ClientDevelopGuide#s-1.1
  
  Revision  Changes    Path
  1.3       +0 -2      siminserver/module/gostop/TODO
  
  	<<Binary file>>
  
  
  1.4       +55 -59    siminserver/module/gostop/ai.py
  
  Index: ai.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/module/gostop/ai.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ai.py	8 Nov 2004 10:51:53 -0000	1.3
  +++ ai.py	4 Dec 2004 15:08:15 -0000	1.4
  @@ -6,64 +6,60 @@
   import gostop
   
   class baboo:
  -	def __init__(self, game):
  -		self.game = game
  +    def __init__(self, game):
  +        self.game = game
   
  -	def do_turn(self):
  -
  -		# ʽ ī尡   ϴ 
  -		flag = False
  -		cardlist = self.game.users.get_cardlist(self.game.currentuser)
  -		if len(cardlist) == 0:
  -			return
  -		
  -		card = cardlist[0]
  -		
  -		for tempcard in cardlist:
  -			if self.game.cards.get_special(tempcard) == self.game.cards.SPECIAL_BONUS:
  -				card = tempcard
  -				flag = True
  -				break
  -
  -		if not flag:
  -			# ʽ ī尡 ٸ  ¦ ´ ī带 ã´
  -			for tempcard in cardlist:
  -				cardgroup = self.game.cards.get_group(tempcard)
  -				for temptablecard in self.game.tablecard:
  -					if cardgroup == self.game.cards.get_group(temptablecard):
  -						flag = True
  -						card = tempcard
  -						break
  -
  -				if flag:
  -					break
  -					
  -
  -		if self.game.mode == self.game.MODE_NORMAL:
  -			# ź ˻
  -			cardgroup = self.game.cards.get_group(card)
  -
  -			# ϴ ´ ٴа ִ ˻
  -			tablematch = 0
  -			for tempcard in self.game.tablecard:
  -				if cardgroup == self.game.cards.get_group(tempcard):
  -					tablematch += 1
  -			count = 0
  -			for tempcard in self.game.users.get_cardlist(self.game.currentuser):
  -				if cardgroup == self.game.cards.get_group(tempcard):
  -					count += 1
  -
  -			if count == 3:
  -				self.game.do_process(self.game.currentuser, self.game.ACTION_BOMB, card)
  -			else:
  -				self.game.do_process(self.game.currentuser, self.game.ACTION_NORMAL, card)
  -
  -		elif self.game.mode == self.game.MODE_SELECT:
  -			for cardlist in self.game.duplication:
  -				data = cardlist[0]
  -				self.game.do_process(self.game.currentuser, self.game.ACTION_NORMAL, data)
  -		elif self.game.mode == self.game.MODE_GOSTOP:
  -			self.game.do_process(self.game.currentuser, self.game.ACTION_STOP)
  -
  -		
  +    def do_turn(self):
   
  +        # ʽ ī尡   ϴ 
  +        flag = False
  +        cardlist = self.game.users.get_cardlist(self.game.currentuser)
  +        if len(cardlist) == 0:
  +            return
  +        
  +        card = cardlist[0]
  +        
  +        for tempcard in cardlist:
  +            if self.game.cards.get_special(tempcard) == self.game.cards.SPECIAL_BONUS:
  +                card = tempcard
  +                flag = True
  +                break
  +
  +        if not flag:
  +            # ʽ ī尡 ٸ  ¦ ´ ī带 ã´
  +            for tempcard in cardlist:
  +                cardgroup = self.game.cards.get_group(tempcard)
  +                for temptablecard in self.game.tablecard:
  +                    if cardgroup == self.game.cards.get_group(temptablecard):
  +                        flag = True
  +                        card = tempcard
  +                        break
  +
  +                if flag:
  +                    break
  +
  +        if self.game.mode == self.game.MODE_NORMAL:
  +            # ź ˻
  +            cardgroup = self.game.cards.get_group(card)
  +
  +            # ϴ ´ ٴа ִ ˻
  +            tablematch = 0
  +            for tempcard in self.game.tablecard:
  +                if cardgroup == self.game.cards.get_group(tempcard):
  +                    tablematch += 1
  +            count = 0
  +            for tempcard in self.game.users.get_cardlist(self.game.currentuser):
  +                if cardgroup == self.game.cards.get_group(tempcard):
  +                    count += 1
  +
  +            if count == 3:
  +                self.game.do_process(self.game.currentuser, self.game.ACTION_BOMB, card)
  +            else:
  +                self.game.do_process(self.game.currentuser, self.game.ACTION_NORMAL, card)
  +
  +        elif self.game.mode == self.game.MODE_SELECT:
  +            for cardlist in self.game.duplication:
  +                data = cardlist[0]
  +                self.game.do_process(self.game.currentuser, self.game.ACTION_NORMAL, data)
  +        elif self.game.mode == self.game.MODE_GOSTOP:
  +            self.game.do_process(self.game.currentuser, self.game.ACTION_STOP)
  
  
  
  1.3       +149 -149  siminserver/module/gostop/cardlist.py
  
  Index: cardlist.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/module/gostop/cardlist.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- cardlist.py	4 Nov 2004 05:06:51 -0000	1.2
  +++ cardlist.py	4 Dec 2004 15:08:15 -0000	1.3
  @@ -2,153 +2,153 @@
   # -*- coding: utf_8 -*-
   
   class cardinfo:
  -	def __init__(self, name, group, type, special, point):
  -		self.name = name            #  ̸
  -		self.group = group          #  з
  -		self.type = type            #  з (, , , )
  -		self.special = special      # , û, ȫ, , 9, , ʽ 
  -		self.point = point          #   (, Ϲ)
  -		
  +    def __init__(self, name, group, type, special, point):
  +        self.name = name            #  ̸
  +        self.group = group          #  з
  +        self.type = type            #  з (, , , )
  +        self.special = special      # , û, ȫ, , 9, , ʽ 
  +        self.point = point          #   (, Ϲ)
  +        
   class cardlist:
  -	def get_name(self, cardid):
  -		return self.cards[cardid].name
  -	
  -	def get_group(self, cardid):
  -		try:
  -			return self.cards[cardid].group
  -		except:
  -			print "߸ ī ȣ"
  -			return 0
  -
  -	def get_type(self, cardid):
  -		return self.cards[cardid].type
  -
  -	def get_point(self, cardid):
  -		return self.cards[cardid].point
  -
  -	def get_special(self, cardid):
  -		return self.cards[cardid].special
  -
  -	def check_card(self, cardid):
  -		if self.cards.has_key(cardid):
  -			return True
  -		else:
  -			return False
  -	
  -	#  ī忡  ű
  -	def __init__(self):
  -		self.TYPE_GWANG = 1
  -		self.TYPE_10JA  = 2
  -		self.TYPE_5JA   = 3
  -		self.TYPE_PEE   = 4
  -
  -		self.SPECIAL_NORMAL    = 1
  -		self.SPECIAL_GODORI    = 2
  -		self.SPECIAL_CHUNGDAN  = 3
  -		self.SPECIAL_HONGDAN   = 4
  -		self.SPECIAL_KOOSA     = 5
  -		self.SPECIAL_SSANGPEE  = 6
  -		self.SPECIAL_BIGWANG   = 7
  -		self.SPECIAL_BONUS     = 8
  -		self.SPECIAL_BOMB      = 9
  -
  -		self.POINT_0 = 0
  -		self.POINT_1 = 1
  -		self.POINT_2 = 2
  -		
  -		self.cards = {}
  -
  -		self.cards[1] = cardinfo(" ",      1,  self.TYPE_GWANG, self.SPECIAL_NORMAL,    self.POINT_0)
  -		self.cards[2] = cardinfo(" ",     1,  self.TYPE_5JA,  self.SPECIAL_HONGDAN,   self.POINT_0)
  -		self.cards[3] = cardinfo(" ",     1,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		self.cards[4] = cardinfo(" ",     1,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -
  -		self.cards[5] = cardinfo(" 10",    2,  self.TYPE_10JA,  self.SPECIAL_GODORI,    self.POINT_0)
  -		self.cards[6] = cardinfo(" ",     2,  self.TYPE_5JA,  self.SPECIAL_HONGDAN,   self.POINT_0)
  -		self.cards[7] = cardinfo(" ",     2,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		self.cards[8] = cardinfo(" ",     2,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		
  -		self.cards[9] = cardinfo(" ",      3,  self.TYPE_GWANG, self.SPECIAL_NORMAL,    self.POINT_0)
  -		self.cards[10] = cardinfo(" ",     3,  self.TYPE_5JA,  self.SPECIAL_HONGDAN,   self.POINT_0)
  -		self.cards[11] = cardinfo(" ",     3,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		self.cards[12] = cardinfo(" ",     3,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -				
  -		self.cards[13] = cardinfo("θ 10",  4,  self.TYPE_10JA,  self.SPECIAL_GODORI,    self.POINT_0)
  -		self.cards[14] = cardinfo("θ ",   4,  self.TYPE_5JA,  self.SPECIAL_KOOSA,     self.POINT_0)
  -		self.cards[15] = cardinfo("θ ",   4,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		self.cards[16] = cardinfo("θ ",   4,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		
  -		self.cards[17] = cardinfo(" 10",    5,  self.TYPE_10JA,  self.SPECIAL_NORMAL,  self.POINT_0)
  -		self.cards[18] = cardinfo(" ",     5,  self.TYPE_5JA,  self.SPECIAL_KOOSA,     self.POINT_0)
  -		self.cards[19] = cardinfo(" ",     5,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		self.cards[20] = cardinfo(" ",     5,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		
  -		self.cards[21] = cardinfo(" 10",    6,  self.TYPE_10JA,  self.SPECIAL_NORMAL,    self.POINT_0)
  -		self.cards[22] = cardinfo(" ",     6,  self.TYPE_5JA,  self.SPECIAL_CHUNGDAN,  self.POINT_0)
  -		self.cards[23] = cardinfo(" ",     6,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		self.cards[24] = cardinfo(" ",     6,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		
  -		self.cards[25] = cardinfo("ȫθ 10", 7,  self.TYPE_10JA,  self.SPECIAL_NORMAL,    self.POINT_0)
  -		self.cards[26] = cardinfo("ȫθ ",   7,  self.TYPE_5JA,  self.SPECIAL_KOOSA,     self.POINT_0)
  -		self.cards[27] = cardinfo("ȫθ ",   7,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		self.cards[28] = cardinfo("ȫθ ",   7,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		
  -		self.cards[29] = cardinfo(" ",     8,  self.TYPE_GWANG, self.SPECIAL_NORMAL,    self.POINT_0)
  -		self.cards[30] = cardinfo(" 10",   8,  self.TYPE_10JA, self.SPECIAL_GODORI,    self.POINT_0)
  -		self.cards[31] = cardinfo(" ",     8,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		self.cards[32] = cardinfo(" ",     8,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		
  -		self.cards[33] = cardinfo(" 10",   9,  self.TYPE_10JA,  self.SPECIAL_SSANGPEE,  self.POINT_0)
  -		self.cards[34] = cardinfo(" ",     9,  self.TYPE_5JA,  self.SPECIAL_CHUNGDAN,  self.POINT_0)
  -		self.cards[35] = cardinfo(" ",     9,  self.TYPE_PEE,  self.SPECIAL_NORMAL,     self.POINT_1)
  -		self.cards[36] = cardinfo(" ",     9,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		
  -		self.cards[37] = cardinfo("ǳ 10",   10, self.TYPE_10JA,  self.SPECIAL_NORMAL,    self.POINT_0)
  -		self.cards[38] = cardinfo("ǳ ",     10, self.TYPE_5JA,  self.SPECIAL_CHUNGDAN,  self.POINT_0)
  -		self.cards[39] = cardinfo("ǳ ",     10, self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		self.cards[40] = cardinfo("ǳ ",     10, self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		
  -		self.cards[41] = cardinfo(" ",     11, self.TYPE_GWANG, self.SPECIAL_NORMAL,    self.POINT_0)
  -		self.cards[42] = cardinfo(" ",   11, self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_2)
  -		self.cards[43] = cardinfo(" ",     11, self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		self.cards[44] = cardinfo(" ",     11, self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  -		
  -		self.cards[45] = cardinfo(" ",       12, self.TYPE_GWANG, self.SPECIAL_BIGWANG,    self.POINT_0)
  -		self.cards[46] = cardinfo(" 10",     12, self.TYPE_10JA, self.SPECIAL_NORMAL,    self.POINT_0)
  -		self.cards[47] = cardinfo(" ",       12, self.TYPE_5JA,  self.SPECIAL_NORMAL,    self.POINT_0)
  -		self.cards[48] = cardinfo(" ",       12, self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_2)
  -
  -		self.cards[49] = cardinfo("ʽ",      0,  self.TYPE_PEE, self.SPECIAL_BONUS,    self.POINT_2)
  -		self.cards[50] = cardinfo("ʽ",      0,  self.TYPE_PEE, self.SPECIAL_BONUS,    self.POINT_2)
  -
  -		self.cards[61] = cardinfo(" 10",   5, self.TYPE_PEE, self.SPECIAL_NORMAL,    self.POINT_2)
  -		self.cards[62] = cardinfo(" 10",   9, self.TYPE_PEE, self.SPECIAL_NORMAL,    self.POINT_2)
  -
  -		self.cards[63] = cardinfo("ź",      0,  self.TYPE_PEE, self.SPECIAL_BOMB,    self.POINT_0)
  -		self.cards[64] = cardinfo("ź",      0,  self.TYPE_PEE, self.SPECIAL_BOMB,    self.POINT_0)
  -		self.cards[65] = cardinfo("ź",      0,  self.TYPE_PEE, self.SPECIAL_BOMB,    self.POINT_0)
  -		self.cards[66] = cardinfo("ź",      0,  self.TYPE_PEE, self.SPECIAL_BOMB,    self.POINT_0)
  -		self.cards[67] = cardinfo("ź",      0,  self.TYPE_PEE, self.SPECIAL_BOMB,    self.POINT_0)
  -		self.cards[68] = cardinfo("ź",      0,  self.TYPE_PEE, self.SPECIAL_BOMB,    self.POINT_0)
  -
  -		self.CARD_BOMB_BASE = 63
  -
  -		self.REALCARDCOUNT = 50
  -
  -	def get_peecard(self, card):
  -		if card == 17: # 
  -			return 61
  -
  -		if card == 33: # 
  -			return 62
  -
  -		return 0
  -		
  -	def is_bonuscard(self, card):
  -		if self.get_special(card) == self.SPECIAL_BONUS:
  -			return True
  -		else:
  -			return False
  -		
  -	def  __len__(self):
  -		return len(self.cards)
  +    def get_name(self, cardid):
  +        return self.cards[cardid].name
  +    
  +    def get_group(self, cardid):
  +        try:
  +            return self.cards[cardid].group
  +        except:
  +            print "߸ ī ȣ"
  +            return 0
  +
  +    def get_type(self, cardid):
  +        return self.cards[cardid].type
  +
  +    def get_point(self, cardid):
  +        return self.cards[cardid].point
  +
  +    def get_special(self, cardid):
  +        return self.cards[cardid].special
  +
  +    def check_card(self, cardid):
  +        if self.cards.has_key(cardid):
  +            return True
  +        else:
  +            return False
  +    
  +    #  ī忡  ű
  +    def __init__(self):
  +        self.TYPE_GWANG = 1
  +        self.TYPE_10JA  = 2
  +        self.TYPE_5JA   = 3
  +        self.TYPE_PEE   = 4
  +
  +        self.SPECIAL_NORMAL    = 1
  +        self.SPECIAL_GODORI    = 2
  +        self.SPECIAL_CHUNGDAN  = 3
  +        self.SPECIAL_HONGDAN   = 4
  +        self.SPECIAL_KOOSA     = 5
  +        self.SPECIAL_SSANGPEE  = 6
  +        self.SPECIAL_BIGWANG   = 7
  +        self.SPECIAL_BONUS     = 8
  +        self.SPECIAL_BOMB      = 9
  +
  +        self.POINT_0 = 0
  +        self.POINT_1 = 1
  +        self.POINT_2 = 2
  +        
  +        self.cards = {}
  +
  +        self.cards[1] = cardinfo(" ",      1,  self.TYPE_GWANG, self.SPECIAL_NORMAL,    self.POINT_0)
  +        self.cards[2] = cardinfo(" ",     1,  self.TYPE_5JA,  self.SPECIAL_HONGDAN,   self.POINT_0)
  +        self.cards[3] = cardinfo(" ",     1,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        self.cards[4] = cardinfo(" ",     1,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +
  +        self.cards[5] = cardinfo(" 10",    2,  self.TYPE_10JA,  self.SPECIAL_GODORI,    self.POINT_0)
  +        self.cards[6] = cardinfo(" ",     2,  self.TYPE_5JA,  self.SPECIAL_HONGDAN,   self.POINT_0)
  +        self.cards[7] = cardinfo(" ",     2,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        self.cards[8] = cardinfo(" ",     2,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        
  +        self.cards[9] = cardinfo(" ",      3,  self.TYPE_GWANG, self.SPECIAL_NORMAL,    self.POINT_0)
  +        self.cards[10] = cardinfo(" ",     3,  self.TYPE_5JA,  self.SPECIAL_HONGDAN,   self.POINT_0)
  +        self.cards[11] = cardinfo(" ",     3,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        self.cards[12] = cardinfo(" ",     3,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +                
  +        self.cards[13] = cardinfo("θ 10",  4,  self.TYPE_10JA,  self.SPECIAL_GODORI,    self.POINT_0)
  +        self.cards[14] = cardinfo("θ ",   4,  self.TYPE_5JA,  self.SPECIAL_KOOSA,     self.POINT_0)
  +        self.cards[15] = cardinfo("θ ",   4,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        self.cards[16] = cardinfo("θ ",   4,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        
  +        self.cards[17] = cardinfo(" 10",    5,  self.TYPE_10JA,  self.SPECIAL_NORMAL,  self.POINT_0)
  +        self.cards[18] = cardinfo(" ",     5,  self.TYPE_5JA,  self.SPECIAL_KOOSA,     self.POINT_0)
  +        self.cards[19] = cardinfo(" ",     5,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        self.cards[20] = cardinfo(" ",     5,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        
  +        self.cards[21] = cardinfo(" 10",    6,  self.TYPE_10JA,  self.SPECIAL_NORMAL,    self.POINT_0)
  +        self.cards[22] = cardinfo(" ",     6,  self.TYPE_5JA,  self.SPECIAL_CHUNGDAN,  self.POINT_0)
  +        self.cards[23] = cardinfo(" ",     6,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        self.cards[24] = cardinfo(" ",     6,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        
  +        self.cards[25] = cardinfo("ȫθ 10", 7,  self.TYPE_10JA,  self.SPECIAL_NORMAL,    self.POINT_0)
  +        self.cards[26] = cardinfo("ȫθ ",   7,  self.TYPE_5JA,  self.SPECIAL_KOOSA,     self.POINT_0)
  +        self.cards[27] = cardinfo("ȫθ ",   7,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        self.cards[28] = cardinfo("ȫθ ",   7,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        
  +        self.cards[29] = cardinfo(" ",     8,  self.TYPE_GWANG, self.SPECIAL_NORMAL,    self.POINT_0)
  +        self.cards[30] = cardinfo(" 10",   8,  self.TYPE_10JA, self.SPECIAL_GODORI,    self.POINT_0)
  +        self.cards[31] = cardinfo(" ",     8,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        self.cards[32] = cardinfo(" ",     8,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        
  +        self.cards[33] = cardinfo(" 10",   9,  self.TYPE_10JA,  self.SPECIAL_SSANGPEE,  self.POINT_0)
  +        self.cards[34] = cardinfo(" ",     9,  self.TYPE_5JA,  self.SPECIAL_CHUNGDAN,  self.POINT_0)
  +        self.cards[35] = cardinfo(" ",     9,  self.TYPE_PEE,  self.SPECIAL_NORMAL,     self.POINT_1)
  +        self.cards[36] = cardinfo(" ",     9,  self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        
  +        self.cards[37] = cardinfo("ǳ 10",   10, self.TYPE_10JA,  self.SPECIAL_NORMAL,    self.POINT_0)
  +        self.cards[38] = cardinfo("ǳ ",     10, self.TYPE_5JA,  self.SPECIAL_CHUNGDAN,  self.POINT_0)
  +        self.cards[39] = cardinfo("ǳ ",     10, self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        self.cards[40] = cardinfo("ǳ ",     10, self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        
  +        self.cards[41] = cardinfo(" ",     11, self.TYPE_GWANG, self.SPECIAL_NORMAL,    self.POINT_0)
  +        self.cards[42] = cardinfo(" ",   11, self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_2)
  +        self.cards[43] = cardinfo(" ",     11, self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        self.cards[44] = cardinfo(" ",     11, self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_1)
  +        
  +        self.cards[45] = cardinfo(" ",       12, self.TYPE_GWANG, self.SPECIAL_BIGWANG,    self.POINT_0)
  +        self.cards[46] = cardinfo(" 10",     12, self.TYPE_10JA, self.SPECIAL_NORMAL,    self.POINT_0)
  +        self.cards[47] = cardinfo(" ",       12, self.TYPE_5JA,  self.SPECIAL_NORMAL,    self.POINT_0)
  +        self.cards[48] = cardinfo(" ",       12, self.TYPE_PEE,  self.SPECIAL_NORMAL,    self.POINT_2)
  +
  +        self.cards[49] = cardinfo("ʽ",      0,  self.TYPE_PEE, self.SPECIAL_BONUS,    self.POINT_2)
  +        self.cards[50] = cardinfo("ʽ",      0,  self.TYPE_PEE, self.SPECIAL_BONUS,    self.POINT_2)
  +
  +        self.cards[61] = cardinfo(" 10",   5, self.TYPE_PEE, self.SPECIAL_NORMAL,    self.POINT_2)
  +        self.cards[62] = cardinfo(" 10",   9, self.TYPE_PEE, self.SPECIAL_NORMAL,    self.POINT_2)
  +
  +        self.cards[63] = cardinfo("ź",      0,  self.TYPE_PEE, self.SPECIAL_BOMB,    self.POINT_0)
  +        self.cards[64] = cardinfo("ź",      0,  self.TYPE_PEE, self.SPECIAL_BOMB,    self.POINT_0)
  +        self.cards[65] = cardinfo("ź",      0,  self.TYPE_PEE, self.SPECIAL_BOMB,    self.POINT_0)
  +        self.cards[66] = cardinfo("ź",      0,  self.TYPE_PEE, self.SPECIAL_BOMB,    self.POINT_0)
  +        self.cards[67] = cardinfo("ź",      0,  self.TYPE_PEE, self.SPECIAL_BOMB,    self.POINT_0)
  +        self.cards[68] = cardinfo("ź",      0,  self.TYPE_PEE, self.SPECIAL_BOMB,    self.POINT_0)
  +
  +        self.CARD_BOMB_BASE = 63
  +
  +        self.REALCARDCOUNT = 50
  +
  +    def get_peecard(self, card):
  +        if card == 17: # 
  +            return 61
  +
  +        if card == 33: # 
  +            return 62
  +
  +        return 0
  +
  +    def is_bonuscard(self, card):
  +        if self.get_special(card) == self.SPECIAL_BONUS:
  +            return True
  +        else:
  +            return False
  + 
  +    def  __len__(self):
  +        return len(self.cards)
  
  
  
  1.7       +803 -803  siminserver/module/gostop/gostop.py
  
  Index: gostop.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/module/gostop/gostop.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- gostop.py	8 Nov 2004 10:51:53 -0000	1.6
  +++ gostop.py	4 Dec 2004 15:08:15 -0000	1.7
  @@ -9,807 +9,807 @@
   import ai
   
   class gostop:
  -	def __init__(self, type="matgo"):
  -		self.dummycard = [] #  Ʈ
  -		self.tablecard = [] # ٴ Ʈ
  -
  -		self.users = userlist.userlist() #   
  -		self.cards = cardlist.cardlist() # ī 
  -		self.ai = ai.baboo(self)            # ǻ ΰ
  -
  -		if type == "matgo":
  -			self.FIRSTTABLECARDCOUNT = 8     # ó ٴڿ 򸮴  
  -			self.FIRSTUSERCARDCOUNT  = 10    # ó ڰ ޾ư  
  -			self.GOSTOP_POINT = 7            #  
  -		else:
  -			self.FIRSTTABLECARDCOUNT = 6
  -			self.FIRSTUSERCARDCOUNT = 7
  -			self.GOSTOP_POINT = 3
  -
  -		self.firstuser = 0               #  
  -		self.currentuser = 0             #  
  -		self.last = 0                    #   ˻
  -
  -		self.status = 0                  #   (//Ϸ)
  -		self.STATUS_WAIT = 0             # 
  -		self.STATUS_GAME = 1             # 
  -		self.STATUS_END = 2              # Ϸ
  -
  -		#  ó  ʿ ͵
  -		self.bbucklist = {}
  -		
  -		#  ó  ʿ ͵
  -		self.returncard = []             #  
  -		self.duplication = []
  -		#   (Ϲ, , Go/Stop)
  -		self.MODE_NORMAL = 0
  -		self.MODE_SELECT = 1
  -		self.MODE_GOSTOP = 2
  -		self.MODE_END    = 3
  -		self.mode = self.MODE_NORMAL
  -
  -		# ׼  (Ϲ, , ź)
  -		# Client -> Server
  -		self.ACTION_NORMAL = 0
  -		self.ACTION_SHAKE  = 1
  -		self.ACTION_BOMB   = 2
  -		self.ACTION_GO     = 3
  -		self.ACTION_STOP   = 4
  -		self.ACTION_START  = 5
  -
  -		# Server -> Client
  -		self.ACTION_JJOCK  = 6
  -		self.ACTION_BBUCK  = 7
  -		self.ACTION_DDADAK = 8
  -		self.ACTION_JABBUCKGET = 9
  -		self.ACTION_BBUCKGET = 10
  -		self.ACTION_MATCH   = 11
  -
  -		self.lastgouser = 0   #  ѻ (׷   :)
  -
  -		self.CODE_START = 1
  -		self.CODE_END   = 2
  -		self.CODE_TURN  = 3
  -		self.CODE_BONUS = 4
  -		self.CODE_BONUSGET = 5
  -		self.CODE_CARD  = 6
  -		self.CODE_SELECT = 7
  -		self.CODE_GOSTOP = 8
  -
  -		# ޼ 
  -		self.msgaction = 0
  -		self.msgcard = 0
  -		self.msgdummy = []
  -		self.msgmatchcard = []
  -		self.msgmatchcard2 = []
  -		self.msgstatus = [0, 0]
  -		self.msgreturncard = []
  -		self.msglostcard = {}
  -		self.msggetcard = {}
  -		self.msguserlostcard = []
  -		self.msgusergetcard = []
  -
  -	def make_packet(self, code, data):
  -		msglen = len(data)
  -		result = struct.pack("BBB", 3, code, msglen)
  -		
  -		if msglen > 0:
  -			result += data
  -
  -		return result
  -	
  -	def send_all(self, code, msg):
  -		for user in self.users.keys():
  -			#if self.users.get_type(user) == self.users.TYPE_HUMAN: # Ը 
  -			self.users.get_fd(user).send(self.make_packet(code, msg))
  -
  -	def send_all_func_each(self, code, func):
  -		for user in self.users.keys():
  -			self.users.get_fd(user).send(self.make_packet(code, func(user)))
  -
  -	def send_all_func(self, code, func):
  -		for user in self.users.keys():
  -			self.users.get_fd(user).send(self.make_packet(code, func()))
  -
  -	def send(self, user, code, msg):
  -		#if self.users.get_type(user) == self.users.TYPE_HUMAN: # Ը 
  -		self.users.get_fd(user).send(self.make_packet(code, msg))
  -
  -	def add_user(self, fd, userid, username):
  -		self.users.append(fd, userid, username)
  -		if len(self.users) == 1:
  -			self.set_firstuser(fd)
  -
  -		#self.send_all(1, "")  ذ
  -
  -	def set_firstuser(self, userid):
  -		self.firstuser = userid
  -		self.set_currentuser(userid)
  -
  -	def set_currentuser(self, userid):
  -		self.currentuser = userid
  -
  -	def check_chongtong(self, cardlist):
  -		counttable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  -		
  -		for card in cardlist:
  -			counttable[self.cards.get_group(card)] += 1
  -
  -		if max(counttable) == 4:
  -			return True
  -		else:
  -			return False
  -
  -	def is_tablechongtong(self): #  ˻ؼ   
  -		return self.check_chongtong(self.tablecard)
  -	
  -	def is_chongtong(self, userid): #  ˻ؼ   
  -		return self.check_chongtong(self.users.get_cardlist(userid))
  -
  -	def cut(self, plist, count):
  -		return plist[0:count], plist[count:]
  -
  -	def pop_dummycard(self, count):
  -		result = self.dummycard[0:count]
  -		self.dummycard = self.dummycard[count:]
  -		return result
  -
  -	def init_card(self):
  -		self.dummycard = range(1, self.cards.REALCARDCOUNT + 1)              # ī带  ä ִ´
  -		random.shuffle(self.dummycard)                              # 켱 ī带 ´
  -		
  -		# ٴڿ и   ڿ и  ش
  -		# ִ   Ӹ ٸ ϴ °  ϵ ڵ
  -		
  -		self.tablecard = self.pop_dummycard(self.FIRSTTABLECARDCOUNT)  # ٴڿ и 
  -		for userid in self.users.keys():           # ڿ е  ش
  -			self.users.set_cardlist(userid, self.pop_dummycard(self.FIRSTUSERCARDCOUNT))
  -
  -		# ٴп ʽ    
  -		for card in self.tablecard:
  -			if self.cards.is_bonuscard(card):
  -				print "ٴڿ ʽа "
  -				while 1:
  -					dummy = self.pop_dummycard(1)[0] # и ϳ ´
  -					if not self.cards.is_bonuscard(dummy): # ʽа ƴҶ ݺ
  -						break
  -					self.users.append_tablecardlist(self.firstuser, self.cards.get_type(dummy), dummy)
  -
  -				self.tablecard.remove(card)
  -				self.tablecard.append(dummy)
  -				self.users.append_tablecardlist(self.firstuser, self.cards.get_type(card), card)
  -
  -		# SEND  ʽ ī 泻뵵 Ŭ̾Ʈ  (׷ Ŭ̾Ʈ ϰ ۾)
  -
  -	def init_var(self):
  -		self.returncard = []
  -		self.duplication = []
  -		self.mode = self.MODE_NORMAL
  -		self.lastgouser = 0
  -		self.bbucklist = {}
  -
  -		# ޼  ʱȭ
  -		self.msgaction = 0
  -		self.msgcard = 0
  -		self.msgdummy = []
  -		self.msgmatchcard = []
  -		self.msgmatchcard2 = []
  -		self.msgstatus = [0, 0]
  -		self.msglostcard = {}
  -		self.msggetcard = {}
  -
  -	def init_game(self):
  -		self.status = self.STATUS_GAME # 
  -		
  -		self.init_var() #    ʱȭ Ѵ
  -		self.users.init_data(self.GOSTOP_POINT) #   ʱȭ Ѵ
  -		self.init_card() # и  , ٴ, з з Ѵ
  -
  -	def make_listpacket(self, list):
  -		result = ""
  -		for data in list:
  -			result += struct.pack("B", data)
  -		return result
  -	
  -	def make_firstcardpacket(self, user):
  -		result = struct.pack("B", len(self.tablecard))
  -		result += self.make_listpacket(self.tablecard)
  -		result += struct.pack("B", len(self.users.get_cardlist(user)))
  -		result += self.make_listpacket(self.users.get_cardlist(user))
  -		result += struct.pack("BB", len(self.users), self.FIRSTUSERCARDCOUNT)
  -
  -		return result
  -
  -	def do_game(self, user):
  -		if self.status == self.STATUS_GAME: #   ٽ   
  -			return
  -
  -		if user != self.firstuser: # 常   
  -			return
  -		
  -		self.set_firstuser(user) #   ְ
  -		#    ְ
  -		self.init_game()              #  ʱȭ Ű
  -
  -		self.send_all_func_each(self.CODE_START, self.make_firstcardpacket)
  -		# SEND  ڿ   ˸
  -		# SEND  ڿ ٴ   ׸ ڽ   ش (ӽ۰   ɵ)
  -		
  -		# ̺κ ʽ ī带  ִ κ Ѿ;
  -		
  -		# ٴп  쿡  
  -		if self.is_tablechongtong():
  -			#   ó ()
  -			print ""
  -			self.end_game() #  
  -			return
  -		
  -		for userid in self.users.keys(): #   ߾ ƾ . ׷ Ѵ    ̱
  -			if self.is_chongtong(userid):
  -				#   ó ()
  -				print ""
  -				self.end_game() #  
  -				return
  -
  -		self.send(self.currentuser, self.CODE_TURN, "")
  -
  -		# SEND    (и ϳ  ˸)
  -		#    ӿ     Ŭ̾Ʈ   ֵ ؾ
  -		
  -		
  -	def get_othercard(self, user, count): # ٸ  ī带 ´
  -		print "  ... "
  -		for userid in self.users.keys():
  -			if userid != user:
  -				flag = 0 # ī带 Դ üũ
  -				cardlist = self.users.get_tablecardlist(userid, self.cards.TYPE_PEE)
  -				for card in cardlist:
  -					if self.cards.get_point(card) == count:
  -						#  ī带 ´
  -						dddd = self.users.remove_tablecard(userid, card, self.cards.TYPE_PEE)
  -						self.returncard.append(card)
  -						flag = 1
  -						print "ī Դ : " + self.get_cardname(card)
  -						break
  -
  -				if not flag:
  -					if count >= len(cardlist):
  -						cardlen = len(cardlist)
  -					else:
  -						cardlen = count
  -
  -					#  ī带 ´
  -					for card in cardlist[:cardlen]:
  -						self.users.remove_tablecard(userid, card, self.cards.TYPE_PEE)
  -						self.returncard.append(card)
  -
  -						print "ī Դ : " + self.get_cardname(card)
  -						
  -						flag = 1
  -						break
  -
  -
  -	def append_card(self, user, list):
  -		for card in list:
  -			self.users.append_tablecardlist(user, self.cards.get_type(card), card)
  -
  -	def print_all(self):
  -		print "-   : " + str(len(self.dummycard))
  -		print "- ٴ " + "-" * 55
  -		for card in self.tablecard:
  -			print self.cards.get_name(card) + "(" + str(card) + ")",
  -		print "\n"
  -
  -		for user in self.users.keys():
  -			print "- " + self.users.get_username(user) + "  " + "-" * 55
  -			for card in self.users.get_cardlist(user):
  -				print self.cards.get_name(card) + "(" + str(card) + ")",
  -			print "\n"
  -
  -			print "- " + self.users.get_username(user) + " ٴ " + "-" * 55
  -			for card in self.users.get_tablecardlistall(user):
  -				print self.cards.get_name(card) + "(" + str(card) + ")",
  -			print "\n"
  -
  -			print "- " + self.users.get_username(user) + "  : " + str(self.get_currentpoint(user))
  -
  -		print "  : " + self.users.get_username(self.currentuser) + "\n"
  -
  -	def do_gostop(self, user, data): # Ұ   
  -		if self.mode != self.MODE_GOSTOP:
  -			return
  -		
  -		# /  ִ Ȳ üũ
  -		currentpoint = self.get_currentpoint(user)
  -		if currentpoint < self.GOSTOP_POINT:
  -			return
  -
  -		if self.last or data == self.ACTION_STOP: #  ̰ų   
  -			print " "
  -			self.end_game() #  
  -		elif data == self.ACTION_GO:
  -			#   
  -			self.lastgouser = user
  -			self.users.go(user, currentpoint + 1) #  纸 ·ų 1 ƾ  
  -			
  -			self.set_nextuser()
  -
  -	def make_cardpacket(self):
  -		result = struct.pack("BBB", self.msgaction, self.msgcard, len(self.msgdummy)) # ׼, , м
  -		result += self.make_listpacket(self.msgdummy) #  
  -
  -		for i in range(2 - len(self.msgmatchcard)):
  -			self.msgmatchcard.append(0)
  -
  -		for i in range(2 - len(self.msgmatchcard2)):
  -			self.msgmatchcard2.append(0)
  -			
  -		result += struct.pack("BBBB", self.msgmatchcard[0], self.msgmatchcard[1], self.msgmatchcard2[0], self.msgmatchcard2[1]) #  . . . .
  -		result += struct.pack("BBB", 0, 0, len(self.msgreturncard)) # 1, 2, м
  -		result += self.make_listpacket(self.msgreturncard) #  
  -		result += struct.pack("B", len(self.users)) # ڼ
  -		for user in self.users.keys():
  -			result += struct.pack("B", 0)
  -
  -		return result
  -			
  -	def completion_turn(self, user):
  -		print " ó"
  -		# ȹ ī尡  
  -		if self.returncard:
  -			self.append_card(user, self.returncard)
  -			self.msgreturncard = self.returncard
  -
  -		# SEND ϴ  ؼ Ŷ ѹ 
  -		self.send_all_func(self.CODE_CARD, self.make_cardpacket)
  -
  -		if len(self.dummycard) == 0:
  -			print " "
  -			self.end_game() #  
  -			return
  -
  -		if self.get_currentpoint(user) >= self.GOSTOP_POINT:
  -			# SEND / 
  -			self.mode = self.MODE_GOSTOP
  -			self.send(user, self.CODE_GOSTOP, "")
  -			return
  -		
  -		self.set_nextuser()
  -
  -	def set_nextuser(self):
  -		self.init_var()  #       ʱȭ Ѵ
  -		
  -		userlist = self.users.keys()
  -		pos = userlist.index(self.currentuser)
  -		if pos == len(self.users) -1:
  -			self.currentuser = userlist[0]
  -		else:
  -			self.currentuser = userlist[pos + 1]
  -
  -		print " ڿ   ", self.users.get_username(self.currentuser)
  -		self.send(self.currentuser, self.CODE_TURN, "")
  -
  -	def do_jjock(self, user, card, dummy):
  -		print " : " + self.get_cardname(card) + " " + self.get_cardname(dummy)
  -		if not self.last: #      
  -			self.get_othercard(user, 1)
  -			self.msgstatus[0] = self.ACTION_JJOCK
  -			self.msgstatus[1] = self.ACTION_JJOCK
  -		self.returncard.append(dummy)
  -		self.returncard.append(card)
  -
  -	def do_bbuck(self, user, card, dummy, matchcard):
  -		print ""
  -		if not self.last: #    ׳  ī ٴи 
  -			cardgroup = self.cards.get_group(card)
  -			self.tablecard.append(card)
  -			self.tablecard.append(dummy)
  -			self.tablecard += self.returncard # ʽе ش
  -			self.users.append_bbucklist(user, cardgroup) # ش   Ʈ ߰Ѵ
  -			self.bbucklist[cardgroup] =  self.returncard #    ߰
  -
  -			self.msgstatus[0] = self.ACTION_BBUCK
  -			self.msgstatus[1] = self.ACTION_BBUCK
  -
  -			if len(self.users.get_bbucklist(user)) == 3:
  -				#    
  -				print " ̱"
  -				self.end_game() #  
  -				return True
  -		else:
  -			self.returncard.append(card)
  -			self.returncard.append(matchcard)
  -			self.tablecard.append(dummy)
  -
  -		return False
  -			
  -	def do_ddadak(self, user, card, dummy, matchcard):
  -		print ""
  -		if not self.last: #      
  -			self.get_othercard(user, 1)
  -
  -			self.msgstatus[0] = self.ACTION_DDADAK
  -			self.msgstatus[1] = self.ACTION_DDADAK
  -			
  -		self.returncard.append(dummy)
  -		self.returncard.append(card)
  -		self.returncard += matchcard
  -		for tempcard in matchcard:    # а  ٴд Ѵ
  -			self.tablecard.remove(tempcard)
  -
  -	def do_bbuckget(self, user, card, matchcard, index):
  -		cardgroup = self.cards.get_group(card)
  -		if not self.last:
  -			if self.users.check_bbucklist(user, cardgroup):
  -				print "ڻ  : ",
  -				peecount = 2
  -				self.msgstatus[index] = self.ACTION_JABBUCKGET
  -			else:
  -				print "  : ",
  -				peecount = 1
  -				self.msgstatus[index] = self.ACTION_BBUCKGET
  -				
  -			self.get_othercard(user, peecount)
  -		self.returncard.append(card)
  -		self.returncard += matchcard
  -
  -		if self.bbucklist.has_key(cardgroup):
  -			for tempcard in self.bbucklist[cardgroup]:
  -				self.returncard.append(tempcard)
  -				self.tablecard.remove(tempcard)
  -			
  -			del self.bbucklist[cardgroup]
  -
  -		for tempcard in matchcard:    # а  ٴд Ѵ
  -			print self.get_cardname(tempcard), 
  -			self.tablecard.remove(tempcard)
  -
  -	def do_makepee(self, user, card): # ʳ  Ƿ 
  -		# ش ڰ  Ǹ  ִ ˻
  -		if not self.users.check_tablecard(user, card):
  -			return
  -
  -		# ش а  10 ˻
  -		if self.userss.get_special(card) != self.cards.SPECIAL_SSANGPEE:
  -			return
  -
  -		self.users.remove_tablecardlist(user, self.cards.TYPE_10JA. card) # ش и  ǿ ִ´
  -		self.users.append_tablecardlist(user, self.cards.TYPE_PEE, self.cards.get_peecard(card))
  -
  -	def do_select(self, user, card): # а  ¾  ϴ κ
  -		if self.mode != self.MODE_SELECT:
  -			return -10
  -		
  -		if len(self.duplication) <= 0:
  -			print " ° ƴ"
  -			return -10
  -
  -		for i in range(len(self.duplication)):
  -			for tempcard in self.duplication[i]:
  -				if card == tempcard:
  -					self.returncard.append(card)
  -					self.tablecard.remove(card)
  -					del self.duplication[i]
  -
  -					print " ؼ  : " + self.get_cardname(card)
  -					
  -					if len(self.duplication) == 0: #    Ǿ   Ѵ
  -						self.mode = self.MODE_NORMAL
  -						self.completion_turn(user)
  -
  -					return 0
  -
  -		return 0
  -
  -	def get_currentpoint(self, user): #    (  )
  -		result = ""
  -		point = 0
  -		mulcount = 1
  -
  -		#   
  -		cardlist = self.users.get_tablecardlist(user, self.cards.TYPE_GWANG)
  -		if len(cardlist) == 5:
  -			point += 15
  -		elif len(cardlist) >= 3:
  -			point += len(cardlist)
  -			print " " + str(len(cardlist)) + " , ", 
  -			for card in cardlist: #   1 
  -				if self.cards.get_special(card) == self.cards.SPECIAL_BIGWANG:
  -					point -= 1
  -					print " 1 , "
  -					break
  -
  -		# 10  
  -		cardlist = self.users.get_tablecardlist(user, self.cards.TYPE_10JA)
  -		if len(cardlist) >= 5:
  -			point += (len(cardlist) - 4)
  -
  -			print "10 " + str(len(cardlist) - 4) + " , ", 
  -
  -		#if len(cardlist) >= 7: # ۵ ˻
  -		#	mulcount += 1
  -
  -		count = 0
  -		for card in cardlist: #  ˻
  -			if self.cards.get_special(card) == self.cards.SPECIAL_GODORI:
  -				count += 1
  -		if count >= 3:
  -			point += 5
  -
  -		#   
  -		cardlist = self.users.get_tablecardlist(user, self.cards.TYPE_5JA)
  -		if len(cardlist) >= 5:
  -			point += (len(cardlist) - 4)
  -
  -			print " " + str(len(cardlist) - 4) + " , ", 
  -
  -		count = 0
  -		for card in cardlist: # û ˻
  -			if self.cards.get_special(card) == self.cards.SPECIAL_CHUNGDAN:
  -				count += 1
  -		if count >= 3:
  -			point += 3
  -
  -			print "û ",
  -
  -		count = 0
  -		for card in cardlist: # ȫ ˻
  -			if self.cards.get_special(card) == self.cards.SPECIAL_HONGDAN:
  -				count += 1
  -		if count >= 3:
  -			point += 3
  -
  -			print "ȫ ",
  -
  -		count = 0
  -		for card in cardlist: #  ˻
  -			if self.cards.get_special(card) == self.cards.SPECIAL_KOOSA:
  -				count += 1
  -		if count >= 3:
  -			point += 3
  -
  -			print " ", 
  -
  -		#   
  -		cardlist = self.users.get_tablecardlist(user, self.cards.TYPE_PEE)
  -		count = 0
  -		for card in cardlist:
  -			count += self.cards.get_point(card)
  -			
  -		if count >= 10:
  -			point += (count - 9)
  -
  -			print " " + str(count - 9) + " , "
  -
  -		print "  : " + str(point) +" "
  -
  -		return point
  -
  -	def do_bonuscard(self, user, card):
  -		print "ʽī "
  -		self.append_card(user, [card])
  -		dummy = self.pop_dummycard(1)[0] # и ϳ ´
  -		self.users.append_cardlist(user, [dummy])
  -
  -		self.send_all(self.CODE_BONUS, struct.pack("B", card))
  -		self.send(user, self.CODE_BONUSGET, struct.pack("B", dummy))
  -		self.send(user, self.CODE_TURN, "")
  -		
  -		if self.is_chongtong(user):
  -			print ""
  -			self.end_game() #  
  -
  -	def check_shake(self, user, card):
  -		templist = self.users.get_cardlist(user)
  -		cardgroup = self.cards.get_group(card)
  -
  -		count = 0
  -		for tempcard in templist:
  -			if self.cards.get_group(tempcard) == cardgroup:
  -				count += 1
  -
  -		if count >= 2: # ϴ   и ϴ 2 
  -			return True
  -		else:
  -			return False
  -
  -	def get_cardname(self, card): # ī̸ ӽ÷  (߿   Լ)
  -		return self.cards.get_name(card) + "(" + str(card) + ")"
  -
  -	def do_bomb(self, user, card): # ź  ó
  -		print "ź"
  -		# 켱 ٴп ´  ִ ˻
  -		cardgroup = self.cards.get_group(card)
  -		flag = 0
  -		for tempcard in self.tablecard:
  -			if cardgroup == self.cards.get_group(tempcard):
  -				flag = 1
  -				break
  -
  -		if flag == 0:
  -			return
  -
  -		self.users.shake(user)
  -		self.get_othercard(user, 1) # ٸ  и ´
  -
  -		print " ź ī : ", 
  -		for tempcard in self.users.get_cardlist(user): #  ź ī п ִ´
  -			if cardgroup == self.cards.get_group(tempcard) and tempcard != card:
  -				print self.get_cardname(tempcard), 
  -				self.returncard.append(tempcard)
  -				self.users.remove_card(user, tempcard)
  -
  -		# ׸ źи ڿ ش
  -		cardbase = self.cards.CARD_BOMB_BASE + self.users.get_shakecount(user) * 2
  -		self.users.append_cardlist(user, [cardbase, cardbase+1])
  -
  -	def do_process(self, user, action, data=0): # ܺ ȣ ޼ҵ
  -		if action == self.ACTION_START:
  -			self.do_game(user)
  -		else:
  -			self.do_turn(user, data, action) #    ó
  -
  -	def do_turn(self, user, card, action): # ѹ  ó
  -		if self.status != self.STATUS_GAME:
  -			print " ƴ"
  -			return [-1]
  -
  -		if self.currentuser != user: #   ڰ ´ ˻
  -			print "  ڰ ƴ"
  -			return [-2]
  -
  -		if self.mode == self.MODE_GOSTOP: # Go/Stop ø 
  -			self.do_gostop(user, action)
  -			return
  -
  -		if not self.cards.check_card(card):
  -			print "ī尪 ߸Ǿ"
  -			return [-3]
  -
  -		if self.mode == self.MODE_SELECT: # ø 
  -			self.do_select(user, card)
  -			return
  -
  -		#print " ī : " + self.get_cardname(card)
  -		
  -		if self.users.remove_card(user, card) == 0: #ش а ش ڿ ִ  ˻
  -			print "ڽſ  и "
  -			return [-4]
  -
  -		if self.cards.is_bonuscard(card): # ʽи   ó
  -			self.do_bonuscard(user, card)
  -			return [0]
  -
  -		if len(self.users.get_cardlist(user)) == 0: #   ˻
  -			print "̹  Դϴ"
  -			self.last = 1
  -		else:
  -			self.last = 0
  -
  -		self.msgcard = card
  -		self.msgaction = action
  -		
  -		# action   Ϲ/ź
  -		if action != self.ACTION_NORMAL:
  -			if self.check_shake(user, card): #  3 ִ ˻
  -				if action == self.ACTION_SHAKE: #   Ƚ 1 ÷ְ ׳ 
  -					self.users.shake(user)
  -				elif action == self.ACTION_BOMB: # ź  ٴи ˻ؾ
  -					self.do_bomb(user, card)
  -				else:
  -					print " ߸ ޵ƽϴ, ", action
  -					return [-5]
  -
  -
  -		while 1:
  -			dummy = self.pop_dummycard(1)[0] # и ϳ ´
  -			self.msgdummy.append(dummy)
  -			print "  : ", self.get_cardname(dummy)
  -			if not self.cards.is_bonuscard(dummy): # ʽа ƴҶ ݺ
  -				break
  -			self.returncard.append(dummy)
  -			
  -		cardgroup = self.cards.get_group(card)      #  ī ׷ о´
  -
  -		matchcount = 0
  -		matchcard = []
  -		
  -		#  ī ٴа ´  ִ ˻Ѵ
  -		for tempcard in self.tablecard:
  -			if cardgroup == self.cards.get_group(tempcard):
  -				matchcount += 1
  -				matchcard.append(tempcard)
  -
  -		self.msgmatchcard = matchcard
  -
  -		#  ī ׷ о´
  -		dummygroup = self.cards.get_group(dummy)
  -
  -		dummymatchcount = 0
  -		dummymatchcard = []
  -		
  -		# ̿  п ٴа ´  ִ ˻Ѵ
  -		for tempcard in self.tablecard:
  -			if dummygroup == self.cards.get_group(tempcard):
  -				dummymatchcount += 1
  -				dummymatchcard.append(tempcard)
  -
  -		self.msgmatchcard2 = dummymatchcard
  -
  -		#  ī ī尡  ˻Ѵ
  -		if cardgroup == dummygroup:
  -			if matchcount == 0: # 
  -				self.do_jjock(user, card, dummy)
  -			elif matchcount == 1: # 
  -				if self.do_bbuck(user, card, dummy, matchcard[0]):
  -					return [0] #   ...
  -			elif matchcount == 2: #  ˻
  -				self.do_ddadak(user, card, dummy, matchcard)
  -		else:
  -			tempmatchcount = [matchcount, dummymatchcount]
  -			tempmatchcard = [matchcard, dummymatchcard]
  -			tempselectcard = [card, dummy]
  -
  -			for i in range(2):
  -				if tempmatchcount[i] == 3: # , ڻ 
  -					self.do_bbuckget(user, tempselectcard[i], tempmatchcard[i], i)
  -				elif tempmatchcount[i] == 1:
  -					self.returncard.append(tempmatchcard[i][0])
  -					self.returncard.append(tempselectcard[i])
  -					self.tablecard.remove(tempmatchcard[i][0])  # а  ٴд Ѵ
  -					print "¾Ҵ : " + self.get_cardname(tempmatchcard[i][0]) + ", " + self.get_cardname(tempselectcard[i])
  -					self.msgstatus[i] = self.ACTION_MATCH
  -				elif tempmatchcount[i] == 2:
  -					self.returncard.append(tempselectcard[i])
  -					self.duplication.append(tempmatchcard[i])
  -					# SEND ī带 ϶ ȣ 
  -					self.mode = self.MODE_SELECT
  -
  -					self.msgstatus[i] = self.ACTION_MATCH
  -					self.send(user, self.CODE_SELECT, struct.pack("BBB", tempselectcard[i], tempmatchcard[i][0], tempmatchcard[i][1]))
  -						
  -				elif tempmatchcount[i] == 0:
  -					if self.cards.get_special(tempselectcard[i]) != self.cards.SPECIAL_BOMB: # ź ī尡 ƴҶ...
  -						print "ٴп ߰ : " + self.get_cardname(tempselectcard[i])
  -						self.tablecard.append(tempselectcard[i])
  -					print " "
  -
  -			if len(self.duplication) > 0: # ΰ  찡    ޾Ƽ  
  -				return [0]
  -
  -			# Ϸᰡ  Ǿ   
  -			# Go  Ϲݻ Ȯ Ŀ
  -			#   ̸̻ Go/Stop 
  -
  -			# Go    Stop    ó
  -			#  
  -
  -			# Ÿ  
  -
  -		# Ǿ ߰
  -		if len(self.tablecard) == 0:
  -			self.get_othercard(user, 1)
  -			
  -		self.completion_turn(user) #  Ų
  -
  -		return [0]
  -
  -	def event_loop(self, data):
  -		# Ŷ ޾Ƽ óϴ κ ߰
  -		pass
  -
  -	def end_game(self):
  -		self.status = self.STATUS_END #  Ϸ
  -		
  -		#  ؼ    Դ  ϰ ϰ
  -		# ش   ڿ 
  -		self.send_all(self.CODE_END, "")
  -		self.set_firstuser(self.currentuser) #   Ѵ
  -
  -	def get_message(self):
  -		# 
  -		# ϰ, , , 1, 2, 1, 2,
  -		#  ں  ī,  ں ī
  -		#  ڰ  ī,  ڰ  ī
  +    def __init__(self, type="matgo"):
  +        self.dummycard = [] #  Ʈ
  +        self.tablecard = [] # ٴ Ʈ
  +
  +        self.users = userlist.userlist() #   
  +        self.cards = cardlist.cardlist() # ī 
  +        self.ai = ai.baboo(self)            # ǻ ΰ
  +
  +        if type == "matgo":
  +            self.FIRSTTABLECARDCOUNT = 8     # ó ٴڿ 򸮴  
  +            self.FIRSTUSERCARDCOUNT  = 10    # ó ڰ ޾ư  
  +            self.GOSTOP_POINT = 7            #  
  +        else:
  +            self.FIRSTTABLECARDCOUNT = 6
  +            self.FIRSTUSERCARDCOUNT = 7
  +            self.GOSTOP_POINT = 3
  +
  +        self.firstuser = 0               #  
  +        self.currentuser = 0             #  
  +        self.last = 0                    #   ˻
  +
  +        self.status = 0                  #   (//Ϸ)
  +        self.STATUS_WAIT = 0             # 
  +        self.STATUS_GAME = 1             # 
  +        self.STATUS_END = 2              # Ϸ
  +
  +        #  ó  ʿ ͵
  +        self.bbucklist = {}
  +        
  +        #  ó  ʿ ͵
  +        self.returncard = []             #  
  +        self.duplication = []
  +        #   (Ϲ, , Go/Stop)
  +        self.MODE_NORMAL = 0
  +        self.MODE_SELECT = 1
  +        self.MODE_GOSTOP = 2
  +        self.MODE_END    = 3
  +        self.mode = self.MODE_NORMAL
  +
  +        # ׼  (Ϲ, , ź)
  +        # Client -> Server
  +        self.ACTION_NORMAL = 0
  +        self.ACTION_SHAKE  = 1
  +        self.ACTION_BOMB   = 2
  +        self.ACTION_GO     = 3
  +        self.ACTION_STOP   = 4
  +        self.ACTION_START  = 5
  +
  +        # Server -> Client
  +        self.ACTION_JJOCK  = 6
  +        self.ACTION_BBUCK  = 7
  +        self.ACTION_DDADAK = 8
  +        self.ACTION_JABBUCKGET = 9
  +        self.ACTION_BBUCKGET = 10
  +        self.ACTION_MATCH   = 11
  +
  +        self.lastgouser = 0   #  ѻ (׷   :)
  +
  +        self.CODE_START = 1
  +        self.CODE_END   = 2
  +        self.CODE_TURN  = 3
  +        self.CODE_BONUS = 4
  +        self.CODE_BONUSGET = 5
  +        self.CODE_CARD  = 6
  +        self.CODE_SELECT = 7
  +        self.CODE_GOSTOP = 8
  +
  +        # ޼ 
  +        self.msgaction = 0
  +        self.msgcard = 0
  +        self.msgdummy = []
  +        self.msgmatchcard = []
  +        self.msgmatchcard2 = []
  +        self.msgstatus = [0, 0]
  +        self.msgreturncard = []
  +        self.msglostcard = {}
  +        self.msggetcard = {}
  +        self.msguserlostcard = []
  +        self.msgusergetcard = []
  +
  +    def make_packet(self, code, data):
  +        msglen = len(data)
  +        result = struct.pack("BBB", 3, code, msglen)
  +        
  +        if msglen > 0:
  +            result += data
  +
  +        return result
  +    
  +    def send_all(self, code, msg):
  +        for user in self.users.keys():
  +            #if self.users.get_type(user) == self.users.TYPE_HUMAN: # Ը 
  +            self.users.get_fd(user).send(self.make_packet(code, msg))
  +
  +    def send_all_func_each(self, code, func):
  +        for user in self.users.keys():
  +            self.users.get_fd(user).send(self.make_packet(code, func(user)))
  +
  +    def send_all_func(self, code, func):
  +        for user in self.users.keys():
  +            self.users.get_fd(user).send(self.make_packet(code, func()))
  +
  +    def send(self, user, code, msg):
  +        #if self.users.get_type(user) == self.users.TYPE_HUMAN: # Ը 
  +        self.users.get_fd(user).send(self.make_packet(code, msg))
  +
  +    def add_user(self, fd, userid, username):
  +        self.users.append(fd, userid, username)
  +        if len(self.users) == 1:
  +            self.set_firstuser(fd)
  +
  +        #self.send_all(1, "")  ذ
  +
  +    def set_firstuser(self, userid):
  +        self.firstuser = userid
  +        self.set_currentuser(userid)
  +
  +    def set_currentuser(self, userid):
  +        self.currentuser = userid
  +
  +    def check_chongtong(self, cardlist):
  +        counttable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  +        
  +        for card in cardlist:
  +            counttable[self.cards.get_group(card)] += 1
  +
  +        if max(counttable) == 4:
  +            return True
  +        else:
  +            return False
  +
  +    def is_tablechongtong(self): #  ˻ؼ   
  +        return self.check_chongtong(self.tablecard)
  +    
  +    def is_chongtong(self, userid): #  ˻ؼ   
  +        return self.check_chongtong(self.users.get_cardlist(userid))
  +
  +    def cut(self, plist, count):
  +        return plist[0:count], plist[count:]
  +
  +    def pop_dummycard(self, count):
  +        result = self.dummycard[0:count]
  +        self.dummycard = self.dummycard[count:]
  +        return result
  +
  +    def init_card(self):
  +        self.dummycard = range(1, self.cards.REALCARDCOUNT + 1)              # ī带  ä ִ´
  +        random.shuffle(self.dummycard)                              # 켱 ī带 ´
  +        
  +        # ٴڿ и   ڿ и  ش
  +        # ִ   Ӹ ٸ ϴ °  ϵ ڵ
  +        
  +        self.tablecard = self.pop_dummycard(self.FIRSTTABLECARDCOUNT)  # ٴڿ и 
  +        for userid in self.users.keys():           # ڿ е  ش
  +            self.users.set_cardlist(userid, self.pop_dummycard(self.FIRSTUSERCARDCOUNT))
  +
  +        # ٴп ʽ    
  +        for card in self.tablecard:
  +            if self.cards.is_bonuscard(card):
  +                print "ٴڿ ʽа "
  +                while 1:
  +                    dummy = self.pop_dummycard(1)[0] # и ϳ ´
  +                    if not self.cards.is_bonuscard(dummy): # ʽа ƴҶ ݺ
  +                        break
  +                    self.users.append_tablecardlist(self.firstuser, self.cards.get_type(dummy), dummy)
  +
  +                self.tablecard.remove(card)
  +                self.tablecard.append(dummy)
  +                self.users.append_tablecardlist(self.firstuser, self.cards.get_type(card), card)
  +
  +        # SEND  ʽ ī 泻뵵 Ŭ̾Ʈ  (׷ Ŭ̾Ʈ ϰ ۾)
  +
  +    def init_var(self):
  +        self.returncard = []
  +        self.duplication = []
  +        self.mode = self.MODE_NORMAL
  +        self.lastgouser = 0
  +        self.bbucklist = {}
  +
  +        # ޼  ʱȭ
  +        self.msgaction = 0
  +        self.msgcard = 0
  +        self.msgdummy = []
  +        self.msgmatchcard = []
  +        self.msgmatchcard2 = []
  +        self.msgstatus = [0, 0]
  +        self.msglostcard = {}
  +        self.msggetcard = {}
  +
  +    def init_game(self):
  +        self.status = self.STATUS_GAME # 
  +        
  +        self.init_var() #    ʱȭ Ѵ
  +        self.users.init_data(self.GOSTOP_POINT) #   ʱȭ Ѵ
  +        self.init_card() # и  , ٴ, з з Ѵ
  +
  +    def make_listpacket(self, list):
  +        result = ""
  +        for data in list:
  +            result += struct.pack("B", data)
  +        return result
  +    
  +    def make_firstcardpacket(self, user):
  +        result = struct.pack("B", len(self.tablecard))
  +        result += self.make_listpacket(self.tablecard)
  +        result += struct.pack("B", len(self.users.get_cardlist(user)))
  +        result += self.make_listpacket(self.users.get_cardlist(user))
  +        result += struct.pack("BB", len(self.users), self.FIRSTUSERCARDCOUNT)
  +
  +        return result
  +
  +    def do_game(self, user):
  +        if self.status == self.STATUS_GAME: #   ٽ   
  +            return
  +
  +        if user != self.firstuser: # 常   
  +            return
  +        
  +        self.set_firstuser(user) #   ְ
  +        #    ְ
  +        self.init_game()              #  ʱȭ Ű
  +
  +        self.send_all_func_each(self.CODE_START, self.make_firstcardpacket)
  +        # SEND  ڿ   ˸
  +        # SEND  ڿ ٴ   ׸ ڽ   ش (ӽ۰   ɵ)
  +        
  +        # ̺κ ʽ ī带  ִ κ Ѿ;
  +        
  +        # ٴп  쿡  
  +        if self.is_tablechongtong():
  +            #   ó ()
  +            print ""
  +            self.end_game() #  
  +            return
  +        
  +        for userid in self.users.keys(): #   ߾ ƾ . ׷ Ѵ    ̱
  +            if self.is_chongtong(userid):
  +                #   ó ()
  +                print ""
  +                self.end_game() #  
  +                return
  +
  +        self.send(self.currentuser, self.CODE_TURN, "")
  +
  +        # SEND    (и ϳ  ˸)
  +        #    ӿ     Ŭ̾Ʈ   ֵ ؾ
  +        
  +        
  +    def get_othercard(self, user, count): # ٸ  ī带 ´
  +        print "  ... "
  +        for userid in self.users.keys():
  +            if userid != user:
  +                flag = 0 # ī带 Դ üũ
  +                cardlist = self.users.get_tablecardlist(userid, self.cards.TYPE_PEE)
  +                for card in cardlist:
  +                    if self.cards.get_point(card) == count:
  +                        #  ī带 ´
  +                        dddd = self.users.remove_tablecard(userid, card, self.cards.TYPE_PEE)
  +                        self.returncard.append(card)
  +                        flag = 1
  +                        print "ī Դ : " + self.get_cardname(card)
  +                        break
  +
  +                if not flag:
  +                    if count >= len(cardlist):
  +                        cardlen = len(cardlist)
  +                    else:
  +                        cardlen = count
  +
  +                    #  ī带 ´
  +                    for card in cardlist[:cardlen]:
  +                        self.users.remove_tablecard(userid, card, self.cards.TYPE_PEE)
  +                        self.returncard.append(card)
  +
  +                        print "ī Դ : " + self.get_cardname(card)
  +                        
  +                        flag = 1
  +                        break
  +
  +
  +    def append_card(self, user, list):
  +        for card in list:
  +            self.users.append_tablecardlist(user, self.cards.get_type(card), card)
  +
  +    def print_all(self):
  +        print "-   : " + str(len(self.dummycard))
  +        print "- ٴ " + "-" * 55
  +        for card in self.tablecard:
  +            print self.cards.get_name(card) + "(" + str(card) + ")",
  +        print "\n"
  +
  +        for user in self.users.keys():
  +            print "- " + self.users.get_username(user) + "  " + "-" * 55
  +            for card in self.users.get_cardlist(user):
  +                print self.cards.get_name(card) + "(" + str(card) + ")",
  +            print "\n"
  +
  +            print "- " + self.users.get_username(user) + " ٴ " + "-" * 55
  +            for card in self.users.get_tablecardlistall(user):
  +                print self.cards.get_name(card) + "(" + str(card) + ")",
  +            print "\n"
  +
  +            print "- " + self.users.get_username(user) + "  : " + str(self.get_currentpoint(user))
  +
  +        print "  : " + self.users.get_username(self.currentuser) + "\n"
  +
  +    def do_gostop(self, user, data): # Ұ   
  +        if self.mode != self.MODE_GOSTOP:
  +            return
  +        
  +        # /  ִ Ȳ üũ
  +        currentpoint = self.get_currentpoint(user)
  +        if currentpoint < self.GOSTOP_POINT:
  +            return
  +
  +        if self.last or data == self.ACTION_STOP: #  ̰ų   
  +            print " "
  +            self.end_game() #  
  +        elif data == self.ACTION_GO:
  +            #   
  +            self.lastgouser = user
  +            self.users.go(user, currentpoint + 1) #  纸 ·ų 1 ƾ  
  +            
  +            self.set_nextuser()
  +
  +    def make_cardpacket(self):
  +        result = struct.pack("BBB", self.msgaction, self.msgcard, len(self.msgdummy)) # ׼, , м
  +        result += self.make_listpacket(self.msgdummy) #  
  +
  +        for i in range(2 - len(self.msgmatchcard)):
  +            self.msgmatchcard.append(0)
  +
  +        for i in range(2 - len(self.msgmatchcard2)):
  +            self.msgmatchcard2.append(0)
  +            
  +        result += struct.pack("BBBB", self.msgmatchcard[0], self.msgmatchcard[1], self.msgmatchcard2[0], self.msgmatchcard2[1]) #  . . . .
  +        result += struct.pack("BBB", 0, 0, len(self.msgreturncard)) # 1, 2, м
  +        result += self.make_listpacket(self.msgreturncard) #  
  +        result += struct.pack("B", len(self.users)) # ڼ
  +        for user in self.users.keys():
  +            result += struct.pack("B", 0)
  +
  +        return result
  +            
  +    def completion_turn(self, user):
  +        print " ó"
  +        # ȹ ī尡  
  +        if self.returncard:
  +            self.append_card(user, self.returncard)
  +            self.msgreturncard = self.returncard
  +
  +        # SEND ϴ  ؼ Ŷ ѹ 
  +        self.send_all_func(self.CODE_CARD, self.make_cardpacket)
  +
  +        if len(self.dummycard) == 0:
  +            print " "
  +            self.end_game() #  
  +            return
  +
  +        if self.get_currentpoint(user) >= self.GOSTOP_POINT:
  +            # SEND / 
  +            self.mode = self.MODE_GOSTOP
  +            self.send(user, self.CODE_GOSTOP, "")
  +            return
  +        
  +        self.set_nextuser()
  +
  +    def set_nextuser(self):
  +        self.init_var()  #       ʱȭ Ѵ
  +        
  +        userlist = self.users.keys()
  +        pos = userlist.index(self.currentuser)
  +        if pos == len(self.users) -1:
  +            self.currentuser = userlist[0]
  +        else:
  +            self.currentuser = userlist[pos + 1]
  +
  +        print " ڿ   ", self.users.get_username(self.currentuser)
  +        self.send(self.currentuser, self.CODE_TURN, "")
  +
  +    def do_jjock(self, user, card, dummy):
  +        print " : " + self.get_cardname(card) + " " + self.get_cardname(dummy)
  +        if not self.last: #      
  +            self.get_othercard(user, 1)
  +            self.msgstatus[0] = self.ACTION_JJOCK
  +            self.msgstatus[1] = self.ACTION_JJOCK
  +        self.returncard.append(dummy)
  +        self.returncard.append(card)
  +
  +    def do_bbuck(self, user, card, dummy, matchcard):
  +        print ""
  +        if not self.last: #    ׳  ī ٴи 
  +            cardgroup = self.cards.get_group(card)
  +            self.tablecard.append(card)
  +            self.tablecard.append(dummy)
  +            self.tablecard += self.returncard # ʽе ش
  +            self.users.append_bbucklist(user, cardgroup) # ش   Ʈ ߰Ѵ
  +            self.bbucklist[cardgroup] =  self.returncard #    ߰
  +
  +            self.msgstatus[0] = self.ACTION_BBUCK
  +            self.msgstatus[1] = self.ACTION_BBUCK
  +
  +            if len(self.users.get_bbucklist(user)) == 3:
  +                #    
  +                print " ̱"
  +                self.end_game() #  
  +                return True
  +        else:
  +            self.returncard.append(card)
  +            self.returncard.append(matchcard)
  +            self.tablecard.append(dummy)
  +
  +        return False
  +            
  +    def do_ddadak(self, user, card, dummy, matchcard):
  +        print ""
  +        if not self.last: #      
  +            self.get_othercard(user, 1)
  +
  +            self.msgstatus[0] = self.ACTION_DDADAK
  +            self.msgstatus[1] = self.ACTION_DDADAK
  +            
  +        self.returncard.append(dummy)
  +        self.returncard.append(card)
  +        self.returncard += matchcard
  +        for tempcard in matchcard:    # а  ٴд Ѵ
  +            self.tablecard.remove(tempcard)
  +
  +    def do_bbuckget(self, user, card, matchcard, index):
  +        cardgroup = self.cards.get_group(card)
  +        if not self.last:
  +            if self.users.check_bbucklist(user, cardgroup):
  +                print "ڻ  : ",
  +                peecount = 2
  +                self.msgstatus[index] = self.ACTION_JABBUCKGET
  +            else:
  +                print "  : ",
  +                peecount = 1
  +                self.msgstatus[index] = self.ACTION_BBUCKGET
  +                
  +            self.get_othercard(user, peecount)
  +        self.returncard.append(card)
  +        self.returncard += matchcard
  +
  +        if self.bbucklist.has_key(cardgroup):
  +            for tempcard in self.bbucklist[cardgroup]:
  +                self.returncard.append(tempcard)
  +                self.tablecard.remove(tempcard)
  +            
  +            del self.bbucklist[cardgroup]
  +
  +        for tempcard in matchcard:    # а  ٴд Ѵ
  +            print self.get_cardname(tempcard), 
  +            self.tablecard.remove(tempcard)
  +
  +    def do_makepee(self, user, card): # ʳ  Ƿ 
  +        # ش ڰ  Ǹ  ִ ˻
  +        if not self.users.check_tablecard(user, card):
  +            return
  +
  +        # ش а  10 ˻
  +        if self.userss.get_special(card) != self.cards.SPECIAL_SSANGPEE:
  +            return
  +
  +        self.users.remove_tablecardlist(user, self.cards.TYPE_10JA. card) # ش и  ǿ ִ´
  +        self.users.append_tablecardlist(user, self.cards.TYPE_PEE, self.cards.get_peecard(card))
  +
  +    def do_select(self, user, card): # а  ¾  ϴ κ
  +        if self.mode != self.MODE_SELECT:
  +            return -10
  +        
  +        if len(self.duplication) <= 0:
  +            print " ° ƴ"
  +            return -10
  +
  +        for i in range(len(self.duplication)):
  +            for tempcard in self.duplication[i]:
  +                if card == tempcard:
  +                    self.returncard.append(card)
  +                    self.tablecard.remove(card)
  +                    del self.duplication[i]
  +
  +                    print " ؼ  : " + self.get_cardname(card)
  +                    
  +                    if len(self.duplication) == 0: #    Ǿ   Ѵ
  +                        self.mode = self.MODE_NORMAL
  +                        self.completion_turn(user)
  +
  +                    return 0
  +
  +        return 0
  +
  +    def get_currentpoint(self, user): #    (  )
  +        result = ""
  +        point = 0
  +        mulcount = 1
  +
  +        #   
  +        cardlist = self.users.get_tablecardlist(user, self.cards.TYPE_GWANG)
  +        if len(cardlist) == 5:
  +            point += 15
  +        elif len(cardlist) >= 3:
  +            point += len(cardlist)
  +            print " " + str(len(cardlist)) + " , ", 
  +            for card in cardlist: #   1 
  +                if self.cards.get_special(card) == self.cards.SPECIAL_BIGWANG:
  +                    point -= 1
  +                    print " 1 , "
  +                    break
  +
  +        # 10  
  +        cardlist = self.users.get_tablecardlist(user, self.cards.TYPE_10JA)
  +        if len(cardlist) >= 5:
  +            point += (len(cardlist) - 4)
  +
  +            print "10 " + str(len(cardlist) - 4) + " , ", 
  +
  +        #if len(cardlist) >= 7: # ۵ ˻
  +        #    mulcount += 1
  +
  +        count = 0
  +        for card in cardlist: #  ˻
  +            if self.cards.get_special(card) == self.cards.SPECIAL_GODORI:
  +                count += 1
  +        if count >= 3:
  +            point += 5
  +
  +        #   
  +        cardlist = self.users.get_tablecardlist(user, self.cards.TYPE_5JA)
  +        if len(cardlist) >= 5:
  +            point += (len(cardlist) - 4)
  +
  +            print " " + str(len(cardlist) - 4) + " , ", 
  +
  +        count = 0
  +        for card in cardlist: # û ˻
  +            if self.cards.get_special(card) == self.cards.SPECIAL_CHUNGDAN:
  +                count += 1
  +        if count >= 3:
  +            point += 3
  +
  +            print "û ",
  +
  +        count = 0
  +        for card in cardlist: # ȫ ˻
  +            if self.cards.get_special(card) == self.cards.SPECIAL_HONGDAN:
  +                count += 1
  +        if count >= 3:
  +            point += 3
  +
  +            print "ȫ ",
  +
  +        count = 0
  +        for card in cardlist: #  ˻
  +            if self.cards.get_special(card) == self.cards.SPECIAL_KOOSA:
  +                count += 1
  +        if count >= 3:
  +            point += 3
  +
  +            print " ", 
  +
  +        #   
  +        cardlist = self.users.get_tablecardlist(user, self.cards.TYPE_PEE)
  +        count = 0
  +        for card in cardlist:
  +            count += self.cards.get_point(card)
  +
  +        if count >= 10:
  +            point += (count - 9)
  +
  +            print " " + str(count - 9) + " , "
  +
  +        print "  : " + str(point) +" "
  +
  +        return point
  +
  +    def do_bonuscard(self, user, card):
  +        print "ʽī "
  +        self.append_card(user, [card])
  +        dummy = self.pop_dummycard(1)[0] # и ϳ ´
  +        self.users.append_cardlist(user, [dummy])
  +
  +        self.send_all(self.CODE_BONUS, struct.pack("B", card))
  +        self.send(user, self.CODE_BONUSGET, struct.pack("B", dummy))
  +        self.send(user, self.CODE_TURN, "")
  +        
  +        if self.is_chongtong(user):
  +            print ""
  +            self.end_game() #  
  +
  +    def check_shake(self, user, card):
  +        templist = self.users.get_cardlist(user)
  +        cardgroup = self.cards.get_group(card)
  +
  +        count = 0
  +        for tempcard in templist:
  +            if self.cards.get_group(tempcard) == cardgroup:
  +                count += 1
  +
  +        if count >= 2: # ϴ   и ϴ 2 
  +            return True
  +        else:
  +            return False
  +
  +    def get_cardname(self, card): # ī̸ ӽ÷  (߿   Լ)
  +        return self.cards.get_name(card) + "(" + str(card) + ")"
  +
  +    def do_bomb(self, user, card): # ź  ó
  +        print "ź"
  +        # 켱 ٴп ´  ִ ˻
  +        cardgroup = self.cards.get_group(card)
  +        flag = 0
  +        for tempcard in self.tablecard:
  +            if cardgroup == self.cards.get_group(tempcard):
  +                flag = 1
  +                break
  +
  +        if flag == 0:
  +            return
  +
  +        self.users.shake(user)
  +        self.get_othercard(user, 1) # ٸ  и ´
  +
  +        print " ź ī : ", 
  +        for tempcard in self.users.get_cardlist(user): #  ź ī п ִ´
  +            if cardgroup == self.cards.get_group(tempcard) and tempcard != card:
  +                print self.get_cardname(tempcard), 
  +                self.returncard.append(tempcard)
  +                self.users.remove_card(user, tempcard)
  +
  +        # ׸ źи ڿ ش
  +        cardbase = self.cards.CARD_BOMB_BASE + self.users.get_shakecount(user) * 2
  +        self.users.append_cardlist(user, [cardbase, cardbase+1])
  +
  +    def do_process(self, user, action, data=0): # ܺ ȣ ޼ҵ
  +        if action == self.ACTION_START:
  +            self.do_game(user)
  +        else:
  +            self.do_turn(user, data, action) #    ó
  +
  +    def do_turn(self, user, card, action): # ѹ  ó
  +        if self.status != self.STATUS_GAME:
  +            print " ƴ"
  +            return [-1]
  +
  +        if self.currentuser != user: #   ڰ ´ ˻
  +            print "  ڰ ƴ"
  +            return [-2]
  +
  +        if self.mode == self.MODE_GOSTOP: # Go/Stop ø 
  +            self.do_gostop(user, action)
  +            return
  +
  +        if not self.cards.check_card(card):
  +            print "ī尪 ߸Ǿ"
  +            return [-3]
  +
  +        if self.mode == self.MODE_SELECT: # ø 
  +            self.do_select(user, card)
  +            return
  +
  +        #print " ī : " + self.get_cardname(card)
  +        
  +        if self.users.remove_card(user, card) == 0: #ش а ش ڿ ִ  ˻
  +            print "ڽſ  и "
  +            return [-4]
  +
  +        if self.cards.is_bonuscard(card): # ʽи   ó
  +            self.do_bonuscard(user, card)
  +            return [0]
  +
  +        if len(self.users.get_cardlist(user)) == 0: #   ˻
  +            print "̹  Դϴ"
  +            self.last = 1
  +        else:
  +            self.last = 0
  +
  +        self.msgcard = card
  +        self.msgaction = action
  +        
  +        # action   Ϲ/ź
  +        if action != self.ACTION_NORMAL:
  +            if self.check_shake(user, card): #  3 ִ ˻
  +                if action == self.ACTION_SHAKE: #   Ƚ 1 ÷ְ ׳ 
  +                    self.users.shake(user)
  +                elif action == self.ACTION_BOMB: # ź  ٴи ˻ؾ
  +                    self.do_bomb(user, card)
  +                else:
  +                    print " ߸ ޵ƽϴ, ", action
  +                    return [-5]
  +
  +
  +        while 1:
  +            dummy = self.pop_dummycard(1)[0] # и ϳ ´
  +            self.msgdummy.append(dummy)
  +            print "  : ", self.get_cardname(dummy)
  +            if not self.cards.is_bonuscard(dummy): # ʽа ƴҶ ݺ
  +                break
  +            self.returncard.append(dummy)
  +            
  +        cardgroup = self.cards.get_group(card)      #  ī ׷ о´
  +
  +        matchcount = 0
  +        matchcard = []
  +        
  +        #  ī ٴа ´  ִ ˻Ѵ
  +        for tempcard in self.tablecard:
  +            if cardgroup == self.cards.get_group(tempcard):
  +                matchcount += 1
  +                matchcard.append(tempcard)
  +
  +        self.msgmatchcard = matchcard
  +
  +        #  ī ׷ о´
  +        dummygroup = self.cards.get_group(dummy)
  +
  +        dummymatchcount = 0
  +        dummymatchcard = []
  +        
  +        # ̿  п ٴа ´  ִ ˻Ѵ
  +        for tempcard in self.tablecard:
  +            if dummygroup == self.cards.get_group(tempcard):
  +                dummymatchcount += 1
  +                dummymatchcard.append(tempcard)
  +
  +        self.msgmatchcard2 = dummymatchcard
  +
  +        #  ī ī尡  ˻Ѵ
  +        if cardgroup == dummygroup:
  +            if matchcount == 0: # 
  +                self.do_jjock(user, card, dummy)
  +            elif matchcount == 1: # 
  +                if self.do_bbuck(user, card, dummy, matchcard[0]):
  +                    return [0] #   ...
  +            elif matchcount == 2: #  ˻
  +                self.do_ddadak(user, card, dummy, matchcard)
  +        else:
  +            tempmatchcount = [matchcount, dummymatchcount]
  +            tempmatchcard = [matchcard, dummymatchcard]
  +            tempselectcard = [card, dummy]
  +
  +            for i in range(2):
  +                if tempmatchcount[i] == 3: # , ڻ 
  +                    self.do_bbuckget(user, tempselectcard[i], tempmatchcard[i], i)
  +                elif tempmatchcount[i] == 1:
  +                    self.returncard.append(tempmatchcard[i][0])
  +                    self.returncard.append(tempselectcard[i])
  +                    self.tablecard.remove(tempmatchcard[i][0])  # а  ٴд Ѵ
  +                    print "¾Ҵ : " + self.get_cardname(tempmatchcard[i][0]) + ", " + self.get_cardname(tempselectcard[i])
  +                    self.msgstatus[i] = self.ACTION_MATCH
  +                elif tempmatchcount[i] == 2:
  +                    self.returncard.append(tempselectcard[i])
  +                    self.duplication.append(tempmatchcard[i])
  +                    # SEND ī带 ϶ ȣ 
  +                    self.mode = self.MODE_SELECT
  +
  +                    self.msgstatus[i] = self.ACTION_MATCH
  +                    self.send(user, self.CODE_SELECT, struct.pack("BBB", tempselectcard[i], tempmatchcard[i][0], tempmatchcard[i][1]))
  +                        
  +                elif tempmatchcount[i] == 0:
  +                    if self.cards.get_special(tempselectcard[i]) != self.cards.SPECIAL_BOMB: # ź ī尡 ƴҶ...
  +                        print "ٴп ߰ : " + self.get_cardname(tempselectcard[i])
  +                        self.tablecard.append(tempselectcard[i])
  +                    print " "
  +
  +            if len(self.duplication) > 0: # ΰ  찡    ޾Ƽ  
  +                return [0]
  +
  +            # Ϸᰡ  Ǿ   
  +            # Go  Ϲݻ Ȯ Ŀ
  +            #   ̸̻ Go/Stop 
  +
  +            # Go    Stop    ó
  +            #  
  +
  +            # Ÿ  
  +
  +        # Ǿ ߰
  +        if len(self.tablecard) == 0:
  +            self.get_othercard(user, 1)
  +            
  +        self.completion_turn(user) #  Ų
  +
  +        return [0]
  +
  +    def event_loop(self, data):
  +        # Ŷ ޾Ƽ óϴ κ ߰
  +        pass
  +
  +    def end_game(self):
  +        self.status = self.STATUS_END #  Ϸ
  +        
  +        #  ؼ    Դ  ϰ ϰ
  +        # ش   ڿ 
  +        self.send_all(self.CODE_END, "")
  +        self.set_firstuser(self.currentuser) #   Ѵ
  +
  +    def get_message(self):
  +        # 
  +        # ϰ, , , 1, 2, 1, 2,
  +        #  ں  ī,  ں ī
  +        #  ڰ  ī,  ڰ  ī
   
  -		return [0]
  +        return [0]
  
  
  
  1.5       +473 -473  siminserver/module/gostop/test.py
  
  Index: test.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/module/gostop/test.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- test.py	8 Nov 2004 10:51:53 -0000	1.4
  +++ test.py	4 Dec 2004 15:08:15 -0000	1.5
  @@ -9,486 +9,486 @@
   import time
   
   class User:
  -	def __init__(self, client, game, userid, username, type="human"):
  -		self.cards = cardlist.cardlist()
  -		self.game = game
  -		self.client = client
  -		self.type = type
  -		self.tablecardlist = []
  -		self.cardlist = []
  -		self.matchcard = []
  -		
  -		self.game.add_user(self, userid, username)
  -
  -		if type == "com":
  -			self.game.users.set_type(self, self.game.users.TYPE_COM)
  -		
  -	def send(self, msg):
  -		print "Ÿ ޾"
  -		# Major Code | Minor Code | Length | Data
  -		major, minor, length = struct.unpack("BBB", msg[:3])
  -		if major != 3:
  -			print "Ÿ ̻ؿ"
  -			return
  -
  -		data = msg[3:]
  -		if minor == self.game.CODE_START:
  -			self.client.mode = self.game.MODE_NORMAL
  -			self.process_start(data)
  -		elif minor == self.game.CODE_END:
  -			print "  "
  -			self.client.mode = self.game.MODE_END
  -			#self.client.draw_end()
  -			pass
  -		elif minor == self.game.CODE_TURN:
  -			self.client.mode = self.game.MODE_NORMAL
  -			self.process_turn()
  -		elif minor == self.game.CODE_SELECT:
  -			self.matchcard = self.process_select(data)
  -			self.client.matchcard = self.matchcard
  -			self.client.mode = self.game.MODE_SELECT
  -		elif minor == self.game.CODE_BONUS:
  -			self.client.mode = self.game.MODE_NORMAL
  -			print self.game.users.get_username(self.game.currentuser), " ڰ ʽ "
  -		elif minor == self.game.CODE_BONUSGET:
  -			self.client.mode = self.game.MODE_NORMAL
  -			self.process_bonuscardget(data)
  -		elif minor == self.game.CODE_CARD:
  -			self.client.mode = self.game.MODE_NORMAL
  -			self.process_card(data)
  -			self.client.oldtablecard = self.game.tablecard
  -		elif minor == self.game.CODE_GOSTOP: #    
  -			self.client.mode = self.game.MODE_GOSTOP
  -			if self.type == "com": # ǻ 
  -				print " "
  -				self.game.ai.do_turn()
  -		else:
  -			print "Ÿ "
  -
  -	def process_card(self, data):
  -		print "ī  оͼ ѷش"
  -
  -		# ׼ |  | м |  
  -		action, card, dummylen = struct.unpack("BBB", data[:3])
  -		data = data[3:]
  -		dummy = []
  -
  -		for i in range(dummylen):
  -			dummy.append(struct.unpack("B", data[i])[0])
  -		data = data[dummylen:]
  -
  -		# 1 | 2 | 3 | 4 | 1 | 2
  -		# м |  
  -
  -		matchcard = struct.unpack("BB", data[:2])
  -		data = data[2:]
  -		matchcard2 = struct.unpack("BB", data[:2])
  -		data = data[2:]
  -		status = struct.unpack("BB", data[:2])
  -		data = data[2:]
  -		returncardlen = struct.unpack("B", data[:1])[0]
  -		data = data[1:]
  -		returncard = []
  -
  -		for i in range(returncardlen):
  -			returncard.append(struct.unpack("B", data[i])[0])
  -		data = data[returncardlen+1:]
  -
  -		self.client.draw_animate(action, card, dummy, matchcard, matchcard2, status, returncardlen, returncard)
  -		
  -		# ڼ | Ÿ ...
  -
  -	def process_bonuscardget(self, data):
  -		card = struct.unpack("B", data)[0]
  -		print self.game.get_cardname(card), " ʽ "
  -		#draw_card()
  -
  -	def process_turn(self):
  -		print " ޾"
  -
  -		if self.type == "com":
  -			self.client.draw_modalress("Computer's turn", [500, 220, 100, 40], 10, 10)
  -			#print "ǻ   -- Ű ּ",
  -			print "ǻ ΰ  =================================================================="
  -			time.sleep(0.3)
  -			
  -			self.game.ai.do_turn()
  -
  -
  -	def process_myturn(self, data):
  -		datalen = len(self.game.users.get_cardlist(self))
  -
  -		if data > datalen:
  -			return
  -		# ź ˻
  -
  -		data = self.game.users.get_cardlist(self)[int(data)-1]
  -		cardgroup = self.game.cards.get_group(int(data))
  -
  -		# ϴ ´ ٴа ִ ˻
  -		tablematch = 0
  -		for card in self.game.tablecard:
  -			if cardgroup == self.game.cards.get_group(card):
  -				tablematch += 1
  -		count = 0
  -		for card in self.game.users.get_cardlist(self.game.currentuser):
  -			if cardgroup == self.game.cards.get_group(card):
  -				count += 1
  -
  -		if count == 3:
  -			if tablematch == 0:
  -				print " = 1, ׳ɳ = 0"
  -				self.client.askbomb = 1
  -			else:
  -				print " = 1, ź = 2, ׳ɳ = 0"
  -				self.client.askbomb = 2
  -				
  -			self.client.currentcard = data
  -		else:
  -			self.game.do_process(self, self.game.ACTION_NORMAL, data)
  -
  -
  -	def process_select(self, data):
  -		print " ó"
  -
  -		if self.type == "com":
  -			print "ǻͰ  ======================================================================"
  -			self.game.ai.do_turn()
  -			return
  -			
  -		#  | 1 | 2
  -		card, match1, match2 = struct.unpack("BBB", data)
  -
  -		print " и ϼ ( " + self.game.get_cardname(match1) + " / " + self.game.get_cardname(match2) + " )"
  -
  -		return [match1, match2]
  -
  -	def process_start(self, data):
  -		
  -		if self.type == "com": # ǻ   ʿ䰡 
  -			return
  -		
  -		print " "
  -		# ٴм | ٴи | м | и |  | ī
  -		tablecardlen = struct.unpack("B", data[0])[0]
  -		print "tablecardlen : ", tablecardlen
  -		for i in range(tablecardlen):
  -			self.tablecardlist.append(struct.unpack("B", data[i+1])[0])
  -
  -		data = data[tablecardlen+1:]
  -		cardlen = struct.unpack("B", data[0])[0]
  -		for i in range(cardlen):
  -			self.cardlist.append(struct.unpack("B", data[i+1])[0])
  -
  -		data = data[cardlen+1:]
  -		users, firstusercardcount = struct.unpack("BB", data)
  -
  -		# ٴи Ѵ
  -		
  -		print "ٴ : ", 
  -		for card in self.tablecardlist:
  -			print self.game.get_cardname(card),
  -
  -		print
  -
  -		#  и Ѵ
  -		print "  : ", 
  -		for card in self.cardlist:
  -			print self.game.get_cardname(card),
  -		print
  +    def __init__(self, client, game, userid, username, type="human"):
  +        self.cards = cardlist.cardlist()
  +        self.game = game
  +        self.client = client
  +        self.type = type
  +        self.tablecardlist = []
  +        self.cardlist = []
  +        self.matchcard = []
  +        
  +        self.game.add_user(self, userid, username)
  +
  +        if type == "com":
  +            self.game.users.set_type(self, self.game.users.TYPE_COM)
  +        
  +    def send(self, msg):
  +        print "Ÿ ޾"
  +        # Major Code | Minor Code | Length | Data
  +        major, minor, length = struct.unpack("BBB", msg[:3])
  +        if major != 3:
  +            print "Ÿ ̻ؿ"
  +            return
  +
  +        data = msg[3:]
  +        if minor == self.game.CODE_START:
  +            self.client.mode = self.game.MODE_NORMAL
  +            self.process_start(data)
  +        elif minor == self.game.CODE_END:
  +            print "  "
  +            self.client.mode = self.game.MODE_END
  +            #self.client.draw_end()
  +            pass
  +        elif minor == self.game.CODE_TURN:
  +            self.client.mode = self.game.MODE_NORMAL
  +            self.process_turn()
  +        elif minor == self.game.CODE_SELECT:
  +            self.matchcard = self.process_select(data)
  +            self.client.matchcard = self.matchcard
  +            self.client.mode = self.game.MODE_SELECT
  +        elif minor == self.game.CODE_BONUS:
  +            self.client.mode = self.game.MODE_NORMAL
  +            print self.game.users.get_username(self.game.currentuser), " ڰ ʽ "
  +        elif minor == self.game.CODE_BONUSGET:
  +            self.client.mode = self.game.MODE_NORMAL
  +            self.process_bonuscardget(data)
  +        elif minor == self.game.CODE_CARD:
  +            self.client.mode = self.game.MODE_NORMAL
  +            self.process_card(data)
  +            self.client.oldtablecard = self.game.tablecard
  +        elif minor == self.game.CODE_GOSTOP: #    
  +            self.client.mode = self.game.MODE_GOSTOP
  +            if self.type == "com": # ǻ 
  +                print " "
  +                self.game.ai.do_turn()
  +        else:
  +            print "Ÿ "
  +
  +    def process_card(self, data):
  +        print "ī  оͼ ѷش"
  +
  +        # ׼ |  | м |  
  +        action, card, dummylen = struct.unpack("BBB", data[:3])
  +        data = data[3:]
  +        dummy = []
  +
  +        for i in range(dummylen):
  +            dummy.append(struct.unpack("B", data[i])[0])
  +        data = data[dummylen:]
  +
  +        # 1 | 2 | 3 | 4 | 1 | 2
  +        # м |  
  +
  +        matchcard = struct.unpack("BB", data[:2])
  +        data = data[2:]
  +        matchcard2 = struct.unpack("BB", data[:2])
  +        data = data[2:]
  +        status = struct.unpack("BB", data[:2])
  +        data = data[2:]
  +        returncardlen = struct.unpack("B", data[:1])[0]
  +        data = data[1:]
  +        returncard = []
  +
  +        for i in range(returncardlen):
  +            returncard.append(struct.unpack("B", data[i])[0])
  +        data = data[returncardlen+1:]
  +
  +        self.client.draw_animate(action, card, dummy, matchcard, matchcard2, status, returncardlen, returncard)
  +        
  +        # ڼ | Ÿ ...
  +
  +    def process_bonuscardget(self, data):
  +        card = struct.unpack("B", data)[0]
  +        print self.game.get_cardname(card), " ʽ "
  +        #draw_card()
  +
  +    def process_turn(self):
  +        print " ޾"
  +
  +        if self.type == "com":
  +            self.client.draw_modalress("Computer's turn", [500, 220, 100, 40], 10, 10)
  +            #print "ǻ   -- Ű ּ",
  +            print "ǻ ΰ  =================================================================="
  +            time.sleep(0.3)
  +            
  +            self.game.ai.do_turn()
  +
  +
  +    def process_myturn(self, data):
  +        datalen = len(self.game.users.get_cardlist(self))
  +
  +        if data > datalen:
  +            return
  +        # ź ˻
  +
  +        data = self.game.users.get_cardlist(self)[int(data)-1]
  +        cardgroup = self.game.cards.get_group(int(data))
  +
  +        # ϴ ´ ٴа ִ ˻
  +        tablematch = 0
  +        for card in self.game.tablecard:
  +            if cardgroup == self.game.cards.get_group(card):
  +                tablematch += 1
  +        count = 0
  +        for card in self.game.users.get_cardlist(self.game.currentuser):
  +            if cardgroup == self.game.cards.get_group(card):
  +                count += 1
  +
  +        if count == 3:
  +            if tablematch == 0:
  +                print " = 1, ׳ɳ = 0"
  +                self.client.askbomb = 1
  +            else:
  +                print " = 1, ź = 2, ׳ɳ = 0"
  +                self.client.askbomb = 2
  +                
  +            self.client.currentcard = data
  +        else:
  +            self.game.do_process(self, self.game.ACTION_NORMAL, data)
  +
  +
  +    def process_select(self, data):
  +        print " ó"
  +
  +        if self.type == "com":
  +            print "ǻͰ  ======================================================================"
  +            self.game.ai.do_turn()
  +            return
  +            
  +        #  | 1 | 2
  +        card, match1, match2 = struct.unpack("BBB", data)
  +
  +        print " и ϼ ( " + self.game.get_cardname(match1) + " / " + self.game.get_cardname(match2) + " )"
  +
  +        return [match1, match2]
  +
  +    def process_start(self, data):
  +        
  +        if self.type == "com": # ǻ   ʿ䰡 
  +            return
  +        
  +        print " "
  +        # ٴм | ٴи | м | и |  | ī
  +        tablecardlen = struct.unpack("B", data[0])[0]
  +        print "tablecardlen : ", tablecardlen
  +        for i in range(tablecardlen):
  +            self.tablecardlist.append(struct.unpack("B", data[i+1])[0])
  +
  +        data = data[tablecardlen+1:]
  +        cardlen = struct.unpack("B", data[0])[0]
  +        for i in range(cardlen):
  +            self.cardlist.append(struct.unpack("B", data[i+1])[0])
  +
  +        data = data[cardlen+1:]
  +        users, firstusercardcount = struct.unpack("BB", data)
  +
  +        # ٴи Ѵ
  +        
  +        print "ٴ : ", 
  +        for card in self.tablecardlist:
  +            print self.game.get_cardname(card),
  +
  +        print
  +
  +        #  и Ѵ
  +        print "  : ", 
  +        for card in self.cardlist:
  +            print self.game.get_cardname(card),
  +        print
   
   
   class Client:
  -	def __init__(self):
  -		# pygame ʱȭ  ̹ о
  -		pygame.init()
  -
  -		size = width, height = 620, 480
  -		self.black = 0, 0, 0
  -		self.green= 0, 100, 0
  -		self.blue = 0, 0, 255
  -		self.yellow = 200, 200, 0
  -		self.screen = pygame.display.set_mode(size)
  -		
  -		self.clock = pygame.time.Clock()
  -		self.askbomb = 0
  -		self.currentcard = 0
  -		self.oldtablecard = []
  -
  -		data_root = "../../../simingostop/data"
  -
  -		self.font = pygame.font.Font(data_root + "/UnBom.ttf", 12)
  -		
  -		self.img = {}
  -		for i in range(1, 51):
  -			self.img[i] = pygame.image.load("%s/card%02d.jpg" % (data_root, i))
  -		for i in range(61, 69):
  -			self.img[i] = pygame.image.load("%s/card%02d.jpg" % (data_root, i))
  -
  -		self.img_back = pygame.image.load("%s/cardback.jpg" % (data_root))
  -	
  -		self.game = gostop.gostop()
  -		self.user1 = User(self, self.game, "Yi", "linux1999@hanmail.net")
  -		self.com1 = User(self, self.game, "Comdori", "test@test.com", "com")
  -
  -		self.mode = self.game.MODE_NORMAL
  -		self.game.do_process(self.user1, self.game.ACTION_START)
  -
  -	def draw_card(self, card, x, y):
  -		img_rect = self.img[card].get_rect()
  -		img_rect[0] = x
  -		img_rect[1] = y
  -		self.screen.blit(self.img[card], img_rect)
  -
  -	def draw_text(self, str, x, y):
  -		text = self.font.render(str, 1, self.blue)
  -		textpos = text.get_rect()
  -		textpos[0] = x
  -		textpos[1] = y
  -		self.screen.blit(text, textpos)
  -
  -	def draw_select(self):
  -		self.screen.fill(self.yellow, [150, 170, 260, 160])
  -
  -		self.draw_card(self.matchcard[0], 200, 200)
  -		self.draw_card(self.matchcard[1], 300, 200)
  -
  -		self.draw_text("1", 230, 180)
  -		self.draw_text("2", 330, 180)
  -
  -		self.draw_text("Select Card", 200, 280)
  -
  -	def draw_gostop(self):
  -		self.screen.fill(self.yellow, [150, 170, 260, 160])
  -
  -		self.draw_text("1 = Go, 2 = Stop", 200, 300)
  -		
  -	def draw_askbomb(self):
  -		self.screen.fill(self.yellow, [150, 170, 260, 160])
  -
  -		i = 0
  -		cardgroup = self.game.cards.get_group(self.currentcard)
  -		for card in self.game.users.get_cardlist(self.user1):
  -			if cardgroup == self.game.cards.get_group(card):
  -				self.draw_card(card, 200 + i * 60, 200)
  -				i += 1
  -			
  -		self.draw_text("Select Action", 200, 280)
  -		if self.askbomb == 1:
  -			self.draw_text("1 = Shake, 0 = Normal", 200, 300)
  -		else:
  -			self.draw_text("1 = Shake, 2 = Bomb, 0 = Normal", 200, 300)
  -		
  -	def draw_end(self):
  -		self.screen.fill(self.yellow, [150, 170, 260, 160])
  -
  -		self.draw_text("Game Over!!!!", 200, 300)
  -		#self.draw_modalress("Game Over!!!!", [300, 300, 200, 200], 50, 50)
  -		
  -	def draw_backcard(self, x, y):
  -		img_rect = self.img_back.get_rect()
  -		img_rect[0] = x
  -		img_rect[1] = y
  -		self.screen.blit(self.img_back, img_rect)
  -
  -	def draw_modalress(self, msg, rect, x, y):
  -		self.update()
  -		self.screen.fill(self.yellow, rect)
  -
  -		self.draw_text(msg, rect[0]+x, rect[1]+y)
  -
  -		pygame.display.flip()
  -
  -	def draw_animate(self, action, firstcard, dummy, matchcard, matchcard2, status, returncardlen, returncard):
  -		return
  -	
  -		cardlist = []
  -		# ϴ  ī带 ׸
  -		cardgroup = self.game.cards.get_group(firstcard)
  -		i = 0
  -		x = 10 + (7 + 2) * 60
  -		y = 100 + 1 * 90
  -		j = 0
  -		for card in self.oldtablecard:
  -			if cardgroup == self.game.cards.get_group(card):
  -				x = 10 + (i+2) * 60 + 20
  -				if i >= 8:
  -					j = 1
  -				y = 100 + j * 90 + 20
  -				break
  -
  -			i += 1
  -
  -		cardlist.append([firstcard, x, y])
  -		
  -		self.update()
  -		self.draw_card(firstcard, x, y)
  -		pygame.display.flip()
  -
  -		for tempcard in dummy:
  -			time.sleep(0.5)
  -			self.update()
  -			self.draw_card(tempcard, 0, 0)
  -			pygame.display.flip()
  -		
  -	def update(self):
  -
  -		self.screen.fill(self.black) #  
  -
  -		# ٴ ׸
  -		self.screen.fill(self.green, [5, 95, 5 + 10 * 60, 190])
  -
  -		# ī  
  -		for i in range(1, 11):
  -			strtext = str(i)
  -			if i == 10:
  -				strtext = "0"
  -			self.draw_text(strtext, 10 + (i - 1) * 60 + 20, 380)
  -
  -		# и ׸
  -		for i in range(0, len(self.game.dummycard)):
  -			self.draw_backcard(10+40-i*1, 100+60-i*1);
  -		
  -		# ٴи ׸
  -		tablecard = self.game.tablecard
  -
  -		i = 0
  -		j = 0
  -		if len(self.game.bbucklist) > 0: # ϴ  ϱ   ׷
  -			for cardgroup in self.game.bbucklist.keys():
  -				k = 0
  -				
  -				for card in tablecard:
  -					if cardgroup == self.game.cards.get_group(card):
  -						self.draw_card(card, 10 + (i+2) * 60- k * 1, 100 - k * 1)
  -						tablecard.remove(card)
  -
  -				
  -				i += 1
  -						
  -		for card in self.game.tablecard:
  -			self.draw_card(card, 10 + (i+2) * 60, 100 + j * 90)
  -			i += 1
  -			if i == 8:
  -				i = 0
  -				j += 1
  -
  -		#  ٴ ׸
  -		self.screen.fill(self.green, [5, 395, 5 + 10 * 60, 190])
  -
  -		# и ׸
  -		i = 0
  -		for card in self.game.users.get_cardlist(self.user1):
  -			self.draw_card(card, 10 + i * 60, 400)
  -			i += 1
  -	
  -		# ǻͰ  и ׸
  -		self.draw_owncard(self.com1, 10)
  -
  -		# ڰ  и ׸
  -		self.draw_owncard(self.user1, 300)
  -		
  -		if self.mode == self.game.MODE_SELECT:
  -			self.draw_select()
  -
  -		if self.askbomb != 0:
  -			self.draw_askbomb()
  -
  -		if self.mode == self.game.MODE_GOSTOP:
  -			self.draw_gostop()
  -
  -		if self.game.status == self.game.STATUS_END:
  -			self.draw_end()
  -			
  -		
  -
  -	def draw_owncard(self, user, y):
  -		cardpos = [0, 0, 100, 220, 340, 460]
  -		for index in range(1, 5):
  -			i = 0
  -			for card in self.game.users.get_tablecardlist(user, index):
  -				self.draw_card(card, cardpos[index] + 10 + i * 10, y)
  -				i += 1
  -
  -	def event_loop(self):
  -		while 1:
  -			for event in pygame.event.get():
  -				if event.type == pygame.QUIT:
  -					sys.exit(0)
  -				elif event.type == pygame.KEYDOWN:
  -					print "Ű "
  -					if event.key == pygame.K_ESCAPE:
  -						sys.exit(0)
  -							
  -					if self.game.status != self.game.STATUS_GAME:
  -						self.game.do_process(self.game.currentuser, self.game.ACTION_START)
  -				
  -					else:
  -						if self.game.currentuser == self.user1:
  -							
  -							if self.game.mode == self.game.MODE_NORMAL:
  -								if self.askbomb != 0:
  -									data = -1
  -									if event.key == pygame.K_1:
  -										data = 1
  -									elif event.key == pygame.K_0:
  -										data = 0
  -									elif event.key == pygame.K_2 and self.askbomb == 2:
  -										data = 2
  -
  -									if data > -1:
  -										self.askbomb = 0
  -										self.game.do_process(self.user1, data,  self.currentcard)
  -								
  -								data = 0
  -								if event.key == pygame.K_1:
  -									data = 1
  -								elif event.key == pygame.K_2:
  -									data = 2
  -								elif event.key == pygame.K_3:
  -									data = 3
  -								elif event.key == pygame.K_4:
  -									data = 4
  -								elif event.key == pygame.K_5:
  -									data = 5
  -								elif event.key == pygame.K_6:
  -									data = 6
  -								elif event.key == pygame.K_7:
  -									data = 7
  -								elif event.key == pygame.K_8:
  -									data = 8
  -								elif event.key == pygame.K_9:
  -									data = 9
  -								elif event.key == pygame.K_0:
  -									data = 10
  -
  -								if data > 0:
  -									self.user1.process_myturn(data)
  -							elif self.game.mode == self.game.MODE_SELECT:
  -								data = -1
  -								if event.key == pygame.K_1:
  -									data = 0
  -								elif event.key == pygame.K_2:
  -									data = 1
  -
  -								if data > -1:
  -									self.game.do_process(self.user1, self.game.ACTION_NORMAL, self.matchcard[data])
  -							elif self.game.mode == self.game.MODE_GOSTOP:
  -								data = -1
  -								if event.key == pygame.K_1:
  -									data = self.game.ACTION_GO
  -								elif event.key == pygame.K_2:
  -									data = self.game.ACTION_STOP
  +    def __init__(self):
  +        # pygame ʱȭ  ̹ о
  +        pygame.init()
  +
  +        size = width, height = 620, 480
  +        self.black = 0, 0, 0
  +        self.green= 0, 100, 0
  +        self.blue = 0, 0, 255
  +        self.yellow = 200, 200, 0
  +        self.screen = pygame.display.set_mode(size)
  +        
  +        self.clock = pygame.time.Clock()
  +        self.askbomb = 0
  +        self.currentcard = 0
  +        self.oldtablecard = []
  +
  +        data_root = "../../../simingostop/data"
  +
  +        self.font = pygame.font.Font(data_root + "/UnBom.ttf", 12)
  +        
  +        self.img = {}
  +        for i in range(1, 51):
  +            self.img[i] = pygame.image.load("%s/card%02d.jpg" % (data_root, i))
  +        for i in range(61, 69):
  +            self.img[i] = pygame.image.load("%s/card%02d.jpg" % (data_root, i))
  +
  +        self.img_back = pygame.image.load("%s/cardback.jpg" % (data_root))
  +    
  +        self.game = gostop.gostop()
  +        self.user1 = User(self, self.game, "Yi", "linux1999@hanmail.net")
  +        self.com1 = User(self, self.game, "Comdori", "test@test.com", "com")
  +
  +        self.mode = self.game.MODE_NORMAL
  +        self.game.do_process(self.user1, self.game.ACTION_START)
  +
  +    def draw_card(self, card, x, y):
  +        img_rect = self.img[card].get_rect()
  +        img_rect[0] = x
  +        img_rect[1] = y
  +        self.screen.blit(self.img[card], img_rect)
  +
  +    def draw_text(self, str, x, y):
  +        text = self.font.render(str, 1, self.blue)
  +        textpos = text.get_rect()
  +        textpos[0] = x
  +        textpos[1] = y
  +        self.screen.blit(text, textpos)
  +
  +    def draw_select(self):
  +        self.screen.fill(self.yellow, [150, 170, 260, 160])
  +
  +        self.draw_card(self.matchcard[0], 200, 200)
  +        self.draw_card(self.matchcard[1], 300, 200)
  +
  +        self.draw_text("1", 230, 180)
  +        self.draw_text("2", 330, 180)
  +
  +        self.draw_text("Select Card", 200, 280)
  +
  +    def draw_gostop(self):
  +        self.screen.fill(self.yellow, [150, 170, 260, 160])
  +
  +        self.draw_text("1 = Go, 2 = Stop", 200, 300)
  +        
  +    def draw_askbomb(self):
  +        self.screen.fill(self.yellow, [150, 170, 260, 160])
  +
  +        i = 0
  +        cardgroup = self.game.cards.get_group(self.currentcard)
  +        for card in self.game.users.get_cardlist(self.user1):
  +            if cardgroup == self.game.cards.get_group(card):
  +                self.draw_card(card, 200 + i * 60, 200)
  +                i += 1
  +            
  +        self.draw_text("Select Action", 200, 280)
  +        if self.askbomb == 1:
  +            self.draw_text("1 = Shake, 0 = Normal", 200, 300)
  +        else:
  +            self.draw_text("1 = Shake, 2 = Bomb, 0 = Normal", 200, 300)
  +        
  +    def draw_end(self):
  +        self.screen.fill(self.yellow, [150, 170, 260, 160])
  +
  +        self.draw_text("Game Over!!!!", 200, 300)
  +        #self.draw_modalress("Game Over!!!!", [300, 300, 200, 200], 50, 50)
  +        
  +    def draw_backcard(self, x, y):
  +        img_rect = self.img_back.get_rect()
  +        img_rect[0] = x
  +        img_rect[1] = y
  +        self.screen.blit(self.img_back, img_rect)
  +
  +    def draw_modalress(self, msg, rect, x, y):
  +        self.update()
  +        self.screen.fill(self.yellow, rect)
  +
  +        self.draw_text(msg, rect[0]+x, rect[1]+y)
  +
  +        pygame.display.flip()
  +
  +    def draw_animate(self, action, firstcard, dummy, matchcard, matchcard2, status, returncardlen, returncard):
  +        return
  +    
  +        cardlist = []
  +        # ϴ  ī带 ׸
  +        cardgroup = self.game.cards.get_group(firstcard)
  +        i = 0
  +        x = 10 + (7 + 2) * 60
  +        y = 100 + 1 * 90
  +        j = 0
  +        for card in self.oldtablecard:
  +            if cardgroup == self.game.cards.get_group(card):
  +                x = 10 + (i+2) * 60 + 20
  +                if i >= 8:
  +                    j = 1
  +                y = 100 + j * 90 + 20
  +                break
  +
  +            i += 1
  +
  +        cardlist.append([firstcard, x, y])
  +        
  +        self.update()
  +        self.draw_card(firstcard, x, y)
  +        pygame.display.flip()
  +
  +        for tempcard in dummy:
  +            time.sleep(0.5)
  +            self.update()
  +            self.draw_card(tempcard, 0, 0)
  +            pygame.display.flip()
  +        
  +    def update(self):
  +
  +        self.screen.fill(self.black) #  
  +
  +        # ٴ ׸
  +        self.screen.fill(self.green, [5, 95, 5 + 10 * 60, 190])
  +
  +        # ī  
  +        for i in range(1, 11):
  +            strtext = str(i)
  +            if i == 10:
  +                strtext = "0"
  +            self.draw_text(strtext, 10 + (i - 1) * 60 + 20, 380)
  +
  +        # и ׸
  +        for i in range(0, len(self.game.dummycard)):
  +            self.draw_backcard(10+40-i*1, 100+60-i*1);
  +        
  +        # ٴи ׸
  +        tablecard = self.game.tablecard
  +
  +        i = 0
  +        j = 0
  +        if len(self.game.bbucklist) > 0: # ϴ  ϱ   ׷
  +            for cardgroup in self.game.bbucklist.keys():
  +                k = 0
  +                
  +                for card in tablecard:
  +                    if cardgroup == self.game.cards.get_group(card):
  +                        self.draw_card(card, 10 + (i+2) * 60- k * 1, 100 - k * 1)
  +                        tablecard.remove(card)
  +
  +                
  +                i += 1
  +                        
  +        for card in self.game.tablecard:
  +            self.draw_card(card, 10 + (i+2) * 60, 100 + j * 90)
  +            i += 1
  +            if i == 8:
  +                i = 0
  +                j += 1
  +
  +        #  ٴ ׸
  +        self.screen.fill(self.green, [5, 395, 5 + 10 * 60, 190])
  +
  +        # и ׸
  +        i = 0
  +        for card in self.game.users.get_cardlist(self.user1):
  +            self.draw_card(card, 10 + i * 60, 400)
  +            i += 1
  +    
  +        # ǻͰ  и ׸
  +        self.draw_owncard(self.com1, 10)
  +
  +        # ڰ  и ׸
  +        self.draw_owncard(self.user1, 300)
  +        
  +        if self.mode == self.game.MODE_SELECT:
  +            self.draw_select()
  +
  +        if self.askbomb != 0:
  +            self.draw_askbomb()
  +
  +        if self.mode == self.game.MODE_GOSTOP:
  +            self.draw_gostop()
  +
  +        if self.game.status == self.game.STATUS_END:
  +            self.draw_end()
  +            
  +        
  +
  +    def draw_owncard(self, user, y):
  +        cardpos = [0, 0, 100, 220, 340, 460]
  +        for index in range(1, 5):
  +            i = 0
  +            for card in self.game.users.get_tablecardlist(user, index):
  +                self.draw_card(card, cardpos[index] + 10 + i * 10, y)
  +                i += 1
  +
  +    def event_loop(self):
  +        while 1:
  +            for event in pygame.event.get():
  +                if event.type == pygame.QUIT:
  +                    sys.exit(0)
  +                elif event.type == pygame.KEYDOWN:
  +                    print "Ű "
  +                    if event.key == pygame.K_ESCAPE:
  +                        sys.exit(0)
  +                            
  +                    if self.game.status != self.game.STATUS_GAME:
  +                        self.game.do_process(self.game.currentuser, self.game.ACTION_START)
  +                
  +                    else:
  +                        if self.game.currentuser == self.user1:
  +                            
  +                            if self.game.mode == self.game.MODE_NORMAL:
  +                                if self.askbomb != 0:
  +                                    data = -1
  +                                    if event.key == pygame.K_1:
  +                                        data = 1
  +                                    elif event.key == pygame.K_0:
  +                                        data = 0
  +                                    elif event.key == pygame.K_2 and self.askbomb == 2:
  +                                        data = 2
  +
  +                                    if data > -1:
  +                                        self.askbomb = 0
  +                                        self.game.do_process(self.user1, data,  self.currentcard)
  +                                
  +                                data = 0
  +                                if event.key == pygame.K_1:
  +                                    data = 1
  +                                elif event.key == pygame.K_2:
  +                                    data = 2
  +                                elif event.key == pygame.K_3:
  +                                    data = 3
  +                                elif event.key == pygame.K_4:
  +                                    data = 4
  +                                elif event.key == pygame.K_5:
  +                                    data = 5
  +                                elif event.key == pygame.K_6:
  +                                    data = 6
  +                                elif event.key == pygame.K_7:
  +                                    data = 7
  +                                elif event.key == pygame.K_8:
  +                                    data = 8
  +                                elif event.key == pygame.K_9:
  +                                    data = 9
  +                                elif event.key == pygame.K_0:
  +                                    data = 10
  +
  +                                if data > 0:
  +                                    self.user1.process_myturn(data)
  +                            elif self.game.mode == self.game.MODE_SELECT:
  +                                data = -1
  +                                if event.key == pygame.K_1:
  +                                    data = 0
  +                                elif event.key == pygame.K_2:
  +                                    data = 1
  +
  +                                if data > -1:
  +                                    self.game.do_process(self.user1, self.game.ACTION_NORMAL, self.matchcard[data])
  +                            elif self.game.mode == self.game.MODE_GOSTOP:
  +                                data = -1
  +                                if event.key == pygame.K_1:
  +                                    data = self.game.ACTION_GO
  +                                elif event.key == pygame.K_2:
  +                                    data = self.game.ACTION_STOP
   
  -								if data > -1:
  -									self.game.do_process(self.user1, data)
  +                                if data > -1:
  +                                    self.game.do_process(self.user1, data)
   
   
  -			self.update()
  -			pygame.display.flip()
  +            self.update()
  +            pygame.display.flip()
   
   
   
   if __name__ == '__main__':
  -	client = Client()
  -	client.event_loop()
  +    client = Client()
  +    client.event_loop()
  
  
  
  1.2       +181 -183  siminserver/module/gostop/userlist.py
  
  Index: userlist.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/module/gostop/userlist.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- userlist.py	2 Nov 2004 17:56:41 -0000	1.1
  +++ userlist.py	4 Dec 2004 15:08:15 -0000	1.2
  @@ -2,187 +2,185 @@
   # -*- coding: utf_8 -*-
   
   class userinfo:
  -	def __init__(self, fd, userid, username):
  -		self.userid        = fd
  -		self.username      = username
  -		self.userloginid   = userid
  -		self.type          = 0  # ,  (0 / 1)
  -		
  -		self.cardlist      = [] #  
  -		self.tablecardlist = [[], [], [], [], []] # ٴ 
  -		self.bbucklist     = [] #  Ʈ
  -		self.point         = 0  # 
  -		self.shake         = 0  #  Ƚ
  -		self.gocount       = 0  #  Ƚ
  -		self.gopoint   = 0  #    (   )
  -		
  +    def __init__(self, fd, userid, username):
  +        self.userid        = fd
  +        self.username      = username
  +        self.userloginid   = userid
  +        self.type          = 0  # ,  (0 / 1)
  +        
  +        self.cardlist      = [] #  
  +        self.tablecardlist = [[], [], [], [], []] # ٴ 
  +        self.bbucklist     = [] #  Ʈ
  +        self.point         = 0  # 
  +        self.shake         = 0  #  Ƚ
  +        self.gocount       = 0  #  Ƚ
  +        self.gopoint   = 0  #    (   )
  +        
   class userlist:
  -	def __init__(self):
  -		self.users		 = {}
  -		self.userindex   = [] # 
  -
  -		self.TYPE_HUMAN    = 0
  -		self.TYPE_COM      = 1
  -
  -	def  __len__(self):
  -		return len(self.users)
  -
  -	def get_fd(self, userid):
  -		return self.users[userid].userid
  -
  -	def get_loginid(self, userid):
  -		return self.suers[userid].userloginid
  -	
  -	def get_type(self, userid):
  -		return self.users[userid].type
  -
  -	def set_type(self, userid, type):
  -		self.users[userid].type = type
  -
  -	def set_gopoint(self, userid, point):
  -		self.users[userid].gopoint = point
  -
  -	def get_gopoint(self, userid):
  -		return self.users[userid].gopoint
  -
  -	def go(self, userid, gopoint):
  -		self.users[userid].gocount += 1
  -		self.users[userid].gopoint = gopoint
  -		
  -	def shake(self, userid):
  -		self.users[userid].shake += 1
  -
  -	def get_shakecount(self, userid):
  -		return self.users[userid].shake
  -
  -	def init_data(self, gopoint):
  -		for userid in self.userindex:
  -			user = self.users[userid]
  -			
  -			user.cardlist = []
  -			user.tablecardlist = [[], [], [], [], []]
  -			user.bbucklist = []
  -			user.point = 0
  -			user.shake = 0
  -			user.gopoint = gopoint
  -
  -	def append(self, fd, userid, username):
  -		self.users[fd] = userinfo(fd, userid, username)
  -		self.userindex.append(fd)
  -		
  -	def keys(self):
  -		#return self.users.keys()
  -		return self.userindex
  -
  -	def has_key(self, userid):
  -		return self.users.has_key(userid)
  -
  -	def remove(self, userid):
  -		if has_key(userid):
  -			del self.users[userid]
  -			del self.userindex
  -
  -	def user(self, userid):
  -		return self.users[userid]
  -
  -	def get_type(self, userid):
  -		return self.users[userid].type
  -	
  -	def get_username(self, userid):
  -		return self.users[userid].userloginid
  -	
  -	def get_cardlist(self, userid):
  -		return self.users[userid].cardlist
  -
  -	def set_cardlist(self, userid, cardlist):
  -		self.users[userid].cardlist = cardlist
  -		self.users[userid].cardlist.sort()
  -
  -	def append_cardlist(self, userid, cardlist):
  -		self.users[userid].cardlist += cardlist
  -
  -	def get_tablecardlist(self, userid, type):
  -		return self.users[userid].tablecardlist[type]
  -
  -	def set_tablecardlist(self, userid, type, list):
  -		self.users[userid].tablecardlist[type] = list
  -
  -	def append_tablecardlist(self, userid, type, data):
  -		self.users[userid].tablecardlist[type].append(data)
  -
  -	def remove_tablecardlist(self, userid, type, card):
  -		try:
  -			cardlist = self.users[userid].tablecardlist(type)
  -			tempcard = cardlist.index(card)
  -
  -			del cardlist[tempcard]
  -			
  -			return True
  -		except:
  -			return False
  -
  -	def append_bbucklist(self, userid, group):
  -		self.users[userid].bbucklist.append(group)
  -
  -	def remove_bbucklist(self, userid, group):
  -		self.users[userid].bbucklist.remove(group)
  -
  -	def get_bbucklist(self, userid):
  -		return self.users[userid].bbucklist
  -
  -	def check_bbucklist(self, userid, group):
  -		try:
  -			self.users[userid].bbucklist.index(group)
  -
  -			return True
  -		except:
  -			return False
  -	
  -	def get_tablecardlistall(self, userid):
  -		result = []
  -		for cardlist in self.users[userid].tablecardlist:
  -			result += cardlist
  -		return result
  -
  -	def remove_tablecard(self, userid, card, type):
  -		try:
  -			cardlist = self.users[userid].tablecardlist[type]
  -			tempcard = cardlist.index(card)
  -
  -			del cardlist[tempcard]
  -			
  -			return True
  -		except:
  -			return False
  -
  -	def check_card(self, userid, card):
  -		try:
  -			cardlist = self.users[userid].cardlist
  -			tempcard = cardlist.index(card)
  -
  -			return True
  -		except:
  -			return False
  -
  -	def check_tablecard(self, userid, card):
  -		try:
  -			cardlist = self.users[userid].tablecardlist[2]
  -			tempcard = cardlist.index(card)
  -
  -			return True
  -		except:
  -			return False
  -		
  -
  -	def remove_card(self, userid, card):
  -		try:
  -			cardlist = self.users[userid].cardlist
  -			tempcard = cardlist.index(card)
  -
  -			del cardlist[tempcard]
  -			
  -			return True
  -		except:
  -			return False
  -	
  -		
  +    def __init__(self):
  +        self.users         = {}
  +        self.userindex   = [] # 
  +
  +        self.TYPE_HUMAN    = 0
  +        self.TYPE_COM      = 1
  +
  +    def  __len__(self):
  +        return len(self.users)
  +
  +    def get_fd(self, userid):
  +        return self.users[userid].userid
  +
  +    def get_loginid(self, userid):
  +        return self.suers[userid].userloginid
  +    
  +    def get_type(self, userid):
  +        return self.users[userid].type
  +
  +    def set_type(self, userid, type):
  +        self.users[userid].type = type
  +
  +    def set_gopoint(self, userid, point):
  +        self.users[userid].gopoint = point
  +
  +    def get_gopoint(self, userid):
  +        return self.users[userid].gopoint
  +
  +    def go(self, userid, gopoint):
  +        self.users[userid].gocount += 1
  +        self.users[userid].gopoint = gopoint
  +        
  +    def shake(self, userid):
  +        self.users[userid].shake += 1
  +
  +    def get_shakecount(self, userid):
  +        return self.users[userid].shake
  +
  +    def init_data(self, gopoint):
  +        for userid in self.userindex:
  +            user = self.users[userid]
  +            
  +            user.cardlist = []
  +            user.tablecardlist = [[], [], [], [], []]
  +            user.bbucklist = []
  +            user.point = 0
  +            user.shake = 0
  +            user.gopoint = gopoint
  +
  +    def append(self, fd, userid, username):
  +        self.users[fd] = userinfo(fd, userid, username)
  +        self.userindex.append(fd)
  +        
  +    def keys(self):
  +        #return self.users.keys()
  +        return self.userindex
  +
  +    def has_key(self, userid):
  +        return self.users.has_key(userid)
  +
  +    def remove(self, userid):
  +        if has_key(userid):
  +            del self.users[userid]
  +            del self.userindex
  +
  +    def user(self, userid):
  +        return self.users[userid]
  +
  +    def get_type(self, userid):
  +        return self.users[userid].type
  +    
  +    def get_username(self, userid):
  +        return self.users[userid].userloginid
  +    
  +    def get_cardlist(self, userid):
  +        return self.users[userid].cardlist
  +
  +    def set_cardlist(self, userid, cardlist):
  +        self.users[userid].cardlist = cardlist
  +        self.users[userid].cardlist.sort()
  +
  +    def append_cardlist(self, userid, cardlist):
  +        self.users[userid].cardlist += cardlist
  +
  +    def get_tablecardlist(self, userid, type):
  +        return self.users[userid].tablecardlist[type]
  +
  +    def set_tablecardlist(self, userid, type, list):
  +        self.users[userid].tablecardlist[type] = list
  +
  +    def append_tablecardlist(self, userid, type, data):
  +        self.users[userid].tablecardlist[type].append(data)
  +
  +    def remove_tablecardlist(self, userid, type, card):
  +        try:
  +            cardlist = self.users[userid].tablecardlist(type)
  +            tempcard = cardlist.index(card)
  +
  +            del cardlist[tempcard]
  +            
  +            return True
  +        except:
  +            return False
  +
  +    def append_bbucklist(self, userid, group):
  +        self.users[userid].bbucklist.append(group)
  +
  +    def remove_bbucklist(self, userid, group):
  +        self.users[userid].bbucklist.remove(group)
  +
  +    def get_bbucklist(self, userid):
  +        return self.users[userid].bbucklist
  +
  +    def check_bbucklist(self, userid, group):
  +        try:
  +            self.users[userid].bbucklist.index(group)
  +
  +            return True
  +        except:
  +            return False
  +    
  +    def get_tablecardlistall(self, userid):
  +        result = []
  +        for cardlist in self.users[userid].tablecardlist:
  +            result += cardlist
  +        return result
  +
  +    def remove_tablecard(self, userid, card, type):
  +        try:
  +            cardlist = self.users[userid].tablecardlist[type]
  +            tempcard = cardlist.index(card)
  +
  +            del cardlist[tempcard]
  +            
  +            return True
  +        except:
  +            return False
  +
  +    def check_card(self, userid, card):
  +        try:
  +            cardlist = self.users[userid].cardlist
  +            tempcard = cardlist.index(card)
  +
  +            return True
  +        except:
  +            return False
  +
  +    def check_tablecard(self, userid, card):
  +        try:
  +            cardlist = self.users[userid].tablecardlist[2]
  +            tempcard = cardlist.index(card)
  +
  +            return True
  +        except:
  +            return False
  +        
  +
  +    def remove_card(self, userid, card):
  +        try:
  +            cardlist = self.users[userid].cardlist
  +            tempcard = cardlist.index(card)
  +
  +            del cardlist[tempcard]
  +            
  +            return True
  +        except:
  +            return False
  
  
  


nohmad      04/12/05 03:26:41

  Added:       module/gostop score.py
  Log:
  Add game score calculation. (not yet work :$)
  
  Revision  Changes    Path
  1.1                  siminserver/module/gostop/score.py
  
  Index: score.py
  ===================================================================
  # -*- coding: utf-8 -*-
  
  from cardlist
  
  try:
      set
  except NameError:
      from sets import Set as set
  
  class PanScore:
      """cardlist
      """
      def __init__(self, cards):
          self.cards = cards
  
      def calculate(self):
          # kwang, pee, ten, five, go, multiplier
          # dan(hong, chung, cho), godori
  
          """
          self.TYPE_GWANG = 1
          self.TYPE_10JA  = 2
          self.TYPE_5JA   = 3
          self.TYPE_PEE   = 4
  
          self.SPECIAL_NORMAL    = 1
          self.SPECIAL_GODORI    = 2
          self.SPECIAL_CHUNGDAN  = 3
          self.SPECIAL_HONGDAN   = 4
          self.SPECIAL_KOOSA     = 5
          self.SPECIAL_SSANGPEE  = 6
          self.SPECIAL_BIGWANG   = 7
          self.SPECIAL_BONUS     = 8
          self.SPECIAL_BOMB      = 9
  
          self.POINT_0 = 0
          self.POINT_1 = 1
          self.POINT_2 = 2
          """
  
          score_special = lambda hunted, special, score: \
                          (len(filter(lambda card: card.special == special, hunted)) == 3) \
                          [0, score]
          # see cardlist.SPECIAL_*
          godori      = score_special(self.cards, 2, 5)
          chungdan    = score_special(self.cards, 3, 3)
          hongdan     = score_special(self.cards, 4, 3)
          koosa       = score_special(self.cards, 5, 3)
          special = godori + chungdan + hongdan + koosa
  
          score_fivten = lambda hunted, matchtype, count: \
                         len(filter(lambda card: card.type == matchtype, hunted)) - count
          # see cardlist.TYPE_*
          fiv = score_fivten(self.cards, 3, 5)
          ten = score_fivten(self.cards, 2, 5)
          fivten = ten + fiv
  
          pee = len(lambda hunted: reduce(lambda x, y: x+y, hunted)(self.cards)) - 9
          kwang = lambda hunted: \
                  len(filter(lambda card: card.type == 1, hunted)) - \
                  len(filter(lambda card: card.special == 7, hunted))
          go = 0
          return special + fivten + pee + kwang + go
  
      def take_money(self, users):
          pass
  
  
  


nohmad      04/12/05 03:28:09

  Modified:    module/gostop score.py
  Log:
  Add cvs tag.
  
  Revision  Changes    Path
  1.2       +2 -0      siminserver/module/gostop/score.py
  
  Index: score.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/module/gostop/score.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- score.py	4 Dec 2004 18:26:41 -0000	1.1
  +++ score.py	4 Dec 2004 18:28:09 -0000	1.2
  @@ -1,4 +1,6 @@
   # -*- coding: utf-8 -*-
  +#
  +# $Id: score.py,v 1.2 2004/12/04 18:28:09 nohmad Exp $
   
   from cardlist
   
  
  
  


djb         04/12/05 12:18:27

  Modified:    .        run.py
  Log:
  blah
  
  Revision  Changes    Path
  1.22      +44 -2     siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- run.py	4 Dec 2004 11:50:51 -0000	1.21
  +++ run.py	5 Dec 2004 03:18:26 -0000	1.22
  @@ -2,6 +2,7 @@
   # -*- coding: utf_8 -*-
   
   import sys , os
  +import random
   
   
   """
  @@ -97,6 +98,9 @@
           #   Ŷ ޴ ƴ... 
           self.gettingPacket = False
   
  +        # ticket !
  +        self.ticket = "00000000"
  +
           #  
           self.isAuth = False
           self.auth_try = 0
  @@ -111,10 +115,22 @@
           return self.fd
   
       def write(self, major, minor, data):
  -        length = len(data)
  +        if type(data) == type([]):
  +            datatype = True
  +            length = 0
  +            for bits in data:
  +                length += len(bits)
  +        else:
  +            datatype = False
  +            length = len(data)
           packet = struct.pack("!BBH", major, minor, length)
           if self._write(packet)>0:
  -            self._write(data)
  +            if datatype == True:
  +                for bits in data:
  +                    self._write(bits)
  +                    print "SEND PACKETS :" + bits
  +            else:
  +                self._write(data)
   
       def _write(self, buffer):
           ret = -1
  @@ -200,12 +216,30 @@
                   
   # import lobby_function by djb
   from lib.lobby_functions import *
  +from lib.house_functions import *
  +from lib.libhouse import house
   class Lobby:
       def __init__(self):
  +        # set house instance
  +        self.houselist = []
  +        self.houselist.append(house(self,"house1","simin.h-9.net:1234"))
  +        self.houselist.append(house(self,"house2","simin.h-9.net:12345"))
           self.clientDict = {} 
  +        self.ticketdict = {}
  +        # this is for usermap
  +        self.userhousemap= {}
  +        # userid , houseObj
  +        # ticket key = ticket
  +        # ticket value = userObj
           self.roomList = []
           self.rpc = xmlrpclib.Server("http://simin.h-9.net/RPC", verbose=1)
           self.errorClientList = []
  +
  +    def _GetNewTicket(self):
  +        while True:
  +            newticket = str(random.random())[-8:]
  +            if newticket not in self.ticketdict:
  +                return newticket
       def addClient(self, sock, addr):
           fd = sock.fileno()
           self.clientDict[fd] = ClientItem(self, sock, addr)
  @@ -225,6 +259,7 @@
           del self.clientDict[fd]
       def clientbyfd(self, fd):
           return self.clientDict[fd]
  +
       def clientbyid(self, id):
           for c in self.clientDict.values():
               if c.id()==id:
  @@ -259,6 +294,12 @@
                   if major==M_LOBBY: # Lobby
                       # see lib/lobby_functions.py
                       eventAuthLobbyMinorFunction(minor,length,data,client,self)
  +                elif major == M_HOUSE:
  +                    print "Ͽ콺 " 
  +                    # see lib/libhouse.py
  +                    eventNotAuthHouseFunction(minor,length,data,client,self)
  +                else:
  +                    print "" 
   
   # Server fd  
   SERVERFDS = [s.fileno()]
  @@ -297,3 +338,4 @@
   
           # event
           LOBBY.event(client)
  +
  
  
  


djb         04/12/05 12:18:47

  Modified:    lib      protocol.py
  Log:
  blah
  
  Revision  Changes    Path
  1.6       +5 -0      siminserver/lib/protocol.py
  
  Index: protocol.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/protocol.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- protocol.py	26 Nov 2004 11:28:31 -0000	1.5
  +++ protocol.py	5 Dec 2004 03:18:47 -0000	1.6
  @@ -1,5 +1,6 @@
   M_RESERVATION                               = 0x00
   M_LOBBY                                     = 0x01
  +M_HOUSE                                     = 0x03
   M_GAME_RESERVATION                          = 0x10
   M_GAME_GOSTOP                               = 0x11
   
  @@ -24,6 +25,7 @@
   RESPONSE_LOBBY_VERSIONCHECK                 = 0xA1
   RESPONSE_LOBBY_LOGIN                        = 0xA2
   RESPONSE_LOBBY_CLIENTLIST                   = 0xA3
  +RESPONSE_LOBBY_LOGINHOUSELIST               = 0xA4
   
   RESPONSE_LOBBY_CREATE_GAMEROOM              = 0xB1
   RESPONSE_LOBBY_MODIFY_GAMEROOM              = 0xB2
  @@ -47,3 +49,6 @@
   
   NOTIFY_LOBBY_RECVMSG_CHAT                   = 0x71
   NOTIFY_LOBBY_FROMMSG_CHAT                   = 0x72
  +#### HOUSE Protocol 
  +REQUEST_HOUSE_LOGIN                         = 0x81
  +RESPONSE_HOUSE_LOGIN                        = 0xC1
  
  
  


djb         04/12/05 12:19:07

  Modified:    lib      lobby_functions.py
  Log:
  blah
  
  Revision  Changes    Path
  1.4       +26 -2     siminserver/lib/lobby_functions.py
  
  Index: lobby_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/lobby_functions.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- lobby_functions.py	4 Dec 2004 11:50:51 -0000	1.3
  +++ lobby_functions.py	5 Dec 2004 03:19:07 -0000	1.4
  @@ -1,6 +1,9 @@
   #!/usr/bin/python
   from protocol import *
   import struct
  +IN_OUTDOOR  = 0
  +IN_LOBBY    = 1
  +IN_GAMEROOM = 2
   
   def eventNotAuthLobbyMinorFunction(minor,length,data,client,self):
       if minor == REQUEST_LOBBY_VERSIONCHECK: # version check
  @@ -28,14 +31,35 @@
               client.moveTo(IN_LOBBY)
               client.setAuth()
               self.setUserInfo(client, id)
  +            # added ticket code by dj
  +            newticket = self._GetNewTicket()
               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  -                                    struct.pack("B", 0x00))
  +                                    struct.pack("B", 0x00)  + newticket)
  +            # added ticket code by dj
  +            client.ticket = newticket
  +            # inser into icketlist
  +            self.ticketdict[newticket] = client
  +            # RESPONSE_LOBBY_LOGINHOUSELIST 
  +            houseinfopacket = ''
  +            for house in self.houselist:
  +                housename = house.housename
  +                namelen = len(housename)
  +                houseinfo = house.houseinfo
  +                infolen =  len(houseinfo)
  +                houseinfopacket = houseinfopacket + struct.pack("B",namelen)
  +                houseinfopacket = houseinfopacket + housename
  +                houseinfopacket = houseinfopacket + struct.pack("B",infolen)
  +                houseinfopacket = houseinfopacket + houseinfo
  +            houseinfopacket = struct.pack("!H",len(self.houselist)) + houseinfopacket
  +            client.write(M_LOBBY, RESPONSE_LOBBY_LOGINHOUSELIST,houseinfopacket)
  +
  +
               # NOTIFY_LOBBY_JOIN_CLIENT
               self.notify(NOTIFY_LOBBY_JOIN_CLIENT, client.id(), client)
           else: 
               print "%s login failed" % id
               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
  -                                    struct.pack("B", 0x01))
  +                                    struct.pack("B", 0x01) + "00000000")
                                       
   def eventAuthLobbyMinorFunction(minor,length,data,client,self):
       if minor==REQUEST_LOBBY_CLIENTLIST: 
  
  
  


djb         04/12/05 12:19:25

  Added:       lib      libhouse.py libpan.py house_functions.py
  Log:
  blah
  
  Revision  Changes    Path
  1.1                  siminserver/lib/libhouse.py
  
  Index: libhouse.py
  ===================================================================
  #!/usr/bin/python
  
  import sys , os 
  import random
  
  from libpan import panclass
  
  class house:
      def __init__(self,dispatcher,housename,houseinfo):
          self.dispatcher = dispatcher
          self.housename = housename
          self.houseinfo = houseinfo
          self.userlist = {}
          # userlist = username , userObj
          self.ticketlist = {}
          # ticketlist = ticket , [ username , userObj ] 
          self.panlist = {}
          # panlist = panid , panObj
  
      # interfaces from and to
      def inter_from_dispatcher(self,major,minor,length,data,obj = None):
          # ds send ticket , username
          # ds send create pan , 
          # USER CREATE PAN
          # User JOIN PAN
          # USER LEAVE PAN
          # USER GAME
          pass
  
      def inter_to_dispatcher(self,major,minor,length,data,Obj = None):
          # after creater pan send ds pandata ( end to user )
          # send ds 
          pass
  
      def EventJoin(self,ticket):
          # whern user join here
          if ticket in self.ticketlist:
              username , userobj = self.ticketlist[ticket]
              self.userlist[username] = userobj
              print "WELCOME TICKET :" + username
          else:
              # you dont have ticket
              print "YOU DONT HAVE TICKET :" + ticket
              return False
      def GetPanId(self):
          while True:
             newid = str(random.random())
             if newid not in self.panlist:
                  return newid
  
      def EventCreate(self):
          panid = self.GetPanId()
          self.panlist[panid] = panclass(panid,"","")
          return panid
  
      def EventLeave(self,username):
          pass
  
  
  
  1.1                  siminserver/lib/libpan.py
  
  Index: libpan.py
  ===================================================================
  #!/usr/bin/python
  # -*- coding: utf_8 -*-
  
  import sys , os
  import time
  
  class panclass:
      def __init__(self,panid,pantopic,panpass):
          self.panid = panid
          self.pantopic = pantopic
          self.panpass = panpass
          self.pangameppl = 0
          # default game type 2 play
          self.gametype = 2
          self.UserList= {}
          self.master = ''
          # UserList key = name
          # UserList Value = jointime
          self.UserObjList = {}
          # UserObjList key = name
          # UserObjList value = userObject
  
      def _SetMaster(self):
          self.UserList.values().sort()
  
      def GetPeople(self):
          return len(self.UserList)
  
      def SetGameType(self,gametype):
          self.gametype = gametype
  
      def EventJoinPan(self,username,panpass,UserObj):
          if username not in self.UserList:
              if len(self.UserList) == 0:
                  #   ° 
                  self.master = username
              else:
                  for users in self.UserObjList:
                      self.UserObjList[users].write(" "  + username + "   äο Ի" )
              self.UserList[username] = time.time()
              self.UserObjList[username] = UserObj
              # check gametype
              if self.gametype == self.GetPeople():
                  # game start broadcast
                  # bangang event?
                  for users in self.UserObjList:
                      self.UserObjList[users].write("ӽ ο ϴ") 
              return True
          else:
              # ̹ ε  blah
              return False
  
      def EventLeavePan(self,username):
          if username in self.UserList:
              del self.UserList[username]
              del self.UserObjList[username]
              # first delete
              for users in self.UserObjList:
                  self.UserObjList[users].write(username + "  濡 !" )
              # second broadcast
          else:
              # 濡  
              return False
      def EventStartGame(self):
          pass
          
  
  if __name__ == "__main__":
      print "StartTesting"
      class UserObj:
          def __init__(self,username):
              self.username = username
  
          def write(self,data):
              print self.username + " WRITE " + data
      # pan create
      pan1 = panclass(1,"1° ",None)
      # ppl1 create
      ppl1 = UserObj("user1")
      # ppl2 create
      ppl2 = UserObj("user2")
      # ppl3 create
      ppl3 = UserObj("user3")
      # ppl1 join
      pan1.EventJoinPan(ppl1.username,None,ppl1)
      pan1.EventJoinPan(ppl2.username,None,ppl2)
      pan1.EventJoinPan(ppl3.username,None,ppl3)
  
  
  
  1.1                  siminserver/lib/house_functions.py
  
  Index: house_functions.py
  ===================================================================
  #!/usr/bin/python
  
  from protocol import *
  import struct
  
  
  def eventNotAuthHouseFunction(minor,length,data,client,self):
      if minor == REQUEST_HOUSE_LOGIN:
          if data in self.ticketdict:
              print " Ͽ콺  " 
              userobj = self.ticketdict[data]
              username = userobj._id
              print "USERNAME %s" % username
              usernamelen = len(username)
              print "USERNAMElen %s" % str(usernamelen)
              client.write(M_HOUSE,RESPONSE_HOUSE_LOGIN, \
                          [ struct.pack("B",0x01) , \
                          struct.pack("B",usernamelen) , \
                              username ])
          else:
              client.write(M_HOUSE,RESPONSE_HOUSE_LOGIN, \
                          strcut.pack("B",0x00) + \
                          struct.pack("!H",5) + \
                              "error" )
  def eventAuthHouseFunction(minor,length,data,client,self):
      pass
  
  
  


nohmad      04/12/12 10:57:17

  Added:       lib      daemonize.py
  Removed:     lib      daemonrize.py
  Log:
  Rename daemonrize.py to daemonize.py
  
  Revision  Changes    Path
  1.1                  siminserver/lib/daemonize.py
  
  Index: daemonize.py
  ===================================================================
  #!/usr/bin/python
  
  import sys , os
  
  
  def run():
  	if os.fork():
  		raise SystemExit
  	else:
  		os.setsid()
  	if os.fork():
  		raise SystemExit
  	print os.getpid()
  
  
  


djb         05/01/03 15:39:40

  Modified:    .        run.py
  Log:
  update by 2004.12 last exman , dj
  
  Revision  Changes    Path
  1.23      +6 -2      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- run.py	5 Dec 2004 03:18:26 -0000	1.22
  +++ run.py	3 Jan 2005 06:39:40 -0000	1.23
  @@ -232,7 +232,8 @@
           # ticket key = ticket
           # ticket value = userObj
           self.roomList = []
  -        self.rpc = xmlrpclib.Server("http://simin.h-9.net/RPC", verbose=1)
  +        #self.rpc = xmlrpclib.Server("http://simin.h-9.net/RPC", verbose=1)
  +        self.rpc = True
           self.errorClientList = []
   
       def _GetNewTicket(self):
  @@ -271,7 +272,10 @@
       def errorOccurredClients(self):
           return self.errorClientList
       def setUserInfo(self, client, id):
  -        info = self.rpc.user.info(id) 
  +        #info = self.rpc.user.info(id) 
  +        info = {
  +				"name" : "test",
  +				"email" : "test@test.com" }
           print info
           client.setId(id)
           client.setName(info['name'])
  
  
  


djb         05/02/19 23:53:34

  Modified:    .        run.py
  Log:
  add config parsing routine
  
  Revision  Changes    Path
  1.24      +5 -0      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- run.py	3 Jan 2005 06:39:40 -0000	1.23
  +++ run.py	19 Feb 2005 14:53:34 -0000	1.24
  @@ -17,6 +17,11 @@
   run()
   """
   # read config
  +from lib.ConfigHandler import ConfigHandler
  +ch = ConfigHandler()
  +ch.load("conf/config.ini")
  +conf = ch.data
  +del ch
   # config parse -> fork
   # load moduloe
   
  
  
  


djb         05/02/19 23:57:05

  Added:       lib      ConfigHandler.py
  Log:
  adding config parser file for loading
  
  Revision  Changes    Path
  1.1                  siminserver/lib/ConfigHandler.py
  
  Index: ConfigHandler.py
  ===================================================================
  import os
  from ConfigParser import ConfigParser
  
  class ConfigHandler:
  
      def __init__(self):
          self.cp = ConfigParser()
          self.positive_values = ["On","Yes","True","1"]
          self.negative_values = ["Off","No","False","0"]
  
      def create(self,filename):
      	self.filename = filename
          f = open(filename,'w') or f.close()
  
      def load(self,filename):
          if not os.path.isfile(filename):
              return self.create(filename)
  
          self.cp.read(filename)
          self.filename = filename
          self.data = {}
          for sec in self.cp.sections():
              name = sec.lower()
              self.data[name] = {}
              for opt_key in self.cp.options(sec):
                  _value = self.cp.get(sec, opt_key)
                  if sec == 'options':
                      if _value in self.positive_values:
                          self.data[name][opt_key] = True
                      elif _value in self.negative_values:
                          self.data[name][opt_key] = False
                      else:
                          self.data[name][opt_key] = _value
                  else:
                      self.data[name][opt_key] = self.cp.get(sec, opt_key)
  
      def flatdata(self):
          ret = {}
          for sec in self.data.keys():
              if sec not in self.cp.sections():
                  self.cp.add_section(sec)
              for opt_key in self.data[sec].keys():
                  ret[opt_key] = self.data[sec][opt_key]
          print ret
  
      def setdata(self, data):
          self.data = data
  
      def save(self):
          for sec in self.data.keys():
              if sec not in self.cp.sections():
                  self.cp.add_section(sec)
              for opt_key in self.data[sec].keys():
                  self.cp.set(sec, opt_key, data[sec][opt_key])
          f = open(self.filename,'w')
          self.cp.write(f)
          f.close()
  
  if __name__ == '__main__':
      ch = ConfigHandler()
      ch.load('test.ini') # creates file if not exists
      print ch.flatdata() # ignore all section identifier
      data = {
          'global': {
              'nickname' : 'maroo'
          },
          'options' : {
              'fullscreen' : False,
              'bgsound' : True,
              'fxsound' : True
          }
      }
      ch.setdata(data)
      ch.save()
  
  
  


djb         05/02/20 00:15:32

  Modified:    lib      protocol.py
  Log:
  update pan
  
  Revision  Changes    Path
  1.7       +1 -0      siminserver/lib/protocol.py
  
  Index: protocol.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/protocol.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- protocol.py	5 Dec 2004 03:18:47 -0000	1.6
  +++ protocol.py	19 Feb 2005 15:15:32 -0000	1.7
  @@ -1,6 +1,7 @@
   M_RESERVATION                               = 0x00
   M_LOBBY                                     = 0x01
   M_HOUSE                                     = 0x03
  +M_PAN                                       = 0x04
   M_GAME_RESERVATION                          = 0x10
   M_GAME_GOSTOP                               = 0x11
   
  
  
  


djb         05/02/20 00:23:29

  Modified:    lib      protocol.py
  Log:
  update form adding pan
  
  Revision  Changes    Path
  1.8       +3 -0      siminserver/lib/protocol.py
  
  Index: protocol.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/protocol.py,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- protocol.py	19 Feb 2005 15:15:32 -0000	1.7
  +++ protocol.py	19 Feb 2005 15:23:29 -0000	1.8
  @@ -53,3 +53,6 @@
   #### HOUSE Protocol 
   REQUEST_HOUSE_LOGIN                         = 0x81
   RESPONSE_HOUSE_LOGIN                        = 0xC1
  +
  +# PAN Protocol
  +
  
  
  


djb         05/02/20 00:24:23

  Modified:    .        run.py
  Log:
  bug
  
  Revision  Changes    Path
  1.25      +6 -2      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- run.py	19 Feb 2005 14:53:34 -0000	1.24
  +++ run.py	19 Feb 2005 15:24:23 -0000	1.25
  @@ -298,7 +298,7 @@
               if not client.auth():
                   if major==M_LOBBY: # Lobby
                        # see lib/lobby_functions.py
  -					eventNotAuthLobbyMinorFunction(minor,length,data,client,self)
  +                    eventNotAuthLobbyMinorFunction(minor,length,data,client,self)
               else:
                   if major==M_LOBBY: # Lobby
                       # see lib/lobby_functions.py
  @@ -307,8 +307,12 @@
                       print "Ͽ콺 " 
                       # see lib/libhouse.py
                       eventNotAuthHouseFunction(minor,length,data,client,self)
  +                elif major == M_PAN:
  +                    pass
                   else:
  -                    print "" 
  +                    pass
  +                
  +                    
   
   # Server fd  
   SERVERFDS = [s.fileno()]
  
  
  


djb         05/02/20 00:26:26

  Modified:    .        run.py
  Log:
  
  
  Revision  Changes    Path
  1.26      +1 -2      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- run.py	19 Feb 2005 15:24:23 -0000	1.25
  +++ run.py	19 Feb 2005 15:26:26 -0000	1.26
  @@ -237,8 +237,7 @@
           # ticket key = ticket
           # ticket value = userObj
           self.roomList = []
  -        #self.rpc = xmlrpclib.Server("http://simin.h-9.net/RPC", verbose=1)
  -        self.rpc = True
  +        self.rpc = xmlrpclib.Server("http://simin.h-9.net/RPC", verbose=1)
           self.errorClientList = []
   
       def _GetNewTicket(self):
  
  
  


djb         05/02/20 00:43:03

  Modified:    lib      libhouse.py
  Log:
  update libhousr for libby func
  
  Revision  Changes    Path
  1.2       +2 -0      siminserver/lib/libhouse.py
  
  Index: libhouse.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/libhouse.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- libhouse.py	5 Dec 2004 03:19:25 -0000	1.1
  +++ libhouse.py	19 Feb 2005 15:43:03 -0000	1.2
  @@ -10,6 +10,8 @@
           self.dispatcher = dispatcher
           self.housename = housename
           self.houseinfo = houseinfo
  +        # Ͽ콺 밡 ƽ ο
  +        self.housemax = 1000
           self.userlist = {}
           # userlist = username , userObj
           self.ticketlist = {}
  
  
  


djb         05/02/20 00:43:22

  Modified:    lib      lobby_functions.py
  Log:
  updateing lobby
  
  Revision  Changes    Path
  1.5       +15 -4     siminserver/lib/lobby_functions.py
  
  Index: lobby_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/lobby_functions.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- lobby_functions.py	5 Dec 2004 03:19:07 -0000	1.4
  +++ lobby_functions.py	19 Feb 2005 15:43:22 -0000	1.5
  @@ -22,6 +22,7 @@
                   # ̹ α̶ RESPONSE  
                   client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                           struct.pack("B", 0x02))
  +                print "SENDING RESPONSE_LOBBY_LOGIN : %s" % struct.pack("B", 0x02)
                   self.removeClient(client.fileno(), "already login")
                   return
       
  @@ -44,12 +45,22 @@
               for house in self.houselist:
                   housename = house.housename
                   namelen = len(housename)
  +
                   houseinfo = house.houseinfo
                   infolen =  len(houseinfo)
  -                houseinfopacket = houseinfopacket + struct.pack("B",namelen)
  -                houseinfopacket = houseinfopacket + housename
  -                houseinfopacket = houseinfopacket + struct.pack("B",infolen)
  -                houseinfopacket = houseinfopacket + houseinfo
  +
  +                housecur = len(house.userlist)
  +                housecurlen = len(str(housecur))
  +
  +                housemax = house.housemax
  +                housemaxlen len(str(house.housemax))
  +
  +
  +
  +                houseinfopacket +=  struct.pack("B",namelen)
  +                houseinfopacket += housename
  +                houseinfopacket += struct.pack("B",infolen)
  +                houseinfopacket += houseinfo
               houseinfopacket = struct.pack("!H",len(self.houselist)) + houseinfopacket
               client.write(M_LOBBY, RESPONSE_LOBBY_LOGINHOUSELIST,houseinfopacket)
   
  
  
  


djb         05/02/20 00:44:51

  Modified:    lib      lobby_functions.py
  Log:
  
  
  Revision  Changes    Path
  1.6       +12 -2     siminserver/lib/lobby_functions.py
  
  Index: lobby_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/lobby_functions.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- lobby_functions.py	19 Feb 2005 15:43:22 -0000	1.5
  +++ lobby_functions.py	19 Feb 2005 15:44:51 -0000	1.6
  @@ -55,12 +55,22 @@
                   housemax = house.housemax
                   housemaxlen len(str(house.housemax))
   
  -
  -
                   houseinfopacket +=  struct.pack("B",namelen)
  +
                   houseinfopacket += housename
  +
                   houseinfopacket += struct.pack("B",infolen)
  +
                   houseinfopacket += houseinfo
  +
  +                houseinfopacket += struct.pack("B",housecurlen)
  +
  +                houseinfopacket += housecurlen
  +
  +                houseinfopacket += struct.pack("B",housemaxlen)
  +
  +                houseinfopacket += housemaxlen
  +
               houseinfopacket = struct.pack("!H",len(self.houselist)) + houseinfopacket
               client.write(M_LOBBY, RESPONSE_LOBBY_LOGINHOUSELIST,houseinfopacket)
   
  
  
  


djb         05/02/20 00:58:50

  Modified:    lib      lobby_functions.py
  Log:
  rath merong
  
  Revision  Changes    Path
  1.7       +4 -3      siminserver/lib/lobby_functions.py
  
  Index: lobby_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/lobby_functions.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- lobby_functions.py	19 Feb 2005 15:44:51 -0000	1.6
  +++ lobby_functions.py	19 Feb 2005 15:58:50 -0000	1.7
  @@ -36,6 +36,7 @@
               newticket = self._GetNewTicket()
               client.write(M_LOBBY, RESPONSE_LOBBY_LOGIN, \
                                       struct.pack("B", 0x00)  + newticket)
  +            print "RESPONSE_LOBBY_LOGIN: %s %s" % ( struct.pack("B", 0x00)  , newticket) 
               # added ticket code by dj
               client.ticket = newticket
               # inser into icketlist
  @@ -53,7 +54,7 @@
                   housecurlen = len(str(housecur))
   
                   housemax = house.housemax
  -                housemaxlen len(str(house.housemax))
  +                housemaxlen = len(str(house.housemax))
   
                   houseinfopacket +=  struct.pack("B",namelen)
   
  @@ -65,11 +66,11 @@
   
                   houseinfopacket += struct.pack("B",housecurlen)
   
  -                houseinfopacket += housecurlen
  +                houseinfopacket += str(housecur)
   
                   houseinfopacket += struct.pack("B",housemaxlen)
   
  -                houseinfopacket += housemaxlen
  +                houseinfopacket += str(housemax)
   
               houseinfopacket = struct.pack("!H",len(self.houselist)) + houseinfopacket
               client.write(M_LOBBY, RESPONSE_LOBBY_LOGINHOUSELIST,houseinfopacket)
  
  
  


djb         05/02/20 01:37:44

  Modified:    test     proxyclient.py
  Log:
  
  
  Revision  Changes    Path
  1.14      +11 -2     siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- proxyclient.py	4 Dec 2004 10:49:09 -0000	1.13
  +++ proxyclient.py	19 Feb 2005 16:37:44 -0000	1.14
  @@ -47,16 +47,25 @@
       def setSock(self, sock):
           self.sock = sock
       def event(self, major, minor, length, data):
  -        print major, minor, length
  +        print "EVENT : %s %s %s %s " % (major, minor, length  , data)
           if major==M_LOBBY:
               if minor==RESPONSE_LOBBY_LOGIN:
  +                ret = data[0]
  +                ticket = data[1:]
  +                """
  +                print "DATA '%s'" % data
  +                print "DATALEN %s" % len(data)
                   ret = struct.unpack("B", data)[0]
  +                """
                   if ret!=0x00:
                       print " ", ret
                       self.sock.close()
                       self.sock = None
                       self.cmd.sock = None
  -                print "α : %d" % ret
  +                print "α : %s" % ret
  +                print "α Ƽ: %s" % ticket
  +            elif minor==RESPONSE_LOBBY_LOGINHOUSELIST:
  +                print "κ Ͽ콺 Ʈ %s" % data
               elif minor==RESPONSE_LOBBY_CLIENTLIST:
                   count = struct.unpack("!H", data[:2])[0]
                   print " Lobby  : %d" % count
  
  
  


djb         05/02/20 02:29:42

  Modified:    test     proxyclient.py
  Log:
   -_-;   α ;;; Ĺ!
  
  Revision  Changes    Path
  1.15      +7 -8      siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- proxyclient.py	19 Feb 2005 16:37:44 -0000	1.14
  +++ proxyclient.py	19 Feb 2005 17:29:42 -0000	1.15
  @@ -50,22 +50,21 @@
           print "EVENT : %s %s %s %s " % (major, minor, length  , data)
           if major==M_LOBBY:
               if minor==RESPONSE_LOBBY_LOGIN:
  -                ret = data[0]
  +                ret = struct.unpack("B",data[0])[0]
                   ticket = data[1:]
  -                """
  -                print "DATA '%s'" % data
  -                print "DATALEN %s" % len(data)
  -                ret = struct.unpack("B", data)[0]
  -                """
  -                if ret!=0x00:
  +                print "RET %s" % ret
  +                print "TICKET %s" % ticket
  +                if ret!= 0:
                       print " ", ret
                       self.sock.close()
                       self.sock = None
                       self.cmd.sock = None
  +                    return
                   print "α : %s" % ret
                   print "α Ƽ: %s" % ticket
               elif minor==RESPONSE_LOBBY_LOGINHOUSELIST:
  -                print "κ Ͽ콺 Ʈ %s" % data
  +                print "κ Ͽ콺 Ʈ %s\n" % data
  +                return
               elif minor==RESPONSE_LOBBY_CLIENTLIST:
                   count = struct.unpack("!H", data[:2])[0]
                   print " Lobby  : %d" % count
  
  
  


djb         05/02/20 02:40:21

  Modified:    lib      protocol.py
  Log:
  !
  
  Revision  Changes    Path
  1.9       +6 -2      siminserver/lib/protocol.py
  
  Index: protocol.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/protocol.py,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- protocol.py	19 Feb 2005 15:23:29 -0000	1.8
  +++ protocol.py	19 Feb 2005 17:40:21 -0000	1.9
  @@ -53,6 +53,10 @@
   #### HOUSE Protocol 
   REQUEST_HOUSE_LOGIN                         = 0x81
   RESPONSE_HOUSE_LOGIN                        = 0xC1
  +REQUEST_HOUSE_PANLIST                       = 0x12
  +RESPONSE_HOUSE_PANLIST                      = 0xB2
  +NOTIFY_HOUSE_PANDIFF                        = 0xB3
  +REQUEST_HOUSE_CREATEPAN                     = 0x11
  +RESPONSE_HOUSE_CREATEPAN                    = 0xB1
   
  -# PAN Protocol
  -
  +## PAN PROTOCOL
  
  
  


djb         05/02/20 02:41:09

  Modified:    .        run.py
  Log:
  Ʈ 
  
  Revision  Changes    Path
  1.27      +7 -1      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- run.py	19 Feb 2005 15:26:26 -0000	1.26
  +++ run.py	19 Feb 2005 17:41:09 -0000	1.27
  @@ -109,6 +109,8 @@
           #  
           self.isAuth = False
           self.auth_try = 0
  +        # Ͽ콺 
  +        self.houseAuth = False
           # info
           self._id = ""
           self._name = ""
  @@ -305,7 +307,11 @@
                   elif major == M_HOUSE:
                       print "Ͽ콺 " 
                       # see lib/libhouse.py
  -                    eventNotAuthHouseFunction(minor,length,data,client,self)
  +                    if client.houseAuth is False:
  +                        print "ȣ lib/libhouse.py/ eventNotAuthHouseFunction"
  +                        eventNotAuthHouseFunction(minor,length,data,client,self)
  +                    else:
  +                        eventAuthHouseFunction(minor,length,data,client,self)
                   elif major == M_PAN:
                       pass
                   else:
  
  
  


djb         05/02/20 02:51:58

  Modified:    lib      lobby_functions.py
  Log:
  RESPONSE_LOBBY_HOUSELIST  Ͽ콺  ߰
  
  Revision  Changes    Path
  1.8       +1 -0      siminserver/lib/lobby_functions.py
  
  Index: lobby_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/lobby_functions.py,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- lobby_functions.py	19 Feb 2005 15:58:50 -0000	1.7
  +++ lobby_functions.py	19 Feb 2005 17:51:58 -0000	1.8
  @@ -43,6 +43,7 @@
               self.ticketdict[newticket] = client
               # RESPONSE_LOBBY_LOGINHOUSELIST 
               houseinfopacket = ''
  +            houseinfopacket += struct.pack("B",len(self.houselist))
               for house in self.houselist:
                   housename = house.housename
                   namelen = len(housename)
  
  
  


djb         05/02/20 03:04:20

  Modified:    lib      lobby_functions.py
  Log:
  ޷
  
  Revision  Changes    Path
  1.9       +2 -7      siminserver/lib/lobby_functions.py
  
  Index: lobby_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/lobby_functions.py,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- lobby_functions.py	19 Feb 2005 17:51:58 -0000	1.8
  +++ lobby_functions.py	19 Feb 2005 18:04:19 -0000	1.9
  @@ -52,10 +52,8 @@
                   infolen =  len(houseinfo)
   
                   housecur = len(house.userlist)
  -                housecurlen = len(str(housecur))
   
                   housemax = house.housemax
  -                housemaxlen = len(str(house.housemax))
   
                   houseinfopacket +=  struct.pack("B",namelen)
   
  @@ -65,13 +63,10 @@
   
                   houseinfopacket += houseinfo
   
  -                houseinfopacket += struct.pack("B",housecurlen)
  +                houseinfopacket += struct.pack("H",housecur)
   
  -                houseinfopacket += str(housecur)
  +                houseinfopacket += struct.pack("H",housemax)
   
  -                houseinfopacket += struct.pack("B",housemaxlen)
  -
  -                houseinfopacket += str(housemax)
   
               houseinfopacket = struct.pack("!H",len(self.houselist)) + houseinfopacket
               client.write(M_LOBBY, RESPONSE_LOBBY_LOGINHOUSELIST,houseinfopacket)
  
  
  


djb         05/02/20 03:23:11

  Modified:    lib      lobby_functions.py
  Log:
   ó
  
  Revision  Changes    Path
  1.10      +1 -1      siminserver/lib/lobby_functions.py
  
  Index: lobby_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/lobby_functions.py,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- lobby_functions.py	19 Feb 2005 18:04:19 -0000	1.9
  +++ lobby_functions.py	19 Feb 2005 18:23:11 -0000	1.10
  @@ -43,6 +43,7 @@
               self.ticketdict[newticket] = client
               # RESPONSE_LOBBY_LOGINHOUSELIST 
               houseinfopacket = ''
  +            print "Ͽ콺  %s" % len(self.houselist)
               houseinfopacket += struct.pack("B",len(self.houselist))
               for house in self.houselist:
                   housename = house.housename
  @@ -68,7 +69,6 @@
                   houseinfopacket += struct.pack("H",housemax)
   
   
  -            houseinfopacket = struct.pack("!H",len(self.houselist)) + houseinfopacket
               client.write(M_LOBBY, RESPONSE_LOBBY_LOGINHOUSELIST,houseinfopacket)
   
   
  
  
  


djb         05/02/20 03:33:07

  Modified:    test     proxyclient.py
  Log:
  proxy update
  
  Revision  Changes    Path
  1.16      +18 -0     siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- proxyclient.py	19 Feb 2005 17:29:42 -0000	1.15
  +++ proxyclient.py	19 Feb 2005 18:33:07 -0000	1.16
  @@ -64,6 +64,24 @@
                   print "α Ƽ: %s" % ticket
               elif minor==RESPONSE_LOBBY_LOGINHOUSELIST:
                   print "κ Ͽ콺 Ʈ %s\n" % data
  +                housecount = struct.unpack("B",data[0])[0]
  +                print "HOUSECOUNT %s" %  housecount
  +                data = data[1:]
  +                for c in range(housecount):
  +                    housenamelen = struct.unpack("B",data[0])[0]
  +                    print "Ͽ콺   %s" % housenamelen
  +                    data = data[1:]
  +                    housename = data[:housenamelen]
  +                    data = data[housenamelen: ]
  +                    houseinfolen = struct.unpack("B",data[0])[0]
  +                    data = data[1:]
  +                    houseinfo = data[:houseinfolen]
  +                    data = data[int(houseinfolen)  : ]
  +                    housecur = struct.unpack("H",data[:2])[0]
  +                    housemax = struct.unpack("H",data[2:4])[0]
  +                    data = data[4:]
  +                    print "Ͽ콺  %s : %s " % ( c , housename )
  +                    print "Ͽ콺  %s %s %s " % ( houseinfo,housecur , housemax)
                   return
               elif minor==RESPONSE_LOBBY_CLIENTLIST:
                   count = struct.unpack("!H", data[:2])[0]
  
  
  


djb         05/02/20 03:35:37

  Modified:    lib      lobby_functions.py
  Log:
  Ʈ
  
  Revision  Changes    Path
  1.11      +1 -1      siminserver/lib/lobby_functions.py
  
  Index: lobby_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/lobby_functions.py,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- lobby_functions.py	19 Feb 2005 18:23:11 -0000	1.10
  +++ lobby_functions.py	19 Feb 2005 18:35:36 -0000	1.11
  @@ -131,4 +131,4 @@
               client.setGameRoom(room)
           client.write(M_LOBBY, RESPONSE_LOBBY_CREATE_GAMEROOM, \
                                       struct.pack("B", ret))
  -    
  +# for test 
  
  
  


djb         05/02/20 03:41:43

  Added:       lib      pan_functions.py
  Log:
  insert pan functions
  
  Revision  Changes    Path
  1.1                  siminserver/lib/pan_functions.py
  
  Index: pan_functions.py
  ===================================================================
  #!/usr/bin/python
  
  from protocol import *
  import struct
  
  
  


djb         05/02/20 03:46:46

  Modified:    test     proxyclient.py
  Log:
  a
  
  Revision  Changes    Path
  1.17      +13 -0     siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- proxyclient.py	19 Feb 2005 18:33:07 -0000	1.16
  +++ proxyclient.py	19 Feb 2005 18:46:46 -0000	1.17
  @@ -43,6 +43,8 @@
           self.sock=None
           self.stop = False
           self.buffer = ""
  +        self.ticket = "1111111"
  +        self.authed = False
   
       def setSock(self, sock):
           self.sock = sock
  @@ -62,6 +64,8 @@
                       return
                   print "α : %s" % ret
                   print "α Ƽ: %s" % ticket
  +                self.ticket = ticket
  +                self.authed = True
               elif minor==RESPONSE_LOBBY_LOGINHOUSELIST:
                   print "κ Ͽ콺 Ʈ %s\n" % data
                   housecount = struct.unpack("B",data[0])[0]
  @@ -241,6 +245,15 @@
           packet += msg
           self.sock.send(struct.pack("!BBH", M_LOBBY, REQUEST_LOBBY_TOMSG_CHAT, len(packet)))
           self.sock.send(packet)
  +    def do_houselogin(self,args):
  +        """
  +        Ͽ콺 α
  +        """
  +        if self.sock == None:
  +            print "α Ͻʽÿ"
  +            return
  +        
  +
       def default(self, line):
           self.do_chat(line)
       def do_createroom(self, arg):
  
  
  


djb         05/02/20 03:54:08

  Modified:    test     proxyclient.py
  Log:
  Ͽ콺 α 
  
  Revision  Changes    Path
  1.18      +10 -1     siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- proxyclient.py	19 Feb 2005 18:46:46 -0000	1.17
  +++ proxyclient.py	19 Feb 2005 18:54:08 -0000	1.18
  @@ -121,6 +121,10 @@
                   else:
                       print "ӷ   ", ret
                       print "  ӷ ȿ ֽϴ."
  +        elif major == M_HOUSE:
  +            if minor == RESPONSE_HOUSE_LOGIN:
  +                print " Ͽ콺 α %s" % data
  +            return
           pass
   
       def run(self):
  @@ -245,6 +249,9 @@
           packet += msg
           self.sock.send(struct.pack("!BBH", M_LOBBY, REQUEST_LOBBY_TOMSG_CHAT, len(packet)))
           self.sock.send(packet)
  +    def do_ticket(self,args):
  +        print "TICKET %s\n" % self.serverHandler.ticket
  +
       def do_houselogin(self,args):
           """
           Ͽ콺 α
  @@ -252,7 +259,9 @@
           if self.sock == None:
               print "α Ͻʽÿ"
               return
  -        
  +        ticket = self.serverHandler.ticket
  +        self.sock.send(struct.pack("!BBH", M_HOUSE , REQUEST_HOUSE_LOGIN , len(ticket) ))
  +        self.sock.send(ticket)
   
       def default(self, line):
           self.do_chat(line)
  
  
  


djb         05/02/20 04:24:24

  Modified:    test     proxyclient.py
  Log:
  Ͽ콺  Ʈ  
  
  Revision  Changes    Path
  1.19      +7 -0      siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- proxyclient.py	19 Feb 2005 18:54:08 -0000	1.18
  +++ proxyclient.py	19 Feb 2005 19:24:24 -0000	1.19
  @@ -124,6 +124,9 @@
           elif major == M_HOUSE:
               if minor == RESPONSE_HOUSE_LOGIN:
                   print " Ͽ콺 α %s" % data
  +            elif minor == RESPONSE_HOUSE_PANLIST:
  +                pancounter = struct.unpack("H",data[:2])
  +                print " Ͽ콺 ǸƮ %s" % pancounter
               return
           pass
   
  @@ -263,6 +266,10 @@
           self.sock.send(struct.pack("!BBH", M_HOUSE , REQUEST_HOUSE_LOGIN , len(ticket) ))
           self.sock.send(ticket)
   
  +    def do_house_panlist(self,args):
  +        print "HOUSE PAN LIST REQUEST"
  +        self.sock.send(struct.pack("!BBH", M_HOUSE , REQUEST_HOUSE_PANLIST, 0 ))
  +
       def default(self, line):
           self.do_chat(line)
       def do_createroom(self, arg):
  
  
  


djb         05/02/20 04:24:39

  Modified:    lib      house_functions.py libpan.py pan_functions.py
  Log:
  Ͽ콺    Ʈ
  
  Revision  Changes    Path
  1.2       +42 -1     siminserver/lib/house_functions.py
  
  Index: house_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/house_functions.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- house_functions.py	5 Dec 2004 03:19:25 -0000	1.1
  +++ house_functions.py	19 Feb 2005 19:24:39 -0000	1.2
  @@ -8,6 +8,7 @@
       if minor == REQUEST_HOUSE_LOGIN:
           if data in self.ticketdict:
               print " Ͽ콺  " 
  +            client.houseAuth = True
               userobj = self.ticketdict[data]
               username = userobj._id
               print "USERNAME %s" % username
  @@ -23,4 +24,44 @@
                           struct.pack("!H",5) + \
                               "error" )
   def eventAuthHouseFunction(minor,length,data,client,self):
  -    pass
  +    if minor == REQUEST_HOUSE_PANLIST:
  +        # FIX
  +        # use 1st element of house list
  +        house = self.houselist[0]
  +
  +        panpacket = ""
  +        panpacket += struct.pack("H",len(house.panlist))
  +        for pan in house.panlist:
  +            panid = pan.panid
  +            pantopic = pan.topic
  +            pantopiclen = len(pantopic)
  +            panmaxuser = pan.maxuser
  +            pancurrentuser = pan.GetPeople()
  +            panuserlist =  ''
  +            for users in pan.UserObjList:
  +                panuserlist += users.username + "\t"
  +            panuserlist = panuserlist[:-1]
  +            panuserlistlen = len(panuserlist)
  +            # FIX for stats update
  +            panstatus = pan.status
  +            pansecret = pan.secret
  +
  +            panpacket += panid
  +            panpacket += struct.pack("H",pantopiclen)
  +            panpacket += pantopic
  +            panpacket += struct.pack("B",panmaxuser)
  +            panpacket += struct.pack("B",pancuurentuser)
  +            panpacket += struct.pack("B",panuserlistlen)
  +            panpacket += panuserlist
  +            panpacket += panstatus
  +            panpacket += pansecret
  +        client.write(M_HOUSE , RESPONSE_HOUSE_PANLIST , panpacket)
  +        return
  +
  +
  +
  +
  +
  +
  +
  +
  
  
  
  1.2       +4 -0      siminserver/lib/libpan.py
  
  Index: libpan.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/libpan.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- libpan.py	5 Dec 2004 03:19:25 -0000	1.1
  +++ libpan.py	19 Feb 2005 19:24:39 -0000	1.2
  @@ -19,6 +19,10 @@
           self.UserObjList = {}
           # UserObjList key = name
           # UserObjList value = userObject
  +        # FIX!! for maxuser , status , secret
  +        self.maxuser = 2
  +        self.status = 0x00
  +        self.secret = 0x00
   
       def _SetMaster(self):
           self.UserList.values().sort()
  
  
  
  1.2       +4 -0      siminserver/lib/pan_functions.py
  
  Index: pan_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/pan_functions.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- pan_functions.py	19 Feb 2005 18:41:43 -0000	1.1
  +++ pan_functions.py	19 Feb 2005 19:24:39 -0000	1.2
  @@ -2,3 +2,7 @@
   
   from protocol import *
   import struct
  +
  +
  +def eventPanFunction(minor,length,data,client,self):
  +    pass
  
  
  


djb         05/02/20 04:47:18

  Modified:    .        run.py
  Log:
  update for pan functions
  
  Revision  Changes    Path
  1.28      +5 -6      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- run.py	19 Feb 2005 17:41:09 -0000	1.27
  +++ run.py	19 Feb 2005 19:47:18 -0000	1.28
  @@ -278,10 +278,7 @@
       def errorOccurredClients(self):
           return self.errorClientList
       def setUserInfo(self, client, id):
  -        #info = self.rpc.user.info(id) 
  -        info = {
  -				"name" : "test",
  -				"email" : "test@test.com" }
  +        info = self.rpc.user.info(id) 
           print info
           client.setId(id)
           client.setName(info['name'])
  @@ -311,11 +308,13 @@
                           print "ȣ lib/libhouse.py/ eventNotAuthHouseFunction"
                           eventNotAuthHouseFunction(minor,length,data,client,self)
                       else:
  +                        print "ȣ lib/libhouse.py/eventAuthHouseFunction"
                           eventAuthHouseFunction(minor,length,data,client,self)
                   elif major == M_PAN:
  -                    pass
  +                    if client.houseAuth is True:
  +                        eventPanFunction(minor,length,data,client,self)
                   else:
  -                    pass
  +                    print "̺Ʈ NOT IN CODED! %s %s %s" % ( major , minor , length )
                   
                       
   
  
  
  


djb         05/02/20 04:47:18

  Modified:    lib      house_functions.py
  Log:
  update for pan functions
  
  Revision  Changes    Path
  1.3       +14 -8     siminserver/lib/house_functions.py
  
  Index: house_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/house_functions.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- house_functions.py	19 Feb 2005 19:24:39 -0000	1.2
  +++ house_functions.py	19 Feb 2005 19:47:18 -0000	1.3
  @@ -24,6 +24,8 @@
                           struct.pack("!H",5) + \
                               "error" )
   def eventAuthHouseFunction(minor,length,data,client,self):
  +    print "eventAuthHouseFunction ȣ"
  +    print "minor!! %s" % minor
       if minor == REQUEST_HOUSE_PANLIST:
           # FIX
           # use 1st element of house list
  @@ -56,12 +58,16 @@
               panpacket += panstatus
               panpacket += pansecret
           client.write(M_HOUSE , RESPONSE_HOUSE_PANLIST , panpacket)
  +    elif minor == REQUEST_HOUSE_CREATEPAN:
  +        print "Ͽ콺 Ʈ Ͽ콺 ũƮ "
  +        kind = data[0]
  +        titlelen = struct.unpack("B",data[1])[0]
  +        title = data[2:2 + titlelen]
  +        passlen = struct.unpack("B",data[2 + titlelen])[0]
  +        if passlen is not 0:
  +            passw = data[-passlen:]
  +        else:
  +            passw = None
  +        print "ǻû : %s ŸƲ : %s" % ( kind , title )
  +        print "               ȣ: %s" % passlen
           return
  -
  -
  -
  -
  -
  -
  -
  -
  
  
  


djb         05/02/20 04:47:18

  Modified:    test     proxyclient.py
  Log:
  update for pan functions
  
  Revision  Changes    Path
  1.20      +14 -0     siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- proxyclient.py	19 Feb 2005 19:24:24 -0000	1.19
  +++ proxyclient.py	19 Feb 2005 19:47:18 -0000	1.20
  @@ -270,6 +270,20 @@
           print "HOUSE PAN LIST REQUEST"
           self.sock.send(struct.pack("!BBH", M_HOUSE , REQUEST_HOUSE_PANLIST, 0 ))
   
  +    def do_house_createpan(self,args):
  +        if len(args) == 0:
  +            print " ־  ϴ"
  +            return
  +        title = args
  +        print "  Ŷ ϴ"
  +        self.sock.send(struct.pack("!BBH", M_HOUSE , REQUEST_HOUSE_CREATEPAN , len( title ) + 3 ))
  +        print "Ŷ %s %s %s" % ( M_HOUSE , REQUEST_HOUSE_CREATEPAN , len( title ) + 3  )
  +        self.sock.send(struct.pack("B",0x00))
  +        self.sock.send(struct.pack("B",0x00))
  +        self.sock.send(struct.pack("B",len(title)))
  +        self.sock.send(struct.pack("B",0x00))
  +        print "  Ŷ ٺ"
  +
       def default(self, line):
           self.do_chat(line)
       def do_createroom(self, arg):
  
  
  


djb         05/02/20 05:01:25

  Modified:    .        run.py
  Log:
  ũƮ  Ʈ
  
  Revision  Changes    Path
  1.29      +1 -1      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- run.py	19 Feb 2005 19:47:18 -0000	1.28
  +++ run.py	19 Feb 2005 20:01:25 -0000	1.29
  @@ -292,7 +292,7 @@
                       c.write(M_LOBBY, minor, data)
       def event(self, client):
           for major, minor, length, data in client.getProtocolList():
  -            print "Client Event %d %d %d" % (major, minor, length)
  +            print "̺Ʈ  %02x %02x %d" % (major, minor, length)
               if not client.auth():
                   if major==M_LOBBY: # Lobby
                        # see lib/lobby_functions.py
  
  
  


djb         05/02/20 05:01:26

  Modified:    lib      house_functions.py
  Log:
  ũƮ  Ʈ
  
  Revision  Changes    Path
  1.4       +3 -4      siminserver/lib/house_functions.py
  
  Index: house_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/house_functions.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- house_functions.py	19 Feb 2005 19:47:18 -0000	1.3
  +++ house_functions.py	19 Feb 2005 20:01:26 -0000	1.4
  @@ -25,7 +25,6 @@
                               "error" )
   def eventAuthHouseFunction(minor,length,data,client,self):
       print "eventAuthHouseFunction ȣ"
  -    print "minor!! %s" % minor
       if minor == REQUEST_HOUSE_PANLIST:
           # FIX
           # use 1st element of house list
  @@ -61,9 +60,9 @@
       elif minor == REQUEST_HOUSE_CREATEPAN:
           print "Ͽ콺 Ʈ Ͽ콺 ũƮ "
           kind = data[0]
  -        titlelen = struct.unpack("B",data[1])[0]
  -        title = data[2:2 + titlelen]
  -        passlen = struct.unpack("B",data[2 + titlelen])[0]
  +        titlelen = struct.unpack("H",data[1:3])[0]
  +        title = data[3:3 + titlelen]
  +        passlen = struct.unpack("B",data[3 + titlelen])[0]
           if passlen is not 0:
               passw = data[-passlen:]
           else:
  
  
  


djb         05/02/20 05:01:26

  Modified:    test     proxyclient.py
  Log:
  ũƮ  Ʈ
  
  Revision  Changes    Path
  1.21      +4 -4      siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- proxyclient.py	19 Feb 2005 19:47:18 -0000	1.20
  +++ proxyclient.py	19 Feb 2005 20:01:26 -0000	1.21
  @@ -276,11 +276,11 @@
               return
           title = args
           print "  Ŷ ϴ"
  -        self.sock.send(struct.pack("!BBH", M_HOUSE , REQUEST_HOUSE_CREATEPAN , len( title ) + 3 ))
  -        print "Ŷ %s %s %s" % ( M_HOUSE , REQUEST_HOUSE_CREATEPAN , len( title ) + 3  )
  +        self.sock.send(struct.pack("!BBH", M_HOUSE , REQUEST_HOUSE_CREATEPAN , len( title ) + 4 ))
  +        print "Ŷ %02x %02x %02x" % ( M_HOUSE , REQUEST_HOUSE_CREATEPAN , len( title ) + 4  )
           self.sock.send(struct.pack("B",0x00))
  -        self.sock.send(struct.pack("B",0x00))
  -        self.sock.send(struct.pack("B",len(title)))
  +        self.sock.send(struct.pack("H",len(title)))
  +        self.sock.send(title)
           self.sock.send(struct.pack("B",0x00))
           print "  Ŷ ٺ"
   
  
  
  


fox9        05/02/20 05:18:52

  Modified:    lib      protocol.py
  Log:
      ߰
     
  
  Revision  Changes    Path
  1.10      +34 -0     siminserver/lib/protocol.py
  
  Index: protocol.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/protocol.py,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- protocol.py	19 Feb 2005 17:40:21 -0000	1.9
  +++ protocol.py	19 Feb 2005 20:18:52 -0000	1.10
  @@ -60,3 +60,37 @@
   RESPONSE_HOUSE_CREATEPAN                    = 0xB1
   
   ## PAN PROTOCOL
  +
  +
  +
  +# Minor code in M_GAME_GOSTOP
  +# Request (0x00~0x4F) ============================
  +REQUEST_GAME_GOSTOP_START                   = 0x01
  +REQUEST_GAME_GOSTOP_GO                      = 0x02
  +REQUEST_GAME_GOSTOP_STOP                    = 0x03
  +
  +REQUEST_GAME_GOSTOP_NORMAL                  = 0x11
  +REQUEST_GAME_GOSTOP_SHAKE                   = 0x12
  +REQUEST_GAME_GOSTOP_BOMB                    = 0x13
  +
  +REQUEST_GAME_GOSTOP_SELECT                  = 0x21
  +
  +# Response (0xA0~0xFF) ===========================
  +
  +
  +# Notificaton (0x50~0x9F) ========================
  +NOTIFY_GAME_GOSTOP_START                    = 0x51
  +NOTIFY_GAME_GOSTOP_END                      = 0x52
  +NOTIFY_GAME_GOSTOP_TURN                     = 0x53
  +NOTIFY_GAME_GOSTOP_BONUS                    = 0x54
  +NOTIFY_GAME_GOSTOP_BONUSGET                 = 0x55
  +NOTIFY_GAME_GOSTOP_CARD                     = 0x56
  +NOTIFY_GAME_GOSTOP_SELECT                   = 0x57
  +NOTIFY_GAME_GOSTOP_GOSTOP                   = 0x58
  +
  +NOTIFY_GAME_GOSTOP_JJOCK                    = 0x71
  +NOTIFY_GAME_GOSTOP_BBUCK                    = 0x72
  +NOTIFY_GAME_GOSTOP_DDADAK                   = 0x73
  +NOTIFY_GAME_GOSTOP_JABBUCKGET               = 0x74
  +NOTIFY_GAME_GOSTOP_BBUCKGET                 = 0x75
  +NOTIFY_GAME_GOSTOP_MATCH                    = 0x76
  
  
  


fox9        05/02/20 05:18:52

  Modified:    module/gostop gostop.py test.py
  Log:
      ߰
     
  
  Revision  Changes    Path
  1.8       +25 -21    siminserver/module/gostop/gostop.py
  
  Index: gostop.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/module/gostop/gostop.py,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- gostop.py	4 Dec 2004 15:08:15 -0000	1.7
  +++ gostop.py	19 Feb 2005 20:18:52 -0000	1.8
  @@ -8,6 +8,10 @@
   import cardlist
   import ai
   
  +import sys
  +sys.path.append("../../lib")
  +from protocol import *
  +
   class gostop:
       def __init__(self, type="matgo"):
           self.dummycard = [] #  Ʈ
  @@ -50,31 +54,31 @@
   
           # ׼  (Ϲ, , ź)
           # Client -> Server
  -        self.ACTION_NORMAL = 0
  -        self.ACTION_SHAKE  = 1
  -        self.ACTION_BOMB   = 2
  -        self.ACTION_GO     = 3
  -        self.ACTION_STOP   = 4
  -        self.ACTION_START  = 5
  +        self.ACTION_NORMAL = REQUEST_GAME_GOSTOP_NORMAL
  +        self.ACTION_SHAKE  = REQUEST_GAME_GOSTOP_SHAKE
  +        self.ACTION_BOMB   = REQUEST_GAME_GOSTOP_BOMB
  +        self.ACTION_GO     = REQUEST_GAME_GOSTOP_GO
  +        self.ACTION_STOP   = REQUEST_GAME_GOSTOP_STOP
  +        self.ACTION_START  = REQUEST_GAME_GOSTOP_START
   
           # Server -> Client
  -        self.ACTION_JJOCK  = 6
  -        self.ACTION_BBUCK  = 7
  -        self.ACTION_DDADAK = 8
  -        self.ACTION_JABBUCKGET = 9
  -        self.ACTION_BBUCKGET = 10
  -        self.ACTION_MATCH   = 11
  +        self.ACTION_JJOCK      = NOTIFY_GAME_GOSTOP_JJOCK
  +        self.ACTION_BBUCK      = NOTIFY_GAME_GOSTOP_BBUCK
  +        self.ACTION_DDADAK     = NOTIFY_GAME_GOSTOP_DDADAK
  +        self.ACTION_JABBUCKGET = NOTIFY_GAME_GOSTOP_JABBUCKGET
  +        self.ACTION_BBUCKGET   = NOTIFY_GAME_GOSTOP_BBUCKGET
  +        self.ACTION_MATCH      = NOTIFY_GAME_GOSTOP_MATCH
   
           self.lastgouser = 0   #  ѻ (׷   :)
   
  -        self.CODE_START = 1
  -        self.CODE_END   = 2
  -        self.CODE_TURN  = 3
  -        self.CODE_BONUS = 4
  -        self.CODE_BONUSGET = 5
  -        self.CODE_CARD  = 6
  -        self.CODE_SELECT = 7
  -        self.CODE_GOSTOP = 8
  +        self.CODE_START    = NOTIFY_GAME_GOSTOP_START
  +        self.CODE_END      = NOTIFY_GAME_GOSTOP_END
  +        self.CODE_TURN     = NOTIFY_GAME_GOSTOP_TURN
  +        self.CODE_BONUS    = NOTIFY_GAME_GOSTOP_BONUS
  +        self.CODE_BONUSGET = NOTIFY_GAME_GOSTOP_BONUSGET
  +        self.CODE_CARD     = NOTIFY_GAME_GOSTOP_CARD
  +        self.CODE_SELECT   = NOTIFY_GAME_GOSTOP_SELECT
  +        self.CODE_GOSTOP   = NOTIFY_GAME_GOSTOP_GOSTOP
   
           # ޼ 
           self.msgaction = 0
  @@ -91,7 +95,7 @@
   
       def make_packet(self, code, data):
           msglen = len(data)
  -        result = struct.pack("BBB", 3, code, msglen)
  +        result = struct.pack("BBB", M_GAME_GOSTOP, code, msglen)
           
           if msglen > 0:
               result += data
  
  
  
  1.6       +8 -5      siminserver/module/gostop/test.py
  
  Index: test.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/module/gostop/test.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- test.py	4 Dec 2004 15:08:15 -0000	1.5
  +++ test.py	19 Feb 2005 20:18:52 -0000	1.6
  @@ -4,10 +4,13 @@
   import gostop
   import struct
   import cardlist
  -import sys
   import pygame
   import time
   
  +import sys
  +sys.path.append("../../lib")
  +from protocol import *
  +
   class User:
       def __init__(self, client, game, userid, username, type="human"):
           self.cards = cardlist.cardlist()
  @@ -27,7 +30,7 @@
           print "Ÿ ޾"
           # Major Code | Minor Code | Length | Data
           major, minor, length = struct.unpack("BBB", msg[:3])
  -        if major != 3:
  +        if major != M_GAME_GOSTOP:
               print "Ÿ ̻ؿ"
               return
   
  @@ -430,11 +433,11 @@
                                   if self.askbomb != 0:
                                       data = -1
                                       if event.key == pygame.K_1:
  -                                        data = 1
  +                                        data = self.game.ACTION_SHAKE
                                       elif event.key == pygame.K_0:
  -                                        data = 0
  +                                        data = self.game.ACTION_NORMAL
                                       elif event.key == pygame.K_2 and self.askbomb == 2:
  -                                        data = 2
  +                                        data = self.game.ACTION_BOMB
   
                                       if data > -1:
                                           self.askbomb = 0
  
  
  


djb         05/02/20 05:28:08

  Modified:    lib      house_functions.py libhouse.py
  Log:
   Ͽ콺 Ʈ
  
  Revision  Changes    Path
  1.5       +11 -4     siminserver/lib/house_functions.py
  
  Index: house_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/house_functions.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- house_functions.py	19 Feb 2005 20:01:26 -0000	1.4
  +++ house_functions.py	19 Feb 2005 20:28:08 -0000	1.5
  @@ -29,12 +29,14 @@
           # FIX
           # use 1st element of house list
           house = self.houselist[0]
  +        print "  Ʈ %s" % house.panlist
   
           panpacket = ""
           panpacket += struct.pack("H",len(house.panlist))
           for pan in house.panlist:
  +            pan = house.panlist[pan]
               panid = pan.panid
  -            pantopic = pan.topic
  +            pantopic = pan.pantopic
               pantopiclen = len(pantopic)
               panmaxuser = pan.maxuser
               pancurrentuser = pan.GetPeople()
  @@ -51,13 +53,15 @@
               panpacket += struct.pack("H",pantopiclen)
               panpacket += pantopic
               panpacket += struct.pack("B",panmaxuser)
  -            panpacket += struct.pack("B",pancuurentuser)
  +            panpacket += struct.pack("B",pancurrentuser)
               panpacket += struct.pack("B",panuserlistlen)
               panpacket += panuserlist
  -            panpacket += panstatus
  -            panpacket += pansecret
  +            panpacket += struct.pack("B",panstatus)
  +            panpacket += struct.pack("B",pansecret)
           client.write(M_HOUSE , RESPONSE_HOUSE_PANLIST , panpacket)
       elif minor == REQUEST_HOUSE_CREATEPAN:
  +        # FIX!!
  +        house1 = self.houselist[0]
           print "Ͽ콺 Ʈ Ͽ콺 ũƮ "
           kind = data[0]
           titlelen = struct.unpack("H",data[1:3])[0]
  @@ -69,4 +73,7 @@
               passw = None
           print "ǻû : %s ŸƲ : %s" % ( kind , title )
           print "               ȣ: %s" % passlen
  +
  +        panid = house1.EventCreate(title,passw)
  +        client.write(M_HOUSE,RESPONSE_HOUSE_CREATEPAN, struct.pack("B",0x00) + panid )
           return
  
  
  
  1.3       +3 -2      siminserver/lib/libhouse.py
  
  Index: libhouse.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/libhouse.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- libhouse.py	19 Feb 2005 15:43:03 -0000	1.2
  +++ libhouse.py	19 Feb 2005 20:28:08 -0000	1.3
  @@ -10,6 +10,7 @@
           self.dispatcher = dispatcher
           self.housename = housename
           self.houseinfo = houseinfo
  +        print " Ͽ콺 ̴ϼȶ %s " % houseinfo
           # Ͽ콺 밡 ƽ ο
           self.housemax = 1000
           self.userlist = {}
  @@ -50,9 +51,9 @@
              if newid not in self.panlist:
                   return newid
   
  -    def EventCreate(self):
  +    def EventCreate(self,topic,passw):
           panid = self.GetPanId()
  -        self.panlist[panid] = panclass(panid,"","")
  +        self.panlist[panid] = panclass(panid,topic,passw)
           return panid
   
       def EventLeave(self,username):
  
  
  


djb         05/02/20 05:28:08

  Modified:    test     proxyclient.py
  Log:
   Ͽ콺 Ʈ
  
  Revision  Changes    Path
  1.22      +5 -0      siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- proxyclient.py	19 Feb 2005 20:01:26 -0000	1.21
  +++ proxyclient.py	19 Feb 2005 20:28:08 -0000	1.22
  @@ -127,6 +127,11 @@
               elif minor == RESPONSE_HOUSE_PANLIST:
                   pancounter = struct.unpack("H",data[:2])
                   print " Ͽ콺 ǸƮ %s" % pancounter
  +                print " Ʈ -_-;;; ֿ"
  +            elif minor == RESPONSE_HOUSE_CREATEPAN:
  +                status = struct.unpack("B",data[0])[0]
  +                panid = data[1:]
  +                print "  Ͽ콺 ũƮ  %02x %s" % ( status , panid )
               return
           pass
   
  
  
  


djb         05/02/20 05:57:30

  Modified:    lib      house_functions.py
  Log:
   Ŭ̾Ʈ ϴٰ 
  
  Revision  Changes    Path
  1.6       +1 -0      siminserver/lib/house_functions.py
  
  Index: house_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/house_functions.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- house_functions.py	19 Feb 2005 20:28:08 -0000	1.5
  +++ house_functions.py	19 Feb 2005 20:57:30 -0000	1.6
  @@ -38,6 +38,7 @@
               panid = pan.panid
               pantopic = pan.pantopic
               pantopiclen = len(pantopic)
  +            print "ȷ:%s :%s" % ( pantopiclen , pantopic)
               panmaxuser = pan.maxuser
               pancurrentuser = pan.GetPeople()
               panuserlist =  ''
  
  
  


djb         05/02/20 05:57:31

  Modified:    test     proxyclient.py
  Log:
   Ŭ̾Ʈ ϴٰ 
  
  Revision  Changes    Path
  1.23      +25 -3     siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- proxyclient.py	19 Feb 2005 20:28:08 -0000	1.22
  +++ proxyclient.py	19 Feb 2005 20:57:31 -0000	1.23
  @@ -125,9 +125,31 @@
               if minor == RESPONSE_HOUSE_LOGIN:
                   print " Ͽ콺 α %s" % data
               elif minor == RESPONSE_HOUSE_PANLIST:
  -                pancounter = struct.unpack("H",data[:2])
  -                print " Ͽ콺 ǸƮ %s" % pancounter
  -                print " Ʈ -_-;;; ֿ"
  +                print "ǸƮ  %s" % data
  +                pancounter = struct.unpack("H",data[:2])[0]
  +                print " Ͽ콺 ǸƮ  :  %s" % pancounter
  +                #for x in range(pancounter):
  +                #    panid = data[2:16]
  +                #    pantopiclen = struct.unpack("H",data[16:18])[0]
  +                #    print " ȷ %s" % pantopiclen
  +                #    pantopic = data[18:18+pantopiclen]
  +                #    panmaxuser = struct.unpack("B",data[18+ pantopiclen + 1])[0]
  +                #    pancurrentuser = struct.unpack("B",data[18+ pantopiclen + 2])[0]
  +                #    panuserlistlen = struct.unpack("B",data[18+ pantopiclen + 3])[0]
  +                #    member = []
  +                #    data = data[18+ pantopiclen + 3:]
  +                #    if panuserlistlen != 0:
  +                #        panuserlist = data[:panuserlistlen]
  +                #    else:
  +                #        panuserlist = ''
  +                #    panstatus = struct.unpack("B",data[panuserlistlen ])[0]
  +                #    panstatus = struct.unpack("B",data[panuserlistlen + 1])[0]
  +                #    data = data[2:]
  +                #    print " Ʈ : ID : %s" % panid
  +                #    print " Ʈ : MAXUSER : %s" % panmaxuser
  +                #    print " Ʈ : : %s" % pantopic
  +                #    print " Ʈ : Ʈ : %s" % panuserlist
  +
               elif minor == RESPONSE_HOUSE_CREATEPAN:
                   status = struct.unpack("B",data[0])[0]
                   panid = data[1:]
  
  
  


djb         05/02/20 06:05:04

  Modified:    lib      protocol.py
  Log:
  Ʈ for pan protocol
  
  Revision  Changes    Path
  1.11      +4 -1      siminserver/lib/protocol.py
  
  Index: protocol.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/protocol.py,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- protocol.py	19 Feb 2005 20:18:52 -0000	1.10
  +++ protocol.py	19 Feb 2005 21:05:04 -0000	1.11
  @@ -59,7 +59,10 @@
   REQUEST_HOUSE_CREATEPAN                     = 0x11
   RESPONSE_HOUSE_CREATEPAN                    = 0xB1
   
  -## PAN PROTOCOL
  +# PAN PROTOCOL
  +
  +REQUEST_PAN_JOIN                            = 0x01
  +RESPONSE_PAN_JOIN                           = 0x01
   
   
   
  
  
  


djb         05/02/20 06:40:32

  Modified:    lib      protocol.py
  Log:
    ߰
  
  Revision  Changes    Path
  1.12      +3 -0      siminserver/lib/protocol.py
  
  Index: protocol.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/protocol.py,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- protocol.py	19 Feb 2005 21:05:04 -0000	1.11
  +++ protocol.py	19 Feb 2005 21:40:32 -0000	1.12
  @@ -64,6 +64,9 @@
   REQUEST_PAN_JOIN                            = 0x01
   RESPONSE_PAN_JOIN                           = 0x01
   
  +REQUEST_PAN_CHAT                            = 0x89
  +NOTIFY_PAN_CHAT                             = 0x90
  +
   
   
   # Minor code in M_GAME_GOSTOP
  
  
  


djb         05/02/20 07:04:15

  Modified:    .        run.py
  Log:
  Ʈ for pan list ( left 5 fix ~ 12 fix )
  
  Revision  Changes    Path
  1.30      +1 -0      siminserver/run.py
  
  Index: run.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/run.py,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- run.py	19 Feb 2005 20:01:25 -0000	1.29
  +++ run.py	19 Feb 2005 22:04:15 -0000	1.30
  @@ -224,6 +224,7 @@
   # import lobby_function by djb
   from lib.lobby_functions import *
   from lib.house_functions import *
  +from lib.pan_functions import *
   from lib.libhouse import house
   class Lobby:
       def __init__(self):
  
  
  


djb         05/02/20 07:04:15

  Modified:    lib      house_functions.py libpan.py pan_functions.py
  Log:
  Ʈ for pan list ( left 5 fix ~ 12 fix )
  
  Revision  Changes    Path
  1.7       +1 -1      siminserver/lib/house_functions.py
  
  Index: house_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/house_functions.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- house_functions.py	19 Feb 2005 20:57:30 -0000	1.6
  +++ house_functions.py	19 Feb 2005 22:04:15 -0000	1.7
  @@ -43,7 +43,7 @@
               pancurrentuser = pan.GetPeople()
               panuserlist =  ''
               for users in pan.UserObjList:
  -                panuserlist += users.username + "\t"
  +                panuserlist += pan.UserObjList[users]._id + "\t"
               panuserlist = panuserlist[:-1]
               panuserlistlen = len(panuserlist)
               # FIX for stats update
  
  
  
  1.3       +12 -3     siminserver/lib/libpan.py
  
  Index: libpan.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/libpan.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- libpan.py	19 Feb 2005 19:24:39 -0000	1.2
  +++ libpan.py	19 Feb 2005 22:04:15 -0000	1.3
  @@ -3,6 +3,8 @@
   
   import sys , os
   import time
  +from protocol import *
  +import struct
   
   class panclass:
       def __init__(self,panid,pantopic,panpass):
  @@ -33,16 +35,23 @@
       def SetGameType(self,gametype):
           self.gametype = gametype
   
  -    def EventJoinPan(self,username,panpass,UserObj):
  +    def EventJoinPan(self,username,panpass,client):
           if username not in self.UserList:
  +            self.UserObjList[username] = client
  +            print " %s %s" % (  username , self.panid)
  +            userid = self.UserObjList[username]._id
  +            userrealname = self.UserObjList[username]._name
  +            usernamelen = len(userid) + len(userrealname) + 1
  +            msg = "%s JOINED GAME!!"  % userrealname
  +            msglen = len(msg)
               if len(self.UserList) == 0:
                   #   ° 
                   self.master = username
               else:
                   for users in self.UserObjList:
  -                    self.UserObjList[users].write(" "  + username + "   äο Ի" )
  +                    self.UserObjList[users].write(M_PAN , NOTIFY_PAN_CHAT , \
  +                         struct.pack("B",usernamelen) + userid + "|" + userrealname + struct.pack("B",msglen) + msg )
               self.UserList[username] = time.time()
  -            self.UserObjList[username] = UserObj
               # check gametype
               if self.gametype == self.GetPeople():
                   # game start broadcast
  
  
  
  1.3       +10 -1     siminserver/lib/pan_functions.py
  
  Index: pan_functions.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/lib/pan_functions.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- pan_functions.py	19 Feb 2005 19:24:39 -0000	1.2
  +++ pan_functions.py	19 Feb 2005 22:04:15 -0000	1.3
  @@ -5,4 +5,13 @@
   
   
   def eventPanFunction(minor,length,data,client,self):
  -    pass
  +    if minor == REQUEST_PAN_JOIN:
  +        house = self.houselist[0]
  +        panid = data[:14]
  +        passlen = struct.unpack("B",data[14])[0]
  +        if passlen == 0x00:
  +            passw = None
  +        else:
  +            passw = data[15:]
  +        pan = house.panlist[panid]
  +        pan.EventJoinPan(client._id,passw,client)
  
  
  


djb         05/02/20 07:04:16

  Modified:    test     proxyclient.py
  Log:
  Ʈ for pan list ( left 5 fix ~ 12 fix )
  
  Revision  Changes    Path
  1.24      +22 -0     siminserver/test/proxyclient.py
  
  Index: proxyclient.py
  ===================================================================
  RCS file: /cvsroot/simin/siminserver/test/proxyclient.py,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- proxyclient.py	19 Feb 2005 20:57:31 -0000	1.23
  +++ proxyclient.py	19 Feb 2005 22:04:16 -0000	1.24
  @@ -155,6 +155,10 @@
                   panid = data[1:]
                   print "  Ͽ콺 ũƮ  %02x %s" % ( status , panid )
               return
  +        elif major == M_PAN:
  +            print "  %s" % data
  +            if minor ==  NOTIFY_PAN_CHAT:
  +                print "Ƽ  ê %s" % data
           pass
   
       def run(self):
  @@ -311,6 +315,24 @@
           self.sock.send(struct.pack("B",0x00))
           print "  Ŷ ٺ"
   
  +    def do_panjoin(self,args):
  +        #args = args.split(" ",1)
  +        ## FIX!!
  +        #print "ARGS %s" % args
  +        #if len(args) != 2:
  +        #    panid = args
  +        #    passwd = 0x00
  +        #else:
  +        #    panid , passwd = args
  +        panid = args 
  +        passwd = None
  +        print "ǿ ϴ!"
  +        self.sock.send(struct.pack("!BBH", M_PAN , REQUEST_PAN_JOIN , 15 ))
  +        self.sock.send(panid)
  +        self.sock.send(struct.pack("B",0x00))
  +        print "ǿ  û "
  +
  +
       def default(self, line):
           self.do_chat(line)
       def do_createroom(self, arg):
  
  
  


