Esempio n. 1
0
    def send_forum(self, msg, forum):
        """ Post a message on a given forum. """
        if not msg:
            print("You didn't enter a message... Try again, sport. ")
            return
        
        ## Identify chosen forum if possible
        forum_id = None
        for forum_name, id in self.forum_ids.items():
            if forum in forum_name:
                forum = forum_name
                forum_id = str(id)
                break
        # Forum not found
        if not forum_id:
            print(f"Could not get forum_id from given forum name: {forum}")
            return

        ## Confirmation via User Input
        if not yn(f"Post message to forum {forum_name}?"):
            return

        ## Make the request
        req_post(
            self.sesh,
            self.suburl_forum_main,
            params={'pag': "postare_noua"},
            data={'categ': forum_id, 'mesaj': msg}
        )
Esempio n. 2
0
 def delete(self):
     """ Deletes the list from Letterboxd. This cannot be undone!
     NOTE: after deleting a list, the instance will become unusable. 
     """
     if not util.yn(
             "Are you sure you want to delete the list? This cannot be undone!"
     ):
         return
     SESSION.request("POST", self.suburl_delete)
     self.soup = None
Esempio n. 3
0
 def energy_fail(player):
     if (final_energy :=
             self.resulting_energy(player)) < energy_warning:
         # Player is tired
         print(
             f"""\nWould you like to train {player.player_name} [ID: {player.player_id}]?\
         They would be at {final_energy}% energy at the start of your next match."""
         )
         if not yn():
             # User does not want tired player trained
             return False
Esempio n. 4
0
    def __call__(self):
        if not self.players:
            print("No players to be trained :(")
            return False

        divider = '\n- '
        # TODO add player positon to string
        # print(f"\nThe following players have been approved for {self.__class__.__name__}:{divider}{divider.join([i.player_name for i in self.players])}")

        # Confirmation
        if not yn("Continue?"): return

        # Train all players in list
        [self.train_player(i) for i in self.players]
Esempio n. 5
0
    def send_guestbook(self, msg, recipient=None, sender=None):
        """ 
        Post a message to the recipient's guestbook. 

        Guestbook is the only place that allows you to post
        as someone else, hence the optional sender parameter
        
        If no sender is given, the sender defaults to the user
        If no recipient is given, the recipient defaults to the user (not to the sender) 
        """

        if not msg:
            print("You didn't enter a message... Try again, sport. ")
            return

        ## Get Club object for sender
        if not sender:
            sender = self.user_club
        else:
            sender = self.get_club(sender)

        ## Get Club object for recipient
        if not recipient:
            recipient = self.user_club
        else:
            recipient = self.get_club(recipient)
        
        ## Confirmation via User Input
        if not yn(f"Sender: {sender.manager}\nRecipient: {recipient.manager}"):
            return

        ## Make the request
        req_post(
            self.sesh,
            self.suburl_guestbook,
            params={'pag': 'new'},
            data={'club': recipient.club_id, 'user': self.user_club.msg_id, 'mesaj': msg}
        )
Esempio n. 6
0
    def __login_loop(self, max_attempts=5):
        """ 
        Keeps attemptng to login until successful
        or reaches max attempts. 
        """
        attempts = 0
        ask_reset = True

        while attempts < max_attempts:
            try:
                self.__login()
            except LoginException:
                if ask_reset:
                    print(f"Could not login.")
                    if util.yn("Reset details?"):
                        USER_SETTINGS.user_details()
                        self.__get_username_password()
                    else:
                        ask_reset = False
            else:
                self.logged_in = True
                self.write_session()  # Save session to pickle file
                return True
Esempio n. 7
0
    def send_msg(self, msg, subject, recipient=None):
        """ Send a message to yourself or another user.
        NOTE: The sender will always be the user - it cannot be changed """

        # Edge case: no message entered
        if not msg:
            print("You didn't enter a message... Try again, sport. ")
            return

        if not recipient:
            # No recipient given - recipient defaults to user
            recipient = self.user_club
        else:
            recipient = self.get_club(recipient)

        if not yn(f"Sender: {self.sesh.username}\nRecipient: {recipient.manager}"):
            return

        req_post(
            self.sesh,
            self.suburl_message,
            params={'catre': str(recipient.msg_id), 'pag': "confirmare"},
            data={'titlu': subject, 'mesaj': msg}
        )
Esempio n. 8
0
    def send_lgepage(self, msg, league_id=None):
        """ Post a message on a league forum. """
        if not msg:
            print("You didn't enter a message... Try again, sport. ")
            return
        
        if not league_id:
            league_id = self.user_club.league
        league_id = str(league_id)
        if not league_id.isdigit():
            print("league_id must be a number!")
            return

        ## Confirmation via User Input
        if not yn(f"Post message to league {league_id}?"):
            return

        ## Make the request
        req_post(
            self.sesh,
            self.suburl_forum_league,
            params={'pag': "postare_noua"},
            data={'categ': str(league_id), 'mesaj': msg}
        )
Esempio n. 9
0
import os
import imp
from util import yn, Box
from game import Game
import pyglet

wide_range = (-4,5)
do_wide = yn(
    'Do you wish to load more chunks? This is recommended\nonly if you are using pypy and/or a powerful computer. '
)
deletion_range = 10 if do_wide else 5
OFFSETS = []
for z in xrange(*wide_range):
    for y  in xrange(*wide_range):
        for x in xrange(*wide_range):
            OFFSETS.append((x,y,z))

CLOSE_OFFSETS = []
for z in xrange(-1,2):
    for y in xrange(-1,2):
        for x in xrange(-1,2):
            CLOSE_OFFSETS.append((x,y,z))
            OFFSETS.remove((x,y,z))

offset_information = Box(
    do_wide=do_wide,
    wide=OFFSETS,
    close=CLOSE_OFFSETS,
    deletion_range=deletion_range
)
Esempio n. 10
0
            elif self.trained_today(player, is_trainable):
                # Player was trained today
                continue

            elif not self.has_pot(player):
                # Player has bad potentials
                continue

            elif (final_energy := self.resulting_energy(player)) < 100:
                # Player is tired
                print(
                    f"""\nWould you like to train {player.player_name} [ID: {player.player_id}]?\
                They would be at {final_energy}% energy at the start of your next match."""
                )
                if not yn():
                    # User does not want tired player trained
                    continue

            self.training_list.append(player)
            print(player.player_name, "deemed fit for training...")

        if not self.training_list:
            print("No players to be trained :(")
            return

        # Confirmation
        if not yn("Continue?"): return

        # Train all players in list
        [self.train_player(i) for i in self.training_list]