Commits

Anonymous committed ff85090 Merge

Started German tutorial.

Comments (0)

Files changed (30)

 0cb91702e697064067af4cca4dd3e2a00508a535 v0.2
+2c4e2b230e055ec75ce68e8d9a95f2f1f29c7ed9 v0.3
+textrpg 0.3 (2008-07-07)
+
+- FIX: Answering Yes in battle screen didn't work. 
 - Now experience is spent incrementally.
 - Added check_skill(name_of_skill).
 

branching_story.py

-"""A branching story: moving through the woods.
-
-decisions: right, left, straight, back
-
-ideas: 
-    - with a pursuer
-
-"""
-from textrpg import story, ask
-
-story("""Fading red light 
-filters through the leaves 
-and trunks of the trees, 
-as you leave the campsite. 
-
-The first chill of the night 
-touches your skin, 
-and your summercoat
-thin as it is, 
-protects you just feebly. 
-
-But the way which was clear 
-the day before today
-now seems forgotten, 
-after this day of dancing
-with the sister of the sun
-a child of the faery kin. 
-""")
-
-wood = [
-['you car', 	'withered leaves', 	0,			0, 	0], 
-[0, 		'the rabbit hill', 	'dark underbrush', 	0, 	0], 
-[0, 		'the angry boar', 	'the campsite', 	0, 	0], 
-[0, 		0, 			0, 			0, 	0], 
-[0, 		0, 			0, 			0, 	0]
-]
-
-def get_text(name):
-    """Get the text for each locations name"""
-    return name # TODO: Get the text from a dict. 
-
-class Path(object):
-    def __init__(self):
-        self.position = [3, 3]
-        self.target = [1, 1]
-    def pos_to_name(self, pos=[3, 3]):
-        """return the location name for a position."""
-        return wood[pos[0]][pos[1]]
-    def move(self):
-        x, y = self.position
-        # specify possible movement. 
-        move = {
-        'north': (x, y + 1), # up
-        'south': (x, y - 1), # down
-        'west': (x - 1, y),  # left
-        'east': (x + 1, y)  # right
-        }
-        question = 'Where do you want to go? '
-        answers = []
-        # get all possible answers by checking if the ways are possible. 
-        for i, j in move.items():
-            print i, j
-            if wood[j[0]][j[1]]:
-                answers.append(i)
-        question = " ".join([question] + answers + [":"])
-        description = "\n".join(['to the ' + i + ' you see ' + 
-self.pos_to_name(move[i]) for i in answers])
-        story(description)
-        target = ""
-        while not target:   
-            ans = ask(question)
-            for i in answers: 
-                if ans in [i.lower(), i.lower[0]]: 
-                    target = move[i]
-        self.position = target
-        story("""You go to """ + self.pos_to_name(self.position))
-        story(get_text(self.pos_to_name(self.position)))
-
-path = Path()
-while not path.position == path.target:
-    path.move()
 #!/usr/bin/env python
 # encoding: utf-8
 
-from textrpg import Char, story, ask, give_exp
+from textrpg import Char, story, ask
 from textrpg import save
 
+
 name = ask("What's your name?")
 
 # First load the chars for better gameflow. 
       url='http://1w6.org/programme',
       packages = find_packages('.'), 
       #py_modules=['babtools_gentoo'],
-      scripts=["ministory.py", "textrpg.py"]
+      scripts=["ministory.py", "textrpg.py", "tutorial.py"]
      )
 Plans: 
     - Simple to use functions in easy to read scriptfiles in the style of the ministory file. 
     - char.compete(other, skill_name) -> See who wins and by how much. 
-    - a basic implementation as minimal api reference for anyrpg plugins.
-
 
 Ideas: 
     - Lazy loading modules, to be able to print stuff at once without having to print before the imports.
     - Add getting experience for groups and show the chars together (only one experience header instead of one per char). 
 
-Design:
-    - revert: story() is a function, but should be heavily overloaded, so it gets 
-used for any kind of interacion with the setting. -> story(background="...", 
-show_image="...", clear_images=True, background_musi="...", play_sound="...", ...)
 
-The code for the TextRPG can be found at U{http://freehg.org/ArneBab/textrpg}
+Basic design principles for the scripting language: 
+    
+    - The action is character centered wherever possible and useful. 
+       -> char.say(text) instead of dialog(char, text)
+    
+    - Anything which affects only one character or any interaction between only a few characters which is initiated by one of them gets called from the character via char.action(). 
+       -> char.compete_skill(char2, skill_name) instead of competition_skill(char1, char2, skill_name)
+    
+    - Anything which affects the whole scene, or a whole group of not necessarily interacting characters gets called as basic function via action() or as class in its own right via class.action(). 
+       -> save([char1, char2]) instead of char1.save() char2.save()
+    
+    - The seperate class way should only be chosen, if the class can feel like a character in its own right and needs seperate states which may or may not be persistent over subsequent runs. 
+       -> For example AI.choose_the_way(players_answer) or music.action()
+    
+    - Data should be stored inside the chars wherever possible. If a script gets started with the same character again, the situation should resemble the previous one as much as possible, except where dictated otherwise by the story. 
+       -> char.save() instead of 'on quit' store_char_data(char) + 'on start' load_char_data(char)
+    
+    - Actions should be written as verb_noun or simply verb. 
+       -> char.say() and char.compete_skill() instead of char.text() and char.skill_compete()
+
+The code for the TextRPG can be found at U{http://dreehg.org/ArneBab/textrpg}
 
 """
 
   MA 02110-1301 USA
 
 """ 
-__version__   = '0.2' 
+__version__   = '0.3' 
 __author__    = 'Arne Babenhauserheide' 
 # __date__      = '7th March 2007' 
 __url__       = 'http://rpg-1d6.sf.net' 
 from textrpg_1d6.char import Char as ews_char
 
 def _(text):
-    '''String function to allow localizing later on)'''
+    '''String function to allow localizing later on. '''
     return str(text)
 
-class Story(object): 
-    """A more complex option for telling stories."""
-    def __init__(self, *args, **kwds): 
-        pass
-    def say(text): 
-        story(text)
-
 class Char(ews_char):
     def __init__(self, template=False, *args, **kwds): 
         super(Char, self).__init__(template=template, *args, **kwds)
         return won, [deep_wounds_self, critical_wounds_self, self.damage_self], [deep_wounds_other, critical_wounds_other, self.damage_other]
     
 
-def ask(question=None, *args, **kwds): 
+def ask(question): 
     """Ask a question."""
-    if question is not None: 
-        return raw_input(_(question) + " ")
+    return raw_input(_(question) + " ")
 
-def story(data=None, *args, **kwds):
-    if data is not None: 
-        data = _(data)
-        for i in data.split("\n"): 
-            if i.strip() != "": 
-                 diag(i, localize=False)
-             # If the string is empty, just add a blank line without the characters name. 
-            else: diag("...", localize=False, *args, **kwds)
+def story(data):
+    data = _(data)
+    for i in data.split("\n"): 
+        if i.strip() != "": 
+            diag(i, localize=False)
+        # If the string is empty, just add a blank line without the characters name. 
+        else: diag("...", localize=False)
 	
 
 def save(chars=[]):
         for i in chars:
                 i.save()
 
-def diag(data, localize=True, autoscroll=False, *args, **kwds):
-    if localize: 
-        text = _(data)
-    else: text = data 
-
-    if not autoscroll: 
-	raw_input(text)
-    else: 
-        print text
-        sleep(len(text)*0.1)
+def diag(data, localize=True):
+	if localize: 
+		raw_input(_(data))
+	else: raw_input(data)
 
 def greet(char): 
     diag("Old man: Welcome traveller. You've come to the right place to learn about your heritage.")
     
     @return: The result of the battle (won or lost, wounds)."""
     
-    if ask('Do you want to attack ' + other.name + '? (Yes, no) ').lower() in ['Yes', 'y', '']: 
+    if ask('Do you want to attack ' + other.name + '? (Yes, no) ').lower() in ['yes', 'y', '']: 
         diag("You attack " + other.name + ".")
         won, injuries_self, injuries_other = select_battle_style(me, other, attacker=True)
     else:

textrpg_1d6/__init__.pyc

Binary file removed.

textrpg_1d6/amov/Charakter.pyc

Binary file removed.

textrpg_1d6/amov/Namensgrammatik.pyc

Binary file removed.

textrpg_1d6/amov/Object.pyc

Binary file removed.

textrpg_1d6/amov/Skripte/Kernskripte/Objekt.pyc

Binary file removed.

textrpg_1d6/amov/Skripte/Kernskripte/__init__.pyc

Binary file removed.

textrpg_1d6/amov/Skripte/Kernskripte/ein_und_ausgabe/__init__.pyc

Binary file removed.

textrpg_1d6/amov/Skripte/Kernskripte/ein_und_ausgabe/tag_zu_datei.pyc

Binary file removed.

textrpg_1d6/amov/Skripte/Kernskripte/ein_und_ausgabe/tag_zu_datei_von_tag.pyc

Binary file removed.

textrpg_1d6/amov/Skripte/Kernskripte/ein_und_ausgabe/tag_zu_objekt.pyc

Binary file removed.

textrpg_1d6/amov/Skripte/__init__.pyc

Binary file removed.

textrpg_1d6/amov/Versionsverwaltung.pyc

Binary file removed.

textrpg_1d6/amov/__init__.pyc

Binary file removed.

textrpg_1d6/char.pyc

Binary file removed.

textrpg_1d6/namegen/__init__.pyc

Binary file removed.

textrpg_1d6/namegen/pycfnamegen/__init__.pyc

Binary file removed.

textrpg_1d6/namegen/pycfnamegen/cfnamegen.pyc

Binary file removed.

textrpg_1d6/namen.pyc

Binary file removed.

textrpg_1d6/pmw6.pyc

Binary file removed.

textrpg_1d6/random_phonetic_name_generator_von_Pointon/__init__.pyc

Binary file removed.

textrpg_1d6/random_phonetic_name_generator_von_Pointon/random_phonetic_name_generator.pyc

Binary file removed.

textrpg_1d6/yould/__init__.pyc

Binary file removed.

textrpg_1d6/yould/yould.pyc

Binary file removed.
+#!/usr/bin/env python
+#encoding: utf-8
+
+# First make sure the user has at least Python 2.5
+from sys import version_info
+if version_info < (2,5): 
+    print "TextRPG braucht mindestens Python Version 2.5."
+    print "Sie finden aktuelle Python Version auf "
+    print "- http://python.org "
+    exit()
+elif version_info >= (3,0): 
+    print "TextRPG wurde noch nicht auf Python Version 3 oder hoeher 
+aktualisiert."
+    print "Bitte gebt uns die noetige Zeit, oder helft uns beim Portieren."
+    print "- http://rpg-1d6.sf.net"
+    exit()
+
+from textrpg import story
+
+# Idee: Den Nutzer die Möglichkeiten gleich testen lassen. 
+from subprocess import call 
+
+story("""Willkommen im Intetaktiven TextRPG Tutorial!
+
+Dieser Leitfaden wird Ihnen Schritt fuer Schritt die Moeglichkeiten des TextRPG 
+nahebringen und es Ihnen so ermoeglihen auf einfache Art eigene TextRPGs zu 
+schreiben. 
+
+Erstmal zur Definition: Ein TextRPG ist eine interaktive Geschichte, in die ihre 
+Nutzer eintauchen und ihrne Ausgang beeinflussen koennen. 
+
+Auch wenn es mit komplexeren Skripten wohl moeglich waere, mit dem TextRPG ein 
+MMORPG zu implementieren, ist das nicht seine grundlegende Zielsetzung. 
+
+Stattdessen definiert es eine einfache Skriptumgebung, mit der der Code einer 
+intreaktiven Geschichte sehr aehnlich aussieht wie ein Skript fuer ein 
+Theatertueck, Sie gleichzeitig aber auf die gesamte Macht von Python 
+zurueckgreifen koennen, mit dem auch Gruppen wie Google und die NASA vollwertige 
+Programme schreiben.
+
+Obwohl diese erste Version rein textbasiert ist, sind die Skripte auf eine Art 
+geschrieben, die eine spaetere Uebertragung in graphische Oberflaechen einfach 
+macht, bei der in den Skripten nur eingefuegt werden muss, welche Oberflaehe sie 
+nutzen sollen. 
+
+Fuer Charakterinteraktionen gibt sie Ihnen ausserdem eine vollstaendige RPG 
+Bibliothek, die das Ein Wuerfel System implementert. 
+
+Da das TextRPG in Python geschrieben ist, funktioniert es direkt auf den 
+verschiedensten Plattformen, GNU/Linux, MacOSX und Windows eingeschlossen. 
+
+Dieser Leitfaaden ist uebrigens auch als TextRPG realiiert. 
+
+Nun aber genug der Vorrede. Gehen wir zur ersten Lektion. 
+""")
+
+call("python")
+
+story("Next step.")