Beispiel #1
0
def dispatch_mahjong_to_room(room, **kwargs):
    func.log_info('[game] dispatch_mahjong_to_room')
    room.random_cards()
    # execute_account_id = room.get_original_execute()
    room.room_player_status(status.PLAYER_STATUS_NORMAL)
    if 'crap_list' in kwargs:
        craps_1, craps_2 = kwargs['crap_list']
    else:
        craps_1 = func.random_get(1, 6)
        craps_2 = func.random_get(1, 6)
    room.craps = [craps_1, craps_2]
    original_count = room.original_count * room.player_count
    room.mahjong_start = original_count
    room.mahjong_end = 1
    room.execute_account_id = room.maker_account_id
    mahjong_craps = {
        'maker_account_id': room.execute_account_id,
        'craps': [craps_1, craps_2],
        'mahjong_start_num': room.mahjong_start,
        'mahjong_end_num': room.mahjong_end
    }
    ready_list = room.room_ready_list
    for account_id in ready_list:
        player = room.get_player(account_id)
        send.send_mahjong_craps(player.dynamic_id, **mahjong_craps)
        send.player_dispatch_cards(room.execute_account_id, player)
        if player.account_id == room.execute_account_id:
            mahjong.dispatch_mahjong_card(player.dynamic_id, True)
Beispiel #2
0
def account_register(dynamic_id, address, user_name, password):
    if not user_name or not password:
        send.system_notice(dynamic_id, content.ACCOUNT_NULL)
        return
    if not func.check_english(user_name):
        send.system_notice(dynamic_id, content.ACCOUNT_ENGLISH)
        return
    sql = 'select * from {} where user_name="{}"'.format(
        dbname.DB_ACCOUNT, user_name)
    if dbexecute.query_one(sql):
        send.system_notice(dynamic_id, content.ACCOUNT_EXIST)
        return
    uuid = user_name
    sex = func.random_get(1, 2)
    name = user_name
    head_frame = ''
    head_icon = ''
    account_id = _register_process(user_name, password, name, uuid, '',
                                   channel.CHANNEL_ZERO, sex, head_frame,
                                   head_icon)
    if account_id:
        func.log_info(
            '[Auth] user_name: {}, account_id: {}, address: {} register success'
            .format(user_name, account_id, address))
        send.account_register(dynamic_id, user_name, password, account_id)
    else:
        func.log_error(
            '[Auth] user_name: {} register failed'.format(user_name))
 def generator_room_id(self):
     hold_count = 0
     calc_count = 0
     while True:
         room_id = func.random_get(100001, 999999)
         if room_id not in self._rooms:
             if calc_count <= 10 and '4' in str(room_id):
                 continue
             return room_id
         hold_count += 1
         calc_count += 1
         if calc_count == 20:
             self.clear_unvalid_room()
         elif calc_count > 2000:
             return -1
Beispiel #4
0
# coding:utf8
from twisted.internet import defer
from firefly.server.globalobject import GlobalObject
from firefly.utils.services import CommandService

from app.util.common import func


class GameCommandService(CommandService):
    def is_target_local(self, target_key):
        return target_key in self._targets


game_service = GameCommandService(str(func.random_get(1, func.time_get())))


def game_service_handle(target):
    game_service.mapTarget(target)


def push_object(target_key, msg, send_list):
    func.log_info('[push_object] target_key: {}, send_list: {}'.format(
        target_key, send_list))


def push_all_game(target_key, msg):
    pass  # TODO: gameservice: push_all_game


def request_gate_node(target_key, *args, **kwargs):
    return GlobalObject().remote['gate'].callRemote(target_key, *args,
Beispiel #5
0
def generator_unique_order_id(money, account_id, dynamic_id):
    t = func.time_get()
    return '%s%d%d' % (str(money * 3 + func.random_get(30000, t)), account_id,
                       dynamic_id)
Beispiel #6
0
# coding:utf8
from twisted.internet import defer
from firefly.server.globalobject import GlobalObject
from firefly.utils.services import CommandService

from app.util.common import func


class GameCommandService(CommandService):

    def is_target_local(self, target_key):
        return target_key in self._targets


game_service = GameCommandService(str(func.random_get(1, func.time_get())))


def game_service_handle(target):
    game_service.mapTarget(target)


def push_object(target_key, msg, send_list):
    func.log_info('[push_object] target_key: {}, send_list: {}'.format(target_key, send_list))


def push_all_game(target_key, msg):
    pass    # TODO: gameservice: push_all_game


def request_gate_node(target_key, *args, **kwargs):
    return GlobalObject().remote['gate'].callRemote(target_key, *args, **kwargs)
Beispiel #7
0
def generator_unique_order_id(money):
    t = func.time_get()
    return str(money * 3 + func.random_get(30000, t))
Beispiel #8
0
def _create_token_key(user_name, password):
    m = hashlib.md5()
    m.update(
        str(user_name) + str(func.time_get()) + str(password) +
        str(func.random_get(100, 500000)))
    return m.hexdigest()
Beispiel #9
0
def _create_verify_key(account_id, token_key):
    m = hashlib.md5()
    m.update(
        str(account_id) + str(token_key) + str(func.time_get()) +
        str(func.random_get(10000, 500000)))
    return m.hexdigest()