Exemplo n.º 1
0
 def __init__(self, library, hand, battlefield, prev_action, parent):
     self._library = deepcopy(library)
     self._hand = deepcopy(hand)
     self._battlefield = deepcopy(battlefield)
     self._prev_action = prev_action
     
     self._floating_mana = Mana()
     self._turn_counter = 1
     self._parent = parent
Exemplo n.º 2
0
 def generate_cards(self, card_info, number):
     if ('error' in card_info):
         print('ERROR: ' + card_info['error'])
         return []
     cards = []
     name = card_info['name']
     types = [type for sublist in [types.strip().split(' ') for types in card_info['types'].split('\u2014')] for type in sublist]
     mana_cost = Mana.of_str_rep(card_info['mana_cost']) if 'mana_cost' in card_info else Mana()
     taps_for_mana = Mana.of_green(1)
     for i in range(number):
         cards.append(Card(name, types, mana_cost, taps_for_mana))
     return cards
Exemplo n.º 3
0
 def new_turn(self):
     if len(self._library == 0):
         return None
         
     new_state = State(self._library, self._hand, self._battlefield, 'new turn', self)
     
     new_state._untap_all()
     new_state._floating_mana = Mana()
     new_state._draw_card()
     new_state._turn_counter += 1
     
     return new_state
Exemplo n.º 4
0
    def __init__(self):
        self.hand = []
        self.field = []
        self.lands = []
        self.dpile = []
        self.deck = deck
        self.playedland = False
        self.mana = Mana(0)

        self.attributes = [
            self.hand, self.field, self.lands, self.dpile, self.deck,
            self.playedland, self.mana
        ]
        self.functions = [
            self.draw, self.move_card, self.play_land, self.tap_for_mana,
            self.tap_all, self.summon, self.untap_all
        ]
Exemplo n.º 5
0
 def get_treasure(cls, treasure):  # treasure is the treasure as string
     kind = treasure.split(':')[0].rstrip(
         ' ')  # ':' splits the kind of treasure and it's description
     descr = treasure.split(':')[1]
     if kind == "weapon":
         from weapon import Weapon
         return Weapon.create_weapon(descr)
     if kind == "spell":
         from spell import Spell
         return Spell.create_spell(descr)
     elif kind == "mana":
         from mana import Mana
         return Mana(int(descr))
     elif kind == "health":
         from health import Health
         return Health(int(descr))
     else:
         raise ValueError("Not correct kind of treasure.")
Exemplo n.º 6
0
class State:

    def __init__(self, library, hand, battlefield, prev_action, parent):
        self._library = deepcopy(library)
        self._hand = deepcopy(hand)
        self._battlefield = deepcopy(battlefield)
        self._prev_action = prev_action
        
        self._floating_mana = Mana()
        self._turn_counter = 1
        self._parent = parent
        
    def tap_all_for_mana(self):
        new_state = State(self._library, self._hand, self._battlefield, 'tap all for mana', self)
        for card in new_state._battlefield:
            if not card.is_tapped:
                new_state._add_floating_mana(card.tap_for_mana())
        if self != new_state:
            return new_state
        else:
            return None
            
    def get_availabale_mana(self):
        mana = Mana()
        for card in self._battlefield:
            if not card.is_tapped:
                mana += card.taps_for_mana
        return mana + self._floating_mana
        
    def play_card(self, card_name):
        new_state = State(self._library, self._hand, self._battlefield, 'play ' + card_name, self)
        card = new_state._get_card_in_hand(card_name)
        
        new_state._hand.remove(card)
        new_state._battlefield.append(card)
        new_state._remove_floating_mana(card.mana_cost)
        return new_state
        
    def get_playable_cards(self):
        playable_cards = []
        for card in self.hand:
            if self._floating_mana.fulfils_cost(card.mana_cost.mana):
                playable_cards.append(deepcopy(card))
        return playable_cards
        
    def new_turn(self):
        if len(self._library == 0):
            return None
            
        new_state = State(self._library, self._hand, self._battlefield, 'new turn', self)
        
        new_state._untap_all()
        new_state._floating_mana = Mana()
        new_state._draw_card()
        new_state._turn_counter += 1
        
        return new_state

    def describe(self):
        return "Turn number: " + str(self.turn_counter) + " library size: " + str(len(self.library)) + " hand size: " + str(len(self.hand)) + " battlefield size: " + str(len(self.battlefield)) + " available mana: " + str(self.get_availabale_mana().get_amount()) + " " + self.prev_action
        
    def _get_card_in_hand(self, card_name):
        for card in self._hand:
            if card.name == card_name:
                return card
        return None
        
    def _add_floating_mana(self, mana):
        self._floating_mana += mana
        
    def _remove_floating_mana(self, mana):
        self._floating_mana -= mana

    def _untap_all(self):
        for card in self._battlefield:
            card.untap()
        
    def _draw_card(self):
        self.hand += self.library[-1:]
        self.library = self.library[:-1]
    
    # TODO: eq, ne, hash
Exemplo n.º 7
0
 def get_availabale_mana(self):
     mana = Mana()
     for card in self._battlefield:
         if not card.is_tapped:
             mana += card.taps_for_mana
     return mana + self._floating_mana
Exemplo n.º 8
0
	def __init__(self, heroClass, name,hp,mana):
		Hp.__init__(self,hp)
		Mana.__init__(self,mana)
		self.name = name
		self.heroClass = heroClass
Exemplo n.º 9
0
import pyautogui
from time import sleep

from health import Health
from mana import Mana


if __name__ == "__main__":
    health_obj = Health()
    mana_obj = Mana()
    while True:
        if health_obj.get_life() <= 80:
            pyautogui.keyDown('f2')
            sleep(1)
        if mana_obj.get_mana() == 90:
            pyautogui.keyDown('f2')
            sleep(1)
Exemplo n.º 10
0
	def __init__(self, monsterKind,hp,mana):
		Hp.__init__(self,hp)
		Mana.__init__(self,mana)
		self.monsterKind = monsterKind
Exemplo n.º 11
0
	def main(self):
		try:
			self.displayInit()
			cycle_count = 1
			cycle_break = 0
			'''
	    	finding mana bar position
	    	'''
			settings.idle(.5)
			settings.get_tibia_active(self.CHAR_NAME)
			settings.take_screenshot(self.SS_HOTKEY) ########## SS
			settings.idle(1.5) #cd to del
			mana_full_path = settings.get_latest_image(self.SS_DIRPATH, valid_extensions='png')
			x_min, x_max, y_min, y_max, mana_full = Mana(self.SS_DIRPATH, mana_full_path)\
			.get_mana_loc() 
			settings.del_screenshot(mana_full_path)
			'''
			main loop
			'''
			pyautogui.press(self.RUNE_HOTKEY) # first rune
			while True:
				settings.get_tibia_active(self.CHAR_NAME)
				settings.idle(.5)
				settings.take_screenshot(self.SS_HOTKEY)
				settings.idle(1.5)
				cycle_pic = settings.get_latest_image(self.SS_DIRPATH, valid_extensions='png')

				print('#'*30)
				print('Cycle:', cycle_count)

				currentMana = Mana(self.SS_DIRPATH, cycle_pic)

				pixels_mana = currentMana.counting_pixels(x_min, x_max, y_min, y_max)
				print('MANA PIXELS:', pixels_mana)
				percentage_mana = round(currentMana.percentage(mana_full, pixels_mana))
				print('PERCENTAGE MANA:', percentage_mana)

				if percentage_mana == 100 or percentage_mana == 0:
					cycle_break+=1
					settings.get_tibia_active(self.CHAR_NAME)
					currentMana.rune(int(self.RUNES_PER_CYCLE), self.RUNE_HOTKEY)
					print('SUA MANA ESTÁ {}%!'.format(percentage_mana))
					print('Verifique seu tempo de ciclo e/ou numero de runas.\n')
					print('- RUNED')
				elif percentage_mana >= 50:

					settings.get_tibia_active(self.CHAR_NAME)
					currentMana.rune(int(self.RUNES_PER_CYCLE), self.RUNE_HOTKEY)
					print('- RUNED')
				else: print('- DIDN\'T RUNED')

				healing = Healing(cycle_pic, self.CHAR_NAME)
				healing.ring(self.RING_HOTKEY)
				settings.idle(.25)
				healing.eat_food(self.FOOD_HOTKEY)
				settings.idle(.5)
				healing.soft_boots(self.SOFT_HOTKEY)

				print('#'*30)
				print('  TECLE CRTL+C PARA CANCELAR  ')

				if cycle_break == 5:
					print('ATENÇÃO: 5 CICLOS COM MANA ESTÁTICA!')
					break

				cycle_count = settings.increment(cycle_count)
				settings.del_screenshot(cycle_pic)
				settings.idle(int(self.CYCLE_TIME)*60)

		except KeyboardInterrupt:
			print('#'*10+'  CANCELADO  '+'#'*10)