Exemple #1
0
    def connect_to_server(self, line):  #  currently used for login purposes only

        outSocket = self.outSocket()

        RAProtocol.sendMessage(line, outSocket)
        self.log.write_line('login message sent to server awaiting response')
        message = RAProtocol.receiveMessage(outSocket)  #return message from server validating login
        self.log.write_line('response recieved = %s' % str(message))
        outSocket.close()
        self.log.write_line('login socket closed.')

        ports = message
        if ports in ['invalid', 'banned_name', "affiliation_get"]: # login fails
            self.emit(QtCore.SIGNAL("mainDisplay(QString)"), "That login is invalid.  Try Again." )
            self.name = ""
            self.password = ""
            self.log.write_line('login attempt invalid.  Reset Name and Password')
        else:  #logIn accepted process
            self.log.write_line('Login Valid changing login file to %s' % str(self.name))
            self.log = Q2logging.out_file_instance('logs/GuiClient/PlayLogs/%s' % str(self.name))
            ports = ports.split()
            self.iPort = int(ports[1])
            self.oPort = int(ports[0])
            self.log.write_line('in/out ports saved in = %d, out = %d' % (self.iPort, self.oPort))
            # set port and host for In thread... Start thread & start ping timer
            self.iThread.port = self.iPort
            self.iThread.host = self.localHost
            self.log.write_line('inThread atributes changed to inPort & localHost')
            self.iThread.start()
            self.pingTimer.start(10000)
            #  Login True for proper input box operation from this point forward.  Emit to print to display.
            self.loggedIn = True
            self.log.write_line('thread started, Ping timer Started')
            self.emit(QtCore.SIGNAL("mainDisplay(QString)"), "You are now logged in...." )
Exemple #2
0
    def __init__(self, name):
        self.logger = Q2logging.out_file_instance('logs/engine/RenEngine')

        self._IsRunning = False
        self._CommandQueue = Queue.Queue() # Commands that are waiting to be run
        self._MessageQueue = Queue.Queue() # Messages that are waiting to be sent to the server

        self._BuilderQueues = {} # Dictionary of builder queues, 'player name' => Queue

        self._Rooms = {} # Rooms currently in the game

        self._Characters = {} # All NPCs and Players currently in the game
        self._Characters_Lock = threading.RLock()

        self._Characters_In_Builder = {} # All Players that are currently in a builder thread
        self._Characters_In_Builder_Lock = threading.RLock()
        
        self._ShopQueues = {} # All players currently in the shop.
        
        self._Characters_In_Shop = {} #Players that are currently in a shop
        self._Characters_In_Shop_Lock = threading.RLock()

        self._Objects = {} # All Objects currently in the game
        self._Objects_Lock = threading.RLock()

        self._NPC_Bucket = {} # List of NPCs
        self._NPC_Bucket_Lock = threading.RLock()

        self._NPC_Queue = Queue.Queue()  # Queue of NPCs to be added to the game
Exemple #3
0
 def __init__(self, player, cmd_queue, engine, inventory):
     threading.Thread.__init__(self)
     self.inventory = {} #Item and cost in likes.
     for item in inventory:
         self.inventory[item] = inventory[item]
     self.cmd_queue = cmd_queue
     self.msg_queue = engine._MessageQueue
     self.name = player.name
     self.logger = Q2logging.out_file_instance('logs/shops/'+player.name)
     self.engine = engine
Exemple #4
0
    def __init__(self, parent=None):
        super(MainDialog, self).__init__(parent)
        self.log = Q2logging.out_file_instance('logs/GuiClient/PreLogins/')
        global _Local_Host
        global _Server_Host
        global _Login_Port
        self.localHost = _Local_Host
        self.serverHost = _Server_Host
        self.lPort = _Login_Port
        self.iPort = ""
        self.oPort = ""
        self.loggedIn = False
        self.name = ""
        self.pingTimer = QtCore.QTimer() # Timer loop for sending stay alive pings

        self.oldStyle = True # Used to accommodate String/Tuple message format and message object formats
        self.setupUi(self) # Sets up Visual aspect of the Gui
        self.appendArt()
        self.iThread = inThread(self.iPort, self.localHost, self.log) #instantiate the in thread for establishing SIGNAL connections

        # Connections/Signals Main Object
        self.connect(self.pingTimer, QtCore.SIGNAL("timeout()"), self.pingServer)
        self.connect(self, QtCore.SIGNAL("mainDisplay(QString)"), self.appendDisplay, QtCore.Qt.DirectConnection)
        self.connect(self, QtCore.SIGNAL("inputBox(QObject)"), self.fillTabs, QtCore.Qt.DirectConnection)
        self.connect(self, QtCore.SIGNAL("artBox(QObject)"), self.appendArt, QtCore.Qt.DirectConnection)
        self.connect(self, QtCore.SIGNAL("statusBox(QObject)"), self.appendStatus, QtCore.Qt.DirectConnection)
        self.connect(self, QtCore.SIGNAL("playSound(QObject)"), self.playSound, QtCore.Qt.DirectConnection)
        self.connect(self, QtCore.SIGNAL("readySend(QString)"), self.sendMessage, QtCore.Qt.DirectConnection)
        self.connect(self, QtCore.SIGNAL("sendOld"), self.sendMessage, QtCore.Qt.DirectConnection)
        #self.connect(self, QtCore.SIGNAL("readySend(QString)"), self.sendMessage, QtCore.Qt.DirectConnection)
        self.inputBox.returnPressed.connect(self.getUserInput)
        # Signal Connection for InThread
        self.connect(self.iThread, QtCore.SIGNAL("messageReceived(QString)"),  self.handleMessageReceived, QtCore.Qt.DirectConnection)

        self.mainDisplay.append('\n'*25+" "*10+'Welcome to the Ren Adventure!!'+'\n'*15)
        self.inputBox.setFocus()
        self.log.write_line('Main Gui object setup complete')
        self.main()
Exemple #5
0
__author__ = 'ADillon, MNutter'

import socket
import sys
import msvcrt
import thread, threading
import time
import string
import Queue
import RAProtocol
import ssl
import winsound
import Q2logging


logger = Q2logging.out_file_instance('logs/client/RenClient')

_Local_Host = socket.gethostname() # replace with actual host address
_Server_Host = socket.gethostname() #'54.244.118.196' # replace with actual server address
_Login_Port = 60005

_CMD_Queue = Queue.Queue()

_Quit = False
_Quit_Lock = threading.RLock()

_Sound_Playing = False

def main():
    """
    def twitterSave(self, statuses):
        fout = open("twitterFeeds\\" + self.user + ".twitter", 'w')
        for status in statuses:
            text = status.text
            text = text.encode("utf-8")
            text = text.replace("\n", "")
            fout.write(text)
            fout.write("\n")
        fout.close()

        logger.write_line("twitterFeeds file saved for %s" % self.user)


#==================================================================================================

logger = Q2logging.out_file_instance("logs\\twitterCrawler\\twitterCrawler")


def main():
    workQueue = Queue.Queue()
    twitThread = twitterThread(workQueue)
    twitThread.start()


class twitterThread(threading.Thread):
    def __init__(self, newNamesQ):
        threading.Thread.__init__(self)
        self.newNamesQ = newNamesQ
        self.oldNamesQ = Queue.Queue()
        self.api = twitter.Api()
This supports IMDB only at this time.

"""

translation = {"&#x27;": "'", "&#x22;": '"', "[<i>": "[", "</i>]": "]", "&amp;": "&", "  ": ""}

# ================================================xxxxxxxxxxxxxxxxxxxx===============================================

"""
to to:


"""

logger = Q2logging.out_file_instance("logs\\quoteCrawler\\quoteCrawler")


def main():
    workQueue = Queue.Queue()
    qThread = quoteThread(workQueue)
    qThread.start()


class quoteThread(threading.Thread):
    def __init__(self, newNamesQ):
        threading.Thread.__init__(self)
        self.newNamesQ = newNamesQ
        self.oldNamesQ = Queue.Queue()

    # takes in imdb id number and character name from the queue
This supports IMDB only at this time.  More to come...

"""

"""
to to:

add extension dictionary

"""


#==============================================================================================

logger = Q2logging.out_file_instance("logs\\siteConverter\\siteConverter")


# siteRef = {imdbUrl: "http://www.imdb.com/character/%s/quotes",
#            imdbPrefix: "<title>",
#            imdbSuffix: " (Character)  - Quotes</title>",
#            # first %s is the first letter of the last name of the character
#            brainyquoteUrl: "http://www.brainyquote.com/quotes/authors/%s/%s.html",
#            # first %s is the first letter of the first name,
#            # the second is the name (no spaces) followed by a 6 digit number.
#            brainyquotePrefix: "quotes/%s/%s.html",
#            brainyquoteSuffix: "</a></span><br>",
#            # xx is a 2 digit number different for each character
#            saidwhatUrl: "http://www.saidwhat.co.uk/characterquotes/%s_xx",
#            # this will miss the first quote
#            saidwhatPrefix: "</span><br /><br />",
import socket, sys
import thread, threading, Queue
import time, random
import RAProtocol
import engine_classes
import os
import msvcrt
import string
import loader
import ssl
import Q2logging
import sense_effect_filters
import engine
import copy

logger = Q2logging.out_file_instance("logs/server/RenServer")

_Player_Locations = (
    {}
)  # {playername: location} where location is "Lobby" or the name of a running world instance? ###IP
_Player_Loc_Lock = threading.RLock()  # Lock for player locations dict. ###IP

_Host = socket.gethostbyname(socket.gethostname())  # replace with actual host address

_CMD_Queue = Queue.Queue()  # Queue of NPC and Player commands

_Lobby_Queue = Queue.Queue()  # Queue of Player chatting/commands for lobby? ###IP

_MSG_Queue = Queue.Queue()

_Players = []  # (mutex controlled)