%% ---------------------------------------------------------------------------
%% @doc lib_fake_role.erl
%% @author  ywf
%% @email  a349162727@qq.com
%% @since  2018-12-17
%% @deprecated 假人
%% ---------------------------------------------------------------------------
-module(lib_fake_role).

-include("fake_role.hrl").
-include("attr.hrl").
-include("def_fun.hrl").

-compile([export_all]).

%% 副本获取假人战斗属性
get_dungeon_faker_role_attr(Lv, _CombatPower) ->
    case data_fake_role:get_fake_role(Lv) of
        #fake_role_cfg{attr_list = AttrList, combat = Combat} ->
            % NewRatio = max(1, CombatPower/Combat * 0.85),
            % NewAttrList = [{?SPEED, ?SPEED_VALUE}] ++ [{AttrId, round(AttrVal * NewRatio)}||{AttrId, AttrVal}<-AttrList],
            NewAttrList = [{?SPEED, ?SPEED_VALUE}] ++ AttrList,
            lib_player_attr:set_battle_attr(#battle_attr{attr = #attr{}, combat_power = Combat}, NewAttrList);
        _ ->
            make_default_battle_attr(10000)
    end.

%% 获取假人战斗属性
get_faker_role_attr(Lv) ->
	get_faker_role_attr(Lv, 10000, 0, 0).
get_faker_role_attr(Lv, CombatPower) ->
	get_faker_role_attr(Lv, CombatPower, 0, 0).
get_faker_role_attr(Lv, CombatPower, _ModuleId, _SubId) ->
	Ratio = 100,
	get_faker_role_attr(Lv, CombatPower, Ratio / 100).

get_faker_role_attr(Lv, CombatPower, Ratio) ->
    NewRatio = ?IF(Ratio=<0, 1, Ratio),
	case data_fake_role:get_fake_role(Lv) of
		#fake_role_cfg{attr_list = AttrList, combat = Combat} ->
			NewAttrList = [{?SPEED, ?SPEED_VALUE}] ++ [{AttrId, round(AttrVal * NewRatio)}||{AttrId, AttrVal}<-AttrList],
			lib_player_attr:set_battle_attr(#battle_attr{attr = #attr{}, combat_power = Combat}, NewAttrList);
		_ ->
			make_default_battle_attr(CombatPower)
	end.


%% 创建默认战斗属性
make_default_battle_attr(CombatPower) ->
    #battle_attr{
        hp     = round(CombatPower * 0.8),
        hp_lim = round(CombatPower * 0.8),
        attr   = #attr{hp = round(CombatPower * 0.8), att = round(CombatPower * 0.025)},
        combat_power = CombatPower
    }.

