Example #1
0
    def __init__(self, xmlElement=None):

        # Get a logmanager
        self.logManager = annchienta.getLogManager()

        # Every battleentity should have a name
        self.name = str(xmlElement.getAttribute("name"))

        # Create a dictionary describing the simple stats
        self.stats = {}

        if xmlElement:
            statsElements = xmlElement.getElementsByTagName("stats")
            if len(statsElements):
                statsElement = statsElements[0]
                for k in statsElement.attributes.keys():
                    self.stats[str(k)] = int(statsElement.attributes[k].value)
            else:
                self.logManager.warning(
                    "A BattleEntity should always define 'stats'.")

        # Create a dictionary describing the elemental properties
        self.elemental = {}

        if xmlElement:
            elementalElements = xmlElement.getElementsByTagName("elemental")
            if len(elementalElements):
                elementalElement = elementalElements[0]
                for k in elementalElement.attributes.keys():
                    self.elemental[k] = float(
                        elementalElement.attributes[k].value)
Example #2
0
    def __init__(self):

        self.audioManager = annchienta.getAudioManager()
        self.mathManager = annchienta.getMathManager()
        self.logManager = annchienta.getLogManager()
        self.engine = annchienta.getEngine()

        self.enemiesInMap = []
        self.battleBackground = None
        self.randomBattleDelay = self.mathManager.randInt(300, 1000)
Example #3
0
    def __init__(self, xmlElement):

        # Stuff for sounds
        self.cacheManager = annchienta.getCacheManager()
        self.audioManager = annchienta.getAudioManager()
        self.soundLevelup = self.cacheManager.getSound('sounds/levelup.ogg')
        self.soundClickNeu = self.cacheManager.getSound(
            'sounds/click-neutral.ogg')

        # Base constructor
        Combatant.Combatant.__init__(self, xmlElement)

        # References
        self.partyManager = PartyManager.getPartyManager()
        self.logManager = annchienta.getLogManager()
        self.inputManager = annchienta.getInputManager()
        self.videoManager = annchienta.getVideoManager()

        # Get our weapon
        weaponElements = xmlElement.getElementsByTagName("weapon")
        if len(weaponElements):
            # Get the weapon name and search for the corresponding element
            weaponName = str(weaponElements[0].getAttribute("name"))
            self.setWeapon(weaponName)
        else:
            self.logManager.warning("No Weapon defined for Ally!")

        # Get the position of our hand
        handElements = xmlElement.getElementsByTagName("hand")
        if len(handElements):
            self.hand = annchienta.Vector(
                float(handElements[0].getAttribute("x")),
                float(handElements[0].getAttribute("y")))
        else:
            self.hand = None

        # Create a dictionary describing the level grades
        self.grades = {}
        gradesElement = xmlElement.getElementsByTagName("grades")[0]
        for k in gradesElement.attributes.keys():
            self.grades[k] = int(gradesElement.attributes[k].value)

        # Create dictionary describing the level learns
        self.learn = {}
        learnElement = xmlElement.getElementsByTagName("learn")[0]
        text = str(learnElement.firstChild.data)
        words = text.split()
        for i in range(int(len(words) / 2)):
            self.learn[int(words[i * 2])] = words[i * 2 + 1]

        # Build the menu.
        self.buildMenu()
Example #4
0
    def __init__(self):

        self.engine = annchienta.getEngine()
        self.mathManager = annchienta.getMathManager()
        self.videoManager = annchienta.getVideoManager()
        self.inputManager = annchienta.getInputManager()
        self.logManager = annchienta.getLogManager()
        self.audioManager = annchienta.getAudioManager()
        self.partyManager = PartyManager.getPartyManager()

        self.enemiesLocation = "battle/enemies.xml"
        self.enemiesFile = xml.dom.minidom.parse(self.enemiesLocation)

        self.randomBattleDelay = self.mathManager.randInt(300, 400)
        self.background = None

        # Drum on battle start
        self.drum = annchienta.Sound("sounds/battle.ogg")

        self.randomBattleEnemies = []
Example #5
0
    def __init__(self, xmlElement):

        # Stuff for sounds
        self.cacheManager = annchienta.getCacheManager()
        self.audioManager = annchienta.getAudioManager()
        self.soundNeg = self.cacheManager.getSound('sounds/click-negative.ogg')
        self.soundHeal = self.cacheManager.getSound('sounds/cure.ogg')
        self.soundHealHi = self.cacheManager.getSound('sounds/cura.ogg')
        self.soundExplode = self.cacheManager.getSound('sounds/grenade.ogg')

        # Get some references
        self.logManager = annchienta.getLogManager()

        text = str(xmlElement.firstChild.data)
        words = text.split()

        self.dictionary = {}

        # Get all the items
        for i in range(int(len(words) / 2)):

            self.dictionary[words[i * 2]] = int(words[i * 2 + 1])
Example #6
0
# Add the scripts directory to the path so we can
# import modules from it.
sys.path.append("scripts")

# This is only to be sure... the windows release
# might need it.
sys.path.append("../lib")

import annchienta

# Fire up the engine.
annchienta.init("saves")

engine = annchienta.getEngine()

logManager = annchienta.getLogManager()

videoManager = annchienta.getVideoManager()
videoManager.setVideoMode( 400, 300, "Annchienta", False )
videoManager.setClearColor(0,0,0)

mapManager = annchienta.getMapManager()
mapManager.setTileWidth(64)
mapManager.setTileHeight(32)
mapManager.setUpdatesPerSecond(60)
mapManager.setMaxAscentHeight(32)
mapManager.setMaxDescentHeight(32)
mapManager.setOnUpdateScript("scripts/onupdate.py")

inputManager = annchienta.getInputManager()
inputManager.setInteractKey( annchienta.SDLK_SPACE )
Example #7
0
        "Aelaan! You can't run now! You're always running! You never face the truth!"
    )

    player.lookAt(esana)

    sceneManager.speak(player, "But I'm so afraid to speak the truth...")

    # Create jelobat enemy
    jelobatEnemy = battleManager.createEnemy("jelobat")

    # Heal party
    partyManager.heal()

    # Adapt to player stats.
    adapt(jelobatEnemy)
    annchienta.getLogManager().message(str(
        jelobatEnemy.status.get("strength")))

    b = battle.Battle(partyManager.team + [jelobatEnemy])
    b.background = annchienta.Surface("images/backgrounds/wooden_floor.png")

    audioManager.playMusic("music/anpere.ogg")
    b.run()
    #b.won = True

    if b.won:

        audioManager.playMusic("music/title.ogg")
        # Fall from boat
        sceneManager.speak(jelobat, "Why... you...")
        sceneManager.move(jelobat, annchienta.Point(annchienta.TilePoint, 7,
                                                    6))
Example #8
0
    def __init__(self, xmlElement):

        # Call super constructor
        BattleEntity.BattleEntity.__init__(self, xmlElement)

        # We need to log stuff
        self.logManager = annchienta.getLogManager()

        # Get references
        self.videoManager = annchienta.getVideoManager()
        self.cacheManager = annchienta.getCacheManager()
        self.mathManager = annchienta.getMathManager()
        self.sceneManager = SceneManager.getSceneManager()

        # Create a dictionary describing the level stuff
        self.level = {}
        levelElement = xmlElement.getElementsByTagName("level")[0]
        for k in levelElement.attributes.keys():
            self.level[k] = int(levelElement.attributes[k].value)

        # Create a dictionary describing the health stats
        self.healthStats = {}
        healthStatsElement = xmlElement.getElementsByTagName("healthstats")[0]
        for k in healthStatsElement.attributes.keys():
            self.healthStats[k] = int(healthStatsElement.attributes[k].value)

        # Get all possible actions. The actual actions are in the first child
        # of the element, hence the code. <actions> action1 action2 </actions>
        actionsElement = xmlElement.getElementsByTagName("actions")[0]
        actionNames = str(actionsElement.firstChild.data).split()
        # Prepare to get the from the xml data
        self.actions = []
        # Get them
        for a in actionNames:
            self.addAction(a)

        # Create a dictionary describing the elemental properties
        # Only enemies have them, usually
        self.primaryElemental = {}
        elementalElements = xmlElement.getElementsByTagName("elemental")
        if len(elementalElements):
            for k in elementalElements[0].attributes.keys():
                self.primaryElemental[k] = float(
                    elementalElements[0].attributes[k].value)

        # Load sprite
        spriteElement = xmlElement.getElementsByTagName("sprite")[0]
        # Keep the filename so we can save it later on
        self.spriteFilename = str(spriteElement.getAttribute("filename"))
        self.sprite = annchienta.Surface(self.spriteFilename)
        if spriteElement.hasAttribute("x1"):
            self.sx1 = int(spriteElement.getAttribute("x1"))
            self.sy1 = int(spriteElement.getAttribute("y1"))
            self.sx2 = int(spriteElement.getAttribute("x2"))
            self.sy2 = int(spriteElement.getAttribute("y2"))
        else:
            self.sx1, self.sy1 = 0, 0
            self.sx2 = self.sprite.getWidth()
            self.sy2 = self.sprite.getHeight()

        # Get width and height from those facts.
        self.width = self.sx2 - self.sx1
        self.height = self.sy2 - self.sy1

        self.position = annchienta.Vector(0, 0)

        # We will draw a mark upon ourselves sometimes
        self.active = False
        self.selected = False

        # Damage done by an attack
        self.damage = 0
        self.damageTimer = 0.0

        self.reset()