Esempio n. 1
0
 def getStatusBarHPAttribute(self):
     percentHealth = float(self.getHP())/self.getMaxHP()
     if (percentHealth <= 0.333):
         return Colors.getPairNumber('RED', 'BLACK')
     elif (percentHealth <= 0.666):
         return Colors.getPairNumber('YELLOW', 'BLACK')
     else: 
         return Colors.getPairNumber('GREEN', 'BLACK')
Esempio n. 2
0
 def updateColor(self, fgColor, bgColor):
     self.attribute = Colors.getPairNumber(fgColor, bgColor)
     self.fgColor = fgColor
     self.bgColor = bgColor
     self.zDepthAttribute = self.attribute
     if (fgColor == bgColor): #Same color! Uh oh!
         if (bgColor != 'BLACK'):
             self.zDepthAttribute = Colors.getPairNumber(self.fgColor, 'BLACK')
         else:
             self.zDepthAttribute = Colors.getPairNumber(self.fgColor, 'WHITE')
Esempio n. 3
0
    def waitForStatusLineUpdateConfirmation(self, inputHandler = None):

        if (inputHandler == None):
            inputHandler = InputHandler.SingletonKeyboardInputHander(self.screen)

        promptMessage = 'PRESS A KEY'
        promptMessageLength = len(promptMessage)

        y = self.getTerminalHeight() - 1
        x = self.getTerminalWidth() - self.maxSideBarLen - 1
        promptMessageAttr = Colors.BLINK | Colors.getPairNumber('BLACK', 'YELLOW')

        self.screen.addnstr(y, x, promptMessage, promptMessageAttr)
        
        self.draw()

        curses.flash() #Visual bell

        keyPressed = inputHandler.waitForKey()

        Logger.put(' key found: %s' % (str(keyPressed)))

        self.resetStatusLinesAppended()
        #erase the prompt message
        self.screen.addnstr(y, x, ' ' * promptMessageLength, promptMessageAttr)

        self.draw()
 def __init__(self):
     CreatureWithInventory.__init__(self)
     self.description = 'outlaw'
     self.representation = 'T'
     self.speed = 220
     self.attribute = Colors.getPairNumber("RED", "BLACK")
     "Outlaws cannot see in the dark well."
     self.minimumLightToSeeThreshold = self.minimumLightToSeeThreshold + 1
 def __init__(self):
     CreatureWithInventory.__init__(self)
     self.description = 'deputy'
     self.representation = '@'
     self.speed = 200
     self.attribute = Colors.getPairNumber("WHITE", "BLACK")
     w = BaseItems.Revolver()
     self.addToInventory(w)
     self.setWeapon(w)
Esempio n. 6
0
    def __init__(self, screen, width = None, height = None):
        self.screen = screen
        self.width = width
        self.height = height
        self.statusLinesHeight = 5
        self.maxSideBarLen = 11
        self.time = 0
        self.eventHeap = []
        self.shouldPause = False
        self.lightSources = []

        self.defaultOverlay = Overlay.Overlay(self)
        self.overlay = self.defaultOverlay

        self.setDrawMode(World.DRAW_DETAIL_PHYSICAL)
        self.setViewMode(World.VIEW_VIEWER_INFORMATION)

        #self.world is referenced by x first, then y
        self.world = []

        if (self.width == None):
            self.width = self.screen.getmaxyx()[1]
        if (self.height == None):
            self.height = self.screen.getmaxyx()[0] - 5

        #self.makeForestMap()
        self.loadMapFromFile('testMap.txt')

        playerA = BaseCreatures.Deputy()
        playerB = BaseCreatures.Sheriff()

        playerA.makePlayerControlled()
        playerB.makePlayerControlled()

        self.team = TeamViewer(self, [playerA, playerB])
        self.currentViewer = self.team.getTeamMember(0)
        for i in range(0, len(self.team.getTeamList())):
            self.placeItem(self.team.getTeamMember(i), i, 0)

        #initialize some static data if not already initialized
        if (World.cannotSeeAttribute == None):
            World.cannotSeeAttribute = Colors.getPairNumber('WHITE', 'BLACK')
            for k in World.zHeightLookupTable.keys():
                result = WorldState.WorldRepresentation.convertString(World.zHeightLookupTable[k])
                if (k < 0):
                    World.zHeightLookupTable[k] = result
                else:
                    World.zHeightLookupTable[k] = result

    
        self.statusLinesAttribute = 0

        self.statusLines = []
        self.statusOffset = 11-6
        self.statusLinesAppended = 0
 def __init__(self):
     CreatureWithInventory.__init__(self)
     self.description = 'thieving bandito'
     self.representation = 'B'
     self.speed = 180
     self.attribute = Colors.getPairNumber("YELLOW", "BLACK")
     w = BaseItems.Revolver()
     self.addToInventory(w)
     self.setWeapon(w)
     "Banditos can see in the dark pretty well."
     self.minimumLightToSeeThreshold = self.minimumLightToSeeThreshold - 1
Esempio n. 8
0
    def __init__(self):
        Item.LocationAwareItem.__init__(self)
        self.x = None
        self.y = None
        self.world = None
        self.speed = 100
        self.description = 'uninherited-from creature'
        self.representation = 't'
        self.foreGroundColorName = 'YELLOW'
        self.attribute = Colors.BOLD | Colors.getPairNumber(self.foreGroundColorName, "BLACK")
        self.inputHandler = InputHandler.SingletonKeyboardInputHander(ToastWrangler.screen)
        Logger.put(str(self.inputHandler))

        self.minimumLightToSeeThreshold = 3

        self.seeDistance = 99
        self.fov = None

        self.light = None

        self.moveActionDistance = 3
        self.moveDistanceThisTurn = 0

        self.didAttack = False

        self.maxHP = 10
        self.hp = 10

        self.horizontalAttackDistance = 1
        self.verticalAttackDistance = 1

        self.attackDamage = 1

        self.toggleLightCost = 1

        self.team = 0

        self.originalThink = self.doThink
Esempio n. 9
0
 def __init__(self, world, creature):
     Overlay.__init__(self, world)
     self.creature = creature
     self.cursorPosX = 0
     self.cursorPosY = 0
     self.attackAttribute = Colors.getPairNumber('WHITE', 'RED') | curses.A_BOLD