Game of boggle added; Newline bug for monospaced messages fixed

master
Stefan Krulj 14 years ago
parent cae82bd051
commit 0ba1aa3623
  1. 51
      modules/active/boggle.py
  2. 4
      sys/brathuhn.py

@ -0,0 +1,51 @@
import brathuhn, random, time
DICE = [['A','A','A','F','R', 'S']]
DICE.append(['A','A','E','E','E','E'])
DICE.append(['A','A','F','I','R','S'])
DICE.append(['A','D','E','N','N','N'])
DICE.append(['A','E','E','E','E','M'])
DICE.append(['A','E','E','G','M','U'])
DICE.append(['A','E','G','M','N','N'])
DICE.append(['A','F','I','R','S','Y'])
DICE.append(['B','J','K','Qu','X','Z'])
DICE.append(['C','C','E','N','S','T'])
DICE.append(['C','E','I','I','L','T'])
DICE.append(['C','E','I','P','S','T'])
DICE.append(['C','E','I','L','P','T'])
DICE.append(['D','D','H','N','O','T'])
DICE.append(['D','H','H','L','O','R'])
DICE.append(['D','H','L','N','O','R'])
DICE.append(['D','H','L','N','O','R'])
DICE.append(['E','I','I','I','T','T'])
DICE.append(['E','M','O','T','T','T'])
DICE.append(['E','N','S','S','S','U'])
DICE.append(['F','I','P','R','S','Y'])
DICE.append(['G','O','R','R','V','W'])
DICE.append(['I','P','R','R','R','Y'])
DICE.append(['N','O','O','T','U','W'])
DICE.append(['O','O','O','T','T','U'])
def timesup(a):
brathuhn.sendMsg(brathuhn.ROOM,"Time's up!",'groupchat')
def boggle(msg,args):
if len(args)==1:
mymsg = ""
random.shuffle(DICE)
i = 0
for d in DICE:
if i % 5 == 0:
mymsg += "\n"
i+=1
mymsg += "%3s" % ( d[random.randint(0,5)] )
brathuhn.sendMonoMsg(brathuhn.ROOM,mymsg,'groupchat')
brathuhn.sendMsg(brathuhn.ROOM,"you have 3 minutes",'groupchat')
brathuhn.callAt(timesup, time.time()+60*3, [1])
else:
brathuhn.sendMsg(brathuhn.ROOM,"Usage: !boggle",'groupchat')
brathuhn.addCommand("boggle","Usage: !boggle",boggle)

@ -116,7 +116,9 @@ def sendMonoMsg(to,body,mtype=None):
c=mymsg.addChild('html', namespace='http://jabber.org/protocol/xhtml-im')
c=c.addChild('body',namespace='http://www.w3.org/1999/xhtml')
c=c.addChild('span', attrs={'style':'font-family: Courier New, monospace;'})
c=c.addChild('pre',payload=body,attrs={'style':'background-color: #ffffff;'})
for part in body.split('\n'):
c=c.addChild('pre',payload=part,attrs={'style':'background-color: #ffffff;'})
c=c.addChild('br')
cl.send(mymsg)
def __help(msg,args):

Loading…
Cancel
Save