Exemple #1
0
    async def log_in(self, login: str, password: str):
        if state() == State.NOT_LOGGED:
            hashed_password = sha1(b'mleczko' +
                                   password.encode('utf-8')).hexdigest()
            content = await self.session.query_game({
                'l': login,
                'ph': hashed_password
            })

            if 'chash' in self.session.cookies:
                state(State.LOGGED_IN)
Exemple #2
0
    def _get_base_url(self):
        if state() == State.NOT_LOGGED:
            return 'http://www.margonem.pl/ajax/logon.php?t=login'

        if state() == State.LOGGED_IN:
            return 'http://www.margonem.pl/ajax/getplayerdata.php'

        if state() in {State.START_INIT, State.INIT}:
            return f'http://{self.game_server}.margonem.pl/engine?t=init'

        if state() == State.ACTIVE:
            return f'http://{self.game_server}.margonem.pl/engine?t=_'
Exemple #3
0
    async def _send(self, payload):
        data = {}
        params = {}

        if state() in {State.NOT_LOGGED, State.LOGGED_IN}:
            data = payload
        elif state() in {State.START_INIT, State.INIT, State.ACTIVE}:
            params = payload

        return await self.post(url=self._get_base_url(),
                               cookies=self.cookies,
                               data=data,
                               params=params)
Exemple #4
0
 async def wait_for_input(self, send_requests):
     async with send_requests:
         while state() == State.ACTIVE:
             #input = self.gui.wait_for_input()
             input = None
             response = 'Normal'
             #response = await self.parse_command(input)
             await send_requests.send((RequestType.NORMAL, response))
             await trio.sleep(5)
Exemple #5
0
    def _get_default_payload(self):
        default = {
            'mucka': str(random()),
            'aid': self.user_id,
            'mobile': '1',
            'ev': self.ev,
            'mobile_token': self.mobile_token,
        }

        return {k: v for (k, v) in default.items() if k in PAYLOAD[state()]}
def state_parser(file_name):

	new_state=states.state()

	f = open(file_name, "r")
	line = f.readline()
	while line:
		new_state.add(parse(line,new_state))
		line = f.readline()

	f.close()

	return new_state
Exemple #7
0
    async def init(self, server, mchar_id):
        async def _init(lvl):
            return await self.session.query_game({'initlvl': lvl})

        if state() == State.LOGGED_IN:
            self.session.game_server = server
            self.session.cookies.update({'mchar_id': str(mchar_id)})

            state(State.START_INIT)
            await _init(1)

            state(State.INIT)
            for lvl in range(2, 5):
                await _init(lvl)

            state(State.ACTIVE)
            await self.active_init()
Exemple #8
0
 async def keep_alive(self, send_requests):
     async with send_requests:
         while state() == State.ACTIVE:
             response = await self.session.query_game()
             await send_requests.send((RequestType.EVENT, response))
             await trio.sleep(0.5)
Exemple #9
0
 async def get_player_data(self):
     if state() == State.LOGGED_IN:
         print(await self.session.query_game())