Пример #1
0
    def challenge(self, ide):
        HOST, PORT = "localhost", 9999
        data = networking.DataFrame(networking.Header(1, "challenge"), {
            "id": self.player.getID(),
            "lobby": ide
        }).toString()

        # Create a socket (SOCK_STREAM means a TCP socket)
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        try:
            # Connect to server and send data
            sock.connect((HOST, PORT))
            sock.sendall(data + "\n")

            # Receive data from the server and shut down
            received = sock.recv(4096)
        finally:
            sock.close()
        received = ast.literal_eval(received)
        if received["header"]["reqtype"] == "heroes":
            p = party.Party(self.player)
            for h in received["data"]["heroes"]:

                p.addHero(hero.createFromJSON(ast.literal_eval(h)))
            print self.player.getID()
            self.createGame(ide, received["data"]["playerID"],
                            self.player.getID())
            b = networkedbattlescene.NetworkedBattleScene(
                ide, self.surface, self.player,
                player.Player(received["data"]["playerID"], "Opponent", p),
                self.party, p)
            self.error = False
        else:
            self.error = True
Пример #2
0
    def connectToGame(self, ide):
        HOST, PORT = "localhost", 9999
        data = networking.DataFrame(networking.Header(1, "testConnectToGame"),
                                    {
                                        "playerID": ide
                                    }).toString()

        # Create a socket (SOCK_STREAM means a TCP socket)
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        try:
            # Connect to server and send data
            sock.connect((HOST, PORT))
            sock.sendall(data + "\n")

            # Receive data from the server and shut down
            received = sock.recv(4096)
            print received
        finally:
            sock.close()
        print received
        received = ast.literal_eval(received)
        if received["header"]["reqtype"] == "success":
            p = party.Party(
                player.Player(received["data"]["playerID"], "Opponent", None))
            for h in received["data"]["heroes"]:
                p.addHero(hero.createFromJSON(ast.literal_eval(h)))
            b = networkedbattlescene.NetworkedBattleScene(
                received["data"]["gameID"], self.surface, self.player,
                player.Player(received["data"]["playerID"], "Opponent", p),
                self.party, p)

            return 1
        else:
            return 0
Пример #3
0
 def initVariables(self):
     self.party = party.Party(self.player)
     self.bgimage = pygame.transform.scale2x(
         pygame.image.load("images/panel_blue.png"))
     self.font = pygame.font.Font(pygame.font.get_default_font(), 12)
     self.addHeroButton = button.Button(self.makeText("Add Hero"),
                                        self.addHero)
     self.addHeroButton.setRect(pygame.Rect(700, 550, 100, 50))
     self.toBattleButton = button.Button(self.makeText("To Lobbies"))
     self.toBattleButton.setRect(pygame.Rect(600, 550, 100, 50))
Пример #4
0
def test_get_repositories():
    """ get_repositories: Returns a list of repositories. """
    artifact = party.Party()
    mock_json_good = json.dumps([{"key": "mykey"}])
    mock_response_good = flexmock(status_code=200, text=mock_json_good)
    flexmock(artifact).should_receive("query_artifactory").and_return(
        mock_response_good)

    repos = artifact.get_repositories("local")
    assert_is_instance(repos, list)
    assert_equals(repos, ["mykey"])
Пример #5
0
def test_find_by_properties_fail():
    """ find_by_properties: Handles list of zero files as expected. """

    artifact = party.Party()

    flexmock(artifact).should_receive("query_artifactory").and_return(None)
    # Method returns None?
    assert_equals(artifact.find_by_properties(testprops), None)
    # File list doesn't exist?
    assert_equals(artifact.files, [])
    # Object has no attribute named "count?"
    with assert_raises(AttributeError):
        assert_equals(artifact.count, 0)
Пример #6
0
 def __init__(self, repo_name=None):
     self.repo_name = repo_name
     self.credentials = load_credentials()
     self.base_url = self.credentials['artifactory_url']
     self.artifactory = party.Party()
     if not self.base_url.endswith('/api'):
         self.api_url = '/'.join([self.base_url, 'api'])
     else:
         self.api_url = self.base_url
     self.artifactory.artifactory_url = self.api_url
     self.artifactory.username = self.credentials['artifactory_username']
     self.artifactory.password = base64.encodebytes(bytes(self.credentials['artifactory_password'], 'utf-8'))
     self.artifactory.certbundle = certifi.where()
Пример #7
0
def createParty():
    while True:
        print('What would you like to do?')
        print('  1 - Create a new Party')
        print('  2 - Edit or Update an existing Party')
        print('  3 - Quit')
        ret = input('>: ')

        try:
            selection = int(ret)
        except Exception as err:
            print('[createParty :: Exception] %s' % (err))
            pass

        if selection in [1, 2, 3]:
            if selection == 3:
                break
            elif selection == 2:
                p_name = input("What is the Party's name: ")
                try:
                    party.loadHeroData(dataFile=p_name + '_party.json')
                except Exception as err:
                    print("[Load Existing Party Exception] :: %s" % (err))
            elif selection == 1:
                p_name = input("Select a Party name: ")
                try:
                    assert p_name + "_party.json" not in listFiles('.')

                    obj_party = party.Party(p_name)

                    while True:
                        print("Let's create our Party Members now.")
                        try:
                            m_cnt = input(
                                "How many Heroes would you like to add? ")
                            m_cnt = int(m_cnt)
                            for cnt in range(1, m_cnt + 1):
                                print(cnt)
                        except Exception as err:
                            print("[Exception] :: %s" % err)
                            pass
                        break
                    printJson(obj_party)
                except AssertionError:
                    print("That Party Name already exists!!! Start again...")
                    pass

        else:
            print('Invalid selection')
Пример #8
0
 def __init__(self, repo_name=None, dryrun=True):
     self.repo_name = repo_name
     self.dryrun = dryrun
     self.credentials = load_credentials()
     self.base_url = self.credentials['artifactory_url']
     self.artifactory = party.Party()
     if not self.base_url.endswith('/api'):
         self.api_url = '/'.join([self.base_url, 'api'])
     else:
         self.api_url = self.base_url
     self.artifactory.artifactory_url = self.api_url
     self.artifactory.username = self.credentials['artifactory_username']
     self.artifactory.password = base64.encodebytes(
         bytes(self.credentials['artifactory_password'], 'utf-8'))
     self.artifactory.certbundle = os.getenv('LAVATORY_CERTBUNDLE_PATH',
                                             certifi.where())
Пример #9
0
def test_find_by_pattern_fail():
    """ find_by_pattern: Handles exceptions as expected. """
    artifact = party.Party()
    mock_json_bad = json.dumps({"repoUri": "", "files": []})
    mock_response_bad = flexmock(status_code=404, text=[])

    flexmock(artifact).should_receive("query_artifactory").and_return(
        mock_response_bad)

    # Ensure ValueError is raised for no filename
    with assert_raises(ValueError):
        artifact.find_by_pattern("")

    # Ensure repotype matches a valid value
    with assert_raises(ValueError):
        artifact.find_by_pattern("filename", None, "nope")
Пример #10
0
def test_find_by_properties_pass():
    """ find_by_properties: We can find an artifact by using properties. """

    artifact = party.Party()

    #== SET UP: GOOD MOCK OBJECT
    mock_json_good = json.dumps({"results": [{"uri": "file-name.rpm"}]})
    mock_response_good = flexmock(status_code=200, text=mock_json_good)

    flexmock(artifact).should_receive("query_artifactory").and_return(
        mock_response_good)

    # Method returns properly?
    assert_equals(artifact.find_by_properties(testprops), "OK")
    # Files are set properly in the object?
    assert_equals(artifact.files, ["file-name.rpm"])
    # Object has the correct returned file count?
    assert_equals(artifact.count, 1)
Пример #11
0
    def load_yadofile(self, path):
        """ファイル("wch", "wcp", "wpl", "wpt", "wyd", "wrm")を読み込む。"""
        with cwfile.CWFile(path, "rb") as f:

            lpath = path.lower()
            if lpath.endswith(".wyd"):
                data = environment.Environment(None, f, True)
                data.skintype = self.skintype
                self.wyd = data
            elif lpath.endswith(".wch"):
                data = adventurer.AdventurerHeader(
                    None, f, True, dataversion=self.dataversion_int)
                self.wchs.append(data)
            elif lpath.endswith(".wcp"):
                data = adventurer.AdventurerCard(None, f, True)
                self.wcps.append(data)
            elif lpath.endswith(".wrm"):
                data = album.Album(None, f, True)
                self.wrms.append(data)
            elif lpath.endswith(".wpl"):
                data = party.Party(None,
                                   f,
                                   True,
                                   dataversion=self.dataversion_int)
                self.wpls.append(data)
            elif lpath.endswith(".wpt"):
                data = party.PartyMembers(None,
                                          f,
                                          True,
                                          dataversion=self.dataversion_int)
                self.wpts.append(data)
            elif lpath.endswith(".whs"):
                cards, albums = party.load_album120(None, f)
                for data in cards:
                    self.wcps.append(data)
                for albumdata in albums:
                    self.wrms.append(albumdata)
                data = None
            else:
                f.close()
                raise ValueError(path)
            f.close()

        return data
    def __init__(self):
        QtWidgets.QWidget.__init__(self)

        self.allParty_list=[]
        self.allParty = db.cursor.execute('select * from party ')
        for p in self.allParty:
            self.allParty_list.append(party.Party(p[0],p[1],p[2]))
        self.layout = QtWidgets.QVBoxLayout()

        for p in self.allParty_list:
            self.button = QtWidgets.QPushButton(p.char+' \n '+p.name)
            self.button.setStyleSheet("background-color: Blue ;color: white; border-style: outset;height:100;width:100")
           # self.text = QtWidgets.QLabel("Hello World")
            #self.text.setAlignment(QtCore.Qt.AlignCenter)
     #       self.layout.addWidget(self.text)
            self.layout.addWidget(self.button)
            self.button.clicked.connect(self.magic)

        self.setLayout(self.layout)
Пример #13
0
    def __init__(self):
        """ Initializer """
        # Call the parent class initializer
        super().__init__()
        #self.ui_manager = ui_manager

        self.last_level = LAST_LEVEL
        self.world = 0
        self.level = 0
        self.wave_timeout = 260 * 2

        # Sprite lists
        self.player_list = None
        self.coin_list = None
        self.pause = PauseView(self)
        self.level_view = ""

        # Set up the player
        self.score = 0
        self.gold = 0

        self.party = party.Party()
Пример #14
0
def test_find_by_pattern_pass():
    """ find_by_pattern: We can find an artifact by using a pattern. """
    artifact = party.Party()
    mock_repo_uri = "http://mock"
    mock_file_list = ["file1.rpm", "file2.rpm"]
    mock_uris = [
        "%s/%s" % (mock_repo_uri, mock_file_list[0]),
        "%s/%s" % (mock_repo_uri, mock_file_list[1])
    ]
    mock_json_good = json.dumps({
        "repoUri": mock_repo_uri,
        "files": mock_file_list
    })
    mock_response_good = flexmock(status_code=200, text=mock_json_good)

    flexmock(artifact).should_receive("query_artifactory").and_return(
        mock_response_good)
    flexmock(artifact).should_receive("get_repositories").and_return(
        {"key": "mock-repo-local"})

    # Ensure artifact.files has spliced filenames
    artifact.find_by_pattern("none", None, None, 1)
    assert_equals(artifact.files, mock_uris)
Пример #15
0
 def initVariables(self):
     self.spriteIndex = 0
     self.lastTime = 0
     self.party = party.Party(1)
     self.party.addHero(self.makeHero())
     self.bgimage = pygame.transform.scale2x(
         pygame.image.load("images/panel_blue.png"))
     self.font = pygame.font.Font(pygame.font.get_default_font(), 12)
     self.addHeroButton = button.Button(
         self.makeText("Add Hero"),
         self.addHero,
         tooltipName="Add Hero",
         tooltipText="Add a new hero to the grid above. Maximum 6 heroes.")
     self.addHeroButton.setRect(
         pygame.Rect(self.surface.get_rect().width - 100,
                     self.surface.get_rect().height - 50, 100, 50))
     self.toBattleButton = button.Button(
         self.makeText("To Battle!"),
         tooltipName="Go to Battle",
         tooltipText="Bring the heroes above into battle against the AI.")
     self.toBattleButton.setRect(
         pygame.Rect(self.surface.get_rect().width - 200,
                     self.surface.get_rect().height - 50, 100, 50))
import xml.etree.ElementTree as ET
import party

from lm.DarBuildServer import DarBuildServer

# get a the buildserver workspace corresponding to the appVersion and appName
server = DarBuildServer.createServer(darBuildServer)

# get the current package manifest
manifest = server.read_manifest(appName, appVersion)

#and translate to an xml root document
manifestRoot = ET.fromstring(manifest)

# query the artifactory repo to see what artifacts we need to get.
artifactory = party.Party()
artifactory.artifactory_url = artifactoryServer['url']
artifactory.username = artifactoryServer['username']
artifactory.password = base64.b64encode(artifactoryServer['password'])


#scan artifactory repo for deployables
def getDeployablesInformation():
    deployables = []
    print artifactTypes.split(',')
    for x in artifactTypes.split(','):
        x, deployableType = x.split(':')
        result = artifactory.find_by_pattern(".%s" % x, artifactRepository)
        if result:
            for y in result:
                file = {}
Пример #17
0
def lancer():
    party.Party(0)
Пример #18
0
def test_artifact_object_structure():
    """ The Artifact object is structured as expected. """
    artifact = party.Party()
    # The 'files' property is a list
    assert_is_instance(artifact.files, list)
Пример #19
0
    def __init__(self):
        pygame.init()  # need to initialize pygame
        self.screen = pygame.display.set_mode(
            SCREEN_RECTANGLE.size)  # creates screen of SCREEN_SIZE

        pygame.display.set_caption(u"天龍の塔")  # set the words on title bar

        self.title = title.Title()
        self.city = None  #city.City()
        self.tower = None  #tower.Tower()
        self.temple = None  #temple.Temple()
        self.shop = None  #shop.Shop()
        self.inn = None  #inn.Inn()
        self.castle = None  #castle.Castle()
        self.bar = None  #bar.Bar()
        self.house = None  #house.House()
        self.dungeon = None  #dungeon.Dungeon()
        self.menu = None  #menu.Menu()

        self.party = party.Party()
        self.character_make = character_make.Character_make()

        self.game_state = TITLE

        self.characters = []
        self.dungeon_characters = []

        self.lost_characters = []

        self.cursor_se = pygame.mixer.Sound("SE/decide.wav")
        self.select_se = pygame.mixer.Sound("SE/decide.wav")
        self.cancel_se = pygame.mixer.Sound("SE/se_sab07.wav")

        self.item_data = []
        temp = []
        file = "Data/item_data.csv"
        fp = open(file, "r")

        for line in fp:
            temp = line[:-1].split(',')
            self.item_data.append(temp)

        self.magic_data = []
        temp = []
        file = "Data/magic_data.csv"
        fp = open(file, "r")

        for line in fp:
            temp = line[:-1].split(',')
            self.magic_data.append(temp)

        self.vertical_wall_temp = None
        self.horizontal_wall_temp = None
        self.ground_temp = None
        self.space_temp = None
        self.object_temp = None

        self.total_time = 0
        self.current_time = 0
        self.this_time = 0

        #if true, don't read shop file for new game
        self.new_game = False

        self.mainloop()