Example #1
0
 def __init__(self, messenger, chips=1000):
     self.messenger = messenger
     self.messenger.evt_messageReceived += self._on_messageReceived
     self.evt_playerResponse = Event()
     self.evt_playerJoin = Event()
     self.players = []
     self.chips = chips
Example #2
0
class PlaysHand(object):
    def __init__(self, interacts):
        self._interacts = interacts
        self.evt_done = Event()
        self._deck = DealsTexasHoldEm(self._interacts)
        self._takeBets = TakesBets(self._interacts)
        self._takeBets.evt_done += self._onRoundDone

    def start(self):
        for player in self._interacts.players:
            player.dropCards()

        self._deck.start()
        self._takeBets.start()

    def _onRoundDone(self, sender=None, args=None):
        if not self._deck.more() or self._onePlayerLeft():
            self._finish()
        else:
            self._deck.next()
            self._takeBets.next()

    def _finish(self):
        dw = DistributesWinnings(self._interacts)
        dw.toPlayers()
        self.evt_done.fire(self)

    def _onePlayerLeft(self):
        hasCards = len([p for p in self._interacts.players if p.isPlaying()])
        return hasCards == 1
Example #3
0
class PlaysHand(object):
    def __init__(self, interacts):
        self._interacts = interacts
        self.evt_done = Event()
        self._deck = DealsTexasHoldEm(self._interacts)
        self._takeBets = TakesBets(self._interacts)
        self._takeBets.evt_done += self._onRoundDone

    def start(self):
        for player in self._interacts.players:
            player.dropCards()

        self._deck.start()
        self._takeBets.start()

    def _onRoundDone(self, sender=None, args=None):
        if not self._deck.more() or self._onePlayerLeft():
            self._finish()
        else:
            self._deck.next()
            self._takeBets.next()

    def _finish(self):
        dw = DistributesWinnings(self._interacts)
        dw.toPlayers()
        self.evt_done.fire(self)

    def _onePlayerLeft(self):
        hasCards = len([p for p in self._interacts.players if p.isPlaying()])
        return hasCards == 1
Example #4
0
 def __init__(self):
     self.evt_playerResponse = Event()
     self.evt_messageReceived = Event()
     self.replies = deque()
     self.sentMessages = []
     self.broadcastMessages = []
     self.goMessages = []
     self.lastMessage = None
     self.cardMessages = []
     self.allMessages = []
     self.dealingMessages = []
     self.wonMessages = []
Example #5
0
class XmppMessenger(sleekxmpp.ClientXMPP):

    def __init__(self, jid, password):
        sleekxmpp.ClientXMPP.__init__(self, jid, password)
        self.evt_messageReceived = Event()
        self.targets = []

    def on_start(self, event):

        self.send_presence()
        self.get_roster()

    def on_message(self, msg):
        if not chat(msg):
            return

        msg = (getName(msg['from']), msg['body'])
        self.evt_messageReceived.fire(self, msg)

    def listen(self, domain, port):

        self.add_event_handler("session_start", self.on_start)
        self.add_event_handler("message", self.on_message)

        self.register_plugin('xep_0030')  # Service Discovery
        self.register_plugin('xep_0004')  # Data Forms
        self.register_plugin('xep_0060')  # PubSub
        self.register_plugin('xep_0199')  # XMPP Ping

        if self.connect((domain, port)):
            self.process(block=False)
        else:
            logging.error('failed to connect to ' + domain + port)

    def addTarget(self, jid):
        self.targets.append(jid)

    def sendMessage(self, jid, message):
        self.send_message(mto=jid, mbody=str(message), mtype='chat')

    def broadcast(self, msg):
        for target in self.targets:
            self.sendMessage(target, msg)

    def finish(self):
        self.disconnect(wait=True)
Example #6
0
class XmppMessenger(sleekxmpp.ClientXMPP):
    def __init__(self, jid, password):
        sleekxmpp.ClientXMPP.__init__(self, jid, password)
        self.evt_messageReceived = Event()
        self.targets = []

    def on_start(self, event):

        self.send_presence()
        self.get_roster()

    def on_message(self, msg):
        if not chat(msg):
            return

        msg = (getName(msg['from']), msg['body'])
        self.evt_messageReceived.fire(self, msg)

    def listen(self, domain, port):

        self.add_event_handler("session_start", self.on_start)
        self.add_event_handler("message", self.on_message)

        self.register_plugin('xep_0030')  # Service Discovery
        self.register_plugin('xep_0004')  # Data Forms
        self.register_plugin('xep_0060')  # PubSub
        self.register_plugin('xep_0199')  # XMPP Ping

        if self.connect((domain, port)):
            self.process(block=False)
        else:
            logging.error('failed to connect to ' + domain + port)

    def addTarget(self, jid):
        self.targets.append(jid)

    def sendMessage(self, jid, message):
        self.send_message(mto=jid, mbody=str(message), mtype='chat')

    def broadcast(self, msg):
        for target in self.targets:
            self.sendMessage(target, msg)

    def finish(self):
        self.disconnect(wait=True)
Example #7
0
 def __init__(self, interacts):
     self._interacts = interacts
     self.evt_done = Event()
     self._deck = DealsTexasHoldEm(self._interacts)
     self._takeBets = TakesBets(self._interacts)
     self._takeBets.evt_done += self._onRoundDone
Example #8
0
 def __init__(self, interacts):
     '''finishes the tournament by giving one player all the chips'''
     self.interacts = interacts
     self.evt_done = Event()
Example #9
0
 def __init__(self, name, chips=0):
     self._cards = []
     self.chips = chips
     self.pot = 0
     self.name = name
     self.evt_response = Event()
Example #10
0
 def __init__(self, interacts):
     self._interacts = interacts
     self.evt_done = Event()
     self._playsHand = PlaysHand(self._interacts)
     self._playsHand.evt_done += self._onHandDone
Example #11
0
 def __init__(self, interacts):
     self._interacts = interacts
     self.evt_done = Event()
     self._interacts.evt_playerResponse += self._on_PlayerResponse
     self.lastToRaise = None
     self.table = Table()
Example #12
0
 def __init__(self, interacts):
     self._interacts = interacts
     self.evt_done = Event()
     self._deck = DealsTexasHoldEm(self._interacts)
     self._takeBets = TakesBets(self._interacts)
     self._takeBets.evt_done += self._onRoundDone
Example #13
0
class StubMessenger(object):
    def __init__(self):
        self.evt_playerResponse = Event()
        self.evt_messageReceived = Event()
        self.replies = deque()
        self.sentMessages = []
        self.broadcastMessages = []
        self.goMessages = []
        self.lastMessage = None
        self.cardMessages = []
        self.allMessages = []
        self.dealingMessages = []
        self.wonMessages = []

    def skipBlind(self):
        self.replies.append('skip')
        return self

    def bet(self, player, amount):
        self.replies.append((player, str(amount)))
        return self

    def join(self, jid):
        self.evt_messageReceived.fire(self, (jid, 'JOIN'))

    def addTarget(self, jid):
        pass

    def sendMessage(self, jid, msg):

        # print 'sending', jid, msg
        if msg.startswith('CARD'):
            msg = 'CARD'

        self.allMessages.append((jid, msg))
        self.sentMessages.append((jid, msg))
        self.lastMessage = (jid, msg)
        if msg.startswith('GO'):
            self.goMessages.append((jid, msg))

        if msg.startswith('CARD'):
            self.cardMessages.append((jid, 'CARD'))

        if msg != 'GO' or len(self.replies) == 0:
            return

        response = self.replies.popleft()

        if response == 'skip':
            return

        # print 'responding', response
        self.evt_messageReceived.fire(self, response)
        self.evt_playerResponse.fire(self, response)

    def broadcast(self, msg):
        # print 'broadcasting', msg

        if msg.startswith('CARD'):
            self.cardMessages.append('CARD')
            msg = 'CARD'

        if msg.startswith('WON'):
            self.wonMessages.append(msg)
            msg = 'WON'

        if msg.startswith('DEALING'):
            self.dealingMessages.append(msg)

        if msg.startswith('WINNER'):
            msg = 'WINNER'

        self.allMessages.append(msg)
        self.broadcastMessages.append(msg)
        self.lastMessage = msg
Example #14
0
 def __init__(self, jid, password):
     sleekxmpp.ClientXMPP.__init__(self, jid, password)
     self.evt_messageReceived = Event()
     self.targets = []
if os.name == 'nt':
    onWindows = True
else:
    onWindows = False

# Get and initialise RIFE
from rifeFunctions import downloadRIFE

downloadRIFE(installPath, onWindows)
os.chdir(installPath)
from rifeInterpolationFunctions import *

gpuBatchSize = 2
gpuIDsList = [0]

interpolationProgressUpdate = Event.Event()
currentSavingPNGRanges:list = []

progressBar = None

def subscribeTointerpolationProgressUpdate(function):
    interpolationProgressUpdate.append(function)


def setFFmpeg4Path(path):
    global FFMPEG4
    FFMPEG4 = path
    setFFmpegLocation(FFMPEG4)


def setNvencSettings(nvencGpuID, preset):
Example #16
0
 def __init__(self, jid, password):
     sleekxmpp.ClientXMPP.__init__(self, jid, password)
     self.evt_messageReceived = Event()
     self.targets = []