示例#1
0
    def setUp(self):
        self.test = objects.objects()

        self.test.add("first_name", "John")
        self.test.add("last_name", "Doe")
        self.test.add("phone", "5555555555")
        self.test.add("address", "1234 Test St")
示例#2
0
    def __init__(self, data, seed):
        super().__init__(data)  # Header removal
        self.modify_data_ice_dark_alert(
        )  # Changement du code en prévision du randomizer pour pouvoir changer le nombre.
        self.modify_objects_data()
        self.removeExitFromData(3, 1, 0)  # Enlever exit inutilisé
        self.removeExitFromData(1, 15, 0)  # Enlever exit inutilisé
        self.removeExitFromData(1, 13, 1)  # Enlever exit inutilisé
        self.arrow_platform_bidirect()
        self.seed = seed
        self.add_credits()  # Ajout credits

        self.setmulti(0x72A9, 0x72D5, 0xEA)  # Free space from piracy check

        self.setmulti(0x0131DF, 0x131E0,
                      0xEA)  # Disable the counter so you never see demo
        # I did this because if we happen to have a dark room in demo, the screens will be glitchy

        # Création des différents world pour permettre leur randomization isolé.
        self.all_worlds = [
            World(self.data, 0),
            World(self.data, 1),
            World(self.data, 2),
            World(self.data, 3),
            World(self.data, 4)
        ]
        self.all_objects = objects(self.data)
示例#3
0
def aptI(name):
    '''import objects from APT ObjectsList.xml file'''
    constellations=stars.load()
    abbrevConst={x.lower():y for x,y in stars.abbrev().items()}   #malym -> osetrenie problem s velkostou pismen

    objects=objClass.objects(constellations)

    xmldoc=ET.parse(name)
    objlist=xmldoc.findall('Obj')

    for obj in objlist:
        params=dict().fromkeys(['name','ra','dec','mag','size','typ','note','const'],'')
        try: params['name']=obj.find('Object').text
        except: params['name']=obj.find('Name').text
        try: params['note']=(obj.find('NameNotes').text or '')
        except: params['note']=''
        if len(params['note'])>0: params['note']=html.unescape(params['note'])   #replace html characters in XML
        try: params['typ']=(obj.find('Type').text or '')
        except: params['typ']=''
        try: params['const']=(obj.find('Const').text or '')
        except: params['const']=''
        if params['const'].lower() in abbrevConst: params['const']=abbrevConst[params['const'].lower()]
        try: params['mag']=obj.find('Mag').text.replace(',','.').strip()
        except AttributeError: params['mag']=''  #bez hodnoty
        try: params['size']=(obj.find('Size').text or '')
        except: params['size']=''
        try: params['ra']=stars.readDMS(obj.find('RA').text.replace(',','.'))
        except:
            messagebox.showerror('RA Format','Wrong RA format or RA not given for '+params['name']+'! Object skipped.')
            print(params['name'],'- RA:',obj.find('RA').text)
        try: params['dec']=stars.readDMS(obj.find('DEC').text.replace(',','.'))
        except:
            messagebox.showerror('DEC Format','Wrong DEC format or DEC not given for '+params['name']+'! Object skipped.')
            print(params['name'],'- DEC:',obj.find('DEC').text)

        if len(str(params['ra']))*len(str(params['dec']))==0: continue  #RA/DEC error
        objects.add(params['name'],params['ra'],params['dec'],params['mag'],params['size'],params['typ'],params['note'])
        found=False
        consts=[]
        for const in constellations:
            if constellations[const].testPoint(params['ra'],params['dec']):
                consts.append(const)
                found=True
        if not found:
            messagebox.showwarning('Constellation','Constellation of '+params['name']+'  not detected! Please, add it manually.')
            objects.objects[params['name']]['object'].const='Ari'
            print(params['name'])
        else:
            objects.objects[params['name']]['object'].const=consts[0]
            if len(consts)>1:
                messagebox.showwarning('Constellation','Multiple possible constellations for '+params['name']+' detected ('\
                +', '.join(consts)+')! Please, add it manually.')
                print(params['name'],consts)
        if (not objects.objects[params['name']]['object'].const.lower()==params['const'].lower()) and len(params['const'])>0:
            messagebox.showwarning('Constellation','Detected constellation ('+objects.objects[params['name']]['object'].const+') for '+params['name']+\
            " is different to catalog's one ("+params['const']+')! Please, add it manually.')
            print(params['name'],objects.objects[params['name']]['object'].const,params['const'])
    return objects
示例#4
0
def join(name1,name2,save=False):
    '''join 2 objects files'''
    constellations=stars.load()

    objects1=objClass.objects(constellations)
    objects1.load(name1)

    objects2=objClass.objects(constellations)
    objects2.load(name2)

    for obj in objects2.objects:
        if obj in objects1.objects:
            print(obj,'is already in file.')
            continue
        objects1.objects[obj]=objects2.objects[obj]

    if save: objects1.save(name1)
    return objects1
示例#5
0
def inventory():
    global inv
    articles = objects("articles")
    statement = "\tYou have in your possession: "
    if len(inv) == 0: statement = "\tNothing here yet."
    for x in inv:
        statement += articles[x]
        statement += x
        if inv.index(x) < len(inv) - 1:
            if inv.index(x) == len(inv) - 2: statement += " and "
            else: statement += ", "
    print(statement + ".")
示例#6
0
 def __init__(self, width, height, framerate, power):
     self.WIDTH = width
     self.HEIGHT = height
     self.FRAMERATE = framerate
     self.root = tk.Tk()
     self.CANVAS = tk.Canvas(self.root,
                             width=self.WIDTH,
                             height=self.HEIGHT)
     self.CANVAS.pack()
     self.OBJECTS = objects.objects(self.CANVAS, self.WIDTH, self.HEIGHT,
                                    power)
     self.setup()
示例#7
0
 def __init__(self, width, height, framerate):
     self.WIDTH = width
     self.HEIGHT = height
     self.FRAMERATE = framerate
     self.ROOT = tk.Tk()
     self.CANVAS = tk.Canvas(self.ROOT, width=self.WIDTH, height=self.HEIGHT)
     self.CANVAS.configure(background="black")
     self.CANVAS.pack()
     self.CANVAS.bind_all('<Left>', self.left_key)
     self.CANVAS.bind_all('<Right>', self.right_key)
     self.create_menu()
     self.draw = objects.objects(self.CANVAS, self.WIDTH, self.HEIGHT, 5)
     self.lim_a, self.lim_b = 0, 720
示例#8
0
 def __init__(self, width, height, framerate, recursions):
     self.WIDTH = width
     self.HEIGHT = height
     self.FRAMERATE = framerate
     self.RECURSIONS = recursions
     self.root = tk.Tk()
     self.canvas = tk.Canvas(self.root,
                             width=self.WIDTH,
                             height=self.HEIGHT)
     self.canvas.pack()
     self.initialise_window()
     self.d = objects.objects(self.HEIGHT, self.WIDTH, self.FRAMERATE,
                              self.canvas, self.RECURSIONS)
示例#9
0
 def __init__(self, width, height, framerate):
     self.WIDTH = width
     self.HEIGHT = height
     self.FRAMERATE = framerate
     self.ROOT = tk.Tk()
     self.CANVAS = tk.Canvas(self.ROOT,
                             width=self.WIDTH,
                             height=self.HEIGHT)
     self.CANVAS.pack()
     self.CANVAS.bind_all('<Left>', self.key_left)
     self.CANVAS.bind_all('<Right>', self.key_right)
     self.obj = objects.objects(self.WIDTH, self.HEIGHT)
     self.coords = [0, 0, self.WIDTH, self.HEIGHT]
     self.initialise()
示例#10
0
 def __init__(self, width, height, framerate):
     self.WIDTH = width
     self.HEIGHT = height
     self.FRAMERATE = framerate
     self.ROOT = tk.Tk()
     self.CANVAS = tk.Canvas(self.ROOT, width=self.WIDTH, height=self.HEIGHT)
     self.CANVAS.configure(background="black")
     self.CANVAS.pack()
     self.CANVAS.bind_all('<Left>', self.left_key)
     self.CANVAS.bind_all('<Right>', self.right_key)
     self.CANVAS.bind_all('<Up>', self.up_key)
     self.CANVAS.bind_all('<Down>', self.down_key)
     self.draw = objects.objects(self.CANVAS, self.WIDTH, self.HEIGHT, 5)
     self.lim_a, self.lim_b = 0, 45
     self.centre = self.lim_b / 2
     self.pos = (self.WIDTH / 2, self.HEIGHT / 2)
示例#11
0
def maximI(name):
    '''import objects from MaximDL file'''
    constellations=stars.load()
    objects=objClass.objects(constellations)
    f=open(name,'r')
    for line in f:
        if 'NAME' in line: continue
        if len(line.strip())==0: continue #prazdny riadok
        dat=line.split(',')
        name=dat[0][1:-1].split('/')[0]
        note=dat[0][1:-1].split('/')[1]
        tmp=dat[1].strip()[1:-1].split()
        while len(tmp)<3: tmp.append('0')
        ra=float(tmp[0])+float(tmp[1])/60.+float(tmp[2])/3600.
        tmp=dat[2].strip()[1:-1].split()
        while len(tmp)<3: tmp.append('0')
        if '-' in tmp[0]: sgn=-1
        else: sgn=1
        dec=float(tmp[0])+sgn*float(tmp[1])/60.+sgn*float(tmp[2])/3600.
        mag=dat[3].strip()[1:-1].strip()
        typ=''
        size=''
        objects.add(name,ra,dec,mag,size,typ,note)
        found=False
        consts=[]
        for const in constellations:
            if constellations[const].testPoint(ra,dec):
                consts.append(const)
                found=True
        if not found:
            messagebox.showwarning('Constellation','Constellation of '+name+'  not detected! Please, add it manually.')
            objects.objects[name]['object'].const='Ari'
            print(name)
        else:
            objects.objects[name]['object'].const=consts[0]
            if len(consts)>1:
                messagebox.showwarning('Constellation','Multiple possible constellations for '+name+' detected ('\
                +', '.join(consts)+')! Please, add it manually.')
                print(name,consts)
    f.close()
    return objects
示例#12
0
# c.execute("""CREATE TABLE Target (
#             name text,
#             price real
#              )""")
# c.execute("""CREATE TABLE Walmart (
#             name text,
#             price real
#              )""")


# c.execute("INSERT INTO objects VALUES('car','22000')")


# obj_1 = Objects('frisbee',7.89)
# obj_2 = Objects('cup',2.99)
obj3 = objects()
obj4=objects()
item=[]
obj4 = obj3.commonObjects(item)
# print("len obj4", len(obj4))
#

# for i in range(0,35):
#      c.execute("INSERT INTO Amazon VALUES(?,?)", (obj4[i].getName(), obj4[i].getPrice()))
#      print(obj4[i].getName(),obj4[i].getPrice())
#
#
# for i in range(0,35):
#      c.execute("INSERT INTO Target VALUES(?,?)", (obj4[i].getName(), obj4[i].getPrice()))
#      print(obj4[i].getName(),obj4[i].getPrice())
示例#13
0
#The game runs by iterating the step() function until the win conditions are met.

#Each command the user types is split by parse() into a "verb" and an optional "noun. Each verb has a corresponding function, and each noun has a corresponding object. So typing "examine poster", for example, sets noun=poster, and calls climb().

#The verbs are all defined in the main files because python doesn't allow imported functions to access the global variables of the parent module. Don't do this! Set up a shared namespace at the get-go!

#import some data
from generators import question
from generators import poster
from generators import prop
from generators import poster1
from objects import objects
surroundings = objects("surroundings")
dialogues = objects("dialogues")
descriptions = objects("descriptions")
intros = objects("intros")
nouns = objects("nouns")
mapp = objects("map")

#set locations as traversable or untraversable
traversable = [
    '24out', '20door', '18door', '11house', '8bar', '4cw', '5cw', '6cw', '7cw',
    '4ws', '5ws', '6ws', '7ws', '3stairs', '4stairs', '6stairs', '8w', '8east',
    '8south', '9north', '9south', '9east', '9west', '10east', '10west',
    '10south', '11west', '11south', '11e', '12north', '13north', '14north',
    '15out', '16.1door', '17out', '17door', '18cw', '18ws', '19out', '24out',
    '20cw', '21cw', '21ws', '22cw', '22ws', '23ws', '20w', '23booth'
]
untraversable = [
    '8n', '10n', '11n', '12e', '12s', '12w', '13e', '13s', '13w', '14s', '14e',
    '14w', '20ws', '23cw', '23w', '19w', '19n', '19s', '21w'
示例#14
0
文件: debug.py 项目: GB127/GT-Rando
    BPL .loopZero       ;80F2CA     
    LDA #$80            ;80F2CC     
    STA $2100           ;80F2CE     Set Force Blank
    BRA $80F2D1         ;80F2D1   
    .return             
    SEP #$30            ;80F2D3     
    RTS                 ;80F2D5     
    }"""


if __name__ == "__main__":
    with open("Vanilla.smc", "rb") as original:
        startTime = datetime.now()
        print("generating...")

        game = debug(original.read())
        # game = randomized(original.read())
        game.activateWorldSelection()
        game.do_all_modify()
        game.no_dark()

        test = objects(game.data)

        test.randomize_grabables()
        test.add_objects(0, 0, [3], [(3, 5)])
        test.save()

        with open("debug.smc", "wb") as newgame:
            print("Time taken to edit files : ", datetime.now() - startTime)
            print(f"Testing case have been created! {datetime.now()}")
            newgame.write(game.data)
示例#15
0
def sipsI(name):
    '''import objects from SIPS file'''
    constellations=stars.load()
    abbrevConst={x.lower():y for x,y in stars.abbrev().items()}   #malym -> osetrenie problem s velkostou pismen

    skratky=[x.lower() for x in constellations]        #malym -> osetrenie problem s velkostou pismen
    objects=objClass.objects(constellations)
    f=open(name,'r')
    group=''    #type of object in catalog (M,NGC etc.)
    delim=' '   #rozdelovac medzi typom (skupinou) a nazvom objektu
    for line in f:
        if len(line.strip())==0: continue #prazdny riadok
        if '[' in line:
            #rozdelenie skupin objektov v SIPS
            group=line[line.find('[')+1:line.find(']')]+delim
            continue
        dat=line.split()
        name=group+dat[0].strip()
        ra=float(dat[1])+float(dat[2])/60.+float(dat[3])/3600.
        if '-' in dat[4]: sgn=-1
        else: sgn=1
        dec=float(dat[4])+sgn*float(dat[5])/60.+sgn*float(dat[6])/3600.
        const0=''
        mag=''
        typ=''
        for d in dat[7:]:
            #osetrenie nahodneho usporiadania stlpcov v SIPS!!!!
            try:
                mag=d[:d.find('m')].strip()
                continue
            except: pass
            if d.strip().lower() in skratky:
                const0=d.strip()
            elif d.strip().lower() in abbrevConst:
                const0=abbrevConst[d.strip().lower()]
            else: typ=d
        size=''
        if '(' in line: note=line[line.find('(')+1:line.find(')')]
        else: note=''
        objects.add(name,ra,dec,mag,size,typ,note)
        found=False
        consts=[]
        for const in constellations:
            if constellations[const].testPoint(ra,dec):
                consts.append(const)
                found=True
        if not found:
            messagebox.showwarning('Constellation','Constellation for '+name+' not detected! Please, add it manually.')
            objects.objects[name]['object'].const='Ari'
            print(name)
        else:
            objects.objects[name]['object'].const=consts[0]
            if len(consts)>1:
                messagebox.showwarning('Constellation','Multiple possible constellations for '+name+' detected ('\
                +', '.join(consts)+')! Please, add it manually.')
                print(name,consts)
        if (not objects.objects[name]['object'].const.lower()==const0.lower()) and len(const0)>0:
            messagebox.showwarning('Constellation','Detected constellation ('+objects.objects[name]['object'].const+') for '+name+\
            " is different to catalog's one ("+const0+')! Please, add it manually.')
            print(name,objects.objects[name]['object'].const,const0)
    f.close()
    return objects
示例#16
0

# Movement of water..
def moving_water():
    for i in range(w1.wave_len):
        for j in range(w1.wave_wid):
            screen.blit(w1.W_wave_img[i][j],
                        (w1.W_wave_X[i][j], w1.W_wave_Y[i][j]))
            w1.wave_move()
    # pygame.display.update()


# Object Section /*/*/*/

# Objects making
ob1 = objects()

# Speed of object
speed_font = pygame.font.SysFont('consolas', 28)

# Level ..
levels_font = pygame.font.SysFont('impact', 38)


# object moving function
def objects_move():
    ticks = pygame.time.get_ticks()
    seconds = int(ticks / 1000 % 60)
    if seconds >= 50:
        status = 6
    elif seconds >= 40: