%%%-------------------------------------------------------------------
%%% @doc    衣橱协议模块
%%% Module  : pp_wardrobe.erl
%%% Created : 2020-11-19
%%% @Author : tyl
%%% @end
%%%-------------------------------------------------------------------
-module(pp_wardrobe).

-include("common.hrl").
-include("server.hrl").
-include("child.hrl").
-include("figure.hrl").
-include("def_module.hrl").
-include("predefine.hrl").
-include("errcode.hrl").


-export([handle/3]).

handle(Cmd, Status, Data) ->
	#player_status{figure = Figure} = Status,
	OpenLv = lib_module:get_open_lv(?MOD_WARDROBE),
	case Figure#figure.lv >= OpenLv of
		true ->
			do_handle(Cmd, Status, Data);
		false -> skip
	end.

%% 衣橱信息
do_handle(42200, Player, []) ->
	lib_wardrobe:send_wardrobe_info(Player);

%% 商品信息
do_handle(42202, Player, [StoreId]) ->
	wardrobe_store:send_store_goods(Player, StoreId),
	{ok, Player};

%% 购买商品
do_handle(42203, Player, [StoreId, GoodTypeId, BuyTimes]) ->
	wardrobe_store:buy_goods(Player, StoreId, GoodTypeId, BuyTimes);

do_handle(_Cmd, _PS, _Args) ->
	?ERR("Nomatch Cmd:~p Args:~p", [_Cmd, _Args]),
	{ok, _PS}.
