def chooseTile(self, activeTile): self.events = [] activeTile.setGameObject(self.getActiveHero()) self.phase.addSubPhase(phase.Phase("Direction")) if self.phaseCount >= len(self.order): self.resetPhase() self.phase = phase.Phase("Main") self.phase.addSubPhase(phase.Phase("TurnStart"))
def chooseDirection(self, pos): self.hexBoard.setDirection(self.getActiveHero(), pos) self.phase.addSubPhase(phase.Phase("Placement")) self.phaseCount += 1 if self.phaseCount >= len(self.order): self.resetPhase() self.phase = phase.Phase("Main") self.phase.addSubPhase(phase.Phase("TurnStart"))
def enemyTurn(self): if self.aion: ts = self.hexBoard.getZone2() r = ts[random.randrange(0, len(ts))] while r.getGameObject() != None: r = ts[random.randrange(0, len(ts))] activeTile = r activeTile.setGameObject(self.getActiveHero()) self.phaseCount += 1 if self.phaseCount >= len(self.order): self.resetPhase() self.phase = phase.Phase("Main") self.phase.addSubPhase(phase.Phase("TurnStart"))
def __init__(self, surface, party1=party.getAi(), party2=party.getAi(), aion=True): pygame.init() self.party1 = party1 self.party2 = party2 self.me = self.party1 self.phase = phase.Phase("Placement") self.phase.addSubPhase(phase.Phase("Placement")) self.phaseCount = 0 self.order = [] self.lastTime = time.clock() self.centered = False self.surface = surface self.determineInitiative() self.battleStatsI = 0 self.aion = aion self.ai = ai.AIBehavior(self.party2) self.heroAnimation = None self.ismain = True self.backButton = button.Button(self.makeText("Back")) self.events = [] self.moving = False self.playerTurn = False self.moved = False self.clouds = [] self.populateBackground() self.attacked = False self.choiceBox = choicebox.ChoiceBox( 155, self.surface.get_rect().height - 100) self.originp = (0, 0) self.animations = [] self.mouseOver = None self.currentSpell = None self.drawToolTip = False self.toolTipPos = None self.hexBoard = isoboard.IsoBoard(10, 10, 64) self.makeChoiceButtons() self.cancelButton = button.Button(self.makeText("Cancel"), self.startPhase) self.cancelButton.setRect(pygame.Rect(200, 550, 100, 50)) self.endTurnButton = button.Button(self.makeText("End Turn"), self.nextHero) self.endTurnButton.setRect(pygame.Rect(700, 550, 100, 50)) self.emitter = None self.initVars() self.mainLoop()
def multiplayerPhase(self): return self.phase = phase.Phase("Multiplayer")
def startPhase(self): self.phase.addSubPhase(phase.Phase("TurnStart")) self.events = [] self.makeChoiceButtons() self.centered = False
def animationPhase(self): self.phase.addSubPhase(phase.Phase("Animation"))
def mainPhase(self): self.phase = phase.Phase("Main")
def getSpellTarget(self, spell): self.phase.addSubPhase(phase.Phase("TargetSpell")) self.currentSpell = spell self.makeAttackTypeChoice()
def spellPhase(self): if not self.attacked: self.phase.addSubPhase(phase.Phase("Spell")) self.makeSpellButtons()
def passwordPhase(self): self.phase = phase.Phase("Password")
def endTurn(self): self.moved = False self.attacked = False self.phase.addSubPhase(phase.Phase("EndTurn"))
def meleePhase(self): self.phase.addSubPhase(phase.Phase("Melee")) self.events = [] self.makeAttackTypeChoice()
def attackPhase(self): if self.attacked == False: self.phase.addSubPhase(phase.Phase("Attack")) self.events = [] self.makeAttackButtons()
def movePhase(self): if self.moved == False: self.phase.addSubPhase(phase.Phase("Move")) self.events = [] self.makeMoveChoice()
def skillPhase(self): self.phase.addSubPhase(phase.Phase("Skill")) self.events = []
def __init__(self): pygame.init() self.sprites = [] self.surface = pygame.display.set_mode((1440, 900)) self.nameLabel = pygame.image.load("images/name.png") self.nameRect = pygame.Rect(0, 0, self.nameLabel.get_rect().width, self.nameLabel.get_rect().height) self.nameRect.center = self.surface.get_rect().center self.nameRect.y -= 100 self.phase = phase.Phase("Main") self.usernameButton = button.Button(self.makeText("Username", 20, color=(255, 255, 255)), self.usernamePhase, color=(0, 0, 0), textColor=(255, 255, 255)) self.passwordButton = button.Button(self.makeText("Password", 20, color=(255, 255, 255)), self.passwordPhase, color=(0, 0, 0), textColor=(255, 255, 255)) temprect = pygame.Rect(self.nameRect.x, self.nameRect.y + 100, 150, 20) temprect.center = self.nameRect.center temprect.y -= 100 self.error = False self.usernameButton.setRect( pygame.Rect((temprect.x, temprect.y + 200), (150, 20))) self.passwordButton.setRect( pygame.Rect((temprect.x, temprect.y + 230), (150, 20))) self.cancelButton = button.Button(self.makeText("Cancel", 20), self.mainPhase) self.registerButton = button.Button(self.makeText("Register", 20), self.register) self.loginButton = button.Button(self.makeText("Login", 20), self.login) self.mapEditorButton = button.Button(self.makeText("Map Editor", 20), self.mapEditor) self.lamp = pygame.image.load("images/lamp.png") self.multiplayerButton = button.Button( self.makeText("Multiplayer", 20), self.multiplayerPhase) self.startButton = button.Button(self.makeText("Play", 20), self.party_screen) rect = pygame.Rect(self.nameRect.x, self.nameRect.y + 100, 200, 50) rect.center = self.nameRect.center rect.y += 150 self.startButton.setRect(pygame.Rect((rect.x, rect.y - 50), (200, 50))) rect.y += 50 self.multiplayerButton.setRect( pygame.Rect((rect.x, rect.y - 50), (200, 50))) self.mapEditorButton.setRect(pygame.Rect(rect.x, rect.y, 200, 50)) self.loginButton.setRect(pygame.Rect((rect.x, rect.y), (200, 50))) rect.y += 50 self.registerButton.setRect(pygame.Rect((rect.x, rect.y), (200, 50))) rect.y += 50 self.cancelButton.setRect(pygame.Rect((rect.x, rect.y), (200, 50))) self.leftLampRect = pygame.Rect(0, 0, 50, 75) self.rightLampRect = pygame.Rect(0, 0, 50, 75) self.leftLampRect.center = self.nameRect.center self.rightLampRect.center = self.nameRect.center self.leftLampRect.x -= 125 self.rightLampRect.x += 125 self.leftLampRect.y += 115 self.rightLampRect.y += 115 self.spm1 = particles.SmokeParticleManager(self.leftLampRect.center[0], self.leftLampRect.y + 5) self.spm2 = particles.SmokeParticleManager( self.rightLampRect.center[0], self.rightLampRect.y + 5) self.userChars = "" self.passwordChars = "" self.mainLoop()
def rangedPhase(self): self.phase.addSubPhase(phase.Phase("Ranged")) self.events = [] self.makeAttackTypeChoice()
def usernamePhase(self): self.phase = phase.Phase("Username")