diff plugins/xxheroinit.py @ 167:5c9a118476b2 alpha

Traipse Alpha 'OpenRPG' {091210-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Keeping up with Beta) New Features: Added Bookmarks Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Dieroller structure from Core Added 7th Sea die roller method; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Includes support for Mythos roller Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and no reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice
author sirebral
date Thu, 10 Dec 2009 10:53:33 -0600
parents c54768cffbd4
children
line wrap: on
line diff
--- a/plugins/xxheroinit.py	Thu Dec 03 00:50:44 2009 -0600
+++ b/plugins/xxheroinit.py	Thu Dec 10 10:53:33 2009 -0600
@@ -11,13 +11,12 @@
 
         # The Following code should be edited to contain the proper information
         self.name = 'Hero Turn Tool'
-        self.author = 'Heroman, based on xxxinit.py'
-        self.help = """This is the Hero Games turn turn. It is a bit more complex than other games."""
+        self.author = 'Heroman, based on xxxinit.py\n'
+        self.author = 'debugged for Traipse by Prof. Ebral'
+        self.help = """This is the Hero Games turn tool. It is a bit more complex than other games."""
 
 
     def plugin_enabled(self):
-        #You can add new /commands like
-        # self.plugin_addcommand(cmd, function, helptext)
         self.plugin_addcommand('/hinit', self.on_hinit, '- Toggle Init Recording on or off')
         self.plugin_addcommand('/hhelp', self.on_hhelp, '- List all of the Hero Init Commands')
         self.plugin_addcommand('/hstart', self.on_hstart, '- Start the Hero Init Tool', False)
@@ -51,36 +50,35 @@
         self.backup_list = []
         self.dexterity = 99
         self.segment = 12
-        self.state_strings = ["0 Phase","1/2 Phase","Full Phase","Stunned","Not Gone", "Held Full", "Held Half", "Abort"]
+        self.state_strings = ["0 Phase",
+                            "1/2 Phase",
+                            "Full Phase",
+                            "Stunned",
+                            "Not Gone", 
+                            "Held Full", "Held Half", "Abort"]
 
     def plugin_disabled(self):
-        #Here you need to remove any commands you added, and anything else you want to happen when you disable the plugin
-        #such as closing windows created by the plugin
-        self.plugin_removecmd('/test')
-        self.plugin_removecmd('/example')
+        self.plugin_removecmd('/hinit')
+        self.plugin_removecmd('/hhelp')
+        self.plugin_removecmd('/hstart')
+        self.plugin_removecmd('/hact')
+        self.plugin_removecmd('/hseg')
+        self.plugin_removecmd('/hdex')
+        self.plugin_removecmd('/hclear')
+        self.plugin_removecmd('/hadd')
+        self.plugin_removecmd('/hdel')
+        self.plugin_removecmd('/hown')
+        self.plugin_removecmd('/hlist')
+        self.plugin_removecmd('/hsort')
+        self.plugin_removecmd('/hrun')
+        self.plugin_removecmd('/hchange')
+        self.plugin_removecmd('/hset')
+        self.plugin_removecmd('/hchange')
 
-        #This is the command to delete a message handler
-        self.plugin_delete_msg_handler('xxblank')
-
-        #This is how you should destroy a frame when the plugin is disabled
-        #This same method should be used in close_module as well
-        try:
-            self.frame.Destroy()
-        except:
-            pass
+        try: self.frame.Destroy()
+        except: pass
 
     def plugin_incoming_msg(self, text, type, name, player):
-        #This is called whenever a message from someone else is received, no matter
-        #what type of message it is.
-        #The text variable is the text of the message. If the type is a regular
-        #message, it is already formatted. Otherwise, it's not.
-        #The type variable is an integer which tells you the type: 1=chat, 2=whisper
-        #3=emote, 4=info, and 5=system.
-        #The name variable is the name of the player who sent you the message.
-        #The player variable contains lots of info about the player sending the
-        #message, including name, ID#, and currently-set role.
-        #Uncomment the following line to see the format for the player variable.
-        #print player
 
         if self.toggle:
             if text.lower().find("heroinit") != -1:
@@ -91,11 +89,8 @@
     #Chat Commands
     def on_hinit(self, cmdargs):
         self.toggle = not self.toggle
-
-        if self.toggle:
-            self.chat.SystemPost("Init recording on.  Enter your info")
-        else:
-            self.chat.SystemPost("Init recording off")
+        if self.toggle: self.chat.SystemPost("Init recording on.  Enter your info")
+        else: self.chat.SystemPost("Init recording off")
 
     def on_hhelp(self, cmdargs):
             self.chat.InfoPost("Commands:<br>/hclear : Clears out list<br>" +
@@ -125,14 +120,9 @@
 
     def on_hact(self, cmdargs):
         cmds = cmdargs.split(None)
-
-        if len(cmds) == 1:
-            msg = self.do_action(-1, -1, cmds[0])
-        elif len(cmds) == 2:
-            msg = self.do_action(-1, int(cmds[0]), cmds[1])
-        else:
-            msg = "Error in command. See format with hero init"
-
+        if len(cmds) == 1: msg = self.do_action(-1, -1, cmds[0])
+        elif len(cmds) == 2: msg = self.do_action(-1, int(cmds[0]), cmds[1])
+        else: msg = "Error in command. See format with hero init"
         self.chat.InfoPost(msg)
 
     def on_hseg(self, cmdargs):
@@ -142,8 +132,7 @@
             new_seg = int(cmds[0])
             self.segment = new_seg
             self.call_time()
-        except:
-            self.chat.SystemPost("Invalid format.  correct command is: /hseg SEGMENT#")
+        except: self.chat.SystemPost("Invalid format.  correct command is: /hseg SEGMENT#")
 
     def on_hdex(self, cmdargs):
         cmds = cmdargs.split(None, 3)
@@ -152,8 +141,7 @@
             new_dex = int(cmds[0])
             self.dexterity = new_dex
             self.call_time()
-        except:
-            self.chat.SystemPost("Invalid format.  correct command is: /hdex DEX#")
+        except: self.chat.SystemPost("Invalid format.  correct command is: /hdex DEX#")
 
     def on_hclear(self, cmdargs):
         self.init_list = []
@@ -163,18 +151,20 @@
         self.chat.Post("<hr><font color='#ff0000'>New Initiative</font><br><font color='#0000ff'>Set new Initiatives</font>", True)
 
     def on_hadd(self, cmdargs):
+        print cmdargs
         cmds = cmdargs.split(None, 3)
+        print cmds, len(cmds)
         try:
             if len(cmds) == 3:
-                new_dex = int(txt[0])
-                new_spd = int(txt[1])
+                new_dex = int(cmds[0])
+                new_spd = int(cmds[1])
                 self.init_list.append([new_dex, new_spd, cmds[2], 0, -1])
                 self.backup_list.append([new_dex, new_spd, cmds[2], 0, -1])
                 self.list_inits()
-            else:
-                self.chat.SystemPost("Invalid format.  correct command is: /hadd dex spd description (" + str(len(cmds)) + " arguments give)")
+            else: self.chat.SystemPost("Invalid format.  correct command is: /hadd dex spd description (" + str(len(cmds)) + " arguments give)")
 
-        except:
+        except Exception, e:
+            print e
             self.chat.SystemPost("Invalid format.  correct command is: /hadd dex spd description")
 
     def on_hdel(self, cmdargs):
@@ -205,31 +195,22 @@
         if cmdargs == "high":
             self.init_list.reverse()
             self.backup_list.reverse()
-
         self.list_inits()
 
     def on_hrun(self, cmdargs):
         advance = True
         nextlowest = 0
         heldactions = False
-
         for player in self.init_list:
-            if self.actson(player[1]. self.segment):
-                if player[3] == 5 or player[3] == 6:
-                    heltactions = True
+            if self.actson(player[1], self.segment):
+                if player[3] == 5 or player[3] == 6: heltactions = True
                 continue
-
             if player[3] == 1 or player[3] == 2:
                 self.chat.InfoPost("Hero " + player[2] + " needs to act before we advance DEX")
                 advance = False
-
             elif player[3] == 3 or player[3] == 4 or player[3] == 7:
-                if player[0] > nextlowest:
-                    nextlowest = player[0]
-
-            elif player[3] == 5 or player[3] == 6:
-                heltactions = True
-
+                if player[0] > nextlowest: nextlowest = player[0]
+            elif player[3] == 5 or player[3] == 6: heltactions = True
         if not advance:
             return
 
@@ -238,53 +219,40 @@
         if nextlowest == 0 and self.dexterity != 0:
             if heldactions or self.segment == 12:
                 msg = "End of Segment " + str(self.segment) + "."
-                if heldactions:
-                    msg += " There are held actions."
-
+                if heldactions: msg += " There are held actions."
                 msg += "  Issue command again to advance to next segment."
-
                 self.chat.InfoPost(msg)
                 self.dexterity = 0
                 return
-            else:
-                advanceseg = True
-        elif nextlowest == 0 and self.dexterify == 0:
+            else: advanceseg = True
+        elif nextlowest == 0 and self.dexterity == 0:
             advanceseg = True
 
         if advanceseg:
             self.dexterity = nextlowest
             for player in self.init_list:
                 if player[0] == self.dexterity:
-                    if player[3] == 3 or player[3] == 7:
-                        player[3] = 0
-                    elif player[3] == 4:
-                        player[3] = 2
+                    if player[3] == 3 or player[3] == 7: player[3] = 0
+                    elif player[3] == 4: player[3] = 2
         else:
             nextsegment = 0
             while nextsegment == 0:
                 self.segment += 1
-                if self.segment == 13:
-                    self.segment = 1
-
+                if self.segment == 13: self.segment = 1
                 elif self.segment == 12:
                     nextsegment = 12
                     break
 
                 for player in self.init_list:
                     if self.actson(player[1], self.segment):
-                        if player[3] == 0 or player[3] == 3 or player[3] == 7:
-                            nextsegment = self.segment
-
-                    if player[3] == 5 or player[3] == 6:
-                        nextsegment = self.segment
+                        if player[3] == 0 or player[3] == 3 or player[3] == 7: nextsegment = self.segment
+                    if player[3] == 5 or player[3] == 6: nextsegment = self.segment
 
             self.dexterity = self.highestdex()
             for player in self.init_list:
                 heldactions = False
                 if self.actson(player[1], self.segment):
-                    if player[3] != 3 and player[3] != 7:
-                        player[3] = 4
-
+                    if player[3] != 3 and player[3] != 7: player[3] = 4
                     if player[0] == self.dexterity:
                         if player[3] == 3:
                             self.chat.InfoPost(player[2] + " unstuns.")
@@ -292,9 +260,7 @@
                         elif player[3] == 7:
                             self.chat.InfoPost(player[2] + " recovers from the abort")
                             player[3] = 0
-                        else:
-                            player[3] = 2
-
+                        else: player[3] = 2
                     if player[3] == 5 or player[3] == 6 and self.dexterity == 0:
                         self.chat.InfoPost("There are held actions. Issue command again to advance to next segment.")
         self.call_time()
@@ -325,19 +291,16 @@
         msg = ""
         stateindex = 0
         for state in self.state_strings:
-            if stateindex != 0:
-                msg += ", "
+            if stateindex != 0: msg += ", "
             msg += str(stateindex) + "=" + state
             stateindex += 1
         return msg
 
     def is_index(self, value):
         try:
-            if value[:1] == "+":
-                offset = 1
+            if value[:1] == "+": offset = 1
             return True
-        except:
-            return False
+        except: return False
 
     def actson(self, spd, segment):
         speeds=[[0,0,0,0,0,0,0,0,0,0,0,1],
@@ -353,41 +316,30 @@
                 [0,1,1,1,1,1,1,1,1,1,1,1],
                 [1,1,1,1,1,1,1,1,1,1,1,1]]
 
-        if spd < 1 or spd > 12:
-            return False
-
-        if speeds[spd-1][segment-1] == 1:
-            return True
-
+        if spd < 1 or spd > 12: return False
+        if speeds[spd-1][segment-1] == 1: return True
         return False
 
     def highestdex(self):
         dex = 0
         for player in self.init_list:
-            if self.actson(player[1], self.segment) and player[0] > dex:
-                dex = player[0]
+            if self.actson(player[1], self.segment) and player[0] > dex: dex = player[0]
         return dex
 
     def do_action(self, playerid, index, action):
         if index == -1:
             count = 1
             for player in self.init_list:
-                if player[4] == playerid:
-                    index = count
+                if player[4] == playerid: index = count
                 count += 1
-
-        if index == -1:
-            return "You do not have any players in the combat list"
-
+        if index == -1: return "You do not have any players in the combat list"
         index -= 1
         player = self.init_list[index]
-        if playerid != -1 and playerid != player[4]:
-            return "You do not own that player."
+        if playerid != -1 and playerid != player[4]: return "You do not own that player."
 
         # You can only perform a full action if you have a full or held full
         if action == "full":
-            if player[3] != 2 and player[3] != 5:
-                msg = player[2] + " cannot perform a full action."
+            if player[3] != 2 and player[3] != 5: msg = player[2] + " cannot perform a full action."
             else:
                 player[3] = 0
                 msg = player[2] + " performs a full action."
@@ -402,8 +354,7 @@
                     player[3] = 1
                     msg = player[2] + " performs a half action (half remaining)"
         elif action == "hold":
-            if player[3] != 1 and player[3] != 2:
-                msg = player[2] + " cannot hold an action."
+            if player[3] != 1 and player[3] != 2: msg = player[2] + " cannot hold an action."
             else:
                 if player[3] == 2:
                     player[3] = 5
@@ -423,58 +374,45 @@
             elif player[3] == 0 and not self.actson(player[1], self.segment):
                 player[3] = 7
                 msg = player[2] + " aborts!"
-            else:
-                msg = player[2] + " cannot abort yet."
-        else:
-            msg = "Unknown command."
-
+            else: msg = player[2] + " cannot abort yet."
+        else: msg = "Unknown command."
         return msg
 
     def list_inits(self, player=0, send=False):
         msg = "Combat Turn:<br>"
         msg += "<table border=1 cellspacing=1 cellpadding=1><tr><th><th></th></th><th></th><th></th><th></th><th></th><th colspan=12>Segments</th></tr>"
         msg += "<tr><th>#</th><th>Owner</th><th>Name</th><th>Spd</th><th>Dex</th><th>State</th>"
-        for x in xrange(1,13):
-            msg += "<th>" + str(x) + "</th>"
+        for x in xrange(1,13): msg += "<th>" + str(x) + "</th>"
         msg += "</tr>"
         count=1
         for m in self.init_list:
             msg += "<tr><td align=center>"+str(count)+"</td>"
-            if m[4]==-1:
-                msg += "<td><font color=red>GM</font></td>"
-            else:
-                msg += "<td>" + m[4] + "</td>"
+            if m[4]==-1: msg += "<td><font color=red>GM</font></td>"
+            else: msg += "<td>" + m[4] + "</td>"
             msg += "<td><font color='#0000ff'>" + m[2] + "</font></td>"
             msg += "<td align=center><font color='#0000ff'>" + str(m[1]) + "</font></td>"
             msg += "<td align=center><font color='#0000ff'>" + str(m[0]) + "</font></td>"
             msg +="<td>" + self.state_strings[m[3]] + "</td>"
 
             for segment in xrange(1,13):
-                if self.actson(m[1],segment):
-                    msg += "<td align=center>" + str(m[0]) + "</td>"
-                else:
-                    msg += "<td></td>"
+                if self.actson(m[1],segment): msg += "<td align=center>" + str(m[0]) + "</td>"
+                else: msg += "<td></td>"
             msg += "</tr>"
             count += 1
         msg += "</table><br>"
-
-        msg += "It is currently Segment " + str(v.segment) + ", DEX " + str(v.dexterity) + "<br>"
+        msg += "It is currently Segment " + str(self.segment) + ", DEX " + str(self.dexterity) + "<br>"
 
-        if send and player != 0:
-            chat.whisper_to_players(msg, [player])
-        else:
-            self.chat.InfoPost(msg)
+        if send and player != 0: chat.whisper_to_players(msg, [player])
+        else: self.chat.InfoPost(msg)
 
     def call_time(self):
         plist = ""
         msg = "Segment is now " + str(self.segment) + ", DEX " + str(self.dexterity)
         for player in self.init_list:
             if player[3] == 1 or player[3] == 2 or player[3] == 5 or player[3] == 6:
-                if plist != "":
-                    plist += ", "
+                if plist != "": plist += ", "
                 plist += player[2] + "(" + self.state_strings[player[3]] + ")"
-        if plist != "":
-            msg += ": " + plist
+        if plist != "": msg += ": " + plist
         self.chat.Post(msg, True)
 
     def process_user(self, command, player):
@@ -487,11 +425,8 @@
                     self.init_list.append([new_dex, new_spd, txt[3], 0, player[2]])
                     self.backup_list.append([new_dex, new_spd, txt[3], 0, player[2]])
                     msg = "Character " + txt[3] + " added to initiative."
-                else:
-                    msg = "Error in command.  See format with heroinit"
-            except:
-                msg = "Error in command.  See format with heroinit"
-
+                else: msg = "Error in command.  See format with heroinit"
+            except: msg = "Error in command.  See format with heroinit"
             self.chat.whisper_to_players(msg, [player[2]])
 
         elif command == "hact":
@@ -504,14 +439,9 @@
                 index = int(txt[1])
                 action = txt[2]
                 msg = self.do_action(player[2], index, action)
-            else:
-                msg = "Error in command.  See format with heroinit"
-
+            else: msg = "Error in command.  See format with heroinit"
             self.chat.whisper_to_players(msg, [player[2]])
-
-        elif command == "hlist":
-            self.list_inits(player[2], True)
-
+        elif command == "hlist": self.list_inits(player[2], True)
         else:
             msg = "Commands:<br>heroinit (hadd DEX SPEED CHARACTERNAME) : add character CHARACTERNAME with dex DEX and speed SPD to initiative list<br>"
             msg += " Example:  heroinit (hadd 18 4 Joey)<br>"