예제 #1
0
//任务列表
int CharAllPrestigeTasks::getList(int race, json_spirit::Array& rlist)
{
    std::map<int, boost::shared_ptr<basePrestigeTask> > tasks = Singleton<PrestigeTaskMgr>::Instance().getPrestigeTasks();
    if (tasks.size() > m_all_prestige_tasks.size())
    {
        for(int i = m_all_prestige_tasks.size(); i < tasks.size(); ++i)
        {
            boost::shared_ptr<basePrestigeTask> bt = Singleton<PrestigeTaskMgr>::Instance().getPrestigeTask(i+1);
            if (bt.get())
            {
                accept(bt);
            }
        }
    }
    int tmp = 0;
    json_spirit::Array list;
    std::map<int, boost::shared_ptr<CharPrestigeTask> >::iterator it = m_all_prestige_tasks.begin();
    while (it != m_all_prestige_tasks.end())
    {
        if (it->second.get() && it->second->m_task.get())
        {
            CharPrestigeTask& ct = *(it->second.get());
            if (race != 0 && race != ct.m_task->race)
            {
                ++it;
                continue;
            }
            if (ct.m_task->reward_prestige != tmp)
            {
                if (tmp != 0)
                {
                    json_spirit::Object robj;
                    robj.push_back( Pair("reward_prestige", tmp) );
                    robj.push_back( Pair("list", list) );
                    rlist.push_back(robj);
                }
                list.clear();
                tmp = ct.m_task->reward_prestige;
            }
            json_spirit::Object obj;
            ct.toObj(obj);
            list.push_back(obj);
        }
        ++it;
    }
    //最后一档
    if (tmp != 0)
    {
        json_spirit::Object robj;
        robj.push_back( Pair("reward_prestige", tmp) );
        robj.push_back( Pair("list", list) );
        rlist.push_back(robj);
    }
    return HC_SUCCESS;
}
예제 #2
0
파일: shop.cpp 프로젝트: lindianyin/sgbj
//查询商品列表
int charShop::getList(json_spirit::Array& glist)
{
    for (int pos = 1; pos <= 6; ++pos)
    {
        if (!m_goods[pos-1].baseGoods.get())
        {
            return HC_ERROR;
        }
        json_spirit::Object shop;
        shop.push_back( Pair("pos", pos) );
        shop.push_back( Pair("type", m_goods[pos-1].baseGoods->type) );
        //商店宝石默认1级
        if (m_goods[pos-1].baseGoods->type == 6)
        {
            shop.push_back( Pair("level", 1) );
        }
        shop.push_back( Pair("id", m_goods[pos-1].baseGoods->id) );
        shop.push_back( Pair("name", m_goods[pos-1].baseGoods->name) );
        shop.push_back( Pair("memo", m_goods[pos-1].baseGoods->memo) );
        shop.push_back( Pair("nums", m_goods[pos-1].baseGoods->num) );
        shop.push_back( Pair("quality", m_goods[pos-1].baseGoods->quality) );
        shop.push_back( Pair("spic", m_goods[pos-1].baseGoods->spic) );
        shop.push_back( Pair("price", m_goods[pos-1].baseGoods->price) );
        shop.push_back( Pair("org_price", m_goods[pos-1].baseGoods->org_price) );
        shop.push_back( Pair("canBuy", m_goods[pos-1].canbuy) );
        glist.push_back(shop);
     }
    return HC_SUCCESS;
}
예제 #3
0
//可能获得奖励列表
void lottery_event::getAwards(json_spirit::Array& list)
{
    for (std::vector<Item>::iterator it = m_awards.begin(); it != m_awards.end(); ++it)
    {
        Item& item = *it;
        json_spirit::Object obj;
        item.toObj(obj);
        list.push_back(obj);
    }
}
예제 #4
0
//活动是否开启
void weekRankings::getButton(CharData* pc, json_spirit::Array& list)
{
    if (pc->isWeekRankingActionOpen()
         && m_event_type)
    {
        json_spirit::Object obj;
        obj.push_back( Pair("type", top_button_weekRanking) );
        obj.push_back( Pair("active", 0) );
        list.push_back(obj);
    }
}
예제 #5
0
void GlobalConfig::fillJSONMessages(json_spirit::Array &arr) {
    mutex::scoped_lock l(msgMutex);
    list<RepetierMsgPtr>::iterator it = msgList.begin(),ie = msgList.end();
    for(;it!=ie;++it) {
        using namespace json_spirit;
        Object obj;
        obj.push_back(Pair("id",(*it)->mesgId));
        obj.push_back(Pair("msg",(*it)->message));
        obj.push_back(Pair("link",(*it)->finishLink));
        arr.push_back(obj);
    }
}
예제 #6
0
void PrestigeTaskMgr::getButton(CharData* pc, json_spirit::Array& list)
{
    if (pc->m_level > iPrestigeOpenLevel)
    {
        int active = pc->m_prestige_tasks.getActive();
        json_spirit::Object obj;
        obj.push_back( Pair("type", top_button_prestige_task) );
        obj.push_back( Pair("active", active) );
        list.push_back(obj);
    }
    return;
}
예제 #7
0
void lottery_event::getAction(json_spirit::Array& elist)
{
    time_t tnow = time(NULL);
    if (m_start_time > tnow || m_end_time <= tnow)
    {
        return;
    }
    
    json_spirit::Object obj;
    obj.push_back( Pair("type", top_level_event_lottery_event) );
    obj.push_back( Pair("active", 0) );
    obj.push_back( Pair("spic", m_spic) );
    elist.push_back(obj);
}
예제 #8
0
파일: rewards.cpp 프로젝트: lindianyin/sgbj
void char_rewards_mgr::getAction(CharData* pc, json_spirit::Array& blist)
{
    for (int i = rewards_type_start+1; i < rewards_type_end; ++i)
    {
        int action_type = get_action_type(i);
        if (pc && action_type != 0 && canGetReward(pc->m_id, i))
        {
            json_spirit::Object obj;
            obj.push_back( Pair("type", action_type) );
            obj.push_back( Pair("active", 1) );
            blist.push_back(obj);
        }
    }
}
예제 #9
0
파일: bank.cpp 프로젝트: lindianyin/sgbj
void bankMgr::getButton(CharData* pc, json_spirit::Array& blist)
{
    if (pc->isBankOpen())
    {
        int state = 0;
        boost::shared_ptr<char_bank_list> bk = GetCharBankList(pc->m_id);
        if (bk.get())
        {
            state = bankCanGet(*bk);
        }
        json_spirit::Object obj;
        obj.push_back( Pair("type", top_button_bank) );
        obj.push_back( Pair("active", state == 1 ? 1 : 0) );
        blist.push_back(obj);
    }
}
void Simulation::fillTeamResults(json_spirit::Array &teamList, std::string cluster)
{
	for (auto &team : teams)
	{
		json_spirit::Object teamData;
		teamData.push_back(json_spirit::Pair("id", team.id));
		if (cluster == "all")
		{
			teamData.push_back(json_spirit::Pair("ranks", clusterTeamResults[cluster][team.id].rankDataToJSONArray(ranks)));
			teamData.push_back(json_spirit::Pair("avg_place", clusterTeamResults[cluster][team.id].getAvgPlace()));
		}
		teamData.push_back(json_spirit::Pair("match_data", clusterTeamResults[cluster][team.id].toJSONObject()));
		teamData.push_back(json_spirit::Pair("avg_goals", clusterTeamResults[cluster][team.id].getAvgGoals()));
		
		
		teamList.push_back(teamData);
	}
}
예제 #11
0
파일: buff.cpp 프로젝트: lindianyin/sgbj
//增益信息
int CharBuffs::getBuffInfo(json_spirit::Array& slist)
{
    if (reload)
    {
        load();
        reload = true;
    }
    refresh();
    for (int i = 0; i < 4; ++i)
    {
        json_spirit::Object obj;
        int left_time = buffs[i].m_end_time-time(NULL);
        obj.push_back( Pair("type", buffs[i].m_type) );
        obj.push_back( Pair("effect", int2percent(buffs[i].m_value,100)) );
        obj.push_back( Pair("end_time", left_time > 0 ? left_time : 0) );
        slist.push_back(obj);
    }
    return HC_SUCCESS;
}
void Simulation::fillRankResults(json_spirit::Array &ranks)
{
	for (RankData &rankData : this->ranks)
		ranks.push_back(rankData.toJSONObject());
}
예제 #13
0
bool checkMaterial(equipment_scroll* sp, CharData& char_data, Bag& m_bag, json_spirit::Array& mlist, int type = 1)
{
    bool canMake = true;
    for (std::list<std::pair<boost::shared_ptr<baseTreasure>,int> >::iterator it = sp->m_mlist.begin(); it != sp->m_mlist.end(); ++it)
    {
        if (it->first.get())
        {
            json_spirit::Object o;
            o.push_back( Pair("name", it->first->name) );
            int32_t num = m_bag.getGemCount(it->first->id);
            if (num >= it->second)
            {
                num = it->second;
            }
            else
            {
                canMake = false;
            }
            o.push_back( Pair("spic", it->first->spic) );
            o.push_back( Pair("type", iItem_type_gem) );
            o.push_back( Pair("id", it->first->id) );
            o.push_back( Pair("quality", it->first->quality) );
            if (it->first->m_place.get())
            {
                bool can_sweep = false;
                o.push_back( Pair("info", it->first->m_place->info) );
                if (it->first->m_place->type == 1)
                {
                    can_sweep = char_data.m_tempo.check_stronghold_can_sweep(it->first->m_place->mapId,it->first->m_place->stageId,it->first->m_place->pos);
                    boost::shared_ptr<StrongholdData> bstronghold = GeneralDataMgr::getInstance()->GetStrongholdData(it->first->m_place->mapId,it->first->m_place->stageId,it->first->m_place->pos);
                    if (bstronghold.get())
                    {
                        o.push_back( Pair("open_level", bstronghold->m_level) );
                    }
                    o.push_back( Pair("can_sweep", can_sweep) );
                }
                else if (it->first->m_place->type == 2)
                {
                    can_sweep = eliteCombatMgr::getInstance()->check_stronghold_can_attack(char_data.m_id,it->first->m_place->mapId,it->first->m_place->pos);
                    o.push_back( Pair("can_sweep", can_sweep) );
                }
            }

            o.push_back( Pair("num", num) );
            o.push_back( Pair("need", it->second) );
            mlist.push_back(o);
        }
    }
    //卷轴信息
    int32_t gem_num = m_bag.getGemCount(sp->m_gem_id);
    if (gem_num <= 0)
    {
        canMake = false;
    }
    if (type == 2)
    {
        boost::shared_ptr<baseTreasure> bt = GeneralDataMgr::getInstance()->GetBaseTreasure(sp->m_gem_id);
        if (bt.get() && bt->m_place.get())
        {
            json_spirit::Object o;
            o.push_back( Pair("name", bt->name) );
            o.push_back( Pair("spic", bt->spic) );
            o.push_back( Pair("type", iItem_type_gem) );
            o.push_back( Pair("id", bt->id) );
            o.push_back( Pair("quality", bt->quality) );
            o.push_back( Pair("num", gem_num) );
            o.push_back( Pair("need", 1) );
            o.push_back( Pair("info", bt->m_place->info) );
            bool can_sweep = false;
            if (bt->m_place->type == 1)
            {
                can_sweep = char_data.m_tempo.check_stronghold_can_sweep(bt->m_place->mapId,bt->m_place->stageId,bt->m_place->pos);
                o.push_back( Pair("can_sweep", can_sweep) );
            }
            else if (bt->m_place->type == 2)
            {
                can_sweep = eliteCombatMgr::getInstance()->check_stronghold_can_attack(char_data.m_id,bt->m_place->mapId,bt->m_place->pos);
                o.push_back( Pair("can_sweep", can_sweep) );
            }
            mlist.push_back(o);
        }
    }
    return canMake;
}
예제 #14
0
파일: boss.cpp 프로젝트: lindianyin/sgbj
int bossMgr::getAction(CharData* pc, json_spirit::Array& blist)
{
    //等级不足的不显示boss战图标
    if (!pc || (!pc->isBossOpen()))
    {
        return 0;
    }
    //获取当前时间格式匹配
    time_t timep;
    struct tm m_timenow;
    time(&timep);
    localtime_r(&timep, &m_timenow);

    //今天要开放的boss列表
    std::map<int, boost::shared_ptr<Boss> >::iterator it = m_boss_maps.begin();
    while (it != m_boss_maps.end())
    {
        Boss* pb = it->second.get();
        if (pb)
        {
            openRule* pOpenRule = pb->_boss._open_rules.getRule(m_timenow);
            if (pb->_boss._open_state || pOpenRule)
            {
                //cout<<pb->_boss._id<<" boss state "<<pb->_boss._open_state<<",";
                json_spirit::Object obj;
                obj.push_back( Pair("type", action_boss) );
                obj.push_back( Pair("id", pb->_boss._id) );
                obj.push_back( Pair("name", pb->_boss._name) );
                obj.push_back( Pair("level", pb->_boss._level) );
                obj.push_back( Pair("spic", pb->_boss._spic) );
                if (pb->_boss._open_state)
                {
                    obj.push_back( Pair("state", 1) );
                    obj.push_back( Pair("memo", strBossOpening) );
                }
                else
                {
                    if ((pOpenRule->_open_hour > m_timenow.tm_hour
                    || (pOpenRule->_open_hour == m_timenow.tm_hour && pOpenRule->_open_min > m_timenow.tm_min)))
                    {
                        obj.push_back( Pair("state", 0) );
                        std::string memo = strBossWillOpen;
                        if (pOpenRule->_open_hour < 10)
                        {
                            str_replace(memo, "$H", "0" + LEX_CAST_STR(pOpenRule->_open_hour));
                        }
                        else
                        {
                            str_replace(memo, "$H", LEX_CAST_STR(pOpenRule->_open_hour));
                        }
                        if (pOpenRule->_open_min < 10)
                        {
                            str_replace(memo, "$M", "0" + LEX_CAST_STR(pOpenRule->_open_min));
                        }
                        else
                        {
                            str_replace(memo, "$M", LEX_CAST_STR(pOpenRule->_open_min));
                        }
                        obj.push_back( Pair("memo", memo) );
                    }
                    else
                    {
                        //结束了
                        obj.push_back( Pair("state", 2) );
                        obj.push_back( Pair("memo", strBossIsClosed) );
                    }
                }
                if (pOpenRule)
                {
                    std::string startTime = time2string(pOpenRule->_open_hour, pOpenRule->_open_min);
                    obj.push_back( Pair("startTime", startTime) );;
                    int endmin = pOpenRule->_open_min;
                    int endhour = pOpenRule->_open_hour + 2;
                    if (endhour > 23)
                    {
                        endhour -= 24;
                    }
                    std::string endTime = time2string(endhour, endmin);
                    obj.push_back( Pair("endTime", endTime) );
                }
                blist.push_back(obj);
            }
        }
        ++it;
    }
    return 1;
}