Exemplo n.º 1
0
 public override bool TakeAction()
 {
     if (!string.IsNullOrEmpty(ContextUser.MercenariesID))
     {
         GuildMember member = new ShareCacheStruct <GuildMember>().FindKey(ContextUser.MercenariesID, ContextUser.UserID);
         if (member != null && member.PostType == PostType.Member)
         {
             ErrorCode = LanguageManager.GetLang().ErrorCode;
             ErrorInfo = LanguageManager.GetLang().St6007_AuditPermissions;
             return(false);
         }
         UserGuild guild = new ShareCacheStruct <UserGuild>().FindKey(ContextUser.MercenariesID);
         if (guild != null && guild.AbilityInfo.Count > 0)
         {
             GuildAbility ability = guild.AbilityInfo.Find(m => m.ID == guildSkillID);
             if (ability != null)
             {
                 GuildAbilityLvInfo abilityLvInfo = new ShareCacheStruct <GuildAbilityLvInfo>().FindKey(ability.ID, ability.Lv);
                 if (abilityLvInfo != null && ability.Lv < 10)
                 {
                     if (abilityLvInfo.UpDonateNum > guild.CurrDonateNum)
                     {
                         ErrorCode = LanguageManager.GetLang().ErrorCode;
                         ErrorInfo = LanguageManager.GetLang().St6205_GuildMemberDonateNotEnough;
                         return(false);
                     }
                     GuildAbilityInfo abilityInfo = new ShareCacheStruct <GuildAbilityInfo>().FindKey(ability.ID);
                     if (abilityInfo != null)
                     {
                         guild.CurrDonateNum = MathUtils.Subtraction(guild.CurrDonateNum, abilityLvInfo.UpDonateNum, 0);
                         ability.Lv          = MathUtils.Addition(ability.Lv, (short)1);
                         abilityLvInfo       = new ShareCacheStruct <GuildAbilityLvInfo>().FindKey(ability.ID, ability.Lv);
                         ability.Type        = abilityInfo.GuildAbilityType;
                         ability.Num         = abilityLvInfo.EffectNum;
                         //guild.Update();
                         CombatHelper.UpGuildAbilityLv(ContextUser.MercenariesID, ability); //加载公会技能升级
                         ErrorCode = 0;
                         ErrorInfo = string.Format(LanguageManager.GetLang().St6205_GuildMemberJiNengShengJi, abilityInfo.AbilityName, ability.Lv);
                     }
                 }
             }
         }
     }
     else
     {
         ErrorCode = LanguageManager.GetLang().ErrorCode;
         ErrorInfo = LanguageManager.GetLang().St6203_GuildMemberNotEnough;
         return(false);
     }
     return(true);
 }