%%%-------------------------------------------------------------------
%%% @author  tyl
%%% @doc
%%%      成就触发逻辑模块
%%% @end
%%% Created : 2021-03-15
%%%-------------------------------------------------------------------
-module(lib_achievement_trigger).

-include("achievement.hrl").
-include("common.hrl").

-export([trigger/3]).

trigger([], _, AchievementInfo) -> AchievementInfo;
trigger([{role_lv, Lv}|L], [{role_lv, NeedLv}] = Condition, AchievementInfo) when is_integer(Lv) ->
    case Lv >= NeedLv of
        true ->
            NewProgress = NeedLv,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Lv}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{own_friend, Num}|L], [{own_friend, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{world_chat, Num}|L], [{world_chat, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{guild_chat, Num}|L], [{guild_chat, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{private_chat, Num}|L], [{private_chat, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{point, Num}|L], [{point, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{honour, Num}|L], [{honour, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{point_store, Num}|L], [{point_store, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{honour_store, Num}|L], [{honour_store, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{equip_stone_sum_lv, EquipStoneList}|L], [{equip_stone_sum_lv, NeedNum}] = Condition, AchievementInfo) ->
    F = fun({Stage, Num}, Acc) ->
        Stage * Num + Acc
        end,
    Sum = lists:foldl(F, 0, EquipStoneList),
    if
        Sum >= NeedNum ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        true ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Sum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{equip_num, EquipList}|L], [{equip_num, NeedNum}, {equip_lv, NeedLv}, {equip_color, NColor}] = Condition, AchievementInfo) ->
    F = fun({Lv, Color, Num}, Acc) ->
        if
            Lv == NeedLv andalso Color >= NColor ->
                Acc + Num;
            true ->
                Acc
        end
    end,
    Sum = lists:foldl(F, 0, EquipList),
    if
        Sum >= NeedNum ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        true ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Sum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{equip_stren_sum_lv, EquipList}|L], [{equip_stren_sum_lv, NeedLv}] = Condition, AchievementInfo) ->
    F = fun({Lv, Num}, Acc) ->
        Lv * Num + Acc
        end,
    Sum = lists:foldl(F, 0, EquipList),
    if
        Sum >= NeedLv ->
            NewProgress = NeedLv,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        true ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Sum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{equip_up_sum_lv, EquipList}|L], [{equip_up_sum_lv, NeedNum}] = Condition, AchievementInfo) ->
    F = fun({Lv, Num}, Acc) ->
        Lv * Num + Acc
        end,
    Sum = lists:foldl(F, 0, EquipList),
    if
        Sum >= NeedNum ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        true ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Sum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{red_equip_num, EquipList}|L], [{red_equip_num, NeedNum}, {red_equip_stage, Lv}] = Condition, AchievementInfo) ->
    Sum = case lists:keyfind(Lv, 1, EquipList) of
              {_, Num} -> Num;
              _ -> 0
          end,
    if
        Sum >= NeedNum ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        true ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Sum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{pet_sum_lv, PetList}|L], [{pet_sum_lv, NeedLv}] = Condition, AchievementInfo) ->
    F = fun({Lv, Num}, Acc) ->
        Lv * Num + Acc
        end,
    Sum = lists:foldl(F, 0, PetList),
    if
        Sum >= NeedLv ->
            NewProgress = NeedLv,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        true ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Sum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{pet_color, PetList}|L], [{pet_num, NeedNum},{pet_color, NeedColor}] = Condition, AchievementInfo) ->
    F = fun({Color, Num}, Acc) ->
        if
            Color >= NeedColor ->
                Acc + Num;
            true ->
                Acc
        end end,
    Sum = lists:foldl(F, 0, PetList),
    if
        Sum >= NeedNum ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        true ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Sum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{pet_stone_num, SkillList}|L], [{pet_stone_num, NeedNum},{pet_stone_color, NeedColor}] = Condition, AchievementInfo) ->
    F = fun({Color, Num}, Acc) ->
        if
            Color >= NeedColor ->
                Acc + Num;
            true ->
                Acc
        end
    end,
    Sum = lists:foldl(F, 0, SkillList),
    if
        Sum >= NeedNum ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        true ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Sum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{foster_lv, [Type, Grade]}|L], [{foster_lv, NeedGrade}, {foster, NeedType}] = Condition, AchievementInfo) ->
    if
        Type == NeedType andalso Grade >= NeedGrade ->
            NewProgress = Grade,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        Type == NeedType ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Grade};
        true ->
            NewAchievementInfo = AchievementInfo
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{activity_point, Num}|L], [{activity_point, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{kill_reward_boss, Num}|L], [{kill_reward_boss_num, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{kill_per_boss, Num}|L], [{kill_per_boss_num, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{kill_world_boss_count, Num}|L], [{kill_world_boss_count, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{world_boss_last_att, Num}|L], [{world_boss_last_att, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{multi_dun_num, Num}|L], [{multi_dun_num, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case  Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{dun_exp, Num}|L], [{dun_exp, NeedTimes}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num >= NeedTimes of
        true ->
            NewProgress = NeedTimes,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = max(Num,Progress)}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{dun_tower, Num}|L], [{dun_tower, NeedTimes}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num >= NeedTimes of
        true ->
            NewProgress = NeedTimes,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = max(Num, Progress)}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{dun_visus, Data}|L], [{dun_visus, NeedFloor, NeedWave}] = Condition, AchievementInfo) ->
    case Data of
        {Floor, Wave} -> ok;
        _ -> Floor = 0, Wave = 0
    end,
    case Floor > NeedFloor of
        true ->
            NewProgress = NeedWave,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            case Floor == NeedFloor of
                true ->
                    case Wave >= NeedWave of
                        true ->
                            NewProgress = NeedWave,
                            NewStatus = ?ACHV_FINISH,
                            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
                        _ ->
                            NewAchievementInfo = AchievementInfo#achievement{progress = Wave}
                    end;
                _ ->
                    NewAchievementInfo = AchievementInfo
            end
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{win_arena_count, Num}|L], [{win_arena_count, NeedTimes}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedTimes of
        true ->
            NewProgress = NeedTimes,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{arena_rank, Ranking}|L], [{arena_rank, NeedRanking}] = Condition, AchievementInfo) when Ranking =< NeedRanking ->
    NewAchievementInfo = AchievementInfo#achievement{progress = 1, status = ?ACHV_FINISH},
    trigger(L, Condition, NewAchievementInfo);
trigger([{void_fam_kill_enemy, Num}|L], [{void_fam_kill_enemy, NeedTimes}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedTimes of
        true ->
            NewProgress = NeedTimes,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{void_fam_score, Num}|L], [{void_fam_score, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{beach, Num}|L], [{beach, NeedTimes}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedTimes of
        true ->
            NewProgress = NeedTimes,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{husong, Num}|L], [{husong, NeedTimes}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedTimes of
        true ->
            NewProgress = NeedTimes,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{visus, Num}|L], [{visus, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{visus_power, Power}|L], [{visus_power, NeedPower}] = Condition, AchievementInfo) ->
    case Power >= NeedPower of
        true ->
            NewProgress = NeedPower,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Power}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{uranium_skill, [{SkillId, Lv}|_]}|L], [{uranium_skill, NeedSkillId, NeedLv}] = Condition, AchievementInfo) ->
    case SkillId =:= NeedSkillId andalso Lv >= NeedLv of
        true ->
            NewProgress = NeedLv,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        _ ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Lv}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{career_skill, Num}|L], [{career_skill, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{career_skill_up, Num}|L], [{career_skill_up, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{career_skill_lv, Data}|L], [{num, NeedNum}, {career_skill_lv, NeedLv}] = Condition, AchievementInfo) ->
    F = fun({_, Lv}, TNum) ->
        case Lv >= NeedLv of
            true -> TNum + 1;
            _ -> TNum
        end end,
    SumNum = lists:foldl(F, 0, Data),
    case SumNum >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = SumNum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{spec_skill, Num}|L], [{spec_skill, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{passive_skill_sum_lv, SumLv}|L], [{passive_skill_sum_lv, NeedLv}] = Condition, AchievementInfo) ->
    case SumLv >= NeedLv of
        true ->
            NewProgress = NeedLv,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = SumLv}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{foster, Data}|L], [{stage, NeedStage}, {star, NeedStar}, {foster, NeedType}] = Condition, AchievementInfo) ->
    case lists:keyfind(NeedType, 1, Data) of
        {_Type, Stage, Star} when Stage > NeedStage orelse (Stage =:= NeedStage andalso Star >= NeedStar) ->
            NewProgress = 1,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        _ ->
            NewAchievementInfo = AchievementInfo
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{foster1, Data}|L], [{lv, NeedLv}, {foster1, NeedType}] = Condition, AchievementInfo) ->
    case lists:keyfind(NeedType, 1, Data) of
        {_Type, Lv} ->
            case Lv >= NeedLv of
                true ->
                    NewProgress = NeedLv,
                    NewStatus = ?ACHV_FINISH,
                    NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
                _ ->
                    NewAchievementInfo = AchievementInfo#achievement{progress = Lv}
            end;
        _ ->
            NewAchievementInfo = AchievementInfo
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{foster_equip, {Type, ColorMap}}|L], [{num, NeedNum}, {foster_equip, NeedType}, {color, NeedColor}] = Condition, AchievementInfo) ->
    case Type =:= NeedType of
        true ->
            ColorList = maps:to_list(ColorMap),
            F = fun(Tuple, TCalcNum) ->
                case Tuple of
                    {TColor, TNum} when TColor >= NeedColor, TNum > TCalcNum -> TNum;
                    _ -> TCalcNum
                end end,
            CalcNum = lists:foldl(F, 0, ColorList),
            case CalcNum >= NeedNum of
                true ->
                    NewProgress = NeedNum,
                    NewStatus = ?ACHV_FINISH,
                    NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
                _ ->
                    NewAchievementInfo = AchievementInfo#achievement{progress = CalcNum}
            end;
        _ ->
            NewAchievementInfo = AchievementInfo
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{foster_skill_sum_lv, Data}|L], [{foster_skill_sum_lv, NeedLv}] = Condition, AchievementInfo) ->
    F = fun({_, Lv}, TSumLv) ->
        Lv + TSumLv
        end,
    SumLv = lists:foldl(F, 0, Data),
    case SumLv >= NeedLv of
        true ->
            NewProgress = NeedLv,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = SumLv}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{shop_buy_equip, Num}|L], [{shop_buy_equip, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{shop_sell_equip, Num}|L], [{shop_sell_equip, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{equip_wear, Data}|L], [{num, NeedNum}, {equip_wear, NeedType}, {color, NeedColor}] = Condition, AchievementInfo) ->
    case lists:keyfind(NeedType, 1, Data) of
        {_, ColorMap} ->
            ColorList = maps:to_list(ColorMap),
            F = fun({Color, Num}, TSum) ->
                case Color >= NeedColor of
                    true -> Num + TSum;
                    _ -> TSum
                end end,
            Sum = lists:foldl(F, 0, ColorList),
            case Sum >= NeedNum of
                true ->
                    NewProgress = NeedNum,
                    NewStatus = ?ACHV_FINISH,
                    NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
                false ->
                    NewAchievementInfo = AchievementInfo#achievement{progress = Sum}
            end;
        _ ->
            NewAchievementInfo = AchievementInfo
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{war_soul_on, Data}|L], [{war_soul_on, NeedNum}, {color, NeedColor}] = Condition, AchievementInfo) ->
    F = fun({Color, Num}, TNum) ->
        case Color >= NeedColor of
            true -> Num + TNum;
            _ -> TNum
        end end,
    SumNum = lists:foldl(F, 0, Data),
    case SumNum >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = SumNum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{war_soul_up, SumLv}|L], [{war_soul_up, NeedLv}] = Condition, AchievementInfo) ->
    case SumLv >= NeedLv of
        true ->
            NewProgress = NeedLv,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = SumLv}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{war_soul_star, SumLv}|L], [{war_soul_star, NeedLv}] = Condition, AchievementInfo) ->
    case SumLv >= NeedLv of
        true ->
            NewProgress = NeedLv,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = SumLv}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{pet_stone_suit, Data}|L], [{pet_stone_suit, NeedNum}, {color, NeedColor}] = Condition, AchievementInfo) ->
    F = fun({Color, Num}, TSum) ->
        case Color >= NeedColor of
            true -> Num + TSum;
            _ -> TSum
        end;
        (_, TSum) ->
            TSum
        end,
    SumNum = lists:foldl(F, 0, maps:to_list(Data)),
    case SumNum >= NeedNum of
        true ->
            NewProgress = SumNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = SumNum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{pet_awaken_sum_lv, SumLv}|L], [{pet_awaken_sum_lv, NeedLv}] = Condition, AchievementInfo) ->
    case SumLv >= NeedLv of
        true ->
            NewProgress = NeedLv,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = SumLv}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{nucleon_suit, Data}|L], [{nucleon_suit, NeedNum}, {color, NeedColor}] = Condition, AchievementInfo) ->
    F = fun({Color, Num}, TSum) ->
            case Color >= NeedColor of
                true -> Num + TSum;
                _ -> TSum
            end;
        (_, TSum) ->
            TSum
    end,
    SumNum = lists:foldl(F, 0, Data),
    case SumNum >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = SumNum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{nucleon_awaken_sum_lv, SumLv}|L], [{nucleon_awaken_sum_lv, NeedLv}] = Condition, AchievementInfo) ->
    case SumLv >= NeedLv of
        true ->
            NewProgress = NeedLv,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = SumLv}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{god_active, Num}|L], [{god_active, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{god_lv, SumLv}|L], [{god_lv, NeedLv}] = Condition, AchievementInfo) ->
    case SumLv >= NeedLv of
        true ->
            NewProgress = NeedLv,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = SumLv}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{god_equip, Data}|L], [{god_equip, NeedNum}, {color, NeedColor}] = Condition, AchievementInfo) ->
    F = fun({Color, Num}, TSum) ->
        case Color >= NeedColor of
            true -> Num + TSum;
            _ -> TSum
        end;
        (_, TSum) ->
            TSum
        end,
    SumNum = lists:foldl(F, 0, Data),
    case SumNum >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = SumNum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{god_equip_lv, Data}|L], [{god_equip_lv, NeedLv}] = Condition, AchievementInfo) ->
    F = fun({_, Lv}, TLv) ->
                case Lv >= TLv of
					true -> Lv;
					_ -> TLv
                end;
            (_, TLv) -> TLv
        end,
    NowLv = lists:foldl(F, 0, Data),
	case NowLv >= NeedLv of
        true ->
            NewProgress = NeedLv,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
	        NewAchievementInfo = AchievementInfo#achievement{progress = NowLv}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{god_suit, SumNum}|L], [{god_suit, NeedNum}] = Condition, AchievementInfo) ->
    case SumNum >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = SumNum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{galaxy_wear, Data}|L], [{galaxy_wear, NeedNum}, {color, NeedColor}] = Condition, AchievementInfo) ->
    case lists:keyfind(NeedColor, 1, Data) of
        {_, Num} when Num >= NeedNum ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        {_, Num} ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num};
        _ ->
            NewAchievementInfo = AchievementInfo
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{galaxy_shop_refresh, Num}|L], [{galaxy_shop_refresh, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        _ ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{galaxy_shop_buy, Num}|L], [{galaxy_shop_buy, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        _ ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{flower, Value}|L], [{flower, NeedValue}] = Condition, AchievementInfo) ->
    case Value >= NeedValue of
        true ->
            NewProgress = NeedValue,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Value}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{support, Num}|L], [{support, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{guild_thank, Num}|L], [{guild_thank, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{mate, Num}|L], [{mate, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{child_vote, Num}|L], [{child_vote, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{child_show, Num}|L], [{child_show, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{guild_boss, Num}|L], [{guild_boss, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{guild_collect, Num}|L], [{guild_collect, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{guild_collect_support_kill, Num}|L], [{guild_collect_support_kill, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{guild_feast, Num}|L], [{guild_feast, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{guild_auction_get, Num}|L], [{guild_auction_get, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{glamour, Num}|L], [{glamour, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{glamour_coin, Num}|L], [{glamour_coin, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{wasteland_war, Num}|L], [{wasteland_war, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{guild_war, Num}|L], [{guild_war, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{guild_war_military, Num}|L], [{guild_war_military, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{cross_guild_war, Num}|L], [{cross_guild_war, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{cross_guild_war_collect, Num}|L], [{cross_guild_war_collect, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{deserted_boss, Num}|L], [{deserted_boss, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{deserted_elite, Num}|L], [{deserted_elite, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{dun_exp_quick, Num}|L], [{dun_exp_quick, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{dun_material, Num}|L], [{dun_material, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{dun_pet, Num}|L], [{dun_pet, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{dun_god, Num}|L], [{dun_god, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{dun_galaxy_pass, Chapter}|L], [{dun_galaxy_pass, NeedChapter}] = Condition, AchievementInfo) ->
    case Chapter >= NeedChapter of
        true ->
            NewProgress = NeedChapter,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Chapter}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{cross_point_fight, Num}|L], [{cross_point_fight, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{cross_country_war, Num}|L], [{cross_country_war, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{guild_donate_get, Num}|L], [{guild_donate_get, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{guild_donate_use, Num}|L], [{guild_donate_use, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num + Progress >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num + Progress}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{active_fashion, Num}|L], [{active_fashion, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{active_designation, Num}|L], [{active_designation, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{active_dress_up, Num}|L], [{active_dress_up, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{wardrobe_value, Num}|L], [{wardrobe_value, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{foster_skin_active, Num}|L], [{foster_skin_active, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{foster_skin_sum_star, Num}|L], [{foster_skin_sum_star, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{child_toy_active, Num}|L], [{child_toy_active, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{child_toy_suit, Num}|L], [{child_toy_suit, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{child_skill, Num}|L], [{child_skill, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{child_fashion, Num}|L], [{child_fashion, NeedNum}] = Condition, AchievementInfo) ->
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Num}
    end,
    trigger(L, Condition, NewAchievementInfo);


%% ================================================================================================================
%% ================================================================================================================
trigger([{equip_wash, ColorList}|L], [{property_num, NeedNum}, {property_color, NeedColor}] = Condition, AchievementInfo) ->
    F = fun(Info, Acc) ->
        {Color, Num} = Info,
        case Color >= NeedColor of
            true -> Acc + Num;
            false -> Acc
        end
    end,
    Sum = lists:foldl(F, 0, ColorList),
    case Sum >= NeedNum of
        true ->
            NewAchievementInfo = AchievementInfo#achievement{progress = NeedNum, status = ?ACHV_FINISH};
        false -> NewAchievementInfo = AchievementInfo#achievement{progress = Sum}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{equip_suit, [NeedType, NeedLv, SLv, Num]}|L], [{suit_type, NeedType}, {suit_lv, NeedLv}, {suit_class, NeedSLv}, {suit_num, NeedNum}] = Condition, AchievementInfo) when SLv >= NeedSLv ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = max(Num, Progress)}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{sign, _}|L], [{sign_count, NeedTimes}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Progress + 1 >= NeedTimes of
        true ->
            NewProgress = NeedTimes,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Progress + 1}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{kill_monster, _}|L], [{kill_monster, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Progress + 1 >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Progress + 1}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{kill_player, _}|L], [{kill_player, NeedTimes}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Progress + 1 >= NeedTimes of
        true ->
            NewProgress = NeedTimes,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Progress + 1}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{kill_red_name, _}|L], [{kill_red_player, NeedTimes}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Progress + 1 >= NeedTimes of
        true ->
            NewProgress = NeedTimes,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Progress + 1}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{death, _}|L], [{death, NeedTimes}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Progress + 1 >= NeedTimes of
        true ->
            NewProgress = NeedTimes,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Progress + 1}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{role_charm, Num}|L], [{flower_get, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Num >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = max(Num, Progress)}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{monster_id, Id}|L], [{monster_num, NeedNum}, {monster_id, NeedId}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Id == NeedId andalso Progress + 1 >= NeedNum of
        true ->
            case Progress + 1 >= NeedNum of
                true ->
                    NewProgress = NeedNum,
                    NewStatus = ?ACHV_FINISH,
                    NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
                false ->
                    NewAchievementInfo = AchievementInfo#achievement{progress = Progress + 1}
            end;
        false ->
                NewAchievementInfo = AchievementInfo
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([{beat, _}|L], [{beat_num, NeedNum}] = Condition, AchievementInfo) ->
    #achievement{progress = Progress} = AchievementInfo,
    case Progress + 1 >= NeedNum of
        true ->
            NewProgress = NeedNum,
            NewStatus = ?ACHV_FINISH,
            NewAchievementInfo = AchievementInfo#achievement{progress = NewProgress, status = NewStatus};
        false ->
            NewAchievementInfo = AchievementInfo#achievement{progress = Progress + 1}
    end,
    trigger(L, Condition, NewAchievementInfo);
trigger([_|L], Condition, AchievementInfo) ->
    trigger(L, Condition, AchievementInfo).