class CurrentRaidEventConfig(Singleton): """開催中または開催予定のレイド. """ class Meta: app_label = settings_sub.APP_NAME abstract = False mid = models.PositiveIntegerField(default=0, verbose_name=u'イベントのマスターID') starttime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'開始時間') endtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'終了時間') prize_flag = models.PositiveIntegerField(default=0, verbose_name=u'ランキング報酬配布フラグ') bigtime = AppDateTimeField(default=OSAUtil.get_datetime_max, verbose_name=u'大ボス出現時間') ticket_endtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'秘宝交換とガチャ公開終了時間') timebonus_time = JsonCharField(default=list, verbose_name=u'タイムボーナス時間') combobonus_opentime = JsonCharField(default=list, verbose_name=u'コンボボーナス公開開始時間') feverchance_opentime = JsonCharField(default=list, verbose_name=u'フィーバーチャンス公開開始時間') fastbonus_opentime = JsonCharField(default=list, verbose_name=u'秘宝ボーナス公開開始時間') epilogue_endtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'エピローグ終了時間') beginer_prize_flag = models.PositiveIntegerField(default=0, verbose_name=u'新店舗ランキング報酬配布フラグ') stageschedule = JsonCharField(default=list, verbose_name=u'途中追加されるステージのスケジュール') def get_stage_max(self, now=None): """現在の最大ステージ数. 無制限の場合はNone. """ stage_max = None if self.stageschedule: now = now or OSAUtil.get_now() self.stageschedule.sort(key=lambda x:x['time']) for data in self.stageschedule: if data['time'] <= now: continue stage_max = data['stage'] - 1 break return stage_max
class RareCardLog(BaseModel): """レアキャバ嬢獲得履歴. """ class Meta: app_label = settings_sub.APP_NAME abstract = False id = models.PositiveIntegerField(primary_key=True, verbose_name=u'ユーザID') card0 = models.PositiveIntegerField(default=0, verbose_name=u'獲得したカード 最新') gtime0 = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'獲得した時間 最新') card1 = models.PositiveIntegerField(default=0, verbose_name=u'獲得したカード 1個前') gtime1 = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'獲得した時間 1個前') def add(self, cardmasterid): self.card1 = self.card0 self.gtime1 = self.gtime0 self.card0 = cardmasterid self.gtime0 = OSAUtil.get_now() def to_array(self): arr = [] for cid, gtime in [(self.card0, self.gtime0), (self.card1, self.gtime1)]: if cid: arr.append({'card': cid, 'time': gtime}) return arr
class CurrentProduceEventConfig(Singleton): """開催中または開催予定のプロデュースイベント. """ class Meta: app_label = settings_sub.APP_NAME abstract = False mid = models.PositiveIntegerField(default=0, verbose_name=u'イベントのマスターID') starttime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'開始時間') endtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'終了時間') bigtime = AppDateTimeField(default=OSAUtil.get_datetime_max, verbose_name=u'大ボス出現時間') epilogue_endtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'エピローグ終了時間') def is_open_event(self, target_time): return self.starttime <= target_time < self.endtime def is_open_epilogue(self, target_time): return self.endtime <= target_time < self.epilogue_endtime def get_produce_event_master(self, model_mgr, using=settings.DB_DEFAULT): produce_event_master = model_mgr.get_model(ProduceEventMaster, self.mid, using=using) if not produce_event_master: raise CabaretError(u'対応するProduceEventMasterが存在しません', code=CabaretError.Code.INVALID_MASTERDATA) return produce_event_master
class PlayerAp(BaseModel): """プレイヤーの行動力. """ class Meta: app_label = settings_sub.APP_NAME abstract = False id = models.PositiveIntegerField(primary_key=True, verbose_name=u'ユーザID') ap = models.PositiveSmallIntegerField(default=0, verbose_name=u'体力') apmax = models.PositiveSmallIntegerField(default=10, verbose_name=u'体力最大値') aprtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'体力を書き込んだ時間') bp = models.PositiveSmallIntegerField(default=0, verbose_name=u'気力') bprtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'気力を書き込んだ時間') bpmax = 100 # 100固定に. AP_COLUMN_NAME = 'ap' BP_COLUMN_NAME = 'bp' AP_TIME_COLUMN_BASE = '%srtime' AP_MAX_COLUMN_BASE = '%smax' AP_RECOVE_TIME_TABLE = { AP_COLUMN_NAME: Defines.AP_RECOVE_TIME, BP_COLUMN_NAME: Defines.BP_RECOVE_TIME, }
class PlayerLogin(BaseModel): """ログイン情報. """ class Meta: app_label = settings_sub.APP_NAME abstract = False id = models.PositiveIntegerField(primary_key=True, verbose_name=u'ユーザID') ltime = AppDateTimeField(default=OSAUtil.get_now, db_index=True, verbose_name=u'最終ログイン時間') ldays = models.PositiveSmallIntegerField(default=0, verbose_name=u'連続ログイン日数') pdays = models.PositiveSmallIntegerField(default=0, verbose_name=u'プレイ日数') lbtime = AppDateTimeField(default=OSAUtil.get_datetime_min, verbose_name=u'ログインボーナス受取り時間') tldays_view = models.PositiveSmallIntegerField(default=0, verbose_name=u'累計ログイン日数') tldays = models.PositiveSmallIntegerField(default=0, verbose_name=u'累計ログイン日数(報酬用)') tlmid = models.PositiveIntegerField( default=0, verbose_name=u'最後に受け取った累計ログインボーナスのマスターID') def getDays(self, tlmid): if 0 < tlmid and self.tlmid == tlmid: return self.tldays else: return 0 def getDaysView(self, tlmid): if 0 < tlmid and self.tlmid == tlmid: return self.tldays_view else: return 0
class ProduceEventFlags(BasePerPlayerBase): """プロデュースイベントフラグ. """ class Meta: app_label = settings_sub.APP_NAME abstract = False mid = models.PositiveIntegerField(db_index=True, verbose_name=u'イベントのマスターID') opvtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'OP演出閲覧時間') epvtime = AppDateTimeField(default=OSAUtil.get_datetime_min, verbose_name=u'EP演出閲覧時間') @staticmethod def get_instance(model_mgr, uid, eventmaster_id, using=settings.DB_DEFAULT): model = model_mgr.get_model(ProduceEventFlags, ProduceEventFlags.makeID( uid, eventmaster_id), get_instance=True, using=using) return model
class ScheduleMaster(BaseMaster): """スケジュール. """ class Meta: app_label = settings_sub.APP_NAME abstract = False id = models.PositiveIntegerField(primary_key=True, verbose_name=u'ID') stime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'公開開始時間') etime = AppDateTimeField(db_index=True, default=OSAUtil.get_now, verbose_name=u'公開終了時間') wday = models.PositiveSmallIntegerField(default=Defines.WeekDay.ALL, verbose_name=u'曜日指定', choices=dict_to_choices( Defines.WeekDay.NAMES)) shour = models.PositiveSmallIntegerField(default=0, verbose_name=u'日毎の開始時間(時)', choices=numberitems(0, 24)) sminute = models.PositiveSmallIntegerField(default=0, verbose_name=u'日毎の開始時間(分)', choices=numberitems(0, 60)) timelimit = models.PositiveSmallIntegerField(default=0, verbose_name=u'日毎の制限時間(分)') target = JsonCharField(default=list, verbose_name=u'対象のユーザID下一桁')
class BaseTreasure(BaseModel): """宝箱. """ class Meta: abstract = True id = PositiveBigAutoField(primary_key=True, verbose_name=u'ID') uid = models.PositiveIntegerField(verbose_name=u'ユーザID') mid = models.PositiveIntegerField(verbose_name=u'マスターID') ctime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'獲得時間') etime = AppDateTimeField(db_index=True, default=OSAUtil.get_now, verbose_name=u'受取終了時間')
class PromotionDataBase(BasePerPlayerBaseWithMasterID): """クロスプロモーション達成データ. """ class Meta: abstract = True app_label = settings_sub.APP_NAME status = models.PositiveSmallIntegerField( default=Defines.PromotionStatus.NONE, choices=dict_to_choices(Defines.PromotionStatus.NAMES), verbose_name=u'達成状態') atime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'達成した時間') rtime = AppDateTimeField(default=OSAUtil.get_datetime_min, verbose_name=u'受け取った時間')
class RaidEventFlags(BasePerPlayerBase): """レイドイベントフラグ. """ class Meta: app_label = settings_sub.APP_NAME abstract = False mid = models.PositiveIntegerField(db_index=True, verbose_name=u'イベントのマスターID') opvtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'OP演出閲覧時間') tbvtime = AppDateTimeField(default=OSAUtil.get_datetime_min, verbose_name=u'タイムボーナス演出閲覧時間') destroyprize_flags = ObjectField(default=list, verbose_name=u'討伐回数報酬受取りフラグ') destroyprize_big_flags = ObjectField(default=list, verbose_name=u'討伐回数報酬受取りフラグ(大ボス)') destroyprize_received = ObjectField(default=list, verbose_name=u'直前に受け取った報酬') epvtime = AppDateTimeField(default=OSAUtil.get_datetime_min, verbose_name=u'EP演出閲覧時間')
class ScoutEventFlags(BasePerPlayerBase): """スカウトイベントフラグ関係. """ class Meta: app_label = settings_sub.APP_NAME abstract = False mid = models.PositiveIntegerField(db_index=True, verbose_name=u'イベントのマスターID') opvtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'OP演出閲覧時間') destroyprize_received = ObjectField(default=list, verbose_name=u'直前に受け取ったポイント報酬') epvtime = AppDateTimeField(default=OSAUtil.get_datetime_min, verbose_name=u'EP演出閲覧時間')
class RaidHelp(BaseModel): """救援依頼. """ class Meta: app_label = settings_sub.APP_NAME abstract = False id = PositiveBigAutoField(primary_key=True, verbose_name=u'ID') fromid = models.PositiveIntegerField(db_index=True, verbose_name=u'ログの所有者') toid = models.PositiveIntegerField(verbose_name=u'ログの所有者') raidid = PositiveBigIntegerField(db_index=True, verbose_name=u'レイドID') raidevent_specialbonusscore = models.PositiveSmallIntegerField( default=0, verbose_name='レイドイベント時ボーナス特攻獲得UP倍率') ctime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'発見した時間') etime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'終了時間')
class GreetPlayerData(BaseModel): """プレイヤーのあいさつ情報. """ class Meta: app_label = settings_sub.APP_NAME abstract = False id = models.PositiveIntegerField(primary_key=True, verbose_name=u'ユーザID') ltime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'最後にあいさつした時間') today = models.PositiveSmallIntegerField(default=0, verbose_name=u'本日あいさつ回数') yesterday = models.PositiveSmallIntegerField(default=0, verbose_name=u'前日あいさつ回数') total = models.PositiveIntegerField(default=0, verbose_name=u'総あいさつ回数') def getTodayCount(self): """今日の挨拶回数を取得. """ now = OSAUtil.get_now() if DateTimeUtil.judgeSameDays(self.ltime, now): return self.today else: return 0 def addCount(self, cnt=1): """あいさつ回数を加算. """ now = OSAUtil.get_now() if not DateTimeUtil.judgeSameDays(self.ltime, now): self.yesterday = self.today self.today = 0 self.today += cnt self.total += cnt self.ltime = now
class ScoutEventPlayStageData(BasePerPlayerBaseWithMasterID): """スカウトイベントのプレイ情報. """ class Meta: app_label = settings_sub.APP_NAME abstract = False ctime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'クリア時間') clevel = models.PositiveIntegerField(default=0, verbose_name=u'クリア時のレベル') dropitems = ObjectField(default=list, verbose_name=u'獲得したカード・トロフィー') @staticmethod def makeDropItemName(itype, mid): return (itype << 32) + mid def addDropItem(self, itype, mid): """ドロップアイテムを追加. """ self.dropitems.append(ScoutEventPlayData.makeDropItemName(itype, mid)) self.dropitems = list(set(self.dropitems)) def idDropped(self, itype, mid): """ドロップしたことあるか. """ return self.dropitems and ScoutEventPlayData.makeDropItemName( itype, mid) in self.dropitems
class BannerBase(BaseMaster): class Meta: abstract = True id = models.PositiveIntegerField(primary_key=True, verbose_name=u'ID') name = models.TextField(verbose_name=u'名前(画像のalt属性に設定します)') jumpto = models.TextField(verbose_name=u'クリック時の飛び先', blank=True) imageurl = models.TextField(verbose_name=u'画像URL') priority = models.PositiveIntegerField(default=0, verbose_name=u'優先度') stime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'掲載開始日') etime = AppDateTimeField(default=OSAUtil.get_now, db_index=True, verbose_name=u'掲載終了日') comment_external = models.TextField(verbose_name=u'外部リンク用文言', default='', blank=True)
class UserLogBase(BaseModel): """ユーザログ. """ class Meta: app_label = settings_sub.APP_NAME abstract = True id = PositiveBigAutoField(primary_key=True, verbose_name=u'ID') uid = models.PositiveIntegerField(verbose_name=u'ユーザーID') ctime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'作成した時間') data = ObjectField(verbose_name=u'データ') @classmethod def create(cls, uid, *args, **kwargs): ins = cls() ins.uid = uid ins._setData(*args, **kwargs) return ins def _setData(self, *args, **kwargs): """各ログごとのデータを書き込む. """ raise NotImplementedError() def getData(self, key, default=None): data = self.data or {} return data.get(key, default)
class InfomationMaster(BaseMaster): """お知らせのマスターデータ. """ class Meta: app_label = settings_sub.APP_NAME abstract = False id = models.PositiveIntegerField(primary_key=True, verbose_name=u'ID') title = models.TextField(verbose_name=u'タイトル') body = models.TextField(verbose_name=u'本文') jumpto = models.TextField(verbose_name=u'クリック時の飛び先', blank=True) imageurl = models.TextField(verbose_name=u'画像URL', blank=True) stime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'掲載開始日') etime = AppDateTimeField(default=OSAUtil.get_now, db_index=True, verbose_name=u'掲載終了日')
class CabaClubItemPlayerData(BaseModel): """キャバクラ店舗のアイテム情報. """ class Meta: app_label = settings_sub.APP_NAME abstract = False id = models.PositiveIntegerField(primary_key=True, verbose_name=u'ユーザID') preferential_id = models.PositiveIntegerField(default=0, verbose_name=u'優待券のID') preferential_time = AppDateTimeField(default=OSAUtil.get_datetime_min, verbose_name=u'優待券の有効期限') barrier_id = models.PositiveIntegerField(default=0, verbose_name=u'バリアアイテムのID') barrier_time = AppDateTimeField(default=OSAUtil.get_datetime_min, verbose_name=u'バリアアイテムの有効期限')
class BaseMaster(BaseModel): class Meta: abstract = True pubstatus = models.PositiveSmallIntegerField( default=Defines.PublishStatus.PUBLIC, choices=dict_to_choices(Defines.PublishStatus.NAMES), verbose_name="公開ステータス") edittime = AppDateTimeField(default=OSAUtil.get_datetime_min(), db_index=True, verbose_name=u'更新時間') @property def is_public(self): return self.pubstatus == Defines.PublishStatus.PUBLIC @classmethod def get_formfields(cls): pkeyname = cls.get_primarykey_column() fields = [pkeyname, 'pubstatus'] for field in cls.get_fields(): if not field.name in fields: fields.append(field.name) return fields @classmethod def makeID(cls, uid, mid): return (uid << 32) + mid
class AlbumAcquisition(BasePerPlayerBaseWithMasterID): """アルバム開放フラグ. """ class Meta: app_label = settings_sub.APP_NAME abstract = False gtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'手に入れた時間')
class EventScoutPlayData(BasePerPlayerBaseWithMasterID): """イベント用スカウトのスカウトイベントの進行情報. """ class Meta: app_label = settings_sub.APP_NAME abstract = True stage = models.PositiveIntegerField(default=0, verbose_name=u'現在のステージ番号') cleared = models.PositiveIntegerField(default=0, verbose_name=u'クリア済みのステージ番号') progress = models.PositiveIntegerField(default=0, verbose_name=u'ステージ実行回数(進行度)') seed = models.PositiveIntegerField(default=AppRandom.makeSeed, verbose_name=u'乱数シード') confirmkey = models.CharField(max_length=20, default=OSAUtil.makeSessionID, verbose_name=u'重複確認用のキー') alreadykey = models.CharField(max_length=20, default='', verbose_name=u'重複確認用のキー') result = ObjectField(default=dict, verbose_name=u'前回の実行結果') ptime = AppDateTimeField(default=OSAUtil.get_datetime_min, verbose_name=u'最終プレイ時間') def _setResult(self, result, eventlist, flag_earlybonus=False): self.result = { 'result': result, 'event': eventlist, 'earlybonus': flag_earlybonus, }
class Friend(BaseModel): """仲間. """ class Meta: app_label = settings_sub.APP_NAME abstract = False FIXED_COLUMNS = ( 'uid','fid' ) id = PositiveBigIntegerField(primary_key=True, verbose_name=u'ID((ユーザID<<32)+フレンドID)') uid = models.PositiveIntegerField(verbose_name=u'ユーザID') fid = models.PositiveIntegerField(db_index=True, verbose_name=u'フレンドID') state = models.PositiveSmallIntegerField(verbose_name=u'状態', choices=dict_to_choices(Defines.FriendState.NAMES)) ctime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'更新時間') @staticmethod def makeID(uid, fid): return (uid << 32) + fid @staticmethod def create(uid, fid, state): ins = Friend() ins.id = Friend.makeID(uid, fid) ins.uid = uid ins.fid = fid ins.state = state return ins @classmethod def makeInstance(cls, key): uid = (key >> 32) fid = (key & 0xffffffff) return Friend.create(uid, fid, 0)
class GreetData(BaseModel): """あいさつ情報. """ class Meta: app_label = settings_sub.APP_NAME abstract = False FIXED_COLUMNS = ( 'fromid','toid' ) id = BigIntegerField(primary_key=True, verbose_name=u'ID((ユーザID<<32)+相手のID)') fromid = models.PositiveIntegerField(db_index=True, verbose_name=u'あいさつしたユーザID') toid = models.PositiveIntegerField(db_index=True, verbose_name=u'あいさつされたユーザID') ltime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'最後にあいさつした時間') @classmethod def makeID(cls, uid, oid): return (uid << 32) + oid @classmethod def makeInstance(cls, key): ins = cls() ins.id = key ins.fromid = (key >> 32) ins.toid = (key & 0xffffffff) return ins
class GachaPlayCount(BasePerPlayerBase): """ガチャプレイ回数. """ class Meta: app_label = settings_sub.APP_NAME abstract = False mid = models.PositiveIntegerField(db_index=True, verbose_name=u'マスターID') cnt = models.PositiveIntegerField(default=0, verbose_name=u'本日プレイ回数') cnttotal = models.PositiveIntegerField(default=0, verbose_name=u'総プレイ回数') step = models.PositiveIntegerField(default=0, verbose_name=u'本日ステップ数') steptotal = models.PositiveIntegerField(default=0, verbose_name=u'総ステップ数') lap = models.PositiveIntegerField(default=0, verbose_name=u'本日周回数') laptotal = models.PositiveIntegerField(default=0, verbose_name=u'総周回数') ptime = AppDateTimeField(default=OSAUtil.get_datetime_min, verbose_name=u'最終プレイ時間') def getTodayPlayCnt(self, now=None): now = now or OSAUtil.get_now() if DateTimeUtil.judgeSameDays(now, self.ptime): return self.cnt else: return 0 def addPlayCnt(self, cnt=1, now=None): self.cnt = self.getTodayPlayCnt(now) + cnt self.cnttotal += cnt self.ptime = now or OSAUtil.get_now()
class TreasureGoldOpened(BaseTreasure): """開封済み宝箱(金)情報. """ class Meta: app_label = settings_sub.APP_NAME abstract = False otime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'開封した時間')
class CardAcquisition(BasePerPlayerBaseWithMasterID): """カード取得フラグ. """ class Meta: app_label = settings_sub.APP_NAME abstract = False gtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'手に入れた時間') maxlevel = models.PositiveIntegerField(default=0, verbose_name=u'手に入れた最大レベル')
class CurrentCabaClubRankEventConfig(Singleton): """開催中または開催予定の経営イベント.""" class Meta(object): app_label = settings_sub.APP_NAME abstract = False mid = models.PositiveIntegerField(default=0, verbose_name=u'イベントのマスターID') starttime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'開始時間') endtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'終了時間') next_starttime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'次回開始時間') next_endtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'次回終了時間') prize_flag = models.PositiveIntegerField(default=0, verbose_name=u'ランキング報酬配布フラグ') previous_mid = models.PositiveIntegerField(default=0, verbose_name=u'前回のイベントのマスターID')
class Memories(BasePerPlayerBaseWithMasterID): """思い出アルバムのデータ. """ class Meta: app_label = settings_sub.APP_NAME abstract = False vtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'閲覧した時間')
class AreaPlayData(BasePerPlayerBaseWithMasterID): """エリアのプレイ情報. """ class Meta: app_label = settings_sub.APP_NAME abstract = False ctime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'クリア時間') clevel = models.PositiveIntegerField(default=0, verbose_name=u'クリア時のレベル')
class PresentEveryoneReceiveBase(BasePerPlayerBaseWithMasterID): """全プレ受け取り情報. """ class Meta: abstract = True rtime = AppDateTimeField(default=OSAUtil.get_datetime_min, verbose_name=u'最後に受け取った時間') cnt = models.PositiveSmallIntegerField(default=0, verbose_name=u'受け取った回数')