Beispiel #1
0
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)
Beispiel #2
0
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'受取終了時間')
Beispiel #3
0
class RaidPrizeDistributeQueue(BaseModel):
    """レイド成功報酬配布キュー.
    """
    class Meta:
        app_label = settings_sub.APP_NAME
        abstract = False

    id = PositiveBigAutoField(primary_key=True, verbose_name=u'ID')
    uid = models.PositiveIntegerField(default=0, verbose_name=u'このキューの作成者')
    raidid = PositiveBigIntegerField(verbose_name=u'レイドID')
Beispiel #4
0
class GreetLog(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'あいさつしたユーザID')
    toid = models.PositiveIntegerField(db_index=True, verbose_name=u'あいさつされたユーザID')
    gtime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'あいさつした時間')
    commenttextid = models.CharField(max_length=64, verbose_name=u'コメントTEXTID', default='')
Beispiel #5
0
class RaidLog(BaseModel):
    """レイドログ.
    """
    class Meta:
        app_label = settings_sub.APP_NAME
        abstract = False

    id = PositiveBigAutoField(primary_key=True, verbose_name=u'ID')
    uid = models.PositiveIntegerField(verbose_name=u'ログの所有者')
    raidid = PositiveBigIntegerField(db_index=True, verbose_name=u'レイドID')
    ctime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'発見した時間')
Beispiel #6
0
class RankingGachaPlayLog(BaseModel):
    """ランキングガチャ全体履歴.
    """
    class Meta:
        app_label = settings_sub.APP_NAME
        abstract = False

    id = PositiveBigAutoField(primary_key=True, verbose_name=u'ID')
    uid = models.PositiveIntegerField(verbose_name=u'ユーザID')
    boxid = models.PositiveIntegerField(verbose_name=u'BoxID')
    point = PositiveBigIntegerField(verbose_name=u'総計pt')
    point_whole = PositiveBigIntegerField(verbose_name=u'総計pt')
    ctime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'作成時間')
Beispiel #7
0
class PlayerLog(BaseModel):
    """行動履歴.
    """
    class Meta:
        app_label = settings_sub.APP_NAME
        abstract = True

    id = PositiveBigAutoField(primary_key=True, verbose_name=u'ID')
    uid = models.PositiveIntegerField(db_index=True,
                                      verbose_name=u'作成したユーザーID')
    ctime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'作成した時間')
    logtype = models.PositiveSmallIntegerField(verbose_name=u'種別')
    data = ObjectField(verbose_name=u'履歴情報')
Beispiel #8
0
class RaidEventHelpSpecialBonusScore(BaseModel):
    id = PositiveBigAutoField(primary_key=True, verbose_name=u'ID')
    raidid = PositiveBigIntegerField(db_index=True, verbose_name=u'レイドID')
    uid = models.PositiveIntegerField(verbose_name=u'救援時ボーナスの所有者')
    bonusscore = models.PositiveSmallIntegerField(default=0, verbose_name=u'裏社会の秘宝ボーナス獲得UP倍率')
    ctime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'ログ生成時間')

    @classmethod
    def makeInstance(cls, raidid, uid, bonusscore=0):
        ins = cls()
        ins.raidid = raidid
        ins.uid = uid
        ins.bonusscore = bonusscore
        return ins
Beispiel #9
0
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'終了時間')
Beispiel #10
0
class SerialCode(BaseModel):
    """シリアルコード.
    """
    class Meta:
        app_label = settings_sub.APP_NAME
        abstract = False

    id = PositiveBigAutoField(primary_key=True, verbose_name=u'ID')
    serial = models.CharField(unique=True,
                              max_length=20,
                              verbose_name=u'シリアルコード')
    mid = models.PositiveIntegerField(default=0, verbose_name=u'マスターID')
    uid = models.PositiveIntegerField(default=0, verbose_name=u'入力したユーザー')
    itime = AppDateTimeField(default=OSAUtil.get_datetime_min,
                             verbose_name=u'入力した時間')
    is_pc = models.BooleanField(default=False, verbose_name=u'PC or SP')
Beispiel #11
0
class ShareSerialLog(BaseModel):
    """共有シリアルコードの入力情報を記録.
    """
    class Meta:
        app_label = settings_sub.APP_NAME
        abstract = False

    id = PositiveBigAutoField(primary_key=True, verbose_name=u'ID')
    serial = models.CharField(max_length=20, verbose_name=u'シリアルコード')
    mid = models.PositiveIntegerField(default=0, verbose_name=u'マスターID')
    uid = models.PositiveIntegerField(default=0, verbose_name=u'入力したユーザー')
    itime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'入力した時間')
    is_pc = models.BooleanField(default=False, verbose_name=u'PC or SP')

    @classmethod
    def createBySerialCode(cls, serialcode):
        ins = cls()
        ins.serial = serialcode.serial
        ins.mid = serialcode.mid
        return ins
Beispiel #12
0
class ProduceEventHappening(BaseModel):
    """プロでハプニング本体.
    """
    class Meta:
        app_label = settings_sub.APP_NAME
        abstract = False

    FIXED_COLUMNS = (
        'oid',
        'mid',
        'ctime',
        'level',
        'hprate',
        'event',
        'gold',
        'items'  # ここはハプニングが無いから固定.
    )

    id = PositiveBigAutoField(primary_key=True, verbose_name=u'ID')
    oid = models.PositiveIntegerField(db_index=True, verbose_name=u'発見者')
    mid = models.PositiveIntegerField(verbose_name=u'マスターID')
    state = TinyIntField(default=Defines.HappeningState.ACTIVE,
                         verbose_name=u'状態')
    ctime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'発生時間')
    progress = models.PositiveSmallIntegerField(default=0, verbose_name=u'進行度')
    gold = models.PositiveIntegerField(default=0, verbose_name=u'獲得ポケットマネー')
    items = ObjectField(default=dict, verbose_name=u'獲得アイテム')
    level = models.PositiveIntegerField(default=1, verbose_name=u'発生時のレベル')
    hprate = models.PositiveIntegerField(default=100, verbose_name=u'HPの変動率')
    event = PositiveBigIntegerField(default=0, verbose_name=u'イベントID')

    @staticmethod
    def makeID(uid, number):
        return (uid << 32) + number

    def is_end(self):
        return self.state == Defines.HappeningState.END

    def is_cleared(self):
        return self.state == Defines.HappeningState.CLEAR

    def is_boss_appeared(self):
        return self.state == Defines.HappeningState.BOSS

    def is_active(self):
        return not (self.is_cleared() or self.is_end())

    def is_canceled(self):
        return False

    @staticmethod
    def makeDropItemName(itype, mid):
        return (itype << 32) + mid

    def addDropItem(self, itype, mid):
        """ドロップアイテムを追加.
        """
        if not itype in (Defines.ItemType.ITEM, Defines.ItemType.CARD):
            raise CabaretError(u'ハプニング未対応のドロップです.タイプ=%s' %
                               Defines.ItemType.NAMES.get(itype, itype))
        key = ProduceEventHappening.makeDropItemName(itype, mid)
        num = self.items.get(key, 0)
        self.items[key] = num + 1

    def idDropped(self, itype, mid):
        """ドロップしたか.
        """
        return self.items and ProduceEventHappening.makeDropItemName(
            itype, mid) in self.items
Beispiel #13
0
class Present(PresentBase):
    """プレゼント.
    """
    class Meta:
        app_label = settings_sub.APP_NAME
        abstract = False

    id = PositiveBigAutoField(primary_key=True, verbose_name=u'ID')
    ctime = AppDateTimeField(default=OSAUtil.get_now, verbose_name=u'送信時間')

    @staticmethod
    def create(fromid, toid, itype, ivalue, textid=0, limittime=None, inum=1):
        """プレゼント作成.
        """
        ins = Present()
        ins.fromid = fromid
        ins.toid = toid
        ins.itype = itype
        ins.ivalue = ivalue
        ins.textid = textid
        ins.inum = inum
        if limittime:
            ins.limittime = limittime
        else:
            ins.limittime = OSAUtil.get_now(
            ) + Defines.PRESENT_RECEIVE_TIMELIMIT
        return ins

    @staticmethod
    def createByGold(fromid, toid, gold, textid=0, limittime=None):
        """お金.
        """
        return Present.create(fromid, toid, Defines.ItemType.GOLD, gold,
                              textid, limittime)

    @staticmethod
    def createByGachaPt(fromid, toid, point, textid=0, limittime=None):
        """引きぬきポイント.
        """
        return Present.create(fromid, toid, Defines.ItemType.GACHA_PT, point,
                              textid, limittime)

    @staticmethod
    def createByItem(fromid,
                     toid,
                     itemmaster,
                     textid=0,
                     limittime=None,
                     num=1):
        """アイテム.
        """
        return Present.create(fromid, toid, Defines.ItemType.ITEM,
                              itemmaster.id, textid, limittime, num)

    @staticmethod
    def createByCard(fromid,
                     toid,
                     cardmaster,
                     textid=0,
                     limittime=None,
                     num=1):
        """カード.
        """
        return Present.create(fromid, toid, Defines.ItemType.CARD,
                              cardmaster.id, textid, limittime, num)

    @staticmethod
    def createByRareoverTicket(fromid, toid, ticket, textid=0, limittime=None):
        """レア以上チケット.
        """
        return Present.create(fromid, toid, Defines.ItemType.RAREOVERTICKET,
                              ticket, textid, limittime)

    @staticmethod
    def createByTicket(fromid, toid, ticket, textid=0, limittime=None):
        """運試しチケット.
        """
        return Present.create(fromid, toid, Defines.ItemType.TRYLUCKTICKET,
                              ticket, textid, limittime)

    @staticmethod
    def createByMemoriesTicket(fromid, toid, ticket, textid=0, limittime=None):
        """思い出チケット.
        """
        return Present.create(fromid, toid, Defines.ItemType.MEMORIESTICKET,
                              ticket, textid, limittime)

    @staticmethod
    def createByGachaTicket(fromid, toid, ticket, textid=0, limittime=None):
        """引き抜きチケット.
        """
        return Present.create(fromid, toid, Defines.ItemType.GACHATICKET,
                              ticket, textid, limittime)

    @staticmethod
    def createByAdditionalTicket(fromid,
                                 toid,
                                 tickettype,
                                 num,
                                 textid=0,
                                 limittime=None):
        """追加ガチャチケット.
        """
        return Present.create(fromid,
                              toid,
                              Defines.ItemType.ADDITIONAL_GACHATICKET,
                              tickettype,
                              textid,
                              limittime,
                              inum=num)

    @staticmethod
    def createByGoldKey(fromid, toid, num, textid=0, limittime=None):
        """金の鍵.
        """
        return Present.create(fromid, toid, Defines.ItemType.GOLDKEY, num,
                              textid, limittime)

    @staticmethod
    def createBySilverKey(fromid, toid, num, textid=0, limittime=None):
        """銀の鍵.
        """
        return Present.create(fromid, toid, Defines.ItemType.SILVERKEY, num,
                              textid, limittime)

    @staticmethod
    def createByEventGachaTicket(fromid,
                                 toid,
                                 eventid,
                                 num,
                                 textid=0,
                                 limittime=None):
        """イベントガチャチケット.
        """
        return Present.create(fromid, toid, Defines.ItemType.EVENT_GACHATICKET,
                              eventid, textid, limittime, num)

    @staticmethod
    def createByScoutEventTanzaku(fromid,
                                  toid,
                                  tanzaku_number,
                                  num,
                                  textid=0,
                                  limittime=None):
        """スカウトイベント短冊.
        """
        return Present.create(fromid, toid,
                              Defines.ItemType.SCOUTEVENT_TANZAKU,
                              tanzaku_number, textid, limittime, num)

    @staticmethod
    def createByCabaretClubMoney(fromid,
                                 toid,
                                 value,
                                 textid=0,
                                 limittime=None):
        """キャバクラシステムの特別なマネー.
        """
        return Present.create(fromid, toid,
                              Defines.ItemType.CABARETCLUB_SPECIAL_MONEY,
                              value, textid, limittime)

    @staticmethod
    def createByCabaretClubHonor(fromid,
                                 toid,
                                 value,
                                 textid=0,
                                 limittime=None):
        """名声ポイント.
        """
        return Present.create(fromid, toid,
                              Defines.ItemType.CABARETCLUB_HONOR_POINT, value,
                              textid, limittime)

    @staticmethod
    def createByPlatinumPiece(fromid, toid, num, textid=0, limittime=None):
        """プラチナの欠片
        """
        return Present.create(fromid, toid, Defines.ItemType.PLATINUM_PIECE,
                              num, textid, limittime)

    @staticmethod
    def createByBattleTicket(fromid, toid, num, textid=0, limittime=None):
        """プラチナの欠片
        """
        return Present.create(fromid, toid, Defines.ItemType.BATTLE_TICKET,
                              num, textid, limittime)

    @staticmethod
    def createByCrystalPiece(fromid, toid, num, textid=0, limittime=None):
        """クリスタルの欠片
        """
        return Present.create(fromid, toid, Defines.ItemType.CRYSTAL_PIECE,
                              num, textid, limittime)