view skaapsteker/sprites/items.py @ 434:827c5d045cf5

Don't allow the cannon to be picked up
author Neil Muller <drnlmuller@gmail.com>
date Sat, 09 Apr 2011 19:14:19 +0200
parents e65f6783a9f7
children a084af91d5dc
line wrap: on
line source

from .. import engine
from .base import Item


def notify(text):
    engine.OpenNotification.post(text=text)


class BreakableItem(Item):
    whole_image_file = None
    broken_image_file = None

    def setup(self, broken, **opts):
        super(BreakableItem, self).setup(**opts)
        self.broken = broken


    def setup_image_data(self, pos):
        self.image_file = self.broken_image_file if self._me.broken else self.whole_image_file
        super(BreakableItem, self).setup_image_data(pos)


    def smash(self):
        self._me.broken = True
        self.broken = True
        self.setup_image_data(self._starting_tile_pos)



##################################################
# Collectibles

class Aburage(Item):
    image_file = 'props/tofu.png'

    def player_action(self, player):
        player.eat_aburage()
        self.remove()


class HaikuScroll(Item):
    image_file = 'props/haiku-scroll.png'

    def player_action(self, player):
        player.collect_scroll(self)
        self.remove()


    def setup(self, text, **opts):
        super(HaikuScroll, self).setup(**opts)
        self.text = text



##################################################
# Monk tea mission

class TeaCup(Item):
    image_file = 'props/teacup_empty.png'


class TeaLeaf(Item):
    image_file = 'props/tealeaf.png'


class TeaCupFull(Item):
    image_file = 'props/teacup_full.png'


class TeaPot(Item):
    image_file = 'props/teapot.png'

    def setup(self, brewed, **opts):
        super(TeaPot, self).setup(**opts)


    def player_action(self, player):
        if player.has_item('tealeaf'):
            self._me.brewed = True
            player.discard_item()
            notify("A nice cup of tea is brewing.")
            return
        if player.has_item('teacup'):
            if self._me.brewed:
                player.discard_item()
                player.take_item_by_name('teacupfull')
                self._me.brewed = False
                notify("You pour a cup of tea.")
            else:
                notify("Sadly, the teapot is empty.")
            return
        notify("A proper tea ceremony requires a cup.")



##################################################
# Guard seduction


class Fan(Item):
    image_file = 'props/fan.png'

    def player_action(self, player):
        player.get_fan(self)



##################################################
# Samurai distraction


class Kindling(Item):
    image_file = 'props/kindling.png'

    def player_action(self, player):
        if player.has_item('oil'):
            set_fire(player, self)
        else:
            player.take_item(self)


class Oil(Item):
    image_file = 'props/oil.png'

    def player_action(self, player):
        if player.has_item('kindling'):
            set_fire(player, self)
        else:
            player.take_item(self)



# TODO: Finish this thing's behaviour
class SignalFire(Item):
    image_file = 'props/signal_fire/signal_fire_unlit.png'

    def setup(self, litness, **opts):
        super(SignalFire, self).setup(**opts)


    def player_action(self, player):
        if self._me.litness == 'set':
            if player.has_item('kindling'):
                notify("You put the kindling in the signal fire.")
            elif player.has_item('oil'):
                notify("You pour the oil on the signal fire.")
            else:
                return
            player.discard_item()
            self._me.litness = 'kindled'
        elif self._me.litness == 'kindled':
            if player.has_item('kindling'):
                notify("You put the kindling on the signal fire and light it.")
            elif player.has_item('oil'):
                notify("You pour the oil on the signal fire and light it.")
            else:
                return
            player.discard_item()
            self._me.litness = 'burning'
            self.world.missions.fire_started_on_road = True


##################################################
# Cannon destruction


class Cannon(BreakableItem):
    whole_image_file = 'props/cannon-whole.png'
    broken_image_file = 'props/cannon-broken.png'

    liftable = False



##################################################
# Geisha character assassination


class Vase(BreakableItem):
    whole_image_file = 'props/vase-whole.png'
    broken_image_file = 'props/vase-broken.png'


class Salmon(Item):
    image_file = 'props/fish.png'



##################################################
# Theatrical debut


class NoMask(BreakableItem):
    whole_image_file = 'props/no-mask-whole.png'
    broken_image_file = 'props/no-mask-broken.png'


class NoCostume(Item):
    image_file = 'props/no-costume.png'



##################################################
# Big business


class Rice(BreakableItem):
    whole_image_file = 'props/rice-whole.png'
    broken_image_file = 'props/rice-broken.png'


class Documents(Item):
    image_file = 'props/haiku-scroll.png'