Changeset 193:897eec397cbb


Ignore:
Timestamp:
04/06/11 19:44:54 (12 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Phase:
public
Rebase:
64353031633963333465623130626561326665316433633266646537656263333235343339613233
Message:

Fix state checks for hattori, ichiro, kaneda and kumiko. In the process provide easier access to other npcs.

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • data/npcs/hattori.json

    r179 r193  
    33        "text" : "Ichiro, there is nothing to fear. Uesugi will light the signal fire if they come close.",
    44        "events" : [
    5             { "matches" : "world.npc_is('ichiro', 'prepared')", "next": "state.wait" }
     5            { "matches" : "npcs.ichiro.state ==  'prepared'", "next": "state.wait" }
    66        ]
    77    },
     
    99        "text" : "There’s nothing more for us to do but sit and wait. Sasuke will arrive with our cannon in a while. We can’t take on the entire Hayashi clan without it.",
    1010        "events" : [
    11             { "matches" : "world.npc_is('ichiro', 'sitting')", "next": "state.relax" }
     11            { "matches" : "npcs.ichiro.state ==  'sitting'", "next": "state.relax" }
    1212        ]
    1313    },
     
    1515        "text" : "Relax! You’re with me, the most fearsome katana in the East. We’re not moving from this spot until we have to. Besides, I need to meditate.",
    1616        "events" : [
    17             { "matches" : "world.npc_is('ichiro', 'but')", "next": "state.omm" }
     17            { "matches" : "npcs.ichiro.state ==  'but'", "next": "state.omm" }
    1818        ]
    1919    },
     
    2121        "text" : "Ommmmm...",
    2222        "events" : [
    23             { "matches" : "world.npc_is('ichiro', 'wakeup')", "next": "state.letsgo" }
     23            { "matches" : "npcs.ichiro.state ==  'wakeup'", "next": "state.letsgo" }
    2424        ]
    2525    },
     
    2727        "text" : "Ha- huh? Uesugi’s fire! Let’s go!",
    2828        "events" : [
    29             { "matches" : "world.npc_is('ichiro', 'cannon')", "next": "state.attack" }
     29            { "matches" : "npcs.ichiro.state ==  'cannon'", "next": "state.attack" }
    3030        ]
    3131    },
  • data/npcs/ichiro.json

    r179 r193  
    33        "text" : "I’m telling you, Hattori. The Hayashi clan will arrive any minute now.",
    44        "events" : [
    5             { "matches" : "world.npc_is('hattori', 'start')", "next": "state.prepared" }
     5            { "matches" : "world.npcs.hattori.state ==  'start'", "next": "state.prepared" }
    66        ]
    77    },
     
    99        "text" : "It doesn’t hurt to be prepared.",
    1010        "events" : [
    11             { "matches" : "world.npc_is('hattori', 'wait')", "next": "state.sitting" }
     11            { "matches" : "npcs.hattori.state ==  'wait'", "next": "state.sitting" }
    1212        ]
    1313    },
     
    1515        "text" : "I just don’t like sitting out in the open like this.",
    1616        "events" : [
    17             { "matches" : "world.npc_is('hattori', 'relax')", "next": "state.but" }
     17            { "matches" : "npcs.hattori.state ==  'relax'", "next": "state.but" }
    1818        ]
    1919    },
     
    2121        "text" : "But-",
    2222        "events" : [
    23             { "matches" : "world.npc_is('hattori', 'omm')", "next": "state.sigh" }
     23            { "matches" : "npcs.hattori.state ==  'omm'", "next": "state.sigh" }
    2424        ]
    2525    },
     
    2727        "text" : "Sigh.",
    2828        "events" : [
    29             { "matches" : "world.fire_started()", "next": "state.wakeup" }
     29            { "matches" : "world.fire_started", "next": "state.wakeup" }
    3030        ]
    3131    },
     
    3333        "text" : "Hattori, wake up! Look! Smoke coming over the rise.",
    3434        "events" : [
    35             { "matches" : "world.npc_is('hattori', 'letsgo')", "next": "state.cannon" }
     35            { "matches" : "npcs.hattori.state ==  'letsgo'", "next": "state.cannon" }
    3636        ]
    3737    },
     
    3939        "text" : "What about the cannon?",
    4040        "events" : [
    41             { "matches" : "world.npc_is('hattori', 'attack')", "next": "state.gone" }
     41            { "matches" : "npcs.hattori.state ==  'attack'", "next": "state.gone" }
    4242        ]
    4343    },
  • data/npcs/kaneda.json

    r184 r193  
    22    "start" : {
    33        "events" : [
    4             { "matches" : "world.npc_is('kumiko', 'torn')", "next": "state.kumiko" }
     4            { "matches" : "npcs.kumiko.state ==  'torn'", "next": "state.kumiko" }
    55        ]
    66    },
     
    99        "auto_next": "state."
    1010        "events" : [
    11             { "matches" : "world.npc_is('kumiko', 'kaneda')", "next": "state.tear" }
     11            { "matches" : "npcs.kumiko.state ==  'kaneda'", "next": "state.tear" }
    1212        ]
    1313    },
     
    1515        "text" : "When I heard of your legendary charm, I rushed to your home right away. It is true what they say about your radiant glow. Ah, but what’s this? A tear?",
    1616        "events" : [
    17             { "matches" : "world.npc_is('kumiko', 'jumped')", "next": "state.vase" }
     17            { "matches" : "npcs.kumiko.state ==  'jumped'", "next": "state.vase" }
    1818        ]
    1919    },
     
    2121        "text" : "Hmm, well, never mind that. Do show me around your charming home. Hmm? Is that a broken vase I see?",
    2222        "events" : [
    23             { "matches" : "world.npc_is('kumiko', 'fallen')", "next": "state.hmm" }
     23            { "matches" : "npcs.kumiko.state ==  'fallen'", "next": "state.hmm" }
    2424        ]
    2525    },
     
    2727        "text" : "Hmm.",
    2828        "events" : [
    29             { "matches" : "world.npc_is('kumiko', 'shallwe')", "next": "state.smell" }
     29            { "matches" : "npcs.kumiko.state ==  'shallwe'", "next": "state.smell" }
    3030        ]
    3131    },
     
    3333        "text" : "Yes. But only if you explain that horrible smell!",
    3434        "events" : [
    35             { "matches" : "world.npc_is('kumiko', 'dropped')", "next": "state.wontstand" }
     35            { "matches" : "npcs.kumiko.state ==  'dropped'", "next": "state.wontstand" }
    3636        ]
    3737    },
     
    3939        "text" : "Kumiko-san, I won’t stand for this! A torn kimono, a house in disarray, dirt everywhere and that pungent stench. You are clearly no home maker! And to blame it all on a fox?",
    4040        "events" : [
    41             { "matches" : "world.npc_is('kumiko', 'but')", "next": "state.wonthear" }
     41            { "matches" : "npcs.kumiko.state ==  'but'", "next": "state.wonthear" }
    4242        ]
    4343    },
  • data/npcs/kumiko.json

    r181 r193  
    77        "text" : "The room smells fresh, I have my best kimono on and I’ve set out my most magnificent vase. Everything is perfect (just like me)!",
    88        "events" : [
    9             { "matches" : "world.vase_broken()", "next": "state.broken" }
     9            { "matches" : "world.vase_broken", "next": "state.broken" }
    1010        ]
    1111    },
     
    1313        "text" : "Oh no, my beautiful vase! What will the businessman think to see it broken on the floor?",
    1414        "events" : [
    15             { "matches" : "world.fish_in_house()", "next": "state.badsmell" }
     15            { "matches" : "world.fish_in_house", "next": "state.badsmell" }
    1616        ]
    1717    },
     
    1919        "text" : "Oh my, what is that terrible smell? Rotten fish? Oh, this won’t do at all!",
    2020        "events" : [
    21             { "matches" : "world.torn_kimono()", "next": "state.torn" }
     21            { "matches" : "world.torn_kimono", "next": "state.torn" }
    2222        ]
    2323    },
     
    2525        "text" : "Shoo, dirty fox! Oh, look what you’ve done – you’ve made a great big tear in my finest silk kimono. What will the businessman think of a ragged dress like this?",
    2626        "events" : [
    27             { "matches" : "world.npc_is('kaneda','kumiko')", "next": "state.kaneda" }
     27            { "matches" : "npcs.kaneda.state == 'kumiko'", "next": "state.kaneda" }
    2828        ]
    2929    },
     
    3131        "text" : "Kaneda-san! I have been waiting for you.",
    3232        "events" : [
    33             { "matches" : "world.npc_is('kaneda','tear')", "next": "state.jumped" }
     33            { "matches" : "npcs.kaneda.state == 'tear'", "next": "state.jumped" }
    3434        ]
    3535    },
     
    3737        "text" : "Oh, Kaneda-san, a dirty little fox jumped on me just as you were approaching and ripped my kimono.",
    3838        "events" : [
    39             { "matches" : "world.npc_is('kaneda','vase')", "next": "state.fallen" }
     39            { "matches" : "npcs.kaneda.state == 'vase'", "next": "state.fallen" }
    4040        ]
    4141    },
     
    4343        "text" : "I am sorry, Kaneda-san, it must just have fallen over. It was probably pushed by that mean-spirited fox.",
    4444        "events" : [
    45             { "matches" : "world.npc_is('kaneda','hmm')", "next": "state.shallwe" }
     45            { "matches" : "npcs.kaneda.state == 'hmm'", "next": "state.shallwe" }
    4646        ]
    4747    },
     
    4949        "text" : "Shall we- go on?",
    5050        "events" : [
    51             { "matches" : "world.npc_is('kaneda','smell')", "next": "state.dropped" }
     51            { "matches" : "npcs.kaneda.state == 'smell'", "next": "state.dropped" }
    5252        ]
    5353    },
     
    5555        "text" : "I- A fox came in and dropped an old fish?",
    5656        "events" : [
    57             { "matches" : "world.npc_is('kaneda','wontstand')", "next": "state.but" }
     57            { "matches" : "npcs.kaneda.state == 'wontstand'", "next": "state.but" }
    5858        ]
    5959    },
     
    6161        "text" : "But-",
    6262        "events" : [
    63             { "matches" : "world.npc_is('kaneda','wonthear')", "next": "state.curse" }
     63            { "matches" : "npcs.kaneda.state == 'wonthear'", "next": "state.curse" }
    6464        ]
    6565    },
  • skaapsteker/dialogue.py

    r190 r193  
    1616       """
    1717
    18     def __init__(self, json_filename, world):
     18    def __init__(self, name, world, json_filename):
     19        me = getattr(world.npcs, name)
     20        self.state = getattr(me, 'state', 'start')
     21        me.state = self.state
    1922        self.world = world
    20         self.state = "start"
    2123        self.states = AttrDict()
    2224        src = json.loads(data.load(json_filename).read())
     
    3234        my_locals = {
    3335            "state": self.states,
    34             "world" : self.world,
     36            "world": self.world,
     37            "npcs": self.world.npcs,
    3538        }
    3639        my_locals.update(ev.items)
  • skaapsteker/gamestate.py

    r189 r193  
    4949    def create_sprites(self, level):
    5050        sprites = []
    51         for stype, key, needs_world in [
    52             ('items', 'items', False),
    53             ('npcs', 'npcs', True)]:
    54             for sprite_dict in self.data[key].values():
     51        for stype, key in [
     52            ('items', 'items'),
     53            ('npcs', 'npcs')]:
     54            for sprite_name, sprite_dict in self.data[key].items():
    5555                sprite_dict = sprite_dict.copy()
    56                 if needs_world:
    57                     sprite_dict['world'] = self.world
     56                sprite_dict['name'] = sprite_name
     57                sprite_dict['world'] = self.world
    5858                if sprite_dict.pop('level') == level:
    5959                    sprites.append(find_sprite(sprite_dict, stype))
  • skaapsteker/sprites/base.py

    r191 r193  
    6161        self.setup(**opts)
    6262
    63     def setup(self, dsm, world):
    64         self.dsm = dialogue.DSM(dsm, world)
     63    def setup(self, name, world, dsm):
     64        self.dsm = dialogue.DSM(name, world, dsm)
    6565
    6666
     
    8989
    9090
    91     def setup(self):
     91    def setup(self, name, world):
    9292        pass
    9393
Note: See TracChangeset for help on using the changeset viewer.