Ejemplo n.º 1
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    table = GameRoom.Current.GetTableData(user)
    if not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    if not table:
        parent.ErrorCode = 1
        parent.ErrorInfo = Lang.getLang("St2011_Gameover")
        actionResult.Result = False
        return actionResult
    position = GameTable.Current.GetUserPosition(user, table)
    if not position:
        parent.ErrorCode = 1
        parent.ErrorInfo = Lang.getLang("St2011_Gameover")
        actionResult.Result = False
        return actionResult

    position.IsAI = urlParam.Op == 1 and True or False
    GameTable.Current.NotifyAutoAiUser(user.UserId, position.IsAI)
    return actionResult
Ejemplo n.º 2
0
def readLang(filepath, reverse=False):
    print("reading lines...")

    # read the file and split into lines
    lines = open(filepath, encoding='utf-8').read().strip().split('\n')

    # getting the language names from filename
    # filename = os.path.splitext(os.path.basename(filepath))[0]
    # lang = filename.split('-')

    # split every line into pairs and normalize
    # pairs = [[normalizeString(s) for s in l.split('\t')] for l in lines]

    # For chatbot, normalize only input side
    pairs = []
    for l in lines:
        split = l.split('\t')
        pairs.append([split[0], split[1]])
        # pairs.append( [util.normalize_no_punc(split[0]), split[1]] )
        # pairs.append( [util.normalize_no_punc(split[0]), split[2]] )

    # reverse pairs if needed, make lang instances
    if reverse:
        pairs = [list(reversed(p)) for p in pairs]
        source_lang = Lang()
        target_lang = Lang()
    else:
        source_lang = Lang()
        target_lang = Lang()

    return source_lang, target_lang, pairs
Ejemplo n.º 3
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    table = GameRoom.Current.GetTableData(user)
    if not user or not table:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    position = GameTable.Current.GetUserPosition(user, table)
    actionResult.MultipleNum = table.MultipleNum > 0 and table.MultipleNum or table.MinMultipleNum
    actionResult.AnteNum = table.MinAnteNum
    actionResult.LandlordId = table.LandlordId
    actionResult.IsAI = position.IsAI and 1 or 0
    actionResult.IsShow = table.IsShow and 1 or 0
    actionResult.BackCardData = table.BackCardData
    actionResult.PlayerList = table.Positions
    actionResult.CodeTime = GameTable.Current.CodeTime
    actionResult.OutCardUserId = table.OutCardUserId
    if not table.PreCardData or table.PreCardData.PosId==position.Id:
        actionResult.IsReNew = 1
    actionResult.GameCoin = user.GameCoin
    if table.PreCardData:
        actionResult.PreUserId = table.PreCardData.UserId
        actionResult.DeckType = int(table.PreCardData.Type)
        actionResult.CardSize = table.PreCardData.CardSize
        for card in table.PreCardData.Cards:
            actionResult.PreCardData.append(card)
    return actionResult
def read_langs(lang1, lang2, reverse=False):
    """Read sentences and instantiate Lang objects

    Args:
        lang1 (str): name of the first language
        lang2 (str): name of the second language
        reverse (bool, optional): reverse language orders? Defaults to False.

    Returns:
        (Lang, Lang, list): input language, output language, sentence pairs
    """
    print('Reading the lines...')

    # read the file and split into lines
    lines = open(f'data/{lang1}-{lang2}.txt',
                 encoding='utf-8').read().strip().split('\n')

    # create pairs (they are separated by a tab ('\t'))
    pairs = [[normalize_string(sentence) for sentence in line.split('\t')]
             for line in lines]

    # reverse pairs, make Lang instances
    if reverse:
        pairs = [list(reversed(pair)) for pair in pairs]
        input_lang = Lang(lang2)
        output_lang = Lang(lang1)
    else:
        input_lang = Lang(lang1)
        output_lang = Lang(lang2)

    return input_lang, output_lang, pairs
Ejemplo n.º 5
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    table = GameRoom.Current.GetTableData(user)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    position = GameTable.Current.GetUserPosition(user, table)
    if not position:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    if table.OutCardList.Count > 0:
        cardData = table.OutCardList[table.OutCardList.Count - 1]
        actionResult.UserId = cardData.UserId
        actionResult.DeckType = int(cardData.Type)
        actionResult.CardSize = cardData.CardSize
        actionResult.Cards = sorted(cardData.Cards, cmp=compeareTo)
        actionResult.NextUserId = table.OutCardUserId
        if not table.PreCardData or table.PreCardData.PosId == position.Id:
            actionResult.IsReNew = 1
        actionResult.MultipleNum = table.MultipleNum
        actionResult.AnteNum = table.AnteNum
        actionResult.PlayerList = table.Positions
        actionResult.IsAI = position.IsAI and 1 or 0

    return actionResult
Ejemplo n.º 6
0
def takeAction(urlParam, parent):
    actionResult = ActionResult();
    userId = str(parent.Current.UserId)
    contextUser = PersonalCacheStruct.Get[GameUser](userId)

    goldNum = ConfigEnvSet.GetInt("Archeology.ChallengeBossGold");

    # 判断晶石是否足够使用
    if contextUser.GoldNum < goldNum:
        parent.ErrorCode = Lang.getLang("1");  # 晶石不足,跳转到充值界面
        parent.ErrorInfo = Lang.getLang("LoadError");
        actionResult.Result = False;
        return actionResult;

    # 减晶石数
    contextUser.UseGold = MathUtils.Addition(contextUser.UseGold, goldNum, sys.maxint)

    userPlotPackage = GameDataCacheSet[UserPlotPackage]().FindKey(userId);
    if not userPlotPackage:
        return loadError();

    plotPackage = userPlotPackage.PlotPackage.Find(lambda x:x.CurrPlotNpcID == urlParam.plotNpcID);
    if not plotPackage:
        return loadError();
    plotPackage.BossChallengeCount += 1;

    return actionResult;
Ejemplo n.º 7
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    table = GameRoom.Current.GetTableData(user)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    position = GameTable.Current.GetUserPosition(user, table)
    if not position:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    actionResult.IsLandlord = position.IsLandlord and 1 or 0
    actionResult.IsLandlordWin = table.IsLandlordWin and 1 or 0
    actionResult.ScoreNum = position.ScoreNum
    actionResult.CoinNum = position.CoinNum
    actionResult.GameCoin = user.GameCoin
    for card in table.PreCardData.Cards:
        actionResult.LastCards.append(card)
    actionResult.LastCards = sorted(actionResult.LastCards, cmp = compeareTo)
    actionResult.LastUserId = table.PreCardData.UserId
    actionResult.MultipleNum = table.MultipleNum
    actionResult.AnteNum = table.AnteNum
    for pos in table.Positions:
        if pos.UserId != user.UserId:
            actionResult.UserList.append(pos)

    return actionResult
Ejemplo n.º 8
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    table = GameRoom.Current.GetTableData(user)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    position = GameTable.Current.GetUserPosition(user, table)
    if not position:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    if table.OutCardList.Count > 0:
        cardData = table.OutCardList[table.OutCardList.Count-1];
        actionResult.UserId = cardData.UserId
        actionResult.DeckType = int(cardData.Type)
        actionResult.CardSize = cardData.CardSize
        actionResult.Cards = sorted(cardData.Cards, cmp = compeareTo)
        actionResult.NextUserId = table.OutCardUserId
        if not table.PreCardData or table.PreCardData.PosId==position.Id:
            actionResult.IsReNew = 1
        actionResult.MultipleNum = table.MultipleNum
        actionResult.AnteNum = table.AnteNum
        actionResult.PlayerList = table.Positions
        actionResult.IsAI = position.IsAI and 1 or 0

    return actionResult
Ejemplo n.º 9
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = parent.Current.User.PersonalId;
    actionResult.userID = userId
    user = parent.Current.User

    cacheSet = GameDataCacheSet[UserAchieve]()
    achievePackage = cacheSet.FindKey(userId);
    if not achievePackage:
        parent.ErrorCode = Lang.getLang("ErrorCode");
        parent.ErrorInfo = Lang.getLang("LoadError");
        actionResult.Result = False
        return actionResult
    AchievementList =  List[AchievementInfo]
    if urlParam.AchieveType == AchieveType.QuanBu:
        AchievementList= ConfigCacheSet[AchievementInfo]().FindAll()
        actionResult.CompleteNum = achievePackage.AchievePackage.FindAll(match = lambda s:s.TaskStatus == TaskStatus.Complete).Count
    else :
        AchievementList= ConfigCacheSet[AchievementInfo]().FindAll(match = lambda s:s.AchieveType == urlParam.AchieveType)
        actionResult.CompleteNum = achievePackage.AchievePackage.FindAll(match = lambda s: s.AchieveType == urlParam.AchieveType and s.TaskStatus == TaskStatus.Complete).Count
    actionResult.AchieveNum = AchievementList.Count
    result = MathUtils.GetPaging[AchievementInfo](AchievementList,urlParam.PageIndex, urlParam.PageSize) 
    if result:
        actionResult.AchieveList = result[0]
        actionResult.PageCount = result[1]
    
    return actionResult
Ejemplo n.º 10
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    table = GameRoom.Current.GetTableData(user)
    if not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    if not table:
        parent.ErrorCode = 1
        parent.ErrorInfo = Lang.getLang("St2011_Gameover")
        actionResult.Result = False
        return actionResult
    position = GameTable.Current.GetUserPosition(user, table)
    if not position:
        parent.ErrorCode = 1
        parent.ErrorInfo = Lang.getLang("St2011_Gameover")
        actionResult.Result = False
        return actionResult

    position.IsAI = urlParam.Op == 1 and True or False
    GameTable.Current.NotifyAutoAiUser(user.UserId, position.IsAI)
    return actionResult
Ejemplo n.º 11
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    table = GameRoom.Current.GetTableData(user)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    if table.IsCallEnd:
        actionResult.IsEnd = 1;
        actionResult.LandlordId = table.LandlordId
        actionResult.LandlordName = ''
    else:
        actionResult.IsEnd = 0;
        actionResult.LandlordId = table.CallLandlordId
        actionResult.LandlordName = table.CallLandlordName
    actionResult.MultipleNum = table.MultipleNum > 0 and table.MultipleNum or table.MinMultipleNum
    actionResult.AnteNum = table.AnteNum
    actionResult.IsCall = urlParam.IsCall
    actionResult.IsRob = urlParam.IsRob
    #需要实现
    return actionResult
Ejemplo n.º 12
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    table = GameRoom.Current.GetTableData(user)
    if not user or not table:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    position = GameTable.Current.GetUserPosition(user, table)
    actionResult.MultipleNum = table.MultipleNum > 0 and table.MultipleNum or table.MinMultipleNum
    actionResult.AnteNum = table.MinAnteNum
    actionResult.LandlordId = table.LandlordId
    actionResult.IsAI = position.IsAI and 1 or 0
    actionResult.IsShow = table.IsShow and 1 or 0
    actionResult.BackCardData = table.BackCardData
    actionResult.PlayerList = table.Positions
    actionResult.CodeTime = GameTable.Current.CodeTime
    actionResult.OutCardUserId = table.OutCardUserId
    if not table.PreCardData or table.PreCardData.PosId == position.Id:
        actionResult.IsReNew = 1
    actionResult.GameCoin = user.GameCoin
    if table.PreCardData:
        actionResult.PreUserId = table.PreCardData.UserId
        actionResult.DeckType = int(table.PreCardData.Type)
        actionResult.CardSize = table.PreCardData.CardSize
        for card in table.PreCardData.Cards:
            actionResult.PreCardData.append(card)
    return actionResult
Ejemplo n.º 13
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    table = GameRoom.Current.GetTableData(user)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    if table.IsCallEnd:
        actionResult.IsEnd = 1
        actionResult.LandlordId = table.LandlordId
        actionResult.LandlordName = ''
    else:
        actionResult.IsEnd = 0
        actionResult.LandlordId = table.CallLandlordId
        actionResult.LandlordName = table.CallLandlordName
    actionResult.MultipleNum = table.MultipleNum > 0 and table.MultipleNum or table.MinMultipleNum
    actionResult.AnteNum = table.AnteNum
    actionResult.IsCall = urlParam.IsCall
    actionResult.IsRob = urlParam.IsRob
    #需要实现
    return actionResult
Ejemplo n.º 14
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    table = GameRoom.Current.GetTableData(user)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    position = GameTable.Current.GetUserPosition(user, table)
    if not position:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    actionResult.IsLandlord = position.IsLandlord and 1 or 0
    actionResult.IsLandlordWin = table.IsLandlordWin and 1 or 0
    actionResult.ScoreNum = position.ScoreNum
    actionResult.CoinNum = position.CoinNum
    actionResult.GameCoin = user.GameCoin
    for card in table.PreCardData.Cards:
        actionResult.LastCards.append(card)
    actionResult.LastCards = sorted(actionResult.LastCards, cmp=compeareTo)
    actionResult.LastUserId = table.PreCardData.UserId
    actionResult.MultipleNum = table.MultipleNum
    actionResult.AnteNum = table.AnteNum
    for pos in table.Positions:
        if pos.UserId != user.UserId:
            actionResult.UserList.append(pos)

    return actionResult
Ejemplo n.º 15
0
    def set_advt_frame(self, parent):
        self.setting_panel = wx.Panel(parent)
        self.setting_panel.SetSizer(self.setting_sizer)
        parent.AddPage(self.setting_panel, self.module_name)

        self.set_load_module()
        self.opt_sizer = wx.BoxSizer(wx.VERTICAL)
        self.grid_sizer = wx.FlexGridSizer(rows=15, cols=2)
        for opt in self.exists_options:
            lbl = wx.StaticText(self.setting_panel, -1, opt)
            self.cfg_ctr[opt] = txt = wx.TextCtrl(self.setting_panel, -1,
                                                  self.cfg['PHP'][opt])
            self.grid_sizer.Add(lbl, 0, wx.ALL, 5)
            self.grid_sizer.Add(txt, 0, wx.ALL, 3)

        conf_btn = wx.Button(self.setting_panel, -1,
                             Lang().get('php_config_file'))
        conf_btn.Bind(wx.EVT_BUTTON, self.open_config_file)

        save_btn = wx.Button(self.setting_panel, -1,
                             Lang().get('php_save_config'))
        save_btn.Bind(wx.EVT_BUTTON, self.save_config)

        self.handler_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.handler_sizer.AddMany([(conf_btn), (save_btn)])

        self.opt_sizer.Add(self.grid_sizer)
        self.opt_sizer.Add(self.handler_sizer, 0, wx.TOP, 5)
        self.setting_sizer.Add(self.opt_sizer, 0, wx.ALL, 5)
Ejemplo n.º 16
0
def takeAction(urlParam, parent):
    actionResult = ActionResult();
    userId = parent.Current.User.PersonalId;
    contextUser = parent.Current.User;
    sec = SdkSectionFactory.Section360;
    appKey =''
    appSecret = ''
    url = '{0}?grant_type=refresh_token&refresh_token={1}&client_id={2}&client_secret={3}&scope={4}'
    
    if sec:
        els = sec.Channels[urlParam.RetailID];
        if els:
            appKey = els.AppKey
            appSecret = els.AppSecret
            url =url.format(sec.GetAceessTokenUrl,urlParam.RefeshToken,appKey,appSecret,urlParam.Scope)
            TraceLog.WriteError('获取360 access_token:url={0}',url)
    result = HttpRequestManager.GetStringData(url,'GET')
    
    getToken = JsonUtils.Deserialize[Login360_V2.SDK360GetTokenError](result)
    if getToken == None:
        actionResult.AccessToken = contextUser.AccessToken
    else:
        if getToken and getToken.error_code != None  and getToken.error_code !='':
            parent.ErrorCode = Lang.getLang("ErrorCode")
            parent.ErrorInfo = Lang.getLang("GetAccessFailure")
            actionResult.Result = False;
            TraceLog.WriteError('获取360 access_token 失败:url={0},result={1},error_code={2},error={3}',url,result,getToken.error_code,getToken.error)
            return actionResult;
        actionResult.AccessToken = getToken.access_token
        contextUser.AccessToken = actionResult.AccessToken
    return actionResult;
Ejemplo n.º 17
0
def takeAction(urlParam, parent):
    actionResult = ActionResult();
    userId = str(parent.Current.UserId)
    contextUser = PersonalCacheStruct.Get[GameUser](userId)

    goldNum = ConfigEnvSet.GetInt("Archeology.ChallengeBossGold");

    # 判断晶石是否足够使用
    if contextUser.GoldNum < goldNum:
        parent.ErrorCode = Lang.getLang("1");  # 晶石不足,跳转到充值界面
        parent.ErrorInfo = Lang.getLang("LoadError");
        actionResult.Result = False;
        return actionResult;

    # 减晶石数
    contextUser.UseGold = MathUtils.Addition(contextUser.UseGold, goldNum, sys.maxint)

    userPlotPackage = PersonalCacheStruct[UserPlotPackage]().FindKey(userId);
    if not userPlotPackage:
        return loadError();

    plotPackage = userPlotPackage.PlotPackage.Find(lambda x:x.CurrPlotNpcID == urlParam.plotNpcID);
    if not plotPackage:
        return loadError();
    plotPackage.BossChallengeCount += 1;

    return actionResult;
Ejemplo n.º 18
0
 def __init__(self, directory):
     self.word_lang = Lang("normal word")
     self.num_normal_word = -1
     self.MAX_LENGTH = MAX_LENGTH
     self.MAX_MEM_SIZE = MAX_MEM_SIZE
     with open(directory, "rb") as pickle_d:
         self.raw_data = pickle.load(pickle_d)
     self.prepare_lang()
Ejemplo n.º 19
0
    def __init__(self, config: Namespace, shuffle_at_init=False, seed=None):
        super(StandardDataset, self).__init__()

        self.config = config

        self.anno_lang = Lang("anno")
        self.code_lang = Lang("code")

        self.__preprocess(shuffle_at_init, seed)
Ejemplo n.º 20
0
def buildPacket(writer, urlParam, actionResult):
    writer.PushIntoStack(len(actionResult.userMail))
    mailInfoCacheSet = ShareCacheStruct[MailInfo]()

    for item in actionResult.userMail:
        dsItem = DataStruct()
        mailType = item.MailType
        dsItem.PushIntoStack(item.UserId)
        dsItem.PushShortIntoStack(MathUtils.ToShort(mailType))
        dsItem.PushIntoStack(item.FromUserId)
        dsItem.PushIntoStack(item.FromUserName if item.FromUserName else '')
        dsItem.PushIntoStack(item.Title)
        dsItem.PushIntoStack(item.Content)
        diffDays = (DateTime.Now - item.SendDate).Days
        if diffDays < 1:
            diffHours = (DateTime.Now - item.SendDate).Hours
            if diffHours < 1:
                diffMinutes = (DateTime.Now - item.SendDate).Minutes
                minutesMsg = Lang.getLang("St9302_Minutes")
                dsItem.PushIntoStack('{0}{1}'.format(diffMinutes, minutesMsg))
            else:
                hourMsg = Lang.getLang("St9302_Hours")
                dsItem.PushIntoStack('{0}{1}'.format(diffHours, hourMsg))
        elif diffDays >= 1 and diffDays < 3:
            dayMsg = Lang.getLang("St9302_Days")
            dsItem.PushIntoStack('{0}{1}'.format(diffDays, dayMsg))
        else:
            dsItem.PushIntoStack(item.SendDate.ToString())
        #diffDays = (DateTime.Now-item.SendDate).TotalDays;
        #if diffDays < 1:
        #    diffHours = (DateTime.Now-item.SendDate).TotalHours;
        #    dsItem.PushIntoStack('{0}{1}'.format(diffHours, Lang.getLang("St9302_Hours")));
        #elif diffDays >= 1 and diffDays < 3:
        #    dsItem.PushIntoStack('{0}{1}'.format(diffDays, Lang.getLang("St9302_Days")));
        #else:
        #    dsItem.PushIntoStack(item.SendDate.ToString());
        #dsItem.PushByteIntoStack(item.IsRead);
        dsItem.PushByteIntoStack(item.IsGuide)

        if item.IsGuide == 1:
            mailInfo = mailInfoCacheSet.Find(
                lambda s: s.MailType == MathUtils.ToInt(mailType))
            if mailInfo:
                dsItem.PushIntoStack(mailInfo.GuideContent)
            else:  # 如果获取不到相应类型的引导内容,下发空
                dsItem.PushIntoStack('')
        else:
            dsItem.PushIntoStack('')
        dsItem.PushByteIntoStack(item.IsReply)
        dsItem.PushShortIntoStack(MathUtils.ToShort(item.ReplyStatus))
        dsItem.PushIntoStack(MathUtils.ToNotNullString(item.MailID))
        dsItem.PushIntoStack(
            item.CounterattackUserID if item.CounterattackUserID else 0)
        dsItem.PushIntoStack(MathUtils.ToNotNullString(item.SendDate))
        writer.PushIntoStack(dsItem)
    return True
Ejemplo n.º 21
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    gameHall = GameHall(parent.Current.User)
    actionResult.Result = gameHall.ChangeUserHead(urlParam.HeadIcon)
    if not actionResult.Result:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("St1010_ChangeHeadError")
        return actionResult

    return actionResult
Ejemplo n.º 22
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    gameHall = GameHall(parent.Current.User)
    actionResult.Result = gameHall.ChangeUserHead(urlParam.HeadIcon)
    if not actionResult.Result:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("St1010_ChangeHeadError")
        return actionResult

    return actionResult
Ejemplo n.º 23
0
def buildPacket(writer, urlParam, actionResult):
    writer.PushIntoStack(len(actionResult.userMail));
    mailInfoCacheSet = ShareCacheStruct[MailInfo]();

    for item in actionResult.userMail:
        dsItem = DataStruct();
        mailType = item.MailType;
        dsItem.PushIntoStack(item.UserId);
        dsItem.PushShortIntoStack(MathUtils.ToShort(mailType));
        dsItem.PushIntoStack(item.FromUserId);
        dsItem.PushIntoStack(item.FromUserName if item.FromUserName else '');
        dsItem.PushIntoStack(item.Title);
        dsItem.PushIntoStack(item.Content);
        diffDays = (DateTime.Now-item.SendDate).Days;
        if diffDays < 1:
            diffHours = (DateTime.Now-item.SendDate).Hours;
            if diffHours < 1:
                diffMinutes = (DateTime.Now-item.SendDate).Minutes;
                minutesMsg = Lang.getLang("St9302_Minutes");
                dsItem.PushIntoStack('{0}{1}'.format(diffMinutes, minutesMsg));
            else:
                hourMsg = Lang.getLang("St9302_Hours");
                dsItem.PushIntoStack('{0}{1}'.format(diffHours, hourMsg));
        elif diffDays >= 1 and diffDays < 3:
            dayMsg = Lang.getLang("St9302_Days");
            dsItem.PushIntoStack('{0}{1}'.format(diffDays, dayMsg));
        else:
            dsItem.PushIntoStack(item.SendDate.ToString());
        #diffDays = (DateTime.Now-item.SendDate).TotalDays;
        #if diffDays < 1:
        #    diffHours = (DateTime.Now-item.SendDate).TotalHours;
        #    dsItem.PushIntoStack('{0}{1}'.format(diffHours, Lang.getLang("St9302_Hours")));
        #elif diffDays >= 1 and diffDays < 3:
        #    dsItem.PushIntoStack('{0}{1}'.format(diffDays, Lang.getLang("St9302_Days")));
        #else:
        #    dsItem.PushIntoStack(item.SendDate.ToString());
        #dsItem.PushByteIntoStack(item.IsRead);
        dsItem.PushByteIntoStack(item.IsGuide);

        if item.IsGuide == 1:
            mailInfo = mailInfoCacheSet.Find(lambda s:s.MailType == MathUtils.ToInt(mailType));
            if mailInfo:
                dsItem.PushIntoStack(mailInfo.GuideContent);
            else: # 如果获取不到相应类型的引导内容,下发空
                dsItem.PushIntoStack('');
        else:
            dsItem.PushIntoStack('');
        dsItem.PushByteIntoStack(item.IsReply);
        dsItem.PushShortIntoStack(MathUtils.ToShort(item.ReplyStatus));
        dsItem.PushIntoStack(MathUtils.ToNotNullString(item.MailID));
        dsItem.PushIntoStack(item.CounterattackUserID if item.CounterattackUserID else 0);
        dsItem.PushIntoStack(MathUtils.ToNotNullString(item.SendDate));
        writer.PushIntoStack(dsItem);
    return True;
Ejemplo n.º 24
0
 def __init__(self, device, log_name):
     environ = os.environ
     self.device_id = environ.get(device)
     if (self.device_id == None):
         device_id = device
     self._device, self._easy_device, self.hierarchyviewer = self._connect_device(
         self.device_id)
     self._logger = createlogger(log_name)
     self._log_path = create_folder()
     self._config = GetConfigs("common")
     self._lang = Lang(device_id)
Ejemplo n.º 25
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    if not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    actionResult.UserId = user.UserId
    actionResult.Status = urlParam.Status
    return actionResult
Ejemplo n.º 26
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    if not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    actionResult.UserId = user.UserId
    actionResult.Status = urlParam.Status
    return actionResult
Ejemplo n.º 27
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    table = GameRoom.Current.GetTableDataByUserId(parent.Current.UserId)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    actionResult.PlayerList = table.Positions
    return actionResult
Ejemplo n.º 28
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    gameHall = GameHall(user)
    actionResult.Result = gameHall.ChangeUserHead(urlParam.HeadIcon)
    if not actionResult.Result:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("St1010_ChangeHeadError")
        return actionResult

    return actionResult;
Ejemplo n.º 29
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    if not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    actionResult.UserId = user.UserId
    actionResult.Status = urlParam.Status
    return actionResult
Ejemplo n.º 30
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    gameHall = GameHall(user)
    actionResult.Result = gameHall.ChangeUserHead(urlParam.HeadIcon)
    if not actionResult.Result:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("St1010_ChangeHeadError")
        return actionResult

    return actionResult
Ejemplo n.º 31
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    if not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    broadcastService = DdzBroadcastService(user)
    actionResult.MessageList = broadcastService.GetMessages()
    return actionResult
Ejemplo n.º 32
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    if not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    actionResult.UserId = user.UserId
    actionResult.Status = urlParam.Status
    return actionResult
Ejemplo n.º 33
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    table = GameRoom.Current.GetTableDataByUserId(parent.Current.UserId)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    actionResult.PlayerList = table.Positions
    return actionResult
Ejemplo n.º 34
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    if not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    broadcastService = DdzBroadcastService(user)
    actionResult.MessageList = broadcastService.GetMessages()
    return actionResult
Ejemplo n.º 35
0
def takeAction(urlParam, parent):
    actionResult = ActionResult();
    #需要实现
    userId = str(parent.Current.UserId)
    contextUser = PersonalCacheStruct.Get[GameUser](userId)
    userExtend = contextUser.UserExtend
    LairTreasure=ShareCacheStruct[LairTreasureInfo]().FindKey(urlParam.LairTreasureType)
    if not LairTreasure:
         parent.ErrorCode = Lang.getLang("ErrorCode");
         parent.ErrorInfo = Lang.getLang("St12101_NotLairTreasure");
         actionResult.Result = False;
         return actionResult;
    actionResult.LairList=LairTreasure.LairTreasureList
    actionResult.ExpendNum=LairTreasure.UseNum
    if LairTreasure.UseType==0:
        actionResult.HaveNum=contextUser.GameCoin
    if LairTreasure.UseType==1:
        actionResult.HaveNum=contextUser.GoldNum
    actionResult.UserType = LairTreasure.UseType
    actionResult.MaxNum = LairTreasure.LairTreasureNum
    if(userExtend.LairDate.Date != DateTime.Now.Date):
        userExtend.LairNum = 0
        userExtend.LairDate = DateTime.Now
    if(userExtend.DaLairDate.Date != DateTime.Now.Date):
        userExtend.DaLairNum = 0
        userExtend.DaLairDate = DateTime.Now
    if(userExtend.ZhongLairDate.Date != DateTime.Now.Date):
        userExtend.ZhongLairNum = 0
        userExtend.ZhongLairDate = DateTime.Now
    if urlParam.LairTreasureType == MathUtils.ToInt(LairTreasureType.ZhuanJiaQuBao):
        #actionResult.MaxNum = ConfigEnvSet.GetInt("UserLair.Num")
        actionResult.LastNum = MathUtils.Subtraction(actionResult.MaxNum,userExtend.LairNum)
    if urlParam.LairTreasureType == MathUtils.ToInt(LairTreasureType.DaShiQuBao):
        #actionResult.MaxNum = ConfigEnvSet.GetInt("UserDaLair.Num")
        actionResult.LastNum = MathUtils.Subtraction(actionResult.MaxNum,userExtend.DaLairNum)
    if urlParam.LairTreasureType == MathUtils.ToInt(LairTreasureType.ZongShiQuBao):
        #actionResult.MaxNum = ConfigEnvSet.GetInt("UserZhongLair.Num")
        actionResult.LastNum = MathUtils.Subtraction(actionResult.MaxNum,userExtend.ZhongLairNum)
    cacheSetFes =  ShareCacheStruct[FestivalInfo]();
    festivalInfo = cacheSetFes.Find(lambda s:s.FestivalType==FestivalType.KaoGu);
    if festivalInfo:
        index = MathUtils.ToInt(MathUtils.DiffDate(DateTime.Now, festivalInfo.EndDate).TotalDays);
        if(index==0):
            actionResult.ActivityEndTime = Lang.getLang("Today")
        else:
            if(index == -1):
                actionResult.ActivityEndTime = Lang.getLang("Tomorrow")
            else:
                if(index < -1):
                    actionResult.ActivityEndTime = festivalInfo.EndDate.ToString(Lang.getLang("DateFormatMMdd"))

    return actionResult;
Ejemplo n.º 36
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    table = GameRoom.Current.GetTableData(user)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    actionResult.Cards = GameTable.Current.GetLandlordCardData(table)
    actionResult.MultipleNum = table.MultipleNum
    actionResult.AnteNum = table.AnteNum
    return actionResult
Ejemplo n.º 37
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    table = GameRoom.Current.GetTableData(user)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    actionResult.Cards = GameTable.Current.GetLandlordCardData(table)
    actionResult.MultipleNum = table.MultipleNum
    actionResult.AnteNum = table.AnteNum
    return actionResult
Ejemplo n.º 38
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    if not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    broadcastService = DdzBroadcastService(user)
    actionResult.MessageList = broadcastService.GetMessages()
    return actionResult
Ejemplo n.º 39
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    if not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    broadcastService = DdzBroadcastService(user)
    actionResult.MessageList = broadcastService.GetMessages()
    return actionResult
Ejemplo n.º 40
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    gameUser = PersonalCacheStruct.Get[GameUser](userId)
    actionResult.UserLv = gameUser.UserLv
    if actionResult.UserLv >= 10:
        userShengJiTa = GameDataCacheSet[UserShengJiTa]().FindKey(
            userId)  #获取玩家信息
        if userShengJiTa == None:
            GameDataCacheSet[UserShengJiTa]().Add(
                UserShengJiTa(MathUtils.ToInt(userId)))
            userShengJiTa = GameDataCacheSet[UserShengJiTa]().FindKey(
                userId)  #获取玩家信息
        if userShengJiTa.EndTime == None or DateTime.Now.Date != userShengJiTa.EndTime.Date:  #判断时间是否同一天
            userShengJiTa.MaxTierNum = 0
            userShengJiTa.ScoreStar = 0
            userShengJiTa.LifeNum = 0
            userShengJiTa.WuLiNum = 0
            userShengJiTa.FunJiNum = 0
            userShengJiTa.MofaNum = 0
            userShengJiTa.FiveTierRewardList.Clear()
            userShengJiTa.IsTierNum = 0  #当前层数
            userShengJiTa.IsTierStar = 0  #当前五层得分
            userShengJiTa.BattleRount = 0
            userShengJiTa.SJTStatus = 0
            userShengJiTa.RoundPoor = 0
            List = []
            List = userShengJiTa.RewardStatusList  #附加奖励是否领取置为否
            for i in List:
                i.IsReceive = 0
        actionResult.BattleRount = userShengJiTa.BattleRount
        if actionResult.BattleRount > 3:
            parent.ErrorCode = Lang.getLang("ErrorCode")
            parent.ErrorInfo = Lang.getLang("St13002_BattleRount")
        actionResult.LastBattleRount = 3 - actionResult.BattleRount
        actionResult.MaxTierNum = userShengJiTa.MaxTierNum
        actionResult.ScoreStar = userShengJiTa.ScoreStar
        rankList = RankingFactory.Get[UserRank](
            ShengJiTaRanking.RankingKey)  #获取玩家的排行
        ranKingUser = rankList.Find(lambda u: u.UserID == userId)
        if ranKingUser:
            actionResult.UserRank = ranKingUser.SJTRankId
        else:
            actionResult.UserRank = 0  #未进入排行榜
        actionResult.SJTStatus = userShengJiTa.SJTStatus  #跳转界面
    else:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("St4405_UserLvNotEnough")
        actionResult.Result = False
        return actionResult
    return actionResult
Ejemplo n.º 41
0
def load_data():
    lang1 = "eng"
    lang2 = "fra"

    print("Reading lines...")

    lines = open('../assets/data/%s-%s.txt' % (lang1, lang2),
                 encoding='utf-8').read().strip().split('\n')

    pairs = [[normalize_string(s) for s in l.split('\t')] for l in lines]

    input_lang = Lang(lang1)
    output_lang = Lang(lang2)

    print("Read %s sentence pairs" % len(pairs))
    print("Trimmed to %s sentence pairs" % len(pairs))
    print("Counting words...")
    for pair in pairs:
        input_lang.add_sentence(pair[0])
        output_lang.add_sentence(pair[1])
    print("Counted words:")
    print(input_lang.name, input_lang.n_words)
    print(output_lang.name, output_lang.n_words)

    return input_lang, output_lang, pairs
Ejemplo n.º 42
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    
    shopinfo = ConfigCacheSet[ShopInfo]().FindKey(urlParam.ItemID)
    if shopinfo == None:
        parent.ErrorCode = Lang.getLang("ErrorCode");
        parent.ErrorInfo = Lang.getLang("St_7002_ShopOffTheShelf");
        actionResult.Result = False;
        return actionResult;
    gameHall = GameHall(user)
    useGold = shopinfo.Price;
    if user.VipLv>0 :
        userGold = shopinfo.VipPrice
    if gameHall.UserGold < useGold:
        parent.ErrorCode = 1
        parent.ErrorInfo = Lang.getLang("St_2909_StGoldNumNullEnough");
        actionResult.Result = False;
        return actionResult;
    if shopinfo.ShopType == ShopType.HeadID:        
        if gameHall.CheckUserItem(urlParam.ItemID):
            parent.ErrorCode = Lang.getLang("ErrorCode");
            parent.ErrorInfo = Lang.getLang("St_7002_PurchasedHeadID");
            actionResult.Result = False;
            return actionResult;        
        gameHall.AddUserItem(urlParam.ItemID,shopinfo.ShopType)     
        ClientNotifier.NotifyAction(ActionIDDefine.Cst_Action1013, user, None);
    if shopinfo.ShopType == ShopType.Beans:
         user.GameCoin = MathUtils.Addition(user.GameCoin,shopinfo.GameCoin)       
    user.UseGold = MathUtils.Addition(user.UseGold,useGold)
    GameTable.Current.NotifyUserChange(user.UserId)    
    
    mallItemLog = MallItemLog()
    mallItemLog.ItemID = urlParam.ItemID
    mallItemLog.Uid = user.UserId
    mallItemLog.Num = 1
    mallItemLog.CurrencyType = MathUtils.ToInt(shopinfo.ShopType)
    mallItemLog.Amount = useGold
    mallItemLog.CreateDate = MathUtils.Now
    mallItemLog.RetailID = user.RetailId
    mallItemLog.MobileType = user.MobileType
    mallItemLog.Pid = user.Pid
    mallItemLog.ItemName = shopinfo.ShopName
    sender = DataSyncManager.GetDataSender()
    sender.Send(mallItemLog)

    #需要实现
    return actionResult
Ejemplo n.º 43
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)

    shopinfo = ConfigCacheSet[ShopInfo]().FindKey(urlParam.ItemID)
    if shopinfo == None:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("St_7002_ShopOffTheShelf")
        actionResult.Result = False
        return actionResult
    gameHall = GameHall(user)
    useGold = shopinfo.Price
    if user.VipLv > 0:
        userGold = shopinfo.VipPrice
    if gameHall.UserGold < useGold:
        parent.ErrorCode = 1
        parent.ErrorInfo = Lang.getLang("St_2909_StGoldNumNullEnough")
        actionResult.Result = False
        return actionResult
    if shopinfo.ShopType == ShopType.HeadID:
        if gameHall.CheckUserItem(urlParam.ItemID):
            parent.ErrorCode = Lang.getLang("ErrorCode")
            parent.ErrorInfo = Lang.getLang("St_7002_PurchasedHeadID")
            actionResult.Result = False
            return actionResult
        gameHall.AddUserItem(urlParam.ItemID, shopinfo.ShopType)
        ClientNotifier.NotifyAction(ActionIDDefine.Cst_Action1013, user, None)
    if shopinfo.ShopType == ShopType.Beans:
        user.GameCoin = MathUtils.Addition(user.GameCoin, shopinfo.GameCoin)
    user.UseGold = MathUtils.Addition(user.UseGold, useGold)
    GameTable.Current.NotifyUserChange(user.UserId)

    mallItemLog = MallItemLog()
    mallItemLog.ItemID = urlParam.ItemID
    mallItemLog.Uid = user.UserId
    mallItemLog.Num = 1
    mallItemLog.CurrencyType = MathUtils.ToInt(shopinfo.ShopType)
    mallItemLog.Amount = useGold
    mallItemLog.CreateDate = MathUtils.Now
    mallItemLog.RetailID = user.RetailId
    mallItemLog.MobileType = user.MobileType
    mallItemLog.Pid = user.Pid
    mallItemLog.ItemName = shopinfo.ShopName
    sender = DataSyncManager.GetDataSender()
    sender.Send(mallItemLog)

    #需要实现
    return actionResult
Ejemplo n.º 44
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    table = GameRoom.Current.GetTableData(user)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    actionResult.LandlordId = table.CallLandlordId
    actionResult.LandlordName = table.CallLandlordName
    actionResult.CodeTime = GameTable.Current.CodeTime
    actionResult.BackCardData = table.BackCardData
    actionResult.UserCardData = GameTable.Current.GetUserCardData(user, table)
    return actionResult
Ejemplo n.º 45
0
def read_data(lang_1, lang_2, reverse=False):
    print("importing dataset")
    f = open("data/{}-{}.txt".format(lang_1, lang_2), "r",
             encoding="utf-8").read().strip()
    pairs = [[normalize_string(s) for s in l.split("\t")]
             for l in f.split("\n")]

    if reverse:
        pairs = [list(reversed(p)) for p in pairs]
        input_lang = Lang(lang_2)
        output_lang = Lang(lang_1)
    else:
        input_lang = Lang(lang_1)
        output_lang = Lang(lang_2)

    return input_lang, output_lang, pairs
Ejemplo n.º 46
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    table = GameRoom.Current.GetTableData(user)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    actionResult.LandlordId = table.CallLandlordId
    actionResult.LandlordName = table.CallLandlordName
    actionResult.CodeTime = GameTable.Current.CodeTime
    actionResult.BackCardData = table.BackCardData
    actionResult.UserCardData = GameTable.Current.GetUserCardData(user, table)
    return actionResult
Ejemplo n.º 47
0
 def choose_dir(self, event):
     #选择并更新根目录
     select_dir = wx.DirDialog(None, Lang().get('apache_choose_doc_root') + ':',
         self.cfg_doc_root.GetLabelText(), style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
     if select_dir.ShowModal() == wx.ID_OK and os.path.isdir(select_dir.GetPath()):
             self.cfg_doc_root.SetLabelText(select_dir.GetPath())
     select_dir.Destroy()
Ejemplo n.º 48
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = parent.Current.User.PersonalId
    gameUser =parent.Current.User
    actionResult.UserLv=gameUser.UserLv   
    if actionResult.UserLv>=10:       
        userShengJiTa = GameDataCacheSet[UserShengJiTa]().FindKey(userId)    #获取玩家信息
        if userShengJiTa == None:
            GameDataCacheSet[UserShengJiTa]().Add(UserShengJiTa(MathUtils.ToInt(userId)), GameEnvironment.CacheUserPeriod)
            userShengJiTa = GameDataCacheSet[UserShengJiTa]().FindKey(userId)    #获取玩家信息
        if userShengJiTa.EndTime==None or DateTime.Now.Date!=userShengJiTa.EndTime.Date:  #判断时间是否同一天
            userShengJiTa.MaxTierNum = 0;
            userShengJiTa.ScoreStar = 0;
            userShengJiTa.LifeNum = 0;
            userShengJiTa.WuLiNum = 0;
            userShengJiTa.FunJiNum = 0;
            userShengJiTa.MofaNum = 0;
            userShengJiTa.FiveTierRewardList.Clear();
            userShengJiTa.IsTierNum=0     #当前层数
            userShengJiTa.IsTierStar=0             #当前五层得分  
            userShengJiTa.BattleRount=0
            userShengJiTa.SJTStatus=0
            userShengJiTa.RoundPoor = 0;
            List=[]
            List=userShengJiTa.RewardStatusList            #附加奖励是否领取置为否
            for i in List:
                i.IsReceive=0
        actionResult.BattleRount=userShengJiTa.BattleRount
        if actionResult.BattleRount>3:
             parent.ErrorCode = Lang.getLang("ErrorCode");
             parent.ErrorInfo = Lang.getLang("St13002_BattleRount")
        actionResult.LastBattleRount=3-actionResult.BattleRount
        actionResult.MaxTierNum=userShengJiTa.MaxTierNum
        actionResult.ScoreStar=userShengJiTa.ScoreStar
        rankList = RankingFactory.Get[UserRank](ShengJiTaRanking.RankingKey)   #获取玩家的排行
        ranKingUser=rankList.Find(lambda u:u.UserID==userId)
        if ranKingUser:
            actionResult.UserRank=ranKingUser.SJTRankId   
        else:
            actionResult.UserRank=0     #未进入排行榜
        actionResult.SJTStatus=userShengJiTa.SJTStatus   #跳转界面
    else:
         parent.ErrorCode = Lang.getLang("ErrorCode");
         parent.ErrorInfo = Lang.getLang("St4405_UserLvNotEnough")
         actionResult.Result = False;
         return actionResult;
    return actionResult;
Ejemplo n.º 49
0
	def __init__(self):
		super(AutoTransferGUI,self).__init__()

		self.__consoleConfig = MainConfigUpdater("config.json")


		self.__tableName = ""
		self.__codeTextBoxXPath = ""
		self.__codeEnterBtnXPath = ""
		self.__transferBtnClassName = ""
		self.__transferBtnSelector = ""
		self.__checkBoxClassName = ""
		self.__fileTreeNodeClassName = ""
		self.__fileTreeDialogXPath = ""
		self.__destnationPath = ""
		self.__fileTreeConfirmClassName = ""
		self.__notFoundID = ""

		self.__langFloder = "." + os.sep + "lang" + os.sep
		self.__langList = []
		self.__config = {}
		self.__curLang = "en"

		self.__getLangList()
		self.__loadConfig()

		self.__isTransferStarted = False
		self.__transferFramework = None
		self.__transferDBFile = ""
		self.__runMode = 0

		self.__lang = Lang(self.__curLang)
		if (self.__lang.reload(self.__curLang) == -1):
			print ("Language Pack Error.")
			sys.exit(1)
		

		self.__title = self.__lang.get("title")
		self.__left = 50
		self.__top = 50
		self.__width = 500
		self.__heigth = 600
		self.__widgetList = []

		self.__initUI()

		self.show()
Ejemplo n.º 50
0
def takeAction(urlParam, parent):
    actionResult = ActionResult();
    user = parent.Current.User;
    table = GameRoom.Current.GetTableData(user)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode");
        parent.ErrorInfo = Lang.getLang("St9002_NotJoinedTheRoom");
        actionResult.Result = False;
        return actionResult;
    chatService = DdzChatService(user)
    actionResult.ChatMaxNum = chatService.CurrVersion;
    chatAll = chatService.Receive();
    actionResult.chatList = chatAll.FindAll(lambda s:s.RoomId == user.Property.RoomId and s.TableId == user.Property.TableId)
    user.Property.ChatVesion = actionResult.ChatMaxNum;

    #需要实现
    return actionResult;
Ejemplo n.º 51
0
 def __init__(self, device,log_name):
     environ = os.environ
     self.device_id = environ.get(device)
     if (self.device_id == None):
         device_id = device
     self._device,self._easy_device,self.hierarchyviewer = self._connect_device(self.device_id)
     self._logger = createlogger(log_name)
     self._log_path = create_folder()
     self._config = GetConfigs("common")
     self._lang = Lang(device_id)
Ejemplo n.º 52
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = parent.Current.User.PersonalId

    # 加载数据出错
    def loadError():
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult

    userInfo = GameDataCacheSet[GameUser]().FindKey(userId)
    if not userInfo:
        return loadError()

    # 判断精灵数目 True if x >= 1 else False
    if userInfo.WizardNum >= 1:
        cacheSetFestivalInfo = ShareCacheStruct[FestivalInfo]().Find(
            match=lambda x: x.FestivalType == FestivalType.SpiritBlessing)
        if not cacheSetFestivalInfo or not cacheSetFestivalInfo.Reward:
            return loadError()

        rewardInfo = UserPrayHelper.GetUserTake(
            cacheSetFestivalInfo.Reward.ToList(), userId, 1)

        if not rewardInfo:
            return loadError()

        userInfo.WizardNum = userInfo.WizardNum - 1

        itemInfo = rewardInfo.split('*')
        reward = Reward()
        reward.content = itemInfo[0]
        reward.num = itemInfo[1]
        reward.headPic = itemInfo[2]
        reward.quality = itemInfo[3]
        actionResult.reward = reward
    else:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("St3013_NoWizard")
        actionResult.Result = False
    return actionResult
Ejemplo n.º 53
0
def takeAction(urlParam, parent):
    actionResult = ActionResult();
    userId = str(parent.Current.UserId)
    contextUser = PersonalCacheStruct.Get[GameUser](userId)
    userName = contextUser.NickName;
    
    mailInfoCacheSet = ShareCacheStruct[MailInfo]();
    mailInfo = mailInfoCacheSet.Find(lambda s:s.MailType ==  MathUtils.ToInt(MailType.Friends));
    if not mailInfo:
        actionResult.Result = False;
        return actionResult;

    # 判断是否为好友
    userFriendsCacheSet = ShareCacheStruct[UserFriends]();
    isUserFriends = userFriendsCacheSet.FindKey(userId.ToString(), urlParam.toUserID);
    isFriends = userFriendsCacheSet.FindKey(urlParam.toUserID, userId.ToString());
    if (isUserFriends and (isUserFriends.FriendType == FriendType.Friend)) or (isFriends and (isFriends.FriendType == FriendType.Friend)):
        contentLength = Text.Encoding.Default.GetByteCount(urlParam.content)
        if contentLength > mailInfo.MaxLength:
            parent.ErrorCode = Lang.getLang("ErrorCode");
            parent.ErrorInfo = Lang.getLang("St9302_OverMaxLength");
            actionResult.Result = False;
            return actionResult;
        tempMail = UserMail(Guid.NewGuid());
        tempMail.UserId = urlParam.toUserID;
        tempMail.MailType =  MailType.Friends;
        tempMail.FromUserId = userId;
        tempMail.FromUserName = userName;
        tempMail.ToUserID = urlParam.toUserID;
        tempMail.ToUserName = urlParam.toUserName;
        tempMail.Title = urlParam.title;
        tempMail.Content = urlParam.content;
        tempMail.SendDate = DateTime.Now;
        tempMail.IsGuide = urlParam.isGuide;
        tjxMailService = TjxMailService(contextUser);
        tjxMailService.Send(tempMail);
        return actionResult;

    parent.ErrorCode = Lang.getLang("ErrorCode");
    parent.ErrorInfo = Lang.getLang("St9302_IsNotFriend");
    actionResult.Result = False;
    return actionResult;
Ejemplo n.º 54
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()    
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    gameRoom = GameRoom.Current
    roomInfo = gameRoom.GetRoom(urlParam.RoomId)
    if not roomInfo or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    #if not user.RemoteAddress or user.RemoteAddress=='':
    #    parent.ErrorCode = Lang.getLang("ErrorCode")
    #    parent.ErrorInfo = Lang.getLang("St2001_ConnectError")
    #    actionResult.Result = False
    #    return actionResult
    if urlParam.Op == 2:
        #续局
        GameRoom.Current.Exit(user)
    else:
        #每日赠送金豆
        result = gameRoom.CheckDailyGiffCoin(user, roomInfo)
        if result:
            parent.ErrorCode = 3
            parent.ErrorInfo = gameRoom.Tip( Lang.getLang("St2001_GiffCoin"),  roomInfo.GiffCion)
            pass

    if user.GameCoin < roomInfo.MinGameCion:
        parent.ErrorCode = 2
        parent.ErrorInfo = gameRoom.Tip( Lang.getLang("St2001_CoinNotEnough"), user.GameCoin, roomInfo.MinGameCion)
        actionResult.Result = False
        return actionResult
    
    table = GameRoom.Current.GetTableData(user)
    actionResult.GameCoin = user.GameCoin
    if table and table.IsStarting and user.Property.TableId > 0:
        GameTable.Current.SyncNotifyAction(ActionIDDefine.Cst_Action2015, user, None, None)
        return actionResult
    else:
        gameRoom.Enter(user, roomInfo)
    return actionResult
Ejemplo n.º 55
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)
    table = GameRoom.Current.GetTableData(user)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    position = GameTable.Current.GetUserPosition(user, table)
    if not position:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    if (not table.PreCardData or table.PreCardData.PosId==position.Id)\
        and urlParam.Cards == '':
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("St2009_ReOutCardError")
        actionResult.Result = False
        return actionResult

    if position.IsAI:
        position.IsAI = False
        GameTable.Current.NotifyAutoAiUser(user.UserId, False)
    result = GameTable.Current.DoOutCard(user.UserId, user.Property.PositionId, table, urlParam.Cards)
    if not result[0]:
        errorCode = result[1]
        parent.ErrorCode = Lang.getLang("ErrorCode")
        if errorCode == 1:
            parent.ErrorInfo = Lang.getLang("St2009_OutCardError")
        elif errorCode == 2:
            parent.ErrorInfo = Lang.getLang("St2009_OutCardNoExist")
        elif errorCode == 3:
            parent.ErrorInfo = Lang.getLang("St2009_OutCardExitPos")
        actionResult.Result = False
        return actionResult

    GameTable.Current.ReStarTableTimer(table)
    return actionResult
Ejemplo n.º 56
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    table = GameRoom.Current.GetTableData(user)
    if not table or not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    
    if table.IsCallEnd:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("St2005_CalledIsEnd")
        actionResult.Result = False
        return actionResult
    position = GameTable.Current.GetUserPosition(user, table)
    if not position:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    if position.IsAI:
        position.IsAI = False
        GameTable.Current.NotifyAutoAiUser(user.UserId, False)
    isCall = urlParam.op == 1 and True or False
    GameTable.Current.CallCard(user.Property.PositionId, table, isCall)
    GameTable.Current.ReStarTableTimer(table)
    return actionResult
Ejemplo n.º 57
0
def takeAction(urlParam, parent):
    actionResult = ActionResult();
    userId = str(parent.Current.UserId)
    packageCacheSet = PersonalCacheStruct[UserItemPackage]();
    if not packageCacheSet:
        actionResult.Result = False;
        return actionResult;
    userItemPack = packageCacheSet.FindKey(userId);
    if not userItemPack or not userItemPack.ItemPackage:
        parent.ErrorCode = Lang.getLang("ErrorCode");
        parent.ErrorInfo = Lang.getLang("LoadError");
        actionResult.Result = False;
        return actionResult;
    userItem = userItemPack.ItemPackage.Find(lambda s:s.UserItemID == urlParam.userItemID);
    if userItem == None:
        parent.ErrorCode = Lang.getLang("ErrorCode");
        parent.ErrorInfo = Lang.getLang("LoadError");
        actionResult.Result = False;
        return actionResult;
    itemID = userItem.ItemID;
    if userItem.ItemType != ItemType.DaoJu or userItem.PropType != 19:
        parent.ErrorCode = Lang.getLang("ErrorCode");
        parent.ErrorInfo = Lang.getLang("St1114_IsNotGiftBag");
        actionResult.Result = False;
        return actionResult;
    itemBaseInfoCacheStruct = ShareCacheStruct[ItemBaseInfo]();
    baseInfo = itemBaseInfoCacheStruct.FindKey(itemID.ToString());
    if not baseInfo:
        parent.ErrorCode = Lang.getLang("ErrorCode");
        parent.ErrorInfo = Lang.getLang("LoadError");
        actionResult.Result = False;
        return actionResult;
    if baseInfo.ItemType != ItemType.DaoJu or baseInfo.PropType != 19:
        parent.ErrorCode = Lang.getLang("ErrorCode");
        parent.ErrorInfo = Lang.getLang("St1114_IsNotGiftBag");
        actionResult.Result = False;
        return actionResult;
    actionResult.prizeInfoList = baseInfo.ItemPack;
    return actionResult;
Ejemplo n.º 58
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    if not user:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("LoadError")
        actionResult.Result = False
        return actionResult
    # 需要实现
    actionResult.FleeUserId = urlParam.FleeUserId
    if actionResult.FleeUserId > 0:
        fuser = GameTable.Current.GetUser(actionResult.FleeUserId)
        if fuser:
            actionResult.FleeNickName = fuser.NickName
    table = GameRoom.Current.GetTableData(user)
    if table:
        pos = GameTable.Current.GetUserPosition(user, table)
        actionResult.InsScoreNum = pos.ScoreNum
        actionResult.InsCoinNum = pos.CoinNum
    actionResult.GameCoin = user.GameCoin
    actionResult.ScoreNum = user.ScoreNum
    return actionResult