def setUp(self): # Player. self.__player0 = self.create_dummy(DummyType.PLAYER) # ボス. boss = self.create_dummy(DummyType.BOSS_MASTER) # エリア. area = self.create_dummy(DummyType.AREA_MASTER, bossid=boss.id) # スカウト. scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, execution=1) self.__scout = scout for _ in xrange(5): scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, opencondition=scout.id) # 経験値情報. self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 1, exp=0) self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 2, exp=1) self.__player0.level = 1 self.__player0.exp = 0 self.__player0.getModel(PlayerExp).save() self.__player0.gold = 0 self.__player0.getModel(PlayerGold).save() # 途中まで進んでいるかもしれないので消しておく. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata: playdata.delete()
def check(self): model_mgr = ModelRequestMgr() # 進行情報があるかを確認. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata is None: raise AppTestError(u'進行情報が保存されていない') elif playdata.progress == 0: raise AppTestError(u'進行度が進んでいない') # 報酬. resultlist = playdata.result.get('result', None) if not resultlist: raise AppTestError(u'結果が設定されていない') for result in resultlist: self.__player0.exp += result['exp_add'] self.__player0.gold += result['gold_add'] # お金確認. playergold = PlayerGold.getByKey(playdata.uid) if playergold.gold != self.__player0.gold: raise AppTestError(u'お金が正しくない') # 経験値. playerexp = PlayerExp.getByKey(playdata.uid) if playerexp.exp != self.__player0.exp: raise AppTestError(u'お金が正しくない') # イベント設定されているか. eventlist = playdata.result.get('event', None) if not eventlist: raise AppTestError(u'イベントが設定されていない') # ハプニング発生のイベントが設定されているか. targetevent = None for event in eventlist: if event.get_type() == Defines.ScoutEventType.HAPPENING: targetevent = event if targetevent is None: raise AppTestError(u'ハプニング発生イベントが設定されていない') elif targetevent.happening != self.__happeningmaster.id: raise AppTestError( u'ハプニング発生イベントに正しくハプニングが設定されていない.%d vs %d' % (targetevent.happening, self.__happeningmaster.id)) happeningset = BackendApi.get_current_happening( model_mgr, self.__player0.id) if happeningset is None or happeningset.happening.mid != self.__happeningmaster.id: raise AppTestError(u'ハプニングが開始されていない.') raidboss = BackendApi.get_raid( model_mgr, happeningset.id, happening_eventvalue=HappeningUtil.make_raideventvalue( self.__eventmaster.id)) record = raidboss.getDamageRecord(self.__player0.id) if not record.champagne: raise AppTestError(u'シャンパンコールのフラグが立っていない.')
def check(self): self.checkResponseStatus() # 進行情報があるかを確認. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata is None: raise AppTestError(u'進行情報が保存されていない') elif playdata.progress == 0: raise AppTestError(u'進行度が進んでいない') # 報酬. resultlist = playdata.result.get('result', None) if not resultlist: raise AppTestError(u'結果が設定されていない') for result in resultlist: self.__player0.exp += result['exp_add'] self.__player0.gold += result['gold_add'] # お金確認. playergold = PlayerGold.getByKey(playdata.uid) if playergold.gold != self.__player0.gold: raise AppTestError(u'お金が正しくない') # 経験値. playerexp = PlayerExp.getByKey(playdata.uid) if playerexp.exp != self.__player0.exp: raise AppTestError(u'お金が正しくない') # デッキコスト. playerdeck = PlayerDeck.getByKey(playdata.uid) if playerdeck.deckcapacityscout != (self.__player0.deckcapacityscout + 1): raise AppTestError(u'デッキコスト上限が正しくない') # イベント設定されているか. eventlist = playdata.result.get('event', None) if not eventlist: raise AppTestError(u'イベントが設定されていない') # レベルアップとスカウト完了のイベントが設定されているか. levelupevent = None completeevent = None for event in eventlist: if event.get_type() == Defines.ScoutEventType.LEVELUP: levelupevent = event elif event.get_type() == Defines.ScoutEventType.COMPLETE: completeevent = event if levelupevent is None: raise AppTestError(u'レベルアップイベントが設定されていない') elif completeevent is None: raise AppTestError(u'スカウト完了イベントが設定されていない') elif playerexp.level != levelupevent.level: raise AppTestError(u'レベルアップイベントに正しくレベルが設定されていない.%d vs %d' % (playerexp.level, levelupevent.level)) elif playdata.mid != completeevent.scoutid: raise AppTestError(u'完了イベントに正しくスカウトIDが設定されていない.%d vs %d' % (playdata.mid, completeevent.scoutid))
def setUp(self): # Player. self.__player0 = self.create_dummy(DummyType.PLAYER) # ボス. boss = self.create_dummy(DummyType.BOSS_MASTER) # エリア. area = self.create_dummy(DummyType.AREA_MASTER, bossid=boss.id) # レイド. raidmaster = self.create_dummy(DummyType.RAID_MASTER) # ハプニング. happeningmaster = self.create_dummy(DummyType.HAPPENING_MASTER, raidmaster.id) data = ScoutHappeningData.create(happeningmaster.id, 10000) happenings = [data.get_dict()] self.__happeningmaster = happeningmaster # スカウト. scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, execution=100, happenings=happenings) self.__scout = scout for _ in xrange(5): scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, opencondition=scout.id) # 経験値情報. self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 1, exp=0) self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 2, exp=999) self.__player0.level = 1 self.__player0.exp = 0 self.__player0.getModel(PlayerExp).save() self.__player0.gold = 0 self.__player0.getModel(PlayerGold).save() self.__player0.cardlimititem = 100 self.__player0.getModel(PlayerDeck).save() # 途中まで進んでいるかもしれないので消しておく. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata: playdata.delete() # レイドイベントは止める. config = BackendApi.get_current_raideventconfig(ModelRequestMgr()) self.__preconfig_endtime = config.endtime now = OSAUtil.get_now() BackendApi.update_raideventconfig(config.mid, config.starttime, now)
def setUp(self): # Player. self.__player0 = self.create_dummy(DummyType.PLAYER) # ボス. boss = self.create_dummy(DummyType.BOSS_MASTER) # エリア. area = self.create_dummy(DummyType.AREA_MASTER, bossid=boss.id) # 宝箱(中身はなんでもいい). self.__treasuremaster = self.create_dummy( DummyType.TREASURE_GOLD_MASTER, Defines.ItemType.GOLD, 0, 100) # 出現テーブル. self.__treasuretablemaster = self.create_dummy( DummyType.TREASURE_TABLE_GOLD_MASTER, [self.__treasuremaster.id]) # スカウト. scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, execution=100, treasuregold=1) self.__scout = scout for _ in xrange(5): scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, opencondition=scout.id) # 経験値情報. self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 1, exp=0) self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 2, exp=999) self.__player0.level = 1 self.__player0.exp = 0 self.__player0.getModel(PlayerExp).save() self.__player0.gold = 0 self.__player0.getModel(PlayerGold).save() self.__player0.cardlimititem = 100 self.__player0.getModel(PlayerDeck).save() # 途中まで進んでいるかもしれないので消しておく. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata: playdata.delete() # 宝箱獲得数. model_mgr = ModelRequestMgr() self.__treasure_num = BackendApi.get_treasure_num( model_mgr, Defines.TreasureType.GOLD, self.__player0.id)
def setUp(self): # Player. self.__player0 = self.create_dummy(DummyType.PLAYER) # ボス. boss = self.create_dummy(DummyType.BOSS_MASTER) # エリア. area = self.create_dummy(DummyType.AREA_MASTER, bossid=boss.id) # レイド. raidmaster = self.create_dummy(DummyType.RAID_MASTER) # ハプニング. happeningmaster = self.create_dummy(DummyType.HAPPENING_MASTER, raidmaster.id) data = ScoutHappeningData.create(happeningmaster.id, 10000) happenings = [data.get_dict()] self.__happeningmaster = happeningmaster # スカウト. scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, execution=100, happenings=happenings) self.__scout = scout for _ in xrange(5): scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, opencondition=scout.id) # 経験値情報. self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 1, exp=0) self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 2, exp=999) self.__player0.level = 1 self.__player0.exp = 0 self.__player0.getModel(PlayerExp).save() self.__player0.gold = 0 self.__player0.getModel(PlayerGold).save() self.__player0.cardlimititem = 100 self.__player0.getModel(PlayerDeck).save() # 途中まで進んでいるかもしれないので消しておく. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata: playdata.delete()
def setUp(self): # Player. self.__player0 = self.create_dummy(DummyType.PLAYER) # ボス. boss = self.create_dummy(DummyType.BOSS_MASTER) # エリア. area = self.create_dummy(DummyType.AREA_MASTER, bossid=boss.id) # カード. cardmaster = self.create_dummy(DummyType.CARD_MASTER) data = ScoutDropItemData.create( Defines.ItemType.CARD, cardmaster.id, filters={'ptype': Defines.CharacterType.TYPE_001}, rate=10000) dropitems = [data.get_dropitem_dict()] self.__cardmaster = cardmaster # スカウト. scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, execution=100, dropitems=dropitems) self.__scout = scout for _ in xrange(5): scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, opencondition=scout.id) # 経験値情報. self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 1, exp=0) self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 2, exp=999) self.__player0.level = 1 self.__player0.exp = 0 self.__player0.getModel(PlayerExp).save() self.__player0.gold = 0 self.__player0.getModel(PlayerGold).save() self.__player0.cardlimititem = 100 self.__player0.getModel(PlayerDeck).save() # 途中まで進んでいるかもしれないので消しておく. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata: playdata.delete()
def check(self): self.checkResponseStatus() model_mgr = ModelRequestMgr() # 進行情報があるかを確認. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata is None: raise AppTestError(u'進行情報が保存されていない') elif playdata.progress == 0: raise AppTestError(u'進行度が進んでいない') # 報酬. resultlist = playdata.result.get('result', None) if not resultlist: raise AppTestError(u'結果が設定されていない') for result in resultlist: self.__player0.exp += result['exp_add'] self.__player0.gold += result['gold_add'] # お金確認. playergold = PlayerGold.getByKey(playdata.uid) if playergold.gold != self.__player0.gold: raise AppTestError(u'お金が正しくない') # 経験値. playerexp = PlayerExp.getByKey(playdata.uid) if playerexp.exp != self.__player0.exp: raise AppTestError(u'お金が正しくない') # 宝箱獲得のイベントが設定されているか. targetevent = BackendApi.find_scout_event( playdata, Defines.ScoutEventType.GET_TREASURE) if targetevent is None: raise AppTestError(u'宝箱獲得イベントが設定されていない') elif targetevent.treasuretype != Defines.TreasureType.GOLD: raise AppTestError(u'宝箱獲得イベントに正しくカードが設定されていない.%d' % targetevent.treasuretype) treasure_num = BackendApi.get_treasure_num(model_mgr, Defines.TreasureType.GOLD, self.__player0.id) if (self.__treasure_num + 1) != treasure_num: raise AppTestError(u'宝箱の所持数が想定外.%d vs %d' % ((self.__treasure_num + 1), treasure_num))
def check(self): self.checkResponseStatus() # 進行情報があるかを確認. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata is None: raise AppTestError(u'進行情報が保存されていない') elif playdata.progress == 0: raise AppTestError(u'進行度が進んでいない') # 報酬. resultlist = playdata.result.get('result', None) if not resultlist: raise AppTestError(u'結果が設定されていない') for result in resultlist: self.__player0.exp += result['exp_add'] self.__player0.gold += result['gold_add'] # お金確認. playergold = PlayerGold.getByKey(playdata.uid) if playergold.gold != self.__player0.gold: raise AppTestError(u'お金が正しくない') # 経験値. playerexp = PlayerExp.getByKey(playdata.uid) if playerexp.exp != self.__player0.exp: raise AppTestError(u'お金が正しくない') # イベント設定されているか. eventlist = playdata.result.get('event', None) if not eventlist: raise AppTestError(u'イベントが設定されていない') # レベルアップのイベントが設定されているか. targetevent = None for event in eventlist: if event.get_type() == Defines.ScoutEventType.LEVELUP: targetevent = event if targetevent is None: raise AppTestError(u'レベルアップイベントが設定されていない') elif playerexp.level != targetevent.level: raise AppTestError(u'イベントに正しくレベルが設定されていない.%d vs %d' % (playerexp.level, targetevent.level))
def setUp(self): # Player. self.__player0 = self.create_dummy(DummyType.PLAYER) # ボス. boss = self.create_dummy(DummyType.BOSS_MASTER) # エリア. area = self.create_dummy(DummyType.AREA_MASTER, bossid=boss.id) # スカウト. scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, execution=100, apcost=100) self.__scout = scout for _ in xrange(5): scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, opencondition=scout.id) # 経験値情報. for i in xrange(Defines.BIGINNER_PLAYERLEVEL): self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, i + 1, exp=i + 1) self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, Defines.BIGINNER_PLAYERLEVEL + 1, exp=999) self.__player0.level = Defines.BIGINNER_PLAYERLEVEL self.__player0.exp = Defines.BIGINNER_PLAYERLEVEL self.__player0.getModel(PlayerExp).save() self.__player0.gold = 0 self.__player0.getModel(PlayerGold).save() self.__player0.cardlimititem = 100 self.__player0.getModel(PlayerDeck).save() # 途中まで進んでいるかもしれないので消しておく. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata: playdata.delete()
def check(self): self.checkResponseStatus() # 進行情報があるかを確認. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata is None: raise AppTestError(u'進行情報が保存されていない') # 報酬. resultlist = playdata.result.get('result', None) if resultlist is None: raise AppTestError(u'結果が設定されていない') for result in resultlist: self.__player0.exp += result['exp_add'] self.__player0.gold += result['gold_add'] # お金確認. playergold = PlayerGold.getByKey(playdata.uid) if playergold.gold != self.__player0.gold: raise AppTestError(u'お金が正しくない') # 経験値. playerexp = PlayerExp.getByKey(playdata.uid) if playerexp.exp != self.__player0.exp: raise AppTestError(u'お金が正しくない') # イベント設定されているか. eventlist = playdata.result.get('event', None) if not eventlist: raise AppTestError(u'イベントが設定されていない') # 体力不足のイベントが設定されているか. targetevent = None for event in eventlist: if event.get_type() == Defines.ScoutEventType.AP_NONE: targetevent = event if targetevent is None: raise AppTestError(u'体力不足イベントが設定されていない')
def check(self): self.checkResponseStatus() # 進行情報があるかを確認. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata is None: raise AppTestError(u'進行情報が保存されていない') elif playdata.progress == 0: raise AppTestError(u'進行度が進んでいない') # 報酬. resultlist = playdata.result.get('result', None) if not resultlist: raise AppTestError(u'結果が設定されていない') for result in resultlist: self.__player0.exp += result['exp_add'] self.__player0.gold += result['gold_add'] # お金確認. playergold = PlayerGold.getByKey(playdata.uid) if playergold.gold != self.__player0.gold: raise AppTestError(u'お金が正しくない') # 経験値. playerexp = PlayerExp.getByKey(playdata.uid) if playerexp.exp != self.__player0.exp: raise AppTestError(u'お金が正しくない') # カード獲得のイベントが設定されているか. targetevent = BackendApi.find_scout_event( playdata, Defines.ScoutEventType.GET_CARD) if targetevent is None: raise AppTestError(u'カード獲得イベントが設定されていない') elif targetevent.card != self.__cardmaster.id: raise AppTestError(u'カード獲得イベントに正しくカードが設定されていない.%d vs %d' % (targetevent.card, self.__cardmaster.id)) elif targetevent.is_received: raise AppTestError(u'カード受取判定済になってしまっている')
def setUp(self): # Player. self.__player0 = self.create_dummy(DummyType.PLAYER) # ボス. boss = self.create_dummy(DummyType.BOSS_MASTER) # エリア. area = self.create_dummy(DummyType.AREA_MASTER, bossid=boss.id) # レイド. raidmaster = self.create_dummy(DummyType.RAID_MASTER) # ハプニング. happeningmaster = self.create_dummy(DummyType.HAPPENING_MASTER, raidmaster.id, execution=0) data = ScoutHappeningData.create(happeningmaster.id, 10000) happenings = [data.get_dict()] self.__happeningmaster = happeningmaster # レイドイベント. data = ScoutHappeningData.create(happeningmaster.id, 10000) eventmaster = self.create_dummy(DummyType.RAID_EVENT_MASTER, happenings, champagne_num_max=10, champagne_time=300) self.__eventmaster = eventmaster # シャンパン情報. champagnedata = self.create_dummy(DummyType.RAID_EVENT_CHAMPAGNE, self.__player0.id, eventmaster.id, eventmaster.champagne_num_max) self.__champagnedata = champagnedata # スカウト. scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, execution=100, happenings=happenings) self.__scout = scout for _ in xrange(5): scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, opencondition=scout.id) # 経験値情報. self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 1, exp=0) self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 2, exp=999) self.__player0.level = 1 self.__player0.exp = 0 self.__player0.getModel(PlayerExp).save() self.__player0.gold = 0 self.__player0.getModel(PlayerGold).save() self.__player0.cardlimititem = 100 self.__player0.getModel(PlayerDeck).save() # 途中まで進んでいるかもしれないので消しておく. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata: playdata.delete() # イベント発生中設定. model_mgr = ModelRequestMgr() config = BackendApi.get_current_raideventconfig(model_mgr) self.__preconfig_mid = config.mid self.__preconfig_starttime = config.starttime self.__preconfig_endtime = config.endtime self.__preconfig_timebonus = config.timebonus_time timebonus_time = [] now = OSAUtil.get_now() BackendApi.update_raideventconfig(self.__eventmaster.id, now, now + datetime.timedelta(days=1), timebonus_time=timebonus_time)
def setUp(self): # Player. self.__player0 = self.create_dummy(DummyType.PLAYER) # ボス. boss = self.create_dummy(DummyType.BOSS_MASTER) # エリア. area = self.create_dummy(DummyType.AREA_MASTER, bossid=boss.id) # カード. cardmaster = self.create_dummy(DummyType.CARD_MASTER) data = ScoutDropItemData.create( Defines.ItemType.CARD, cardmaster.id, filters={'ptype': Defines.CharacterType.TYPE_001}, rate=10000) dropitems = [data.get_dropitem_dict()] self.__cardmaster = cardmaster # スカウト. scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, execution=100, dropitems=dropitems) self.__scout = scout for _ in xrange(5): scout = self.create_dummy(DummyType.SCOUT_MASTER, area=area, opencondition=scout.id) # 報酬. prize = self.create_dummy(DummyType.PRIZE_MASTER, gold=100, gachapt=10) # レイドマスター. raidmaster = self.create_dummy(DummyType.RAID_MASTER, hp=1, prizes=[prize.id], helpprizes=[prize.id], cabaretking=100, demiworld=10) self.__raidmaster = raidmaster # ハプニング. happeningmaster = self.create_dummy(DummyType.HAPPENING_MASTER, raidmaster.id) self.__happeningmaster = happeningmaster # レイドイベント. data = ScoutHappeningData.create(happeningmaster.id, 10000) happenings = [data.get_dict()] eventmaster = self.create_dummy(DummyType.RAID_EVENT_MASTER, happenings, champagne_num_max=10, champagne_time=300) self.__eventmaster = eventmaster # シャンパン情報. champagnedata = self.create_dummy(DummyType.RAID_EVENT_CHAMPAGNE, self.__player0.id, eventmaster.id, eventmaster.champagne_num_max) self.__champagnedata = champagnedata # 経験値情報. self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 1, exp=0) self.create_dummy(DummyType.PLAYER_LEVEL_EXP_MASTER, 2, exp=999) self.__player0.level = 1 self.__player0.exp = 0 self.__player0.getModel(PlayerExp).save() self.__player0.gold = 0 self.__player0.getModel(PlayerGold).save() self.__player0.cardlimititem = 100 self.__player0.getModel(PlayerDeck).save() # 途中まで進んでいるかもしれないので消しておく. playdata = ScoutPlayData.getByKey( ScoutPlayData.makeID(self.__player0.id, self.__scout.id)) if playdata: playdata.delete() # イベント発生中設定. model_mgr = ModelRequestMgr() config = BackendApi.get_current_raideventconfig(model_mgr) self.__preconfig_mid = config.mid self.__preconfig_starttime = config.starttime self.__preconfig_endtime = config.endtime self.__preconfig_timebonus = config.timebonus_time timebonus_time = [] now = OSAUtil.get_now() BackendApi.update_raideventconfig(self.__eventmaster.id, now, now + datetime.timedelta(days=1), timebonus_time=timebonus_time)
def handle(self, *args, **options): print '================================' print 'create_benchmark_csv' print '================================' USER_ID_START = OSAUtil.BENCH_USER_ID_START USER_NUM = 0 if args: USER_NUM = int(args[0]) USER_NUM = max(OSAUtil.BENCH_USER_ID_NUM, USER_NUM) print '================================' print 'USER_NUM=%d' % USER_NUM LEVEL = 1 GOLD = 100000 GACHA_PT = 3000 CARD_NUM = 100 CARD_LIMIT = CARD_NUM + 50 FRIEND = 50 FRIEND_REQUEST = 50 FRIEND_EMPTY = 50 FRIENDLIMIT = FRIEND + FRIEND_REQUEST * 2 + FRIEND_EMPTY RAID_ENDTIME = DateTimeUtil.strToDateTime("20150101", "%Y%m%d") RAIDLOG = 100 GREETLOG = 100 PRESENT = int(100 / len(Defines.ItemType.PRESENT_TYPES.keys())) PRESENT_LIMITTIME = DateTimeUtil.strToDateTime("20150101", "%Y%m%d") ITEM_RNUM = 50 ITEM_VNUM = 50 DECK_CAPACITY = 1000000 CABARET_TREASURE = 100000 TREASURE_NUM = 20 OUTPUT_DIR = os.path.join(settings_sub.TMP_DOC_ROOT, 'dummy') csvmgr = ModelCSVManager(OUTPUT_DIR) model_mgr = ModelRequestMgr() # 各種マスターデータ. levelexpmaster = model_mgr.get_model(PlayerLevelExpMaster, LEVEL) item_all = model_mgr.get_mastermodel_all(ItemMaster) card_all = [master for master in model_mgr.get_mastermodel_all(CardMaster) if master.ckind == Defines.CardKind.NORMAL and master.hklevel == 1] happeningall = model_mgr.get_mastermodel_all(HappeningMaster) arealist = model_mgr.get_mastermodel_all(AreaMaster, order_by='id')[:2] scoutlist = ScoutMaster.fetchValues(filters={'area__in':[area.id for area in arealist]}, order_by='id') treasure_gold_all = model_mgr.get_mastermodel_all(TreasureGoldMaster) treasure_silver_all = model_mgr.get_mastermodel_all(TreasureSilverMaster) treasure_bronze_all = model_mgr.get_mastermodel_all(TreasureBronzeMaster) now = OSAUtil.get_now() print '================================' print 'players..' class ModelList: def __init__(self): self.modellist_all = [] def add(self, modellist): csvmgr.setModelList(modellist) modellist_all = ModelList() for i in xrange(USER_NUM): modellist = [] uid = i + USER_ID_START # プレイヤー作成. player = self.install(uid) # タイプ決定とか. self.regist(player, levelexpmaster, GOLD, GACHA_PT, FRIENDLIMIT, CARD_LIMIT, DECK_CAPACITY, CABARET_TREASURE) modellist.append(player.getModel(Player)) for model_cls in ModelPlayer.Meta.MODELS: p = player.getModel(model_cls) if p: modellist.append(p) # スカウト完了. for scout in scoutlist: playdata = ScoutPlayData.makeInstance(ScoutPlayData.makeID(uid, scout.id)) playdata.progress = scout.execution modellist.append(playdata) # フレンドの近況. logdata = ScoutClearLog.makeData(player.id, scout.id) modellist.append(logdata) for area in arealist: model = AreaPlayData.makeInstance(AreaPlayData.makeID(uid, area.id)) model.clevel = levelexpmaster.level modellist.append(model) # フレンドの近況. logdata = BossWinLog.makeData(player.id, area.id) modellist.append(logdata) # カード付与. playercard = player.getModel(PlayerCard) cardidlist = [] for _ in xrange(CARD_NUM): playercard.card += 1 cardid = Card.makeID(uid, playercard.card) cardmaster = random.choice(card_all) card = BackendApi.create_card_by_master(cardmaster) card.id = cardid card.uid = uid modellist.append(card) cardidlist.append(cardid) # デッキ設定. deck = Deck() deck.id = uid deck.set_from_array(cardidlist[:Defines.DECK_CARD_NUM_MAX]) modellist.append(deck) # カード獲得フラグ. for cardmaster in card_all: cardacquisition = CardAcquisition.makeInstance(CardAcquisition.makeID(uid, cardmaster.id)) cardacquisition.maxlevel = cardmaster.maxlevel modellist.append(cardacquisition) albumacquisition = AlbumAcquisition.makeInstance(AlbumAcquisition.makeID(uid, cardmaster.album)) modellist.append(albumacquisition) # アイテム. for itemmaster in item_all: item = Item.makeInstance(Item.makeID(uid, itemmaster.id)) item.rnum = ITEM_RNUM item.vnum = ITEM_VNUM modellist.append(item) # レイド履歴. states = (Defines.HappeningState.END, Defines.HappeningState.MISS, Defines.HappeningState.CANCEL) for lognumber in xrange(RAIDLOG): happeningmaster = random.choice(happeningall) raidmaster = BackendApi.get_raid_master(model_mgr, happeningmaster.boss) self.putRaidLog(modellist, player, happeningmaster, raidmaster, states[lognumber % len(states)]) # レイド. happeningmaster = random.choice(happeningall) raidmaster = BackendApi.get_raid_master(model_mgr, happeningmaster.boss) self.putRaid(modellist, player, happeningmaster, raidmaster, RAID_ENDTIME) # プレゼント. def putPresent(itype, itemid, itemvalue): presentlist = BackendApi.create_present(model_mgr, 0, uid, itype, itemid, itemvalue, Defines.TextMasterID.ACCESS_BONUS, PRESENT_LIMITTIME, do_set_save=False) modellist.extend(presentlist) presentlist = BackendApi.create_present(model_mgr, 0, uid, itype, itemid, itemvalue, Defines.TextMasterID.ACCESS_BONUS, now, do_set_save=False) modellist.extend(presentlist) for _ in xrange(PRESENT): putPresent(Defines.ItemType.GOLD, 0, 1000) putPresent(Defines.ItemType.GACHA_PT, 0, 10) putPresent(Defines.ItemType.ITEM, random.choice(item_all).id, 1) putPresent(Defines.ItemType.CARD, random.choice(card_all).id, 1) putPresent(Defines.ItemType.RAREOVERTICKET, 0, 1) putPresent(Defines.ItemType.TRYLUCKTICKET, 0, 1) putPresent(Defines.ItemType.MEMORIESTICKET, 0, 1) putPresent(Defines.ItemType.GACHATICKET, 0, 1) putPresent(Defines.ItemType.GOLDKEY, 0, 1) putPresent(Defines.ItemType.SILVERKEY, 0, 1) # 宝箱. def makeTreasure(masterlist, model_cls, etime): master = random.choice(masterlist) model = model_cls() model.uid = uid model.mid = master.id model.etime = etime modellist.append(model) for _ in xrange(TREASURE_NUM): makeTreasure(treasure_gold_all, TreasureGold, now) makeTreasure(treasure_gold_all, TreasureGold, PRESENT_LIMITTIME) makeTreasure(treasure_silver_all, TreasureSilver, now) makeTreasure(treasure_silver_all, TreasureSilver, PRESENT_LIMITTIME) makeTreasure(treasure_bronze_all, TreasureBronze, now) makeTreasure(treasure_bronze_all, TreasureBronze, PRESENT_LIMITTIME) modellist_all.add(modellist) print 'complete uid=%d' % uid print '================================' print 'friends..' # ユーザーがそろっていないと作れないレコード. for i in xrange(USER_NUM): modellist = [] uid = i + USER_ID_START # フレンド設定. self.putFriends(modellist, uid, USER_ID_START, USER_NUM, FRIEND, FRIEND_REQUEST) # あいさつ履歴. fid = uid for _ in xrange(GREETLOG): fid = ((fid - USER_ID_START + 1) % USER_NUM) + USER_ID_START while fid == uid: fid = ((fid - USER_ID_START + 1) % USER_NUM) + USER_ID_START model = GreetLog() model.fromid = fid model.toid = uid modellist.append(model) modellist_all.add(modellist) print 'complete uid=%d' % uid csvmgr.output() print '================================' print 'all done..'
def process(self): try: # スカウトID. args = self.getUrlArgs('/scoutdo/') scoutid = int(args.get(0)) or None scoutkey = urllib.unquote(args.get(1) or '') str_flag_skip = self.request.get(Defines.URLQUERY_SKIP) if not str_flag_skip in ('1', '0'): str_flag_skip = None except: raise CabaretError(u'引数が想定外です', CabaretError.Code.ILLEGAL_ARGS) v_player = self.getViewerPlayer() # 演出スキップフラグ. if str_flag_skip: flag_skip = bool(int(str_flag_skip)) BackendApi.set_scoutskip_flag(v_player.id, flag_skip) else: flag_skip = BackendApi.get_scoutskip_flag(v_player.id) model_mgr = self.getModelMgr() using = settings.DB_DEFAULT # マスターデータ. scoutmaster = None if scoutid: scoutmasterlist = BackendApi.get_scouts(model_mgr, [scoutid], using) scoutmaster = scoutmasterlist[0] if scoutmasterlist else None if scoutmaster is None: raise CabaretError(u'不正なアクセスです', CabaretError.Code.ILLEGAL_ARGS) areamaster = BackendApi.get_area(model_mgr, scoutmaster.area, using) if areamaster is None: self.redirectWithError(CabaretError(u'閲覧できないエリアです', CabaretError.Code.ILLEGAL_ARGS)) return # 遊べるかを確認. if not BackendApi.check_scout_playable(model_mgr, scoutmaster, v_player, using): # クリア条件を満たしていない. self.redirectWithError(CabaretError(u'閲覧できないエリアです', CabaretError.Code.ILLEGAL_ARGS)) return if not scoutkey: scoutkey = BackendApi.get_scoutkey(model_mgr, v_player.id, scoutmaster.id, using) # SHOWTIME確認. raideventmaster = BackendApi.get_current_raideventmaster(model_mgr, using=using) if raideventmaster is None or raideventmaster.flag_dedicated_stage: champagnecall_start = False champagnecall = False else: champagnecall_start = BackendApi.get_raidevent_is_champagnecall_start(model_mgr, v_player.id, using=using) champagnecall = not champagnecall_start and BackendApi.get_raidevent_is_champagnecall(model_mgr, v_player.id, using=using) # 実行. champagnecall_started = False try: model_mgr, playdata = db_util.run_in_transaction(self.tr_write, v_player.id, scoutmaster, scoutkey, champagnecall, champagnecall_start) model_mgr.write_end() champagnecall_started = bool(playdata.result.get('champagne')) except CabaretError, err: if err.code == CabaretError.Code.ALREADY_RECEIVED: model_mgr.delete_models_from_cache(ScoutPlayData, [ScoutPlayData.makeID(v_player.id, scoutmaster.id)]) else: # うまく実行できない. if settings_sub.IS_DEV: # マスターデータが正しくないとかあるだろうからそのチェック用. raise # ここに来るのは不正アクセス等のユーザという想定. self.redirectWithError(CabaretError(u'閲覧できないエリアです', CabaretError.Code.ILLEGAL_ARGS)) return