min/modules/bake.py

104 lines
3.1 KiB
Python
Raw Normal View History

2020-04-06 20:32:51 +00:00
2020-04-06 22:18:22 +00:00
import dataset
2020-04-07 00:17:59 +00:00
import random
2020-04-06 22:18:22 +00:00
async def cheat(self, c, n, m):
if not await self.is_admin(n):
await self.message(c,'{} was a bad bad bad. {} got sucked into the oven'.format(n,n))
m = m.split(' ')
2020-04-07 00:17:59 +00:00
if len(m) < 2:
2020-04-06 22:18:22 +00:00
await message(c, 'i refuse.')
return
inv = self.db['inv']
inv.insert(dict(name=m[0], item=m[1]))
await self.message(c,'ok il allow this once')
async def bake(self, c, n, m):
if len(m) < 1:
await self.message(c, 'Dummy thicc you cant bake air!')
return
inv = self.db['inv']
2020-04-07 00:17:59 +00:00
its = (inv.find_one(name=n, item=m))
if its == None:
2020-04-06 22:18:22 +00:00
await self.message(c, 'You dont have any {}'.format(m))
return
2020-04-07 00:17:59 +00:00
# if item has value, use that, else use a okay value
if m in list(self.bakedGoods.keys()):
value = self.bakedGoods[m]
else:
value = 15
# consume the item
inv.delete(id=its['id'])
# oooo randomize what will pop out
2020-04-07 00:29:04 +00:00
value += random.uniform(-20, 20)
2020-04-07 00:17:59 +00:00
# choose the output
while value not in list(self.bakedPrice.keys()):
value = int(value - 1)
if value < 0:
2020-04-07 00:29:04 +00:00
await self.message(c, 'you notice some smoke, shouldint have put that {} in the oven!'.format(m))
return
2020-04-06 22:18:22 +00:00
2020-04-07 00:17:59 +00:00
newitem = self.bakedPrice[value]
inv.insert(dict(name=n, item=newitem))
await self.message(c, 'You bake your {}, and out pops a {}!'.format(m, newitem))
async def invsee(self, c, n, m):
if len(m) < 1:
m = n
inv = self.db['inv']
it = [ i['item'] for i in inv.find(name=m) ]
if len(it) < 1:
await self.message(c, 'you look through your kitchen and see nothing')
else:
2020-04-07 00:29:04 +00:00
await self.message(c, 'you look through your kitchen and see {}, with a combined value of ${}'.format(' '.join(it), sum([self.bakedGoods[i] for i in it])/10))
2020-04-06 20:32:51 +00:00
2020-04-07 01:15:28 +00:00
async def generate(self, c, n, m):
if int(random.uniform(0,20)) == 1:
inv = self.db['inv']
inv.insert(dict(name=n, item=random.choice(list(self.bakedGoods.keys()))))
qed = self.db['qed']
if qed.find_one(name=n) == None:
qed.insert(dict(name=n))
await self.message(n, 'Ding! you left some stuff in the oven! (you were lucky and found an item!!!) check out what you have with "ov items" and you can do cool stuff like bake them! (i will not query you again, so periodically check for new items!)')
2020-04-06 20:32:51 +00:00
async def init(self):
2020-04-06 22:18:22 +00:00
self.db = dataset.connect('sqlite:///database.db')
self.cmd['bake'] = bake
self.cmd['cheat'] = cheat
2020-04-07 00:17:59 +00:00
self.cmd['inv'] = invsee
self.cmd['items'] = invsee
self.cmd['goods'] = invsee
2020-04-07 01:32:57 +00:00
self.help['bake'] = ['bake <item> - bake some stuff', 'dont dirty the oven!']
self.help['cheat'] = ['cheat <user> <item> - you are bad if you use it', 'bad bad bad bad']
self.help['items'] = ['items - show the stuff in your inventory (more for aliases)', 'aliases for items include: inv, goods']
2020-04-07 01:15:28 +00:00
self.raw['genGoods'] = generate
2020-04-07 00:17:59 +00:00
self.bakedGoods = {
'cheese': 50,
'wheat': 1,
'turd': 0,
'flour': 10,
'bread': 30,
'crispy': 15,
'tortilla': 35,
'egg': 20,
'bird': 32,
'erotic': 69,
'phallic': 65,
'pizza': 34,
'hairball': 6,
'cookie': 44
}
self.bakedPrice = dict((v,k) for k,v in self.bakedGoods.items())
2020-04-06 20:32:51 +00:00