Beispiel #1
0
 def insert_stack(self):
     s = Stack()
     s.title = "Example Stack"
     s.image_base = "http://incf.ini.uzh.ch/image-stack-fib/"
     s.trakem2_project = False
     s.dimension = Integer3D(x=2048, y=1536, z=460)
     s.resolution = Double3D(x=5.0001, y = 5.0002, z=9.0003)
     s.save()
     return s
Beispiel #2
0
 def insert_stack(self):
     s = Stack()
     s.title = "Example Stack"
     s.image_base = "http://incf.ini.uzh.ch/image-stack-fib/"
     s.trakem2_project = False
     s.dimension = Integer3D(x=2048, y=1536, z=460)
     s.resolution = Double3D(x=5.0001, y = 5.0002, z=9.0003)
     s.save()
     return s
Beispiel #3
0
   def decorated_function(*args, **kwargs):
      if 'username' not in session or session['username'] is None or session['username'] == '':
         #This bypasses the actual set cookie for angularAuthentication in the notes route. So call it here!
         resp = make_response(render_template('app.html'))
         set_user_cookie(resp)
         return resp, 401

      #Check if this user already has a floating stack
      try:
         user = User.objects.get(username=session['username'])  # @UndefinedVariable
      except DoesNotExist:
         return dumps({'error':'could not retrieve user object while creating floating stack'}), 500
      try:
         #does the stack exist already, if not, create it
         stack = Stack.objects.get(title='Floating', owner=user)  # @UndefinedVariable
      except DoesNotExist:
         try:
            stack = Stack(
                       title='Floating',
                       owner = user,
                       createdat = datetime.now().strftime('%Y%m%d%H%M%S')
                    )
            stack.save()
         
         except:
            return dumps({'error':'could not create floating stack'}), 500
        
         
      #Remove floating 'new' atts
      attinstorage = Attachment.objects.filter(cardid__startswith='new')
      for att in attinstorage:
         if 'file' in att:
            att.file.delete()
         else:
            att.image.delete
         att.delete()
         
      linksinstorage = UrlAttachment.objects.filter(cardid__startswith='new')
      for att in linksinstorage:
         att.delete()
         
      return function(*args, **kwargs)   
Beispiel #4
0
def start(player):
    """
    Attempts creating a new game session for the given player.
    """
    if not player:
        return None

    # Initialize all the stacks.
    room_stack = Stack()
    room_stack.save()

    you_stack = Stack()
    you_stack.save()

    equipment_stack = Stack()
    equipment_stack.save()

    forge_stack = Stack()
    forge_stack.save()

    treasure_stack = Stack()
    treasure_stack.save()

    discard_stack = Stack()
    discard_stack.save()

    # Begin a new session.
    session = Session(
        health=HEALTH_CAPACITY,

        # Important to note that a session has to be tied to a player. Same goes for
        # cards and stacks; they must, ultimately, be tied to a session. Otherwise
        # it would be possible to move cards between sessions.
        belongs_to_player=player,
        room_stack=room_stack,
        you_stack=you_stack,
        equipment_stack=equipment_stack,
        forge_stack=forge_stack,
        treasure_stack=treasure_stack,
        discard_stack=discard_stack)

    session.save()

    # Draw the first 5 cards.
    initial_room_cards = draw(session, ROOM_CAPACITY)

    # Put the initial cards in place.
    room_stack.push_many(initial_room_cards)

    # If everything went as expected, activate the session by hooking it up to the player.
    player.active_session = session
    player.save()

    return session
Beispiel #5
0
def start(player):
    """
    Attempts creating a new game session for the given player.
    """
    if not player:
        return None

    # Initialize all the stacks.
    room_stack = Stack()
    room_stack.save()

    you_stack = Stack()
    you_stack.save()

    equipment_stack = Stack()
    equipment_stack.save()

    forge_stack = Stack()
    forge_stack.save()

    treasure_stack = Stack()
    treasure_stack.save()

    discard_stack = Stack()
    discard_stack.save()

    # Begin a new session.
    session = Session(
        health=HEALTH_CAPACITY,

        # Important to note that a session has to be tied to a player. Same goes for
        # cards and stacks; they must, ultimately, be tied to a session. Otherwise
        # it would be possible to move cards between sessions.
        belongs_to_player=player,
        room_stack=room_stack,
        you_stack=you_stack,
        equipment_stack=equipment_stack,
        forge_stack=forge_stack,
        treasure_stack=treasure_stack,
        discard_stack=discard_stack)

    session.save()

    # Draw the first 5 cards.
    initial_room_cards = draw(session, ROOM_CAPACITY)

    # Put the initial cards in place.
    room_stack.push_many(initial_room_cards)

    # If everything went as expected, activate the session by hooking it up to the player.
    player.active_session = session
    player.save()

    return session