Commits

Arne Babenhauserheide  committed e107da6

Added avatarsay files

  • Participants
  • Parent commits 007cb6a
  • Branches avatarsay

Comments (0)

Files changed (16)

File media/bandit

Binary file added.

File media/boy

Binary file added.

File media/die

Binary file added.

File media/fanfare

Binary file added.

File media/hero

Binary file added.

File media/hero-angry

Binary file added.

File media/media/bandit

Binary file added.

File media/media/boy

Binary file added.

File media/media/die

Binary file added.

File media/media/fanfare

Binary file added.

File media/media/hero

Binary file added.

File media/media/hero-angry

Binary file added.

File media/media/peasant

Binary file added.

File media/peasant

Binary file added.

File rpg_lib/avatarsay.py

+from os import environ
+from sys import stdout
+
+# does it run in the terminal emulation of avatarsay (AKFAvatar)?
+akfavtterm = ("AKFAVTTERM" in environ)
+
+def avatarsay(cmd):
+    """send a command to avatarsay (AKFAvatar)"""
+    if akfavtterm:
+        stdout.write('\033_')
+	stdout.write(cmd)
+	stdout.write('\033\\')
+	stdout.flush()
+

File simple_story.py

 #!/usr/bin/env python
 # encoding: utf-8
 
+
+from rpg_lib.avatarsay import *
+
+# der Befehl avatarsay überprüft auch akfavtterm,
+# aber bei einer Gruppe von Aufrufen kann man so etwas Zeit sparen
+if akfavtterm:
+  avatarsay("datadir media") # should better be an absolute path
+  avatarsay("title simple story")
+  avatarsay("backgroundcolor #605030")
+  avatarsay("scrolling on")
+  avatarsay("size 2, 30")
+
 from rpg_lib.textrpg import *
 
 hero = Char() # a generic human :)
 peasant = Char(template=True) # A random human with random name. 
 enemy = Char() # another generic human :)
 
-
+avatarsay("slow on")
+avatarsay("size 3, 45")
 story("""Welcome to the world of easy RPG scripting. 
 
-I hope you enjoy your stay!
-""")
+I hope you enjoy your stay!""")
 
+# empty is sometimes needed, when you want to move in later
+avatarsay("empty")
+avatarsay("avatarimage hero")
+avatarsay("move in")
+avatarsay("size 6, 65")
 hero.say("""And welcome from me, too!
 
 I hope we'll be able to go adventuring, soon!
 
 hero.say("""So now you know my name. Would you tell me yours?""")
 
+avatarsay("avatarimage none")
+avatarsay("height 1")
 name = ask("Your name:")
 
 player = Char(source="tag:1w6.org,2008:" + name)
 
+avatarsay("avatarimage hero")
+avatarsay("height 1")
 hero.say("So this time in style: Welcome " + player.name + "!")
 
+avatarsay("empty")
+avatarsay("avatarimage bandit")
+avatarsay("move in")
+avatarsay("size 3, 60")
 enemy.say("""How nice to see you. I hope you enjoy your glee. 
 
-It won't last too long.
-""")
+It won't last too long.""")
 
+avatarsay("avatarimage hero")
+avatarsay("height 3")
 hero.say("""How dare you come here! 
 
 I'll splatter your guts, Granash Barn!""")
 
 enemy.name = "Granash Barn"
 
+avatarsay("avatarimage bandit")
+avatarsay("height 1")
 enemy.say("""Well well, try it!""")
 
 hero.attack = 18 # A quite formidable fighter. 
 
 peasant.attack = 6 # Knows not to grab a dagger from the wrong side. 
 
+avatarsay("empty")
+avatarsay("avatarimage peasant")
+avatarsay("move in")
+avatarsay("height 1")
 peasant.act("tries to get out of the way of " + enemy.name)
-
+avatarsay("move out")
+avatarsay("avatarimage none")
+avatarsay("height 1")
 story(enemy.name + " attacks " + peasant.name)
 
+avatarsay("audio fanfare")
 won = enemy.fight_round(peasant)[0]
 if won: 
+   avatarsay("avatarimage peasant")
+   avatarsay("height 1")
+   avatarsay("audio die")
    peasant.say("""Aaargh!""")
-else: enemy.say("""Damn peasant.""")
+else:
+   avatarsay("avatarimage bandit")
+   avatarsay("height 1")
+   enemy.say("""Damn peasant.""")
 
-
+avatarsay("avatarimage hero-angry")
+avatarsay("size 1, 55")
 hero.say("""How dare you! I'll taste your blood!""")
 
+avatarsay("avatarimage none")
+avatarsay("height 1")
 hero.act("attacks " + enemy.name)
 
+avatarsay("slow off")
+avatarsay("audio fanfare")
 while hero.active and enemy.active: 
    hero.fight_round(enemy)
+avatarsay("slow on")
 
 if hero.active:
    hero.act("won.")
+   avatarsay("avatarimage hero-angry")
    hero.say("""That's what they call villain these days. 
 
 So now to you. You look kinda sorry for him. 
 
 Seems I'll have to kill you, too.""")
+
+   avatarsay("avatarimage none")
+   avatarsay("slow off")
+   avatarsay("audio fanfare")
    won = player.battle(hero)
-   if not won: 
+   avatarsay("slow on")
+   if not won:
+       avatarsay("audio die")
        story("""And so the adventure of """ + player.name + """ended quite early.""")
 else:
    enemy.act("won.")
+   avatarsay("avatarimage bandit")
    enemy.say("""So much for heroes. 
 
 I hope you didn't stand with that bastard. I'm leaving. 
 
 Want to come with me?""")
 
+   avatarsay("avatarimage none")
    join_the_enemy = ask("""Come with him? (Yes, no)""")
 
+   avatarsay("avatarimage bandit")
    if join_the_enemy.lower() in ["yes", "y", ""]: 
       enemy.say("""A wise decision. Now carry my bag.""")
    else: 
 
 Do you want to fight me, then?""")
 
+avatarsay("avatarimage none")
 if player.active: 
    fight = ask("Fight him? (Yes, no)")
 else:
    fight = "No"
 if fight.lower() in ["yes", "y", ""]:
+   avatarsay("slow off")
+   avatarsay("audio fanfare")
    won = player.battle(enemy)
+   avatarsay("slow on")
    if not won:
+      avatarsay("audio die")
       story("Sorry, you lost.")
 else:
+   avatarsay("avatarimage bandit")
    enemy.say("""A good fight.""")
 
+avatarsay("move out")
 exit()