Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. from datetime import datetime
  2.  
  3. from sqlalchemy import Column, Integer, DateTime, String
  4.  
  5. from app.util import Table
  6. from app.models import Base, Default
  7.  
  8.  
  9. class SpecialStage(Base, Default):
  10. __tablename__ = 'special_stages'
  11.  
  12. id = Column(Integer, primary_key=True)
  13. uid = Column(Integer)
  14. type = Column(String)
  15. next_at = Column(DateTime)
  16.  
  17. def __init__(self, **kwargs):
  18. Base.__init__(self, **kwargs)
  19. next_at = datetime.utcnow() + datetime(seconds=Table['StageSpecial']['ReAppearCondValue_Clear']['Value'])
  20.  
  21. def win(self, at):
  22. self.next_at = at + datetime(seconds=Table['StageSpecial']['ReAppearCondValue_Clear']['Value'])
  23.  
  24. def lose(self, at):
  25. self.next_at = at + datetime(seconds=Table['StageSpecial']['ReAppearCondValue_Fail']['Value'])
  26.  
  27. def to_dto(self, user):
  28. dto = SpecialStageDto()
  29.  
  30. desc = list(filter(lambda x: x['AppearStageIndexMin'] < user.stage, Table['StageSpecial'].values()))
  31. desc = sorted(desc, key=lambda x: x['AppearStageIndexMin'])
  32. desc = data[-1]
  33.  
  34. dto.desc_id = desc['id']
  35.  
  36. return dto
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement