Changeset 421

Show
Ignore:
Timestamp:
04/06/2012 11:38:07 PM (2 years ago)
Author:
jelinson
Message:

dynamic text in stat description

Files:
9 added
2 removed
6 modified

Legend:

Unmodified
Added
Removed
  • .pydevproject

    r413 r421  
    44<pydev_project> 
    55<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> 
    6 <path>/mt</path> 
    7 <path>/mt/src</path> 
    8 <path>/mt/dim</path> 
     6<path>/cs121sp2012_5</path> 
     7<path>/cs121sp2012_5/src</path> 
     8<path>/cs121sp2012_5/dim</path> 
    99</pydev_pathproperty> 
    1010<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property> 
  • src/fileio.py

    r386 r421  
    1111__all__ = ["resourceDir", "imageDir", "mapDir", "landscapeDir", "sequenceDir", 
    1212           "iconDir", "dataDir", "sceneDir", "saveDir", "saveExt", 
    13            "buildingDir", "buildExt", "arrowsDir", "buttonDir", "imgExt", "mapDataDir"] 
     13           "buildingDir", "buildExt", "arrowsDir", "buttonDir", "imgExt",  
     14           "mapDataDir", "specDir", "specExt"] 
    1415 
    1516 
     
    1920dataDir = resourceDir + "data" + os.sep 
    2021 
    21 mapDir = imageDir + "map" + os.sep 
    2222arrowsDir = imageDir + "arrows" + os.sep 
    2323buttonDir = imageDir + "new_layout" + os.sep 
    24 landscapeDir = mapDir + "landscapes" + os.sep 
    2524sequenceDir = imageDir + "sequences" + os.sep 
    2625iconDir = imageDir + "menu_icons" + os.sep 
    2726 
     27mapDir = imageDir + "map" + os.sep 
     28landscapeDir = mapDir + "landscapes" + os.sep 
     29 
    2830mapDataDir = dataDir + "landscapes" + os.sep 
    29  
    3031sceneDir = dataDir + "scenes" + os.sep 
    3132saveDir = dataDir + "saves" + os.sep 
    3233buildingDir = dataDir + "buildings" + os.sep 
    3334 
     35analysisDir = dataDir + "analysis" + os.sep 
     36specDir = analysisDir + "specs" + os.sep 
     37 
    3438saveExt = ".trek" 
    3539buildExt = ".bld" 
    3640imgExt = ".png" 
     41specExt = ".spec" 
  • src/scene.py

    r401 r421  
    172172        backResponse = sceneData.readline().rstrip('\n') 
    173173        scene.setBackResponse(backResponse) 
    174          
     174 
    175175        forwardResponse = sceneData.readline().rstrip('\n') 
    176176        scene.setForwardResponse(forwardResponse) 
    177          
     177 
    178178        textLine = sceneData.readline() 
    179179        while textLine != "": 
    180             print textLine 
    181180            img = sceneData.readline() 
    182181            img = img.rstrip('\n') 
     
    185184            textLine = sceneData.readline() 
    186185 
     186        sceneData.close() 
    187187        return scene 
  • src/scripts/generateBuildings.py

    r356 r421  
    9494    solarPanelStats.setOneTime(Spec(-100, -20, -20, -10, 0)) 
    9595    solarPanelStats.setCont(Spec(0, 5, 0, 0, 0)) 
    96     solarPanel = Building('solarpanel', POWER, solarPanelStats, (20, 0, 0), 
     96    solarPanel = Building('solar panel', POWER, solarPanelStats, (20, 0, 0), 
    9797                          ['windmill']) 
    9898    solarPanel.setMenuDescript("A solar panel uses the sun to make energy.") 
     
    108108    nuclearPlantStats.setOneTime(Spec(-200, -20, -50, -10, 0)) 
    109109    nuclearPlantStats.setCont(Spec(0, 50, 0, 0, 20)) 
    110     nuclearPlant = Building('nuclearplant', POWER, 
     110    nuclearPlant = Building('nuclear plant', POWER, 
    111111                            nuclearPlantStats, (40, 0, 0),[]) 
    112112    nuclearPlant.setMenuDescript("A nuclear power plant makes energy really fast.") 
  • src/spec.py

    r356 r421  
    88 
    99from globals import * 
     10 
     11specList = ["money", "power", "material", "space", "pollution"] 
    1012 
    1113 
  • src/statDescription.py

    r412 r421  
    55''' 
    66 
     7from specAnalysis import SpecAnalysis, specAnalysisLUT 
    78from window import Window 
    89from closeButton import CloseButton 
     
    2829 
    2930    def update(self, state): 
     31        self.message = "" 
    3032        self.message = self.category.capitalize() 
    31         self.message += ": " + str(state.specs.stringToValue(self.category)) 
    32         self.message += "\n More descriptions!" 
     33        self.message += ": " + str(state.specs.stringToValue(self.category)) + "\n" 
     34        analysis = specAnalysisLUT[self.category] 
     35        self.message += analysis.getDescription() 
     36        (toBuy, toDelete) = analysis.suggestions(state) 
     37        if len(toBuy) != 0: 
     38            self.message += "Consider buying a " 
     39            if (len(toBuy) > 1): 
     40                for i in range(len(toBuy) - 1): 
     41                    self.message += toBuy[i] + ", " 
     42                self.message += "or " 
     43            self.message += toBuy[len(toBuy) - 1] 
     44            self.message += ". " 
     45        if len(toDelete) != 0: 
     46            self.message += "Consider deleting your " 
     47            if (len(toDelete) > 1): 
     48                for i in range(len(toDelete) - 1): 
     49                    self.message += toDelete[i] + ", " 
     50                self.message += "or " 
     51            self.message += toDelete[len(toDelete) - 1] 
     52            self.message += ". " 
     53 
    3354        self.text = [] 
    34         self.text.append(Text((self.pos[0] + 5, self.pos[1] + 5), self.message, LG_TEXT, WHITE, DIM.W - 10)) 
     55        self.text.append(Text((self.pos[0] + 5, self.pos[1] + 5), self.message, MD_TEXT, WHITE, DIM.W - 10))