Anonymous avatar Anonymous committed 9723a88

started integrating the Result() and Command() concept from hexbattle for easy and lean communication between logic and display. Might need adaption for interacting with the logic over a network, but that’s for later if needed…

Comments (0)

Files changed (1)

 - First level: Protect the tree lpc_full_assets/Barbara_Rivera__Concept Art for LPC Entry/fullpufftree.png. You have one character and 4 zombies attack.
 """
 
+class Logic:
+    """Basic Game Logic"""
+    pass
+
+class PlayerAction:
+    def __init__(self, name, info=None, description=None, commands=[]):
+        """Give results of the previos action and request the next
+        player action.
+
+        >>> def loop():
+        ...   return PlayerAction("init", commands=[Command(loop, "loop")])
+        >>> pa = loop()
+        >>> print pa
+        PlayerAction("init", info=None, description=None, commands=[Command(loop, "loop")])
+        >>> dir(pa)
+        ['__doc__', '__init__', '__module__', '__repr__', 'command', 'commands', 'description', 'info', 'name']
+        >>> pa.info
+        >>> pa.command()
+        PlayerAction("init", info=None, description=None, commands=[Command(loop, "loop")])
+        >>> print pa.commands
+        [Command(loop, "loop")]
+        """
+        self.name = name
+        self.info = info
+        self.description = description
+        self.commands = commands
+        # often used case of having only one command.
+        if len(commands) == 1:
+            self.command = commands[0]
+        else:
+            self.command = None
+    def __repr__(self):
+        return self.__class__.__name__ + "(\"" + self.name + "\", info=" + str(self.info) + ", description=" + str(self.description) + ", commands=" + str(self.commands) + ")"
+
+class Command:
+    def __init__(self, fun, name, **arguments):
+        """A single command with a function, a name as identifier and
+        arguments with the possible values in a tuple."""
+        self.fun = fun
+        self.name = name
+        self.arguments = arguments
+    def __call__(self, *args, **kwds): # the args are only there to catch dt=… from schedule.
+        return self.fun(**kwds)
+    def __repr__(self):
+        return self.__class__.__name__ + "(" + self.fun.__name__ + ", \"" + str(self.name) + "\"" + ",".join(self.arguments) + ")"
+
+
+class Welcome:
+    """Welcome Level."""
+    def __init__(self):
+        self.current = None
+        self.info = []
+        self.options = [self.startscreen]
+
+    def startscreen(self, *args):
+        """The starting screen."""
+        
+
+if __name__ == "__main__":
+    from doctest import testmod
+    testmod()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.