%%-----------------------------------------------------------------------------
%% @Module  :       lib_dungeon_sample.erl
%% @Author  :       J
%% @Email   :       j-som@foxmail.com
%% @Created :       2018-02-05
%% @Description:    示例
%%-----------------------------------------------------------------------------

-module(lib_dungeon_sample).

-include("dungeon.hrl").

-export ([
    dispatch_dun_event/2
    ]).

-spec dispatch_dun_event(Msg, State) -> ReturnVal when
    Msg :: term(),
    State :: #dungeon_state{},
    ReturnVal :: #dungeon_state{}.

%% 拦截事件,即自己处理
%% 如拦截了{'create_mon', MonList}表示自己创建怪物,不走默认处理
dispatch_dun_event({'create_mon', _MonList}, State) ->
    %% // ....
    State;
    
%% 不需要拦截事件时直接默认返回
%% dungeon_default模块处理
dispatch_dun_event(Msg, State) ->
    dungeon_default:dispatch_dun_event(Msg, State).