Пример #1
0
def loadTable(group, x=0, y=0):
    mute()

    if not group == "Yes":

        if 1 != askChoice(
                'You are about to LOAD a previous game onto your current table.   This will not replace the current game.   To avoid problems, you should only use this option in a new/reset game.  \nAlso, to ensure only one player loads a game, it is best if the host does this.',
            ['I want to load a game!', 'Nevermind...'],
            ['#dd3737', '#d0d0d0']):
            return

        try:
            dir = wd('')
            if 'GameDatabase' in dir:
                filename = dir.replace('GameDatabase', 'Decks').replace(
                    'b81599ea-7717-4725-9acd-f62947782fd6', 'Dragon Ball S')
            else:
                filename = "Decks\Dragon Ball S".join(dir.rsplit('OCTGN', 1))
            filename = filename + '\\GameStates\\autosave.json'
            filename = askString(
                'Please provide the file path to load the table states',
                filename)

            if filename == None:
                return
        finally:
            mute()

    try:
        if group == "Yes":
            tab = json().DeserializeObject(x)
        else:
            with open(filename, 'r') as f:
                tab = json().DeserializeObject(f.read())

        deserializeTable(tab['table'])

        if tab['counters'] is not None and len(tab['counters']) > 0:
            deserializeCounters(tab['counters'], shared)

        if tab['shared'] is not None and len(tab['shared']) > 0:
            for k in tab['shared'].Keys:
                if k not in shared.piles:
                    continue
                deserializePile(tab['shared'][k], shared.piles[k])

        if tab['counters'] is not None and len(tab['counters']) > 0:
            deserializeCounters(tab['counters'], shared)

        if tab['players'] is not None and len(tab['players']) > 0:
            for player in tab['players']:
                deserializePlayer(player)


##		notify("Successfully load table state from {}".format(filename))
    finally:
        print("Hi")
Пример #2
0
def loadTable(phase):
    mute()

    if 1 != askChoice(
            'You are about to LOAD the table states including the elements on the table, shared deck and each player\'s hand and piles.\nThis option should be execute on the a game host.',
        ['I am the Host!', 'I am not...'], ['#dd3737', '#d0d0d0']):
        return

    if not getLock():
        whisper("Others players are locking the table, please try again")
        return

    try:
        if phase == "":
            filename = openFileDlg('', '', 'Json Files|*.json')
        else:
            with open("data.path", 'r') as f:
                dir = f.readline()
                filename = dir + "\\GameDatabase\\055c536f-adba-4bc2-acbf-9aefb9756046\\" + "AutoSave.json"
                notify("Restore Table state saves to last phase")

        if not filename:
            return

        with open(filename, 'r') as f:
            tab = json().DeserializeObject(f.read())

        deserializeTable(tab['table'])

        if tab['shared'] is not None and len(tab['shared']) > 0:
            for k in tab['shared'].Keys:
                if k not in shared.piles:
                    continue
                deserializePile(tab['shared'][k], shared.piles[k])

        if tab['counters'] is not None and len(tab['counters']) > 0:
            deserializeCounters(tab['counters'], shared)

        if tab['players'] is not None and len(tab['players']) > 0:
            for player in tab['players']:
                deserializePlayer(player)

        if tab['ActivePlayer'] is not None and len(tab['ActivePlayer']) > 0:
            setActivePlayer(Player(num(tab['ActivePlayer'])))

        if tab['phase'] is not None and len(tab['phase']) > 0:
            activePlayerNum = num(tab['ActivePlayer']) - 1
            if tab['phase'] == "Hero Phase":
                players[activePlayerNum].setActive()
            if tab['phase'] == "Villain Phase":
                players[activePlayerNum].setActive()
                setPhase(2)

        if tab['globalVariable'] is not None and len(
                tab['globalVariable']) > 0:
            for k in tab['globalVariable'].Keys:
                deserializeGlobalVariable(k, tab['globalVariable'][k])

    finally:
        clearLock()
Пример #3
0
def saveTable(group, x=0, y=0):
    mute()

    if 1 != askChoice(
            'You are about to SAVE the table states including the elements on the table, shared deck and each player\'s hand and piles.\nThis option should be execute on the a game host.',
        ['I am the Host!', 'I am not...'], ['#dd3737', '#d0d0d0']):
        return

    if not getLock():
        whisper("Others players are saving, please try manual saving again")
        return

    try:
        tab = {"table": [], "shared": {}, 'counters': None, "players": None}

        # loop and retrieve cards from the table
        for card in table:
            tab['table'].append(serializeCard(card))

        # loop and retrieve item from the shared decks
        for p in shared.piles:
            if p == 'Trash':
                continue
            for card in shared.piles[p]:
                if p not in tab['shared']:
                    tab['shared'].update({p: []})
                tab['shared'][p].append(serializeCard(card))

        tab['counters'] = serializeCounters(shared.counters)

        # loop each player
        players = sorted(getPlayers(), key=lambda x: x._id, reverse=False)
        tab['players'] = [serializePlayer(pl) for pl in players]

        dir = wd('table-state-{}.json'.format('{:%Y%m%d%H%M%S}'.format(
            dt.now())))
        if 'GameDatabase' in dir:
            filename = dir.replace('GameDatabase', 'Decks').replace(
                'a21af4e8-be4b-4cda-a6b6-534f9717391f',
                'Lord of the Rings - The Card Game')
        else:
            filename = "Decks\Lord of the Rings - The Card Game".join(
                dir.rsplit('OCTGN', 1))

        filename = askString('Please input the path to save the game state',
                             filename)

        if filename == None:
            return

        with open(filename, 'w+') as f:
            f.write(json().Serialize(tab))

        notify("Table state saves to {}".format(filename))
    finally:
        clearLock()
Пример #4
0
def saveTable(phase):
	mute()
	if phase == "":
		if 1 != askChoice('You are about to SAVE the table states including the elements on the table, shared deck and each player\'s hand and piles.\nThis option should be execute on the a game host.'
			, ['I am the Host!', 'I am not...'], ['#dd3737', '#d0d0d0']):
			return
	
		if not getLock():
			whisper("Others players are saving, please try manual saving again")
			return
	
	try:
		tab = {"table":[], "shared": {}, 'counters': None, "players": None}
		
		# loop and retrieve cards from the table
		for card in table:	
			#if card.Type == "Chaos Token" and card.Subtype == "Sealed":
			#	tab['sealed'].append(serializeCard(card))
			#else:
				tab['table'].append(serializeCard(card))

		# loop and retrieve item from the shared decks
		for p in shared.piles :
			if p == 'Trash':
				continue
			for card in shared.piles[p]:
				if p not in tab['shared']:
					tab['shared'].update({p: []})
				tab['shared'][p].append(serializeCard(card))
				
		tab['counters'] = serializeCounters(shared.counters)
		
		# loop each player
		players = sorted(getPlayers(), key=lambda x: x._id, reverse=False)
		tab['players'] = [serializePlayer(pl) for pl in players]
	
		if phase == "":
			filename = saveFileDlg('', '', 'Json Files|*.json')
		else: 
			with open("data.path", 'r') as f:
				dir = f.readline()
				filename = dir + "\\GameDatabase\\a6d114c7-2e2a-4896-ad8c-0330605c90bf\\" + "AutoSave.json"
				n = open(dir + "\\GameDatabase\\a6d114c7-2e2a-4896-ad8c-0330605c90bf\\" + "phase.txt", 'w+')
				n.write(phase)
			
		if filename == None:
			return
		
		with open(filename, 'w+') as f:
			f.write(json().Serialize(tab))
		
		if phase == "":
			notify("Table state saves to {}".format(filename))

	finally:
		clearLock()
Пример #5
0
def loadTable(group, x=0, y=0):
    mute()

    if 1 != askChoice(
            'You are about to LOAD the table states including the elements on the table, shared deck and each player\'s hand and piles.\nThis option should be execute on the a game host.',
        ['I am the Host!', 'I am not...'], ['#dd3737', '#d0d0d0']):
        return

    if not getLock():
        whisper("Others players are locking the table, please try again")
        return

    try:
        #dir = wd('table-state.json')
        #if 'GameDatabase' in dir:
        #	filename = dir.replace('GameDatabase','Decks').replace('a6d114c7-2e2a-4896-ad8c-0330605c90bf','Arkham Horror - The Card Game')
        #else:
        #	filename = "Decks\Arkham Horror - The Card Game".join(dir.rsplit('OCTGN',1))

        #filename = askString('Please provide the file path to load the table states', filename)

        #if filename == None:
        #	return
        filename = openFileDlg('', '', 'Json Files|*.json')

        with open(filename, 'r') as f:
            tab = json().DeserializeObject(f.read())

        deserializeTable(tab['table'])

        if tab['counters'] is not None and len(tab['counters']) > 0:
            deserializeCounters(tab['counters'], shared)

        if tab['shared'] is not None and len(tab['shared']) > 0:
            for k in tab['shared'].Keys:
                if k not in shared.piles:
                    continue
                deserializePile(tab['shared'][k], shared.piles[k])

        if tab['counters'] is not None and len(tab['counters']) > 0:
            deserializeCounters(tab['counters'], shared)

        if tab['players'] is not None and len(tab['players']) > 0:
            for player in tab['players']:
                deserializePlayer(player)

        if "Setup.json" in filename:
            shuffle(encounterDeck())
            shuffle(specialDeck())
            for cardT in table:
                loadClues(cardT)

    finally:
        clearLock()
Пример #6
0
def loadTable(group, x=0, y=0):
    mute()

    if 1 != askChoice(
            'You are about to LOAD the table states including the elements on the table, shared deck and each player\'s hand and piles.\nThis option should be execute on the a game host.',
        ['I am the Host!', 'I am not...'], ['#dd3737', '#d0d0d0']):
        return

    if not getLock():
        whisper("Others players are locking the table, please try again")
        return

    try:
        dir = wd('table-state.json')
        if 'GameDatabase' in dir:
            filename = dir.replace('GameDatabase', 'Decks').replace(
                'a21af4e8-be4b-4cda-a6b6-534f9717391f',
                'Lord of the Rings - The Card Game')
        else:
            filename = "Decks\Lord of the Rings - The Card Game".join(
                dir.rsplit('OCTGN', 1))

        filename = askString(
            'Please provide the file path to load the table states', filename)

        if filename == None:
            return

        with open(filename, 'r') as f:
            tab = json().DeserializeObject(f.read())

        deserializeTable(tab['table'])

        if tab['counters'] is not None and len(tab['counters']) > 0:
            deserializeCounters(tab['counters'], shared)

        if tab['shared'] is not None and len(tab['shared']) > 0:
            for k in tab['shared'].Keys:
                if k not in shared.piles:
                    continue
                deserializePile(tab['shared'][k], shared.piles[k])

        if tab['counters'] is not None and len(tab['counters']) > 0:
            deserializeCounters(tab['counters'], shared)

        if tab['players'] is not None and len(tab['players']) > 0:
            for player in tab['players']:
                deserializePlayer(player)

        notify("Successfully load table state from {}".format(filename))
    finally:
        clearLock()
Пример #7
0
def saveTable(group, x=0, y=0, auto=False):
    mute()
    verifySaveDirectory('')

    if auto == False:
        if 1 != askChoice(
                'You are about to SAVE a game.  This will save everything, including all hand and deck states.  \nIf you are certain you want to do this, please take note of the name of your save file.',
            ['I understand and want to save a game!', 'Nevermind...'],
            ['#dd3737', '#d0d0d0']):
            return

    try:
        tab = {"table": [], "shared": {}, 'counters': None, "players": None}

        # loop and retrieve cards from the table
        for card in table:
            tab['table'].append(serializeCard(card))

        tab['counters'] = serializeCounters(shared.counters)

        # loop each player
        players = sorted(getPlayers(), key=lambda x: x._id, reverse=False)
        tab['players'] = [serializePlayer(pl) for pl in players]

        dir = wd("")
        if 'GameDatabase' in dir:
            filename = dir.replace('GameDatabase', 'Decks').replace(
                '383a6ac2-6e52-40a5-980f-fade09e4908b', 'Dragon Ball Z')
        else:
            filename = "Decks\Dragon Ball Z".join(dir.rsplit('OCTGN', 1))
        if auto == True:
            filename = filename + "\\GameStates\\autosave.json"
        else:
            filename = filename + '\\GameStates\\' + 'table-state-{}.json'.format(
                '{:%Y%m%d%H%M%S}'.format(dt.now()))
            filename = askString(
                'Please input the path to save the game state', filename)

        if filename == None:
            return
        try:
            with open(filename, 'w+') as f:
                f.write(json().Serialize(tab))
        except:
            pass


##		notify("Table state saved to {}".format(filename))
    finally:
        mute()
Пример #8
0
def saveChaosBag(group, x=0, y=0):
	mute()

	if 1 != askChoice('You are about to SAVE chaos bag, this option will :\n- Unseal all seal token on the table and move in chaos bag\n- Remove bless and curse token in chaos bag\n- Save the chaos bag for the next scenario'
		, ['I am the Host!', 'I am not...'], ['#dd3737', '#d0d0d0']):
		return

	if not getLock():
		whisper("Others players are saving, please try manual saving again")
		return
	
	try:
		tab = {"shared": {}}
		#discard all token on table
		for card in table:
			if card.Type == "Chaos Token": 
				if card.controller == me:
					doDiscard(me, card, chaosBag())
				else:
					remoteCall(card.controller, "doDiscard", [me, card, chaosBag()])
		
		#remove blurse token in chaos bag
		for p in shared.piles:
			if p == 'Chaos Bag':
				for card in shared.piles[p]:
					if card.Subtype == "Blurse":
						card.delete()
		updateBlessCurse()

		# loop and retrieve item from the shared decks
		for p in shared.piles:
			if p == 'Chaos Bag':
				for card in shared.piles[p]:
					if p not in tab['shared']:
						tab['shared'].update({p: []})
					tab['shared'][p].append(serializeCard(card))
					
		filename = saveFileDlg('', '', 'Json Files|*.json')
			
		if filename == None:
			return
		
		with open(filename, 'w+') as f:
			f.write(json().Serialize(tab))
		
		notify("Chaos Bag saves to {}".format(filename))

	finally:
		clearLock()
Пример #9
0
def loadTable(group, x=0, y=0):	
	mute()

	filename = openFileDlg('Select the file to load the table states', '', 'All files (*.*)|*.*')
	if filename == None or filename == '':
		return

	with open(filename, 'r') as f:
		tab = json().DeserializeObject(f.read())
		
	if tab['players'] is not None and len(tab['players']) > 0:
		for player in tab['players']:
			deserializePlayer(player)

	notify("{} loaded table state from {}".format(me,filename))
Пример #10
0
def saveTable(group, x=0, y=0):
	mute()

	tab = {"players": None}
			
	# loop each player
	tab['players'] = [serializePlayer(pl) for pl in players]

	filename = saveFileDlg('Select the file to save the game state', '', 'All files (*.*)|*.*')
	if filename == None or filename == '':
		return

	with open(filename, 'w+') as f:
		f.write(json().Serialize(tab))

	notify("{} saved table state to {}".format(me,filename))
Пример #11
0
def loadChaosBag(group, x=0, y=0):
	mute()
		
	try:
		filename = openFileDlg('', '', 'Json Files|*.json')

		if not filename:
			return

		with open(filename, 'r') as f:
			tab = json().DeserializeObject(f.read())
			
		if tab['shared'] is not None and len(tab['shared']) > 0:
			for k in tab['shared'].Keys:
				if k not in shared.piles:
					continue
				deserializePile(tab['shared'][k], shared.piles[k])

		createChaosBag(table)	

	finally:
		clearLock()				
Пример #12
0
def saveTable(group, x=0, y=0):
    mute()

    if 1 != askChoice(
            'You are about to SAVE the table states including the elements on the table, shared deck and each player\'s hand and piles.\nThis option should be execute on the a game host.',
        ['I am the Host!', 'I am not...'], ['#dd3737', '#d0d0d0']):
        return

    if not getLock():
        whisper("Others players are saving, please try manual saving again")
        return

    try:
        tab = {
            "table": [],
            "shared": {},
            'counters': None,
            "players": None,
            "gameProperties": None
        }

        # loop and retrieve cards from the table
        for card in table:
            tab['table'].append(serializeCard(card))

        # loop and retrieve item from the shared decks
        for p in shared.piles:
            if p == 'Trash':
                continue
            for card in shared.piles[p]:
                if p not in tab['shared']:
                    tab['shared'].update({p: []})
                tab['shared'][p].append(serializeCard(card))

        tab['counters'] = serializeCounters(shared.counters)

        # loop each player
        players = sorted(getPlayers(), key=lambda x: x._id, reverse=False)
        tab['players'] = [serializePlayer(pl) for pl in players]

        tab['gameProperties'] = [serializePlayerVariables(None)]
        dir = wd('marvel-champions-table-state-{}.json'.format(
            '{:%Y%m%d%H%M%S}'.format(dt.now())))
        if 'GameDatabase' in dir:
            filename = dir.replace('GameDatabase', 'Decks').replace(
                '055c536f-adba-4bc2-acbf-9aefb9756046\\', '')
        else:
            filename = "Decks".join(dir.rsplit('OCTGN', 1)).replace(
                '055c536f-adba-4bc2-acbf-9aefb9756046\\', '')

        filename = askString('Please input the path to save the game state',
                             filename)

        if filename == None:
            return

        with open(filename, 'w+') as f:
            f.write(json().Serialize(tab))

        notify("Table state saves to {}".format(filename))
        savedGames = getSetting("SavedGames", '')
        if len(savedGames) != 0:
            savedGames = savedGames + '|' + str(filename).split("\\")[-1]
        else:
            savedGames = str(filename).split("\\")[-1]
        setSetting("SavedGames", str(savedGames))
    finally:
        clearLock()
Пример #13
0
def saveTable(phase):
    mute()
    if phase == "":
        if 1 != askChoice(
                'You are about to SAVE the table states including the elements on the table, shared deck and each player\'s hand and piles.\nThis option should be execute on the a game host.',
            ['I am the Host!', 'I am not...'], ['#dd3737', '#d0d0d0']):
            return

        if not getLock():
            whisper(
                "Others players are saving, please try manual saving again")
            return

    try:
        tab = {
            "table": [],
            "shared": {},
            'counters': None,
            "players": None,
            "ActivePlayer": None,
            "phase": None,
            "globalVariable": {}
        }

        # loop and retrieve cards from the table
        for card in table:
            tab['table'].append(serializeCard(card))

        # loop and retrieve item from the shared decks
        for p in shared.piles:
            if p == 'Trash':
                continue
            for card in shared.piles[p]:
                if p not in tab['shared']:
                    tab['shared'].update({p: []})
                tab['shared'][p].append(serializeCard(card))

        tab['counters'] = serializeCounters(shared.counters)

        # loop each player
        players = sorted(getPlayers(), key=lambda x: x._id, reverse=False)
        tab['players'] = [serializePlayer(pl) for pl in players]

        # Active Player
        tab['ActivePlayer'] = str(getActivePlayer()._id)

        # Phase
        tab['phase'] = getGlobalVariable("phase")

        # Global Variable
        tab['globalVariable'] = serializeGlobalVariable()

        if phase == "":
            filename = saveFileDlg('', '', 'Json Files|*.json')
        else:
            with open("data.path", 'r') as f:
                dir = f.readline()
                filename = dir + "\\GameDatabase\\055c536f-adba-4bc2-acbf-9aefb9756046\\" + "AutoSave.json"

        if filename == None:
            return

        with open(filename, 'w+') as f:
            f.write(json().Serialize(tab))

        if phase == "":
            notify("Table state saves to {}".format(filename))

    finally:
        clearLock()