def doubleGold(self, uid,*args,**kwargs):# return gold buff for a fight
GoldWin = 250
GoldLoose = 100
try:
gbuff = UserBuffGold.objects.filter(ubuff_id =uid)
for t in gbuff:
exp = parser.parse(t.exp_time)
if ((exp-datetime.now().day) <0 or (exp-datetime.now().hour<0) or (exp-datetime.now().minute<0)):
gbuff.delete()
GoldWin = 250
GoldLoose = 100
return GoldWin,GoldLoose
else:
#gbuff.delete()
GoldWin = 500
GoldLoose = 250
return GoldWin,GoldLoose
#return GoldWin,GoldLoose
except:
return GoldWin,GoldLoose
class UserBuffGold(models.Model):
ubuff = models.OneToOneField(User,on_delete=models.CASCADE,primary_key=True)
buffName = models.CharField(max_length = 150,default='Эссенция двойного опыта')
buffInfo = models.CharField(max_length = 150,default='Удваивает опыт на 20 боёв')
accept_time = models.DateTimeField(default=None)
exp_time = models.DateTimeField(default=None)
def __str__(self):
return (self.buffName + '|' + str(self.ubuff.username))
exp_time = models.DateTimeField(default=None)
print(exp - datetime.now())
>> -1 day, 13:00:00
gbuff = UserBuffGold.objects.filter(ubuff_id =uid)
for t in gbuff:
exp = t.exp_time
if (exp-datetime.now()<=datetime.now()): # Вот именно в этом условии проблема
gbuff.delete()
GoldWin = 250
GoldLoose = 100
return GoldWin,GoldLoose
File "C:/Users/valinor/PycharmProjects/strBot/dt.py", line 8, in <module>
if ((exp - datetime.now())<datetime.now()):
TypeError: '<' not supported between instances of 'datetime.timedelta' and 'datetime.datetime'
if (isset($_GET['id1']))
{
mysqli_query($connection,
"UPDATE users SET gold = gold - 36,pwr = pwr +39 ,ptime = 40*60,exp = exp + 39, pname='Госпительер',pimg='images/warrior/hosp.jpg' WHERE login ='$nm'");
}