Example #1
0
 def assignVoices(self):
     """now we have all remote user voices"""
     assert self.belongsToHumanPlayer()
     available = Voice.availableVoices()[:]
     # available is without transferred human voices
     for player in self.players:
         if player.voice and player.voice.oggFiles():
             # remote human player sent her voice, or we are human and have a voice
             if Debug.sound and player != self.myself:
                 logDebug('%s got voice from opponent: %s' % (player.name, player.voice))
         else:
             player.voice = Voice.locate(player.name)
             if player.voice:
                 if Debug.sound:
                     logDebug('%s has own local voice %s' % (player.name, player.voice))
         if player.voice:
             for voice in Voice.availableVoices():
                 if voice in available and voice.md5sum == player.voice.md5sum:
                     # if the local voice is also predefined,
                     # make sure we do not use both
                     available.remove(voice)
     # for the other players use predefined voices in preferred language. Only if
     # we do not have enough predefined voices, look again in locally defined voices
     predefined = [x for x in available if x.language() != 'local']
     predefined.extend(available)
     for player in self.players:
         if player.voice is None and predefined:
             player.voice = predefined.pop(0)
             if Debug.sound:
                 logDebug('%s gets one of the still available voices %s' % (player.name, player.voice))
Example #2
0
 def __init__(self,
              names,
              ruleset,
              gameid=None,
              wantedGame=None,
              client=None,
              playOpen=False,
              autoPlay=False):
     """a new game instance, comes from database if gameid is set"""
     self.__activePlayer = None
     self.prevActivePlayer = None
     self.defaultNameBrush = None
     Game.__init__(self,
                   names,
                   ruleset,
                   gameid,
                   wantedGame=wantedGame,
                   client=client)
     self.playOpen = playOpen
     self.autoPlay = autoPlay
     myself = self.myself
     if self.belongsToHumanPlayer() and myself:
         myself.voice = Voice.locate(myself.name)
         if myself.voice:
             if Debug.sound:
                 logDebug('myself %s gets voice %s' %
                          (myself.name, myself.voice))
         else:
             if Debug.sound:
                 logDebug('myself %s gets no voice' % (myself.name))
Example #3
0
 def __loggedIn(self, connection):
     """callback after the server answered our login request"""
     self.connection = connection
     self.ruleset = connection.ruleset
     self.name = connection.username
     self.tableList.show()
     voiceId = None
     if Preferences.uploadVoice:
         voice = Voice.locate(self.name)
         if voice:
             voiceId = voice.md5sum
         if Debug.sound and voiceId:
             logDebug('%s sends own voice %s to server' % (self.name, voiceId))
     maxGameId = Query('select max(id) from game').records[0][0]
     maxGameId = int(maxGameId) if maxGameId else 0
     self.callServer('setClientProperties',
         Internal.dbIdent,
         voiceId, maxGameId, Internal.version).addCallbacks(self.__initTableList, self.__versionError)
Example #4
0
 def __init__(self, names, ruleset, gameid=None, wantedGame=None, shouldSave=True, \
         client=None, playOpen=False, autoPlay=False):
     """a new game instance, comes from database if gameid is set"""
     self.__activePlayer = None
     self.prevActivePlayer = None
     self.defaultNameBrush = None
     PlayingGame.__init__(self, names, ruleset, gameid,
         wantedGame=wantedGame, shouldSave=shouldSave, client=client)
     self.playOpen = playOpen
     self.autoPlay = autoPlay
     myself = self.myself
     if self.belongsToHumanPlayer() and myself:
         myself.voice = Voice.locate(myself.name)
         if myself.voice:
             if Debug.sound:
                 logDebug('RemoteGame: myself %s gets voice %s' % (myself.name, myself.voice))
         else:
             if Debug.sound:
                 logDebug('myself %s gets no voice'% (myself.name))
Example #5
0
 def __loggedIn(self, connection):
     """callback after the server answered our login request"""
     self.connection = connection
     self.ruleset = connection.ruleset
     self.name = connection.username
     self.tableList.show()
     voiceId = None
     if Internal.Preferences.uploadVoice:
         voice = Voice.locate(self.name)
         if voice:
             voiceId = voice.md5sum
         if Debug.sound and voiceId:
             logDebug(
                 u'%s sends own voice %s to server' %
                 (self.name, voiceId))
     maxGameId = Query('select max(id) from game').records[0][0]
     maxGameId = int(maxGameId) if maxGameId else 0
     self.callServer('setClientProperties',
                     Internal.db.identifier,
                     voiceId, maxGameId,
                     Internal.defaultPort).addCallbacks(self.__initTableList, self.__versionError)
Example #6
0
 def assignVoices(self):
     """now we have all remote user voices"""
     assert self.belongsToHumanPlayer()
     available = Voice.availableVoices()[:]
     # available is without transferred human voices
     for player in self.players:
         if player.voice and player.voice.oggFiles():
             # remote human player sent her voice, or we are human
             # and have a voice
             if Debug.sound and player != self.myself:
                 logDebug('%s got voice from opponent: %s' %
                          (player.name, player.voice))
         else:
             player.voice = Voice.locate(player.name)
             if player.voice:
                 if Debug.sound:
                     logDebug('%s has own local voice %s' %
                              (player.name, player.voice))
         if player.voice:
             for voice in Voice.availableVoices():
                 if (voice in available
                         and voice.md5sum == player.voice.md5sum):
                     # if the local voice is also predefined,
                     # make sure we do not use both
                     available.remove(voice)
     # for the other players use predefined voices in preferred language.
     # Only if we do not have enough predefined voices, look again in
     # locally defined voices
     predefined = [x for x in available if x.language() != 'local']
     predefined.extend(available)
     for player in self.players:
         if player.voice is None and predefined:
             player.voice = predefined.pop(0)
             if Debug.sound:
                 logDebug('%s gets one of the still available voices %s' %
                          (player.name, player.voice))
Example #7
0
 def clientAction(self, dummyClient, move):
     """the server gave us a voice id about another player"""
     if Internal.Preferences.useSounds and Options.gui:
         move.player.voice = Voice.locate(move.source)
         if not move.player.voice:
             return Message.ClientWantsVoiceData, move.source
Example #8
0
 def clientAction(self, dummyClient, move):
     """the server gave us a voice id about another player"""
     if Internal.Preferences.useSounds and Options.gui:
         move.player.voice = Voice.locate(move.source)
         if not move.player.voice:
             return Message.ClientWantsVoiceData, move.source
Example #9
0
 def clientAction(self, dummyClient, move):
     """the server gave us a voice id about another player"""
     if Sound.enabled:
         move.player.voice = Voice.locate(move.source)
         if not move.player.voice:
             return Message.ClientWantsVoiceData, move.source