def card_stove(): """ 炼化 """ game_config.subareas_conf() game_config.set_subarea('1') #sell_ucids = params['sell_ucids'] user_property_obj = UserProperty.get_instance(uid) sell_ucids = '201410161423224907513' if not sell_ucids: return 11,{'msg':utils.get_msg('card','no_cost_card')} sell_ucids = sell_ucids.split(',') sell_ucids = utils.remove_null(sell_ucids) user_card_obj = UserCards.get(uid) #检查武将是否存在 for ucid in sell_ucids: if ucid and not user_card_obj.has_card(ucid): return 11,{'msg':utils.get_msg('card','no_card')} #如果有主角卡,则不能消耗 if user_property_obj.leader_role_card in sell_ucids: return 11,{'msg':utils.get_msg('card','role_card')} #带装备武将不允许卖出 if user_card_obj.is_equip_used(sell_ucids): return 11,{'msg':utils.get_msg('equip','is_used')} #被锁定武将不能卖出 if user_card_obj.is_locked(sell_ucids): return 11,{'msg':utils.get_msg('card','locked')} #检查武将是否在deck中 rc,msg = check_card_in_deck(user_card_obj,sell_ucids) if rc: return rc,{'msg':msg} sell_cards = [user_card_obj.cards[ucid] for ucid in sell_ucids] return 0,{'cards_info':sell_cards,'cards_ucids':sell_ucids}
def show_banquet_info(): game_config.subareas_conf() game_config.set_subarea('1') open_gaps = game_config.operat_config.get('open_stamina_banquet_gaps') ul = UserLogin.get_instance(uid) user_banquet_info = ul.banquet_info print user_banquet_info
def check_card_in_deck(user_card_obj,card_list): """ 检查武将是否在队伍中 """ game_config.subareas_conf() game_config.set_subarea('1') for ucid in card_list: for deck in user_card_obj.decks: ucid_ls = [card['ucid'] for card in deck if card.get('ucid','')] if ucid in ucid_ls: return 11,utils.get_msg('card','in_deck') return 0,''
def refresh_store_by_self(): """ 玩家主动刷新时 调用此接口 params 参数需包含 store_type : "gold_store" or "coin_store" """ game_config.subareas_conf() game_config.set_subarea('1') store_type_list = ['coin_store','fight_soul_store'] needed_cost = game_config.mystery_store["store_refresh_cost"] user_property_obj = UserProperty.get_instance(uid) # 消耗元宝 minus_func = getattr(user_property_obj, "minus_coin") #根据vip刷新次数 if not vip.check_limit_recover(user_property_obj,'recover_mystery_store'): return 11,{'msg':utils.get_msg('user','max_times')} #回复次数+1 user_property_obj.add_recover_times('recover_mystery_store') # 再判断是否 coin or gold 足够 if not minus_func(needed_cost, 'refresh_mystery_store'): return 11,{'msg': utils.get_msg('user', 'not_enough_coin')} # 记录 消费元宝log #data_log_mod.set_log("ConsumeRecord", rk_user, # lv=rk_user.user_property.lv, # num=needed_cost, # consume_type='refresh_coin_store', # before_coin=rk_user.user_property.coin + needed_cost, # after_coin=rk_user.user_property.coin #) user_mystery_store_obj = UserMysteryStore.get_instance(uid) for store_type in store_type_list: user_mystery_store_obj.refresh_store(store_type) #return 0, _pack_store_info(user_mystery_store_obj.store_info()) k = _pack_store_info(user_mystery_store_obj.store_info()) print 'data=',json.dumps(k,indent=1)
import copy import json from apps.models.user_mystery_store import UserMysteryStore from apps.models.user_property import UserProperty from apps.common import utils from apps.config.game_config import game_config from apps.logics import vip from apps.models import data_log_mod from apps.models.user_cards import UserCards from apps.models.user_equips import UserEquips from apps.models.user_pack import UserPack from apps.logics import card from apps.logics import equip from apps.models.user_base import UserBase game_config.subareas_conf() game_config.set_subarea('1') rk_user = UserBase.get(uid) def check_card_in_deck(user_card_obj,card_list): """ 检查武将是否在队伍中 """ game_config.subareas_conf() game_config.set_subarea('1') for ucid in card_list: for deck in user_card_obj.decks: ucid_ls = [card['ucid'] for card in deck if card.get('ucid','')] if ucid in ucid_ls: return 11,utils.get_msg('card','in_deck') return 0,''
# import apps.settings as settings env = "apps.settings" settings = importlib.import_module(env) # import apps.settings_stg as settings from django.core.management import setup_environ setup_environ(settings) from apps.oclib import app from apps.models import pvp_redis from apps.config.game_config import game_config top_name = "real_pvp" all_subareas = game_config.subareas_conf() def save_yesterday_pvp_top(): # 每天于22:00 将此刻排行榜信息存入 昨日排行榜 for subarea_num in all_subareas: now_top = pvp_redis.get_pvp_redis(subarea_num, top_name) yesterday_top = pvp_redis.get_yesterday_pvp_redis(subarea_num, top_name) # 清空老的昨日排名 yesterday_top.zremrangeallrank() now_member_scores = app.top_redis.zrange(now_top.top_name, 0, -1, withscores=True) for uid, score in now_member_scores: yesterday_top.set(uid, score)
cur_dir = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(cur_dir, "..")) # import apps.settings as settings env = "apps.settings" settings = importlib.import_module(env) # import apps.settings_stg as settings from django.core.management import setup_environ setup_environ(settings) from apps.oclib import app from apps.models import pvp_redis from apps.config.game_config import game_config top_name = 'real_pvp' all_subareas = game_config.subareas_conf() def save_yesterday_pvp_top(): # 每天于22:00 将此刻排行榜信息存入 昨日排行榜 for subarea_num in all_subareas: now_top = pvp_redis.get_pvp_redis(subarea_num, top_name) yesterday_top = pvp_redis.get_yesterday_pvp_redis( subarea_num, top_name) # 清空老的昨日排名 yesterday_top.zremrangeallrank() now_member_scores = app.top_redis.zrange(now_top.top_name, 0, -1,
def subareas_conf(request): return HttpResponse( json.dumps(game_config.subareas_conf(), indent=1), content_type='application/x-javascript', )