package com.tagmae.tsgame_erwang;

import com.game.webgame.view.pmutil;
import com.orhanobut.logger.Logger;
import com.tsgame.tsgame_niuniu.Bean1.Agentlist;
import com.tsgame.tsgame_niuniu.Bean1.Channellist;
import com.tsgame.tsgame_niuniu.Bean1.ConfigData;
import com.tsgame.tsgame_niuniu.Bean1.Gamelist;
import com.tsgame.tsgame_niuniu.Bean1.Marketlist;
import com.tsgame.tsgame_niuniu.Bean1.gameversionUtil;
import com.tsgame.tsgame_niuniu.util.apputil;

public class GameupdateUtil {


    public gameversionUtil agentUtil(ConfigData mconfigData, Agentlist magentlist, Gamelist Ygamelist){

        gameversionUtil mgameversionutil=new gameversionUtil();

        if(magentlist!=null){
            if(!pmutil.isnullorEmpty(magentlist.getAgentid())){
                if(magentlist.getAgentid().equals(mconfigData.getAgentid())){
                    setshowmessage(magentlist.getShowmessage());
                    if(magentlist.getChannellist()!=null){
                        for(int i=0;i<magentlist.getChannellist().size();i++){

                            Channellist mChannellist=magentlist.getChannellist().get(i);
                            if(!pmutil.isnullorEmpty(mChannellist.getChannelid())){
                                if(mChannellist.getChannelid().equals(mconfigData.getChannelid())){

                                    setshowmessage(mChannellist.getShowmessage());
                                    if(mChannellist.getMarketlist()!=null){
                                        for(int j=0;j<mChannellist.getMarketlist().size();j++){

                                            Marketlist marketlist=mChannellist.getMarketlist().get(j);
                                            if(!pmutil.isnullorEmpty(marketlist.getMarketid())){
                                                if(marketlist.getMarketid().equals(mconfigData.getMarketid())){

                                                    setshowmessage(marketlist.getShowmessage());

                                                    if(!pmutil.isnullorEmpty(marketlist.getApp_download())&&!pmutil.isnullorEmpty(marketlist.getApp_version())){
                                                        Logger.v("代理市场层配置app升级");

                                                        mgameversionutil.setApp_download(marketlist.getApp_download());
                                                        mgameversionutil.setApp_version(marketlist.getApp_version());

                                                    }
                                                    if(marketlist.getGamelist()!=null){
                                                        for(int k=0;k<marketlist.getGamelist().size();k++){
                                                            Gamelist mgamelist=marketlist.getGamelist().get(k);
                                                            if(!pmutil.isnullorEmpty(mgamelist.getGameid())){
                                                                if(mgamelist.getGameid().equals(mconfigData.getGameid())){

                                                                    setshowmessage(mgamelist.getShowmessage());

                                                                    if(!pmutil.isnullorEmpty(mgamelist.getApp_download())&&!pmutil.isnullorEmpty(mgamelist.getApp_version())){
                                                                        mgameversionutil.setApp_download(mgamelist.getApp_download());
                                                                        mgameversionutil.setApp_version(mgamelist.getApp_version());
                                                                        Logger.v("代理游戏层配置app升级");


                                                                    }
                                                                    if(!pmutil.isnullorEmpty(mgamelist.getGame_download())&&!pmutil.isnullorEmpty(mgamelist.getGame_version())){
                                                                        Logger.v("代理游戏层配置游戏升级");
                                                                        mgameversionutil.setGame_download(mgamelist.getGame_download());
                                                                        mgameversionutil.setGame_version(mgamelist.getGame_version());

                                                                    }



                                                                }
                                                            }


                                                        }
                                                    }



                                                }
                                            }

                                        }

                                    }

                                    break;
                                }
                            }




                        }
                    }


                    Logger.v("代理配置文件完成");



                }else{
                    Logger.v("代理配置文件不匹配");
                }
            }else{
                Logger.v("没有配置代理ID");
            }

        }
       if(Ygamelist!=null){
           if(!pmutil.isnullorEmpty(Ygamelist.getGameid())){
               if(Ygamelist.getGameid().equals(mconfigData.getGameid())){
                   mgameversionutil=new gameversionUtil();
                   setshowmessage(Ygamelist.getShowmessage());
                   if(!pmutil.isnullorEmpty(Ygamelist.getGame_download())&&!pmutil.isnullorEmpty(Ygamelist.getGame_version())){
                       Logger.t("chulipeizhiGame").v("游戏层配置游戏升级");
                       mgameversionutil.setGame_download(Ygamelist.getGame_download());
                       mgameversionutil.setGame_version(Ygamelist.getGame_version());

                   }
                   if(Ygamelist.getAgentlist()!=null){
                       for(int i=0;i<Ygamelist.getAgentlist().size();i++){
                           Agentlist mAgentlist=Ygamelist.getAgentlist().get(i);
                           if(!pmutil.isnullorEmpty(mAgentlist.getAgentid())){
                               if(mAgentlist.getAgentid().equals(mconfigData.getAgentid())){
                                   setshowmessage(mAgentlist.getShowmessage());

                                   if(!pmutil.isnullorEmpty(mAgentlist.getGame_download())&&!pmutil.isnullorEmpty(mAgentlist.getGame_version())){
                                       Logger.t("chulipeizhiGame").v("游戏代理层配置游戏升级");
                                       mgameversionutil.setGame_download(mAgentlist.getGame_download());
                                       mgameversionutil.setGame_version(mAgentlist.getGame_version());

                                   }
                                   if(mAgentlist.getChannellist()!=null){
                                       for(int j=0;j<mAgentlist.getChannellist().size();j++){

                                           Channellist mChannellist=mAgentlist.getChannellist().get(j);
                                           if(!pmutil.isnullorEmpty(mChannellist.getChannelid())){
                                               if(mChannellist.getChannelid().equals(mconfigData.getChannelid())){

                                                   setshowmessage(mChannellist.getShowmessage());

                                                   if(!pmutil.isnullorEmpty(mChannellist.getGame_download())&&!pmutil.isnullorEmpty(mChannellist.getGame_version())){
                                                       Logger.t("chulipeizhiGame").v("游戏渠道层配置游戏升级");
                                                       mgameversionutil.setGame_download(mChannellist.getGame_download());
                                                       mgameversionutil.setGame_version(mChannellist.getGame_version());

                                                   }
                                                   if(mChannellist.getMarketlist()!=null){
                                                       for(int k=0;k<mChannellist.getMarketlist().size();k++){
                                                           Marketlist mMarketlist=mChannellist.getMarketlist().get(k);
                                                           if(!pmutil.isnullorEmpty(mMarketlist.getMarketid())){
                                                               if(mMarketlist.getMarketid().equals(mconfigData.getMarketid())){
                                                                   setshowmessage(mMarketlist.getShowmessage());

                                                                   if(!pmutil.isnullorEmpty(mMarketlist.getGame_download())&&!pmutil.isnullorEmpty(mMarketlist.getGame_version())){
                                                                       Logger.t("chulipeizhiGame").v("游戏市场层配置游戏升级");
                                                                       mgameversionutil.setGame_download(mMarketlist.getGame_download());
                                                                       mgameversionutil.setGame_version(mMarketlist.getGame_version());

                                                                   }
                                                                   if(!pmutil.isnullorEmpty(mMarketlist.getApp_download())&&!pmutil.isnullorEmpty(mMarketlist.getApp_version())){
                                                                       Logger.t("chulipeizhiGame").v("游戏市场层配置app升级");
                                                                       mgameversionutil.setApp_download(mMarketlist.getApp_download());
                                                                       mgameversionutil.setApp_version(mMarketlist.getApp_version());

                                                                   }
                                                               }
                                                           }


                                                       }
                                                   }


                                               }
                                           }

                                       }
                                   }

                                   break;
                               }
                           }



                       }
                   }

                   Logger.t("chulipeizhiGame").v("游戏配置文件完成");


               }else{
                   Logger.t("chulipeizhiGame").v("游戏配置文件不匹配");
               }
           }



       }



      return mgameversionutil;


    }

    public void setshowmessage(String Showmessage) {
        System.out.println("----" + Showmessage);
        if (!pmutil.isnullorEmpty(Showmessage)) {
            apputil.Showmessage = Showmessage;

        }
    }
}
