Exemple #1
0
    def test_tagged_ml(self):
        from pymudclient.tagged_ml_parser import taggedml

        weapon_name = "battleaxe"
        weapon_number = "123"
        ml = taggedml("Weapon <red*>%s<white> set to <red*>%s" % (weapon_name, weapon_number))
        print(ml.line)
Exemple #2
0
    def who_trigger(self, match, realm):
        location = match.group(2)
        target = match.group(1)

        if self.who_state=='sent_who':
            
            if target.lower() == self.who_target:
                self.who_state = 'sent_path_search'
                self.who_location = location
                realm.send('path search %s'%location)
                realm.root.set_timer(5, self.reset_who_state)
        
        
        #line = taggedml(' <white>(<yellow*>'+'<white>,<yellow>'.join([str(i.vnum) for i in self.mapper.find_by_name(location)]) + '<white>)')
        l = [str(i.vnum) for i in self.mapper.find_by_name(location)]
        if len(l) == 1:            
            line = ' <white>(<yellow*>%s<white>)'%l[0]
        elif len(l) == 0:
            line = ' <white>(<red*>*<white>)'
        else:
            line = ' <white>(<yellow*>%s<white>,<yellow*>...<white>)'%l[0]
            
        ml = taggedml(line)
        #realm.cwrite(line)
       
        realm.alterer.insert_metaline(len(realm.metaline.line), ml)
Exemple #3
0
    def who_trigger(self, match, realm):
        location = match.group(2)
        target = match.group(1)

        if self.who_state == 'sent_who':

            if target.lower() == self.who_target:
                self.who_state = 'sent_path_search'
                self.who_location = location
                realm.send('path search %s' % location)
                realm.root.set_timer(5, self.reset_who_state)

        #line = taggedml(' <white>(<yellow*>'+'<white>,<yellow>'.join([str(i.vnum) for i in self.mapper.find_by_name(location)]) + '<white>)')
        l = [str(i.vnum) for i in self.mapper.find_by_name(location)]
        if len(l) == 1:
            line = ' <white>(<yellow*>%s<white>)' % l[0]
        elif len(l) == 0:
            line = ' <white>(<red*>*<white>)'
        else:
            line = ' <white>(<yellow*>%s<white>,<yellow*>...<white>)' % l[0]

        ml = taggedml(line)
        #realm.cwrite(line)

        realm.alterer.insert_metaline(len(realm.metaline.line), ml)
Exemple #4
0
 def match_item(self,match,realm):
     if self.weapon_match_status=='matching':
         name=match.group(1)
         number=match.group(2)   
         realm.write(taggedml('Weapon <red*>%s<white> set to <red*>%s'%(self.ii_matching_item,number)))
         self.items[self.ii_matching_item]=number
         self.weapon_match_status='off'
Exemple #5
0
 def pb_do_pb(self, match, realm):
     if self.on:
         print("pb_do_pb")
         self.pb_balance=False
         if self.unknown_affs>0:
             self.unknown_affs-=1
             realm.write(taggedml('<red>Unknown afflictions: <red*>%d'%self.unknown_affs))        
Exemple #6
0
 def pb_back(self, match, realm):
     if self.on:
         print("pb_back")
         self.pb_balance=True
         if self.unknown_affs>0:
             realm.send('pb')
             realm.write(taggedml('<red>Unknown afflictions: <red*>%d'%self.unknown_affs))
Exemple #7
0
 def unknown_affliction(self, match, realm):
     if self.on:
         print("unknown_affliction")
         self.unknown_affs+=1
         if self.pb_balance:
             realm.send('pb')
         realm.write(taggedml('<red>Unknown afflictions: <red*>%d'%self.unknown_affs))
Exemple #8
0
 def set_weapon(self,match,realm):
     weapon_name=match.group(1)
     weapon_number=match.group(2)
     realm.send_to_mud=False
     realm.write(taggedml('Weapon <red*>%s<white> set to <red*>%s'%(weapon_name,weapon_number)))
     self.items[weapon_name]=weapon_number
     f=open(self.item_setting_file,'w+')
     pickle.dump(self.items, f)
Exemple #9
0
 def set_target(self, match, realm):
     my_target=match.group(1).capitalize()
     
     #ml = Metaline('Target set: %s'%my_target, RunLengthList([(0, fg_code(CYAN, True)),
     #                                                         (12,fg_code(RED,True))]),
     #              RunLengthList([(0,bg_code(BLACK))]))
     ml = taggedml('<cyan*:black>Target set: <red*>%s'%my_target)                                                    
     realm.write(ml)
     realm.root.state['target']=my_target
     realm.send_to_mud=False  
Exemple #10
0
 def execute_on_prompt(self, match, realm):
     target = realm.root.get_state('target')
     if target=='':
         return
     
     ent = self.entropy(target)
     if self.can_whirl:
         line_whirl = taggedml('[<orange*>B<white>]')
         realm.alterer.insert_metaline(len(realm.metaline.line), line_whirl)
     if ent.entropy>0:
         line_end=taggedml('[<red*>Ent: <green*>%d<white>]'%ent.entropy)
         realm.alterer.insert_metaline(len(realm.metaline.line), line_end)
     seeds = self.seed(target)
     if len(seeds.get_seeds())>0:
         line_seeds = taggedml('[<red*>Seeds: <blue>%s<white>]'%'<white>,<blue>'.join(seeds.get_seeds()))
         realm.alterer.insert_metaline(len(realm.metaline.line), line_seeds)
     saps = self.sap(target).get_color_coded_string()
     if saps!='':
         realm.alterer.insert_metaline(len(realm.metaline.line), taggedml(saps))
Exemple #11
0
    def execute_on_prompt(self, match, realm):
        target = realm.root.get_state('target')
        if target == '':
            return

        ent = self.entropy(target)
        if self.can_whirl:
            line_whirl = taggedml('[<orange*>B<white>]')
            realm.alterer.insert_metaline(len(realm.metaline.line), line_whirl)
        if ent.entropy > 0:
            line_end = taggedml('[<red*>Ent: <green*>%d<white>]' % ent.entropy)
            realm.alterer.insert_metaline(len(realm.metaline.line), line_end)
        seeds = self.seed(target)
        if len(seeds.get_seeds()) > 0:
            line_seeds = taggedml('[<red*>Seeds: <blue>%s<white>]' %
                                  '<white>,<blue>'.join(seeds.get_seeds()))
            realm.alterer.insert_metaline(len(realm.metaline.line), line_seeds)
        saps = self.sap(target).get_color_coded_string()
        if saps != '':
            realm.alterer.insert_metaline(len(realm.metaline.line),
                                          taggedml(saps))
Exemple #12
0
 def on_prompt(self, match, realm):
     target=realm.root.get_state('target')
     
     for t in self.trackers.values():
         t.process()
     
     if target != "":
         tracker = self.tracker(target)
         mentals = [a.name for a in tracker.affs.values() if a.is_it(FOCUSABLE) and a.on==True]
         physicals = [a.name for a in tracker.affs.values() if not a.is_it(FOCUSABLE) and a.on==True ]
         if len(mentals)>0 or len(physicals)>0:
             line = '[M: <blue>%(mentals)s <white>P:<red*> %(physicals)s<white>]'%{'mentals':'<white>,<blue>'.join(mentals),
                                                                       'physicals':'<white>,<red*>'.join(physicals)}
             
             realm.alterer.insert_metaline(len(realm.metaline.line), taggedml(line))
Exemple #13
0
 def cwrite(self, line, soft_line_start=False, channels = ['main']):
     ml=taggedml(line)
     ml.channels = channels
     self.write(ml, soft_line_start)
Exemple #14
0
 def cwrite(self, line, display_line=True, channels=['main']):
     ml=taggedml(line)
     ml.channels = channels
     self.write(ml, display_line)
Exemple #15
0
 def cwrite(self, line, soft_line_start=False):
     ml=taggedml(line)
     self.write(ml, soft_line_start)