Advertisement
1400_SpaceCat

mdl_travelsystem.py

Oct 18th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.11 KB | None | 0 0
  1. from sys import executable,argv
  2. from os import execl,getcwd,chdir,path,stat,SEEK_END
  3.  
  4. from random import randrange as rr
  5. from random import seed as rs
  6.  
  7. from pickle import dump,load
  8. from re import search
  9. from inspect import getframeinfo, currentframe
  10. from locale import setlocale,LC_ALL,getlocale
  11.  
  12. from mdl_magic import magic,Colors
  13. from mdl_herosave import *
  14.  
  15.  
  16. class travel:
  17.  
  18.     def __init__(self):
  19.         heroStat() #mdl_herosave
  20.  
  21.         self.heroHealth = heroStat.heroHealth
  22.         self.heroPunch  = heroStat.heroPunch
  23.         self.heroCurse  = heroStat.heroCurse
  24.  
  25.         self.heroMeetingUnusually = heroStat.heroMeetingUnusually
  26.         self.heroCurrentLocation  = heroStat.heroCurrentLocation
  27.         self.heroLevel            = heroStat.heroLevel
  28.  
  29.         self.heroHelmet = heroStat.heroHelmet
  30.         self.heroArmor  = heroStat.heroArmor
  31.         self.heroPants  = heroStat.heroPants
  32.         self.heroBoots  = heroStat.heroBoots
  33.  
  34.         self.heroHealthMiddle    = heroStat.heroHealthMiddle
  35.         self.heroHealthButtle    = heroStat.heroHealthButtle
  36.         self.heroHealthButtleHPP = heroStat.heroHealthButtleHPP
  37.  
  38.         self.locN = []
  39.         self.locS = []
  40.         self.locE = []
  41.         self.locW = []
  42.  
  43.         self.north = "module/loc_north.lsv"
  44.         self.south = "module/loc_south.lsv"
  45.         self.east  = "module/loc_east.lsv"
  46.         self.west  = "module/loc_west.lsv"
  47.  
  48.         self.debug = []
  49.        
  50.         self.walk()
  51.  
  52.     def restart(self):
  53.         python = executable
  54.         execl(python, python, * argv)
  55.  
  56.     def writeLI(self,fileName,listName, locName,locID,locLVL):
  57.         listName.append((locName,locID,locLVL))
  58.         listName = list(set(listName))
  59.         with open(fileName,"wb") as locFile:
  60.             dump(listName, locFile)
  61.            
  62.     def readLI(self,fileName):
  63.         with open(fileName,"rb") as locFile:
  64.             self.returnedData = load(locFile)
  65.            
  66.     def walk(self):
  67.            
  68.         if ( stat(self.north).st_size == 0 ):
  69.             self.writeLI(self.north,self.locN,"Оборонительный пост 'Старый волк'",1000,1)
  70.             self.writeLI(self.south,self.locS,"Ворота в деревню",2000,1)
  71.             self.writeLI(self.west,self.locW, "Лодочная пристань",3000,1)
  72.             self.writeLI(self.west,self.locW,"Бар 'Пьяная устрица'",3001,1)
  73.             self.writeLI(self.east,self.locE,"Деревня 'Слеза девы'",4000,1)
  74.  
  75.         self.readLI(self.north)
  76.  
  77.         #restart()
  78.  
  79.         setlocale(LC_ALL, '')
  80.         self.debug.append(("sf:full",str(getlocale()) ))
  81.  
  82.         magic.Clear()
  83.         while ( True ):
  84.             print(self.debug)
  85.            
  86.             self.readLI(self.north)
  87.             self.readLI(self.south)
  88.             self.readLI(self.west)
  89.             self.readLI(self.east)
  90.            
  91.             print("\n[ Локация:",self.heroCurrentLocation,"]\n[ Здоровье: (",self.heroHealth,") ]\n[ ? -- Справка ]\n")
  92.             action = input("Ваше действие: ").upper()
  93.            
  94.             if ( action == "?" ):
  95.                 print('''
  96.                 \r=======================================
  97.                 \r1 - отправиться на север
  98.                 \r2 - отправиться на юг
  99.                 \r3 - отправиться на восток
  100.                 \r4 - отправиться на запад
  101.                 \r5 - карта мира
  102.                 \r6 - очистить экран
  103.                 \r7 - спать (в часах)
  104.                 \r8 - открыть инвентарь
  105.                 \r9 - статистика
  106.                 \r0 - сохраниться
  107.                 \rE - выход
  108.                 \rD - Debug Menu
  109.                 \r=======================================''')
  110.                
  111.             elif ( action == "1" ):
  112.                 print("Отправляемся в северные дали! Выберите одну из локаций: ")
  113.                
  114.                 self.writeLI(self.north,self.locN,"Фаруко",1001,1)
  115.                 self.writeLI(self.north,self.locN,"Старый лес",1002,1)
  116.                
  117.                 self.readLI(self.north)
  118.                 locFile = self.returnedData
  119.                 showLocFile = [ value[0] for value in locFile ]
  120.                
  121.                 for i in range(len(showLocFile)):
  122.                     print(i+1,"/",locFile[i][0])
  123.                    
  124.                 for j in range(1):
  125.                     #print(i+1,"/",locFile[i][0])
  126.                        
  127.                     chooseLocation = int(input("\n--------------\nВыбор локации: "))
  128.                     self.heroCurrentLocation = locFile[chooseLocation-1][0]
  129.                     print(self.heroCurrentLocation)
  130.                        
  131.                        
  132.             elif ( action == "6" ):
  133.                 magic.Clear()
  134.                
  135.             elif ( action == "E" ):
  136.                 exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement