Commits

Anonymous committed 327b84b

# 10/24/09 - Some minor tweaks to terrain / trait learning - 0.4.1 Beta
- Rearranged some info placement in move menu
- Added terrain data drawing function to map object
- Added drawing of data about terrain currently under cursor
- Traits are drawn grayed out if you don't have enough TP to buy them
- Updated the last line of CH2ST2 to correspond with version number
- [Bugfix] Trait points at top weren't updating when you bought traits

  • Participants
  • Parent commits f1f0147
  • Tags v0.4.1 Beta

Comments (0)

Files changed (5)

Story of a Lost Sky/battle_system/mapobj.py

     
     def render_background(self):
         
-        
         """
         # Function Name: render background
         # Purpose: renders a background with all the tiles.
             if unit != notrender:
                 unit.render()
 
+    def render_current_terrain_data(self):
+        """
+        # Function Name: render current terrain data
+        # Purpose: draws information about the current tile under the unit's cursor
+        """
+        
+        # Draws current terrain tile info
+        text_current_terrain_type = self.engine.bfont.render(self.terrainmap[tuple(self.cursor_pos)][0].name,True, (0,0,0))
+        text_current_terrain_tdef = self.engine.sfont.render("TDEF: %2.1f"%self.terrainmap[tuple(self.cursor_pos)][0].TDEF,True, (0,0,0))
+        text_current_terrain_agl = self.engine.sfont.render("AGL: "+str(self.terrainmap[tuple(self.cursor_pos)][0].aglmod),True, (0,0,0))
+        text_current_terrain_acc = self.engine.sfont.render("ACC: "+str(self.terrainmap[tuple(self.cursor_pos)][0].accmod),True, (0,0,0))
+        
+        self.engine.surface.blit(text_current_terrain_type,(450,505))
+        self.engine.surface.blit(self.engine.terrain_icon,(450,523),(self.terrainmap[tuple(self.cursor_pos)][0].ident*50,0,50,50))
+        self.engine.surface.blit(text_current_terrain_tdef,(450,575))
+        self.engine.surface.blit(text_current_terrain_agl,(450,587))
+        self.engine.surface.blit(text_current_terrain_acc,(450,599))
+
     def render_cursor(self):
         """
         # Function Name: render cursor
                     self.render_all_units()
                     self.render_cursor()
                     self.engine.surface.blit(self.engine.menu_board,(0,490))
+                    self.render_current_terrain_data()
 
                     if selected != False:
                         self.all_units_by_name[selected].plot_stats()
                             
+                                
                     pygame.display.set_caption("Story of a Lost Sky - Pos (%1.0f,%1.0f) - Shift (%1.0f,%1.0f)"
                                                        %(self.cursor_pos.x,self.cursor_pos.y,self.screen_shift.x,self.screen_shift.y))
                     

Story of a Lost Sky/battle_system/trait.py

         
         # Generate List of available traits
         all_learnable_traits = self.get_learnable_traits(unit)
-        all_trait_data = []
-        [all_trait_data.append([self.engine.sfont.render(trait_data[0],True,(0,0,0)),
-            self.engine.sfont.render(str(trait_data[1]),True,(0,0,0))]) for trait_data in all_learnable_traits]
-        text_TP = self.engine.bfont.render("Trait Points: "+str(unit.trait_points),True,(0,0,0))
+        all_trait_data = self.refresh_trait_list(unit,all_learnable_traits)
         
         if all_learnable_traits:
             text_selected_trait = self.engine.get_text_selected_trait(self.engine.trait_catalog[all_learnable_traits[menu_pos][0]])
+        text_TP = self.engine.bfont.render("Trait Points: "+str(unit.trait_points),True,(0,0,0))
+        
         
         while menu_flag:
         
                             text_selected_trait = self.engine.get_text_selected_trait(self.engine.trait_catalog[all_learnable_traits[menu_pos][0]])
                     if event.key == K_z or event.key == K_RETURN:
                         if all_learnable_traits:
+                            
                             #Checks if there are enough TP available to learn this trait
                             if unit.trait_points >= all_learnable_traits[menu_pos][1]:
                                 
                                 learned_trait = self.engine.trait_catalog[all_learnable_traits[menu_pos][0]]
-                                if learned_trait.variation == "Action":
-                                    trait_index = 0
-                                elif learned_trait.variation == "Support":
-                                    trait_index = 1
                                 
-                                # If the reserve trait list is empty, remove the empty listing
-                                if unit.reserve_traits[trait_index][0] == 'Empty':
-                                    del (unit.reserve_traits[trait_index][0])
+                                confirmed = self.trait_confirm_menu(unit, learned_trait)
+                                
+                                if confirmed:
+                                
+                                    if learned_trait.variation == "Action":
+                                        trait_index = 0
+                                    elif learned_trait.variation == "Support":
+                                        trait_index = 1
                                     
-                                # Sends the trait to reserve
-                                unit.reserve_traits[trait_index].append(learned_trait)
+                                    # If the reserve trait list is empty, remove the empty listing
+                                    if unit.reserve_traits[trait_index][0] == 'Empty':
+                                        del (unit.reserve_traits[trait_index][0])
+                                        
+                                    # Sends the trait to reserve
+                                    unit.reserve_traits[trait_index].append(learned_trait)
+                                    
+                                    # Updates unit's trait points
+                                    unit.trait_points -= all_learnable_traits[menu_pos][1]
+                                    
+                                    # Refreshes displayed data
+                                    all_learnable_traits = self.get_learnable_traits(unit)
+                                    all_trait_data = self.refresh_trait_list(unit,all_learnable_traits)
+                                    text_TP = self.engine.bfont.render("Trait Points: "+str(unit.trait_points),True,(0,0,0))
+        
+                                    # Fixes cursor position if beyond range
+                                    if menu_pos > len(all_learnable_traits)-1:
+                                        menu_pos = len(all_learnable_traits)-1
                                 
-                                # Updates unit's trait points
-                                unit.trait_points -= all_learnable_traits[menu_pos][1]
-                                
-                                # Refreshes displayed data
-                                all_learnable_traits = self.get_learnable_traits(unit)
-                                all_trait_data = []
-                                [all_trait_data.append([self.engine.sfont.render(trait_data[0],True,(0,0,0)),
-                                    self.engine.sfont.render(str(trait_data[1]),True,(0,0,0))]) for trait_data in all_learnable_traits]
-                                text_TP = self.engine.bfont.render("Trait Points: "+str(unit.trait_points),True,(0,0,0))
-                                
-                                # Fixes cursor position if beyond range
-                                if menu_pos > len(all_learnable_traits)-1:
-                                    menu_pos = len(all_learnable_traits)-1
-                            
-                                # Updates trait detail display
-                                if all_learnable_traits:
-                                    text_selected_trait = self.engine.get_text_selected_trait(self.engine.trait_catalog[all_learnable_traits[menu_pos][0]])
+                                    # Updates trait detail display
+                                    if all_learnable_traits:
+                                        text_selected_trait = self.engine.get_text_selected_trait(self.engine.trait_catalog[all_learnable_traits[menu_pos][0]])
                     
                     if event.key == K_x:
                         menu_flag = False
         
                 pygame.display.flip()
                 self.engine.clock.tick(60)
+                
+    def trait_confirm_menu(self,unit,trait):
+        """
+        # Function Name: trait confirm menu
+        # Purpose: trait asks the user to verify that they want to learn the trait
+        """
+        text_menu_header = self.engine.bfont.render('Learn Traits: '+unit.name,True,(0,0,0))
+        text_cost = self.engine.bfont.render('Cost',True,(0,0,0))
+        text_empty = self.engine.sfont.render('Empty',True,(0,0,0))
+        text_name = self.engine.bfont.render('Trait Name',True,(0,0,0))
+        
+        text_confirm = self.engine.bfont.render('Confirm learning trait:',True,(0,0,0))
+        text_trait_name = self.engine.bfont.render(trait.name,True,(0,0,0))
+        text_yes = self.engine.bfont.render('Yes',True,(0,0,0))
+        text_no = self.engine.bfont.render('No',True,(0,0,0))
+        text_trait_name = self.engine.bfont.render(trait.name,True,(0,0,0))
+        text_unit_name = self.engine.sfont.render("Character: "+unit.name,True,(0,0,0))
+        text_trait_type = self.engine.sfont.render("Type: "+trait.variation,True,(0,0,0))
+        text_trait_cost = self.engine.sfont.render("Cost: %s TP"%(trait.cost),True,(0,0,0))
+        
+        menu_flag = True
+        menu_pos = True
+        
+        # Generate List of available traits
+        all_learnable_traits = self.get_learnable_traits(unit)
+        all_trait_data = self.refresh_trait_list(unit,all_learnable_traits)
+                
+        text_TP = self.engine.bfont.render("Trait Points: "+str(unit.trait_points),True,(0,0,0))
+        
+        while menu_flag:
+        
+            # looks for event type data to select interaction
+            for event in pygame.event.get():
+                if event.type == QUIT or (event.type == KEYDOWN and event.key == KMOD_ALT|K_F4):
+                    exit()
+                if event.type == KEYDOWN:
+                    
+                    if event.key in (K_UP,K_LEFT,K_RIGHT,K_DOWN):
+                        menu_pos = not menu_pos
+                        
+                    if event.key == K_z or event.key == K_RETURN:
+                        return menu_pos
+                            
+                    if event.key == K_x:
+                        return False
+
+            if menu_flag:
+                # Draw the learnable traits on the left side
+                self.engine.surface.blit(self.engine.stats_bg,(0,0))
+                self.engine.surface.blit(text_menu_header,(50,50))
+                self.engine.surface.blit(text_name,(60,70))
+                self.engine.surface.blit(text_cost,(250,70))
+                self.engine.surface.blit(text_TP,(250,50))
+                
+                
+                # Draw the information about the selected trait on the right side
+                if all_learnable_traits:
+                    for count,trait_data in enumerate(all_trait_data):
+                        self.engine.surface.blit(trait_data[0],(70,90+count*20))
+                        self.engine.surface.blit(trait_data[1],(270,90+count*20))
+                    
+                self.engine.surface.blit(self.engine.results_panel,(280,140))
+                self.engine.surface.blit(text_confirm,(300,160))
+                self.engine.surface.blit(text_yes,(360,180))
+                self.engine.surface.blit(text_no,(460,180))
+
+                self.engine.surface.blit(text_trait_name,(300,300))
+                self.engine.surface.blit(text_unit_name,(320,320))
+                self.engine.surface.blit(text_trait_type,(320,340))
+                self.engine.surface.blit(text_trait_cost,(320,360))
+                
+                # Draws the cursor
+                pygame.draw.circle(self.engine.surface, (0,0,0), (453-100*menu_pos,188),5)
+                
+                pygame.display.flip()
+                self.engine.clock.tick(60)
         
     def get_learnable_traits(self,unit):
         """
     
         all_learnable_traits = []
     
-        # Appends [Trait name, cost] if trait can be learned
-        [all_learnable_traits.append([trait.name,trait.cost])for trait in self.engine.trait_catalog.values() if trait.check_restrictions(unit)]
+        # Appends [Trait name, cost, T/F if unit has enough TP to learn this] if trait can be learned
+        [all_learnable_traits.append([trait.name,trait.cost, unit.trait_points >= trait.cost])for trait in self.engine.trait_catalog.values() if trait.check_restrictions(unit)]
         
         all_learnable_traits.sort()
     
         return all_learnable_traits
 
+    def refresh_trait_list(self,unit,all_learnable_traits):
+        
+        """
+        # Function Name: refresh_trait_list
+        # Purpose: renders the trait list into appropriate text surface images.
+        # Input: unit - unit to get traits for
+        #        all_learnable_traits - a list of all traits unit can learn
+        # Output: all_trait_data = list of all text objects
+        """
+        all_trait_data = []
+        # Draws info in black if unit has enough TP, gray if it doesn't
+        for trait_data in all_learnable_traits:
+            
+            # 3rd entry in list is a T/F flag to determine if the unit has enough TP
+            # Case: unit has enough TP
+            if trait_data[2]:
+                all_trait_data.append([self.engine.sfont.render(trait_data[0],True,(0,0,0)),
+                                   self.engine.sfont.render(str(trait_data[1]),True,(0,0,0))])
+            # Case: unit doesn't have enough
+            else:
+                all_trait_data.append([self.engine.sfont.render(trait_data[0],True,(100,100,100)),
+                                   self.engine.sfont.render(str(trait_data[1]),True,(100,100,100))])
+
+        return all_trait_data
+            
+        text_TP = self.engine.bfont.render("Trait Points: "+str(unit.trait_points),True,(0,0,0))
+
+
 class Trait(object):
 
 

Story of a Lost Sky/changelog.txt

-# 10/24/09 -
+# 10/24/09 - Some minor tweaks to terrain / trait learning - 0.4.1 Beta
 - Rearranged some info placement in move menu
+- Added terrain data drawing function to map object
+- Added drawing of data about terrain currently under cursor
+- Traits are drawn grayed out if you don't have enough TP to buy them
+- Updated the last line of CH2ST2 to correspond with version number
+- [Bugfix] Trait points at top weren't updating when you bought traits
 
 # 10/18/09 - Tiny sized fixes
 - Added ability to use Left/Right arrow keys on world map top level menu
 - Added some text explaining that Marisa can't take many hits.
 - [Issue 29] Added an exit option to the world map menu.
 
-# 10/17/09 - Pursuit AI
+# 10/17/09 - Pursuit AI -0.4.1 Alpha
 - Autosave enabled by default
 - Added Pursuit type AI that does not have a restricted range (Best used with Flight trait)
 - Added Flight trait to fireflies in CH2ST1 and gave them the pursuit AI

Story of a Lost Sky/data/XML/Missions/CH2ST2.xml

 			</sub_action>
 			<sub_action name="say">
 				<line>Be sure to regularly check the missions screen for new missions. They may lead you to new discoveries.</line>
-                <speaker>None</speaker>
+                <speaker>Tutorial</speaker>
 			</sub_action>
 			<sub_action name="say">
-				<line>This brings us to the end of Story of a Lost Sky 0.4.0. Thank you for playing!</line>
+				<line>This brings us to the end of Story of a Lost Sky 0.4.1. Thank you for playing!</line>
                 <speaker>None</speaker>
 			</sub_action>
              

Story of a Lost Sky/srpg.py

 engine.single_turn_win = False
 engine.enable_splash = False
 engine.enable_wm_tutorial = False
-engine.unlock_wm = True
+engine.unlock_wm = False
 engine.unlock_shops = False  
 
 ############################