Example #1
0
 def add_rune(self, rune_name, position):
     rune_type = self.rune_types[rune_name]
     new_rune = rune_type(self, position)
     
     if self.tiles[position] != "0":
         raise engine.Illegal_move("Can only place a rune on a wall")
     
     if self.money < rune_type.cost:
         raise engine.Illegal_move("No money")
     
     for r in self.runes:
         if r.position == list(position):
             raise engine.Illegal_move("Can only place a rune on top of another rune")
     
     self.money -= new_rune.cost
     self.money_display.text = "%d gold" % self.money
     
     self.runes.append(new_rune)
     self.sprites.add(new_rune)
     self.runes_on_screen.text = "%s runes" % len(self.runes)
Example #2
0
    def sell_rune(self, position):
        the_rune = None

        for r in self.runes:
            if r.position == list(position):
                the_rune = r

        if not the_rune:
            raise engine.Illegal_move("Cannot sell an empty tile")

        self.money += math.floor(the_rune.cost / 2.0)
        self.money_display.text = "%d gold" % self.money

        self.remove_rune(the_rune)