예제 #1
0
   def __init__(self, node, mMap, position=None, level=None):
      """
      aa

      node - the <sprite> node.
      mMap - the map to put the sprite on.
      position - the position to start at. If None it gets taken from the node.
      level - the level to start on. If None it gets taken from the node.
      """

      #init the VisibleObject
      objects.VisibleObject.__init__(self)

      #store the map for later
      self.map = mMap

      #create the tileset
      #determine the tile offset, so that the sprite is drawn at the centre bottom of a map tile
      tilesetPath = os.path.join(settings.path, "data", data.getAttr(node, "tileset", data.D_STRING))
      self.tileset = tileset.Tileset(tilesetPath)

      #determine position, and initialise destination to position
      if position is None:
         self.position = tuple(data.getAttr(node, "position", data.D_INT2LIST))
      else:
         self.position = position
      self.destination = self.position

      #determine the level
      if level is None:
         self.level = data.getAttr(node, "level", data.D_INT)
      else:
         self.level = level

      #find out the id, if there is one
      self.id = data.getOptionalAttr(node, "id", data.D_STRING, None)

      #initialise variables
      self.direction = DIR_DOWN
      self.status = S_WALK
      self.speed = 1 #walking
      self.walkCycle = 0
      self.busy = False
      self.switch = False
      self.locked = False
      self.hasBumped = False

      #no script engine given yet
      self.scriptEngine = script_engine.ScriptEngine()

      #for scripting
      self.scriptCommands["foo"] = self.command_foo

      #create the basic walk animations
      #set the current animation but don't play it (so it can be ticked without errors)
      self.animations[DIR_UP] = animation.Animation([12,12,13,13,14,14,15,15])
      self.animations[DIR_DOWN] = animation.Animation([0,0,1,1,2,2,3,3])
      self.animations[DIR_LEFT] = animation.Animation([4,4,5,5,6,6,7,7])
      self.animations[DIR_RIGHT] = animation.Animation([8,8,9,9,10,10,11,11])
      self.animation = self.animations[0]
예제 #2
0
   def __init__(self, species, level):
      self.species = species

      fn = os.path.join(settings.path, "data", globs.POKEMON)
      root = data.getTreeRoot(fn, "Ditto main")

      for sp in data.getChildren(root, "species"):
         if data.getAttr(sp, "id", data.D_STRING) == self.species:
            self.speciesNode = sp
            break                           
      
      self.nickname = None
      
      self.level = level
      self.exp = 0

      typeNode = data.getChild(self.speciesNode, "type")
      self.type1 = data.getAttr(typeNode, "primary", data.D_STRING)
      self.type2 = data.getOptionalAttr(typeNode, "secondary", data.D_STRING, None)

      self.PID = random.randint(0, 4294967295)
      self.trainer = None
      self.trainerID = None

      self.ability = None

      self.gender = G_MALE
      self.nature = 0
      self.shiny = False

      self.form = 0
      self.happiness = 0
      self.pokerus = False
      
      self.EVs = {ST_HP: 0,
                  ST_ATTACK: 0,
                  ST_DEFENSE: 0,
                  ST_SPEED: 0,
                  ST_SPATTACK: 0,
                  ST_SPDEFENSE: 0}
      
      self.IVs = {ST_HP: random.randint(0,31),
                  ST_ATTACK: random.randint(0,31),
                  ST_DEFENSE: random.randint(0,31),
                  ST_SPEED: random.randint(0,31),
                  ST_SPATTACK: random.randint(0,31),
                  ST_SPDEFENSE: random.randint(0,31)}

      self.stats = {}
      self.calcStats()

      self.currentHP = self.stats[ST_HP]
      self.status = None

      self.moves = [None, None, None, None]
      movesNode = data.getChild(self.speciesNode, "attacks")
      moveNodes = sorted(data.getChildren(movesNode, "move"), key=lambda n: int(n.attrib["level"]))
      i = 0
      for node in moveNodes[-4:]:
         self.moves[i] = moves.Move(data.getAttr(node, "id", data.D_STRING))
         i += 1
      
      self.ballCaughtIn = 0

      self.heldItem = None
예제 #3
0
    def __init__(self, species, level):
        self.species = species

        fn = os.path.join(settings.path, "data", globs.POKEMON)
        root = data.getTreeRoot(fn, "Ditto main")

        for sp in data.getChildren(root, "species"):
            if data.getAttr(sp, "id", data.D_STRING) == self.species:
                self.speciesNode = sp
                break

        self.nickname = None

        self.level = level
        self.exp = 0

        typeNode = data.getChild(self.speciesNode, "type")
        self.type1 = data.getAttr(typeNode, "primary", data.D_STRING)
        self.type2 = data.getOptionalAttr(typeNode, "secondary", data.D_STRING,
                                          None)

        self.PID = random.randint(0, 4294967295)
        self.trainer = None
        self.trainerID = None

        self.ability = None

        self.gender = G_MALE
        self.nature = 0
        self.shiny = False

        self.form = 0
        self.happiness = 0
        self.pokerus = False

        self.EVs = {
            ST_HP: 0,
            ST_ATTACK: 0,
            ST_DEFENSE: 0,
            ST_SPEED: 0,
            ST_SPATTACK: 0,
            ST_SPDEFENSE: 0
        }

        self.IVs = {
            ST_HP: random.randint(0, 31),
            ST_ATTACK: random.randint(0, 31),
            ST_DEFENSE: random.randint(0, 31),
            ST_SPEED: random.randint(0, 31),
            ST_SPATTACK: random.randint(0, 31),
            ST_SPDEFENSE: random.randint(0, 31)
        }

        self.stats = {}
        self.calcStats()

        self.currentHP = self.stats[ST_HP]
        self.status = None

        self.moves = [None, None, None, None]
        movesNode = data.getChild(self.speciesNode, "attacks")
        moveNodes = sorted(data.getChildren(movesNode, "move"),
                           key=lambda n: int(n.attrib["level"]))
        i = 0
        for node in moveNodes[-4:]:
            self.moves[i] = moves.Move(data.getAttr(node, "id", data.D_STRING))
            i += 1

        self.ballCaughtIn = 0

        self.heldItem = None