예제 #1
0
def send_demolish(user_id, password, sector_x, sector_y, x, y, client_token):
	if _is_tutorial:
		return fake().send_demolish(user_id, password, sector_x, sector_y, x, y, client_token)
	return _send_command('demolish', {
		'sector': util.fromtuple((sector_x, sector_y)),
		'loc': util.fromtuple((x, y)),
		'client_token': client_token
	}, user_id, password)
예제 #2
0
def send_demolish(user_id, password, sector_x, sector_y, x, y, client_token):
    if _is_tutorial:
        return fake().send_demolish(user_id, password, sector_x, sector_y, x,
                                    y, client_token)
    return _send_command(
        'demolish', {
            'sector': util.fromtuple((sector_x, sector_y)),
            'loc': util.fromtuple((x, y)),
            'client_token': client_token
        }, user_id, password)
예제 #3
0
def send_build(user_id, password, type, sector_x, sector_y, loc_x, loc_y, sector_you_care_about, last_ids_by_sector, client_token):
	if _is_tutorial:
		return fake().send_build(user_id, password, type, sector_x, sector_y, loc_x, loc_y, sector_you_care_about, last_ids_by_sector, client_token)
	
	poll_sectors = _get_poll_args(sector_you_care_about, last_ids_by_sector)
	last_id = last_ids_by_sector.get((sector_x, sector_y), 0)
	return _send_command('build', {
		'type': type,
		'sector': util.fromtuple((sector_x, sector_y)),
		'last_id': last_id,
		'loc': util.fromtuple((loc_x, loc_y)),
		'client_token': client_token,
		'poll_sectors': poll_sectors
		}, user_id, password)
예제 #4
0
def send_build(user_id, password, type, sector_x, sector_y, loc_x, loc_y,
               sector_you_care_about, last_ids_by_sector, client_token):
    if _is_tutorial:
        return fake().send_build(user_id, password, type, sector_x, sector_y,
                                 loc_x, loc_y, sector_you_care_about,
                                 last_ids_by_sector, client_token)

    poll_sectors = _get_poll_args(sector_you_care_about, last_ids_by_sector)
    last_id = last_ids_by_sector.get((sector_x, sector_y), 0)
    return _send_command(
        'build', {
            'type': type,
            'sector': util.fromtuple((sector_x, sector_y)),
            'last_id': last_id,
            'loc': util.fromtuple((loc_x, loc_y)),
            'client_token': client_token,
            'poll_sectors': poll_sectors
        }, user_id, password)
예제 #5
0
def _get_poll_args(sector, last_ids_by_sector):
	nsectors = {}
	if '^' in str(sector):
		x,y = util.totuple(sector)
	else:
		x,y = sector
	
	for dx in (-1, 0, 1):
		for dy in (-1, 0, 1):
			nsectors[(x + dx, y + dy)] = True
	s_r = []
	for s in nsectors.keys():
		last_id = last_ids_by_sector.get(s, 0)
		s_r.append(str(last_id) + '^' + util.fromtuple(s))
	return ','.join(s_r)
예제 #6
0
def _get_poll_args(sector, last_ids_by_sector):
    nsectors = {}
    if '^' in str(sector):
        x, y = util.totuple(sector)
    else:
        x, y = sector

    for dx in (-1, 0, 1):
        for dy in (-1, 0, 1):
            nsectors[(x + dx, y + dy)] = True
    s_r = []
    for s in nsectors.keys():
        last_id = last_ids_by_sector.get(s, 0)
        s_r.append(str(last_id) + '^' + util.fromtuple(s))
    return ','.join(s_r)