Nov-01-2017, 04:46 PM
(This post was last modified: Nov-01-2017, 04:46 PM by SnekLover123.)
I'm making a text game, and for the crafting part, it seems to be working, but when I view the inventory, nothing changed. I can't see why it's ignoring the kenyan_sand_boa["blah blah blah"] = new value. I only posted the parts I thought could be causing the failure. Sorry there's so much code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
import os import sys #dictionary kenyan_sand_boa = { "snek" : "kenyan sand boa" , "prey" : "mice, " "birds, " "lizards, " , "biome" : "desert" , "predators" : "desert monitor lizard" , "6 months age" : 182 , "adult age" : 365 , "baby size" : 10 , "6 months size" : 15 , "adult size" : 20 , "current size" : 10 , "current days" : 0 , "current age" : "baby" , "name" : "none" , "current home" : "none" , "home size" : 0 , "health" : 100 , "max health" : 100 , "last ate" : 0 , "plants" : 50 , "wood" : 50 , "rocks" : 50 , "regeneration" : 10 , } def menu(): os.system( 'cls' ) if kenyan_sand_boa[ "last ate" ] > = 7 : print "GAME OVER!!!! YOU STARVED TO DEATH!!!!! YOU SUCC!!!!!!!!!!!!!" os.system( 'pause' ) sys.exit() elif kenyan_sand_boa[ "current days" ] = = 182 : print """Congradulations! You are 6 months old. Your size is now 15. If your home is smaller than 15, then you will need to find a new home.""" kenyan_sand_boa[ "current size" ] = 15 kenyan_sand_boa[ "current age" ] = "6 months" os.system( 'pause' ) os.system( 'cls' ) print """-------------------------------------------------------------------------------- Health: %s | Day: %s | Last ate: %s days ago | Size: %s | Home size: %s -------------------------------------------------------------------------------- What do you want to do? 1. Read info about kenyan sand boas. 2. Explore. 3. Hunt. 4. Crafting. 5. View inventory. 6. Save. 7. Load save file. 8. Exit. """ % (kenyan_sand_boa["health "], kenyan_sand_boa[" current days "], kenyan_sand_boa[" last ate "], kenyan_sand_boa[" current size "], kenyan_sand_boa[" home size"]) elif kenyan_sand_boa[ "current days" ] = = 365 : print """Congradulations! You are a fully grown adult. Your size is now 20. If your home is smaller than 20, then you will need to find a new home.""" kenyan_sand_boa[ "current size" ] = 20 kenyan_sand_boa[ "current age" ] = "adult" os.system( 'pause' ) os.system( 'cls' ) print """-------------------------------------------------------------------------------- Health: %s | Day: %s | Last ate: %s days ago | Size: %s | Home size: %s -------------------------------------------------------------------------------- What do you want to do? 1. Read info about kenyan sand boas. 2. Explore. 3. Hunt. 4. Crafting. 5. View inventory. 6. Save. 7. Load save file. 8. Exit. """ % (kenyan_sand_boa["health "], kenyan_sand_boa[" current days "], kenyan_sand_boa[" last ate "], kenyan_sand_boa[" current size "], kenyan_sand_boa[" home size"]) else : print """-------------------------------------------------------------------------------- Health: %s | Day: %s | Last ate: %s days ago | Size: %s | Home size: %s -------------------------------------------------------------------------------- What do you want to do? 1. Read info about kenyan sand boas. 2. Explore. 3. Hunt. 4. Crafting. 5. View inventory. 6. Save. 7. Load save file. 8. Exit. """ % (kenyan_sand_boa["health "], kenyan_sand_boa[" current days "], kenyan_sand_boa[" last ate "], kenyan_sand_boa[" current size "], kenyan_sand_boa[" home size"]) def explore(): global monitor_health os.system( 'cls' ) print "You decide to slither around the desert" os.system( 'pause' ) os.system( 'cls' ) explore_int = random.randint( 1 , 450 ) home_size = random.randint( 7 , 14 ) monitor_health = random.randint( 100 , 150 ) if 1 < = explore_int < = 15 : print "A wild desert monitor lizard appeared!" os.system( 'pause' ) os.system( 'cls' ) snek_attack_monitor() menu() elif 16 < = explore_int < = 120 : print "You found a burrow. Size: %s. Would you like to live in this burrow? y/n?" % home_size choose_home = raw_input () if choose_home = = "y" : if home_size < kenyan_sand_boa[ "current size" ]: os.system( 'cls' ) print "This burrow is too small for you." os.system( 'pause' ) menu() else : os.system( 'cls' ) kenyan_sand_boa[ "home size" ] = home_size kenyan_sand_boa[ "current home" ] = "burrow" print "This is now your home." os.system( 'pause' ) menu() else : print "You decided not to live in the burrow." os.system( 'pause' ) menu() elif 21 < = explore_int < = 100 : print "You found a log. Size: %s. Would you like to live in this log? y/n?" % home_size choose_home = raw_input () if choose_home = = "y" : if home_size < kenyan_sand_boa[ "current size" ]: os.system( 'cls' ) print "This log is too small for you." os.system( 'pause' ) menu() else : os.system( 'cls' ) kenyan_sand_boa[ "home size" ] = home_size kenyan_sand_boa[ "current home" ] = "log" print "This is now your home." os.system( 'pause' ) menu() else : print "You decided not to live in the log." os.system( 'pause' ) menu() elif 101 < = explore_int < = 200 : print "You found a cave. Size: %s. Would you like to live in this cave? y/n?" % home_size choose_home = raw_input () if choose_home = = "y" : if home_size < kenyan_sand_boa[ "current size" ]: os.system( 'cls' ) print "This cave is too small for you." os.system( 'pause' ) menu() else : os.system( 'cls' ) kenyan_sand_boa[ "home size" ] = home_size kenyan_sand_boa[ "current home" ] = "cave" print "This is now your home." os.system( 'pause' ) menu() else : print "You decided not to live in the cave." os.system( 'pause' ) menu() elif 201 < = explore_int < = 250 : print "You found a plant. Would you like to keep it? y/n?" plant = raw_input () if plant = = "y" : kenyan_sand_boa[ "plants" ] + = 1 print "You decided to keep the plant." os.system( 'pause' ) menu() else : print "You decided not to keep the plant." os.system( 'pause' ) menu() elif 251 < = explore_int < = 350 : print "You found a rock. Would you like to keep it? y/n?" rock = raw_input () if rock = = "y" : kenyan_sand_boa[ "rocks" ] + = 1 print "You decided to keep the rock." os.system( 'pause' ) menu() else : print "You decided not to keep the rock" os.system( 'pause' ) menu() elif 351 < = explore_int < = 450 : print "You found wood. Would you like to keep it? y/n?" wood = raw_input () if wood = = "y" : kenyan_sand_boa[ "wood" ] + = 1 print "You decided to keep the wood." os.system( 'pause' ) menu() else : print "You decided not to keep the wood." os.system( 'pause' ) menu() def crafting(): if kenyan_sand_boa[ "rocks" ] = = 0 and kenyan_sand_boa[ "wood" ] = = 0 and kenyan_sand_boa[ "plants" ] = = 0 : print "You don't have any items." os.system( 'pause' ) os.system( 'cls' ) menu() else : print """To craft, first pick how many rocks to use. Then pick how many wood to use. Then pick how many plants to use. """ os.system( 'pause' ) rocks = int ( raw_input ( "Rocks: " )) wood = int ( raw_input ( "Wood: " )) plants = int ( raw_input ( "Plants: " )) if rocks > 0 and wood = = 0 and plants > 0 : if rocks > kenyan_sand_boa[ "rocks" ]: print "You don't have enough rocks." os.system( 'pause' ) menu() elif wood > kenyan_sand_boa[ "wood" ]: print "You don't have enough wood." os.system( 'pause' ) menu() elif plants > kenyan_sand_boa[ "plants" ]: print "You don't have enough plants." os.system( 'pause' ) menu() else : print "You created a size %s bio cave. It increases you health regeneration by 1 and your maximum health by %s." % (rocks, plants) choose_home = raw_input ( "Do you want to live in this bio cave? y/n?" ) if choose_home = = "y" : if rocks < kenyan_sand_boa[ "current size" ]: print "The bio cave is too small." os.system( 'pause' ) menu() elif rocks > = kenyan_sand_boa[ "current size" ]: kenyan_sand_boa[ "current home" ] = = "Bio cave" kenyan_sand_boa[ "home size" ] = = rocks kenyan_sand_boa[ "max health" ] + = plants kenyan_sand_boa[ "regeneration" ] + = 1 kenyan_sand_boa[ "rocks" ] - = rocks kenyan_sand_boa[ "plants" ] - = plants print "This is now your home." os.system( 'pause' ) menu() else : print "You decided not to live in the bio cave." os.system( 'pause' ) menu() if rocks = = 0 and wood > 0 and plants > 0 : if rocks > kenyan_sand_boa[ "rocks" ]: print "You don't have enough rocks." os.system( 'pause' ) menu() elif wood > kenyan_sand_boa[ "wood" ]: print "You don't have enough wood." os.system( 'pause' ) menu() elif plants > kenyan_sand_boa[ "plants" ]: print "You don't have enough plants." os.system( 'pause' ) menu() else : print "You created a size %s bio log. It increases you health regeneration by 5 and your maximum health by %s." % (wood, plants) choose_home = raw_input ( "Do you want to live in this bio log? y/n?" ) if choose_home = = "y" : if wood < kenyan_sand_boa[ "current size" ]: print "The bio log is too small." os.system( 'pause' ) menu() elif wood > = kenyan_sand_boa[ "current size" ]: kenyan_sand_boa[ "current home" ] = = "Bio log" kenyan_sand_boa[ "home size" ] = = wood kenyan_sand_boa[ "max health" ] + = plants kenyan_sand_boa[ "regeneration" ] + = 5 kenyan_sand_boa[ "wood" ] - = wood kenyan_sand_boa[ "plants" ] - = plants print "This is now your home." os.system( 'pause' ) menu() else : print "You decided not to live in the bio log." os.system( 'pause' ) menu() |