コード例 #1
0
 def Block(self, amount_pln, game):
     self._proto.payments.free_balance_pln -= amount_pln
     self._proto.payments.total_blocked_pln += amount_pln
     self._proto.payments.transaction.add(
         timestamp=time_util.DateTimeToTimestampProto(time_util.now()),
         type=vbreg_pb2.Transaction.BLOCK,
         amount_pln=amount_pln,
         game={'id': game.id})
コード例 #2
0
 def Return(self, amount_pln, game):
     self._proto.payments.balance_pln += amount_pln
     self._proto.payments.free_balance_pln += amount_pln
     self._proto.payments.total_paid_pln -= amount_pln
     self._proto.payments.transaction.add(
         timestamp=time_util.DateTimeToTimestampProto(time_util.now()),
         type=vbreg_pb2.Transaction.RETURN,
         amount_pln=amount_pln,
         game={'id': game.id})
コード例 #3
0
 def Deposit(self, amount_pln, deposit_source):
     self._proto.payments.balance_pln += amount_pln
     self._proto.payments.free_balance_pln += amount_pln
     self._proto.payments.total_deposited_pln += amount_pln
     self._proto.payments.transaction.add(
         timestamp=time_util.DateTimeToTimestampProto(time_util.now()),
         type=vbreg_pb2.Transaction.DEPOSIT,
         amount_pln=amount_pln,
         deposit_source=deposit_source)
コード例 #4
0
    def FromRequest(cls, request, games):
        """Creates an instance from a proto request. Factory method.

    Args:
      request: PlayerAddOrTouchRequest. Player to add.
      games: Games. Shared service state.
    Returns:
      _Player.
    """
        # Create a new Player proto from request.
        proto = vbreg_pb2.Player(
            facebook_id=request.facebook_id,
            name=request.name,
            bank_transfer_id=cls._GenerateBankTransferId(request.name, games),
            last_touch=time_util.DateTimeToTimestampProto(time_util.now()))
        proto.payments.balance_pln = 0
        proto.payments.free_balance_pln = 0
        proto.payments.total_deposited_pln = 0
        proto.payments.total_paid_pln = 0
        proto.payments.total_blocked_pln = 0
        # Wrap a _Player instance around the Player proto.
        return cls(observable.Create(proto, with_delta=False))
コード例 #5
0
 def UpdateLastTouch(self):
     time_util.DateTimeToTimestampProto(time_util.now(),
                                        self._proto.last_touch)