Beispiel #1
0
 def cb(self, pts):
     for pt in pts:
         w, h = pt
         # print(w, h)
         for x in range(1, 5):
             click = [(w + random.randint(-10, 15),
                       h + random.randint(100, 300))]
             print(click)
             self.touch(click)
             action.wait(0.8, 1.1)
 def test_253(self):
     action.signup_with_existed_email()
     self.assertTrue(
         action.wait(
             type='id',
             el="com.deepblu.android.deepblu.internal:id/editTextEmailError"
         ))
     android_signup_test.result = True
 def test_1948(self):
     action.signup_resend_email()
     self.assertTrue(
         action.wait(
             type='id',
             el=
             "com.deepblu.android.deepblu.internal:id/popup_bottom_btn_right"
         ))
     android_signup_test.result = True
 def test_2020(self):
     email = action.signup()
     action.verify(verify='code', Useremail=email)
     action.edit_profile_after_signup()
     self.assertTrue(
         action.wait(
             type='id',
             el='com.deepblu.android.deepblu.internal:id/edit_text_user_name'
         ))
     android_signup_test.result = True
 def test_93_2(self):
     email = action.signup()
     action.verify(verify='link', Useremail=email)
     self.assertTrue(
         action.wait(
             type='id',
             el=
             "com.deepblu.android.deepblu.internal:id/popup_bottom_btn_right"
         ))
     android_signup_test.result = True
 def test_2085(self):
     email = action.signup()
     action.signup_skip()
     action.signup_token_expire(email)
     self.assertTrue(
         action.wait(
             type='id',
             el=
             "com.deepblu.android.deepblu.internal:id/activity_toolbar_title"
         ))
     android_signup_test.result = True
 def test_1415(self):
     rm_email('*****@*****.**')
     action.signup(email="*****@*****.**")
     action.verify(verify='code', Useremail='*****@*****.**')
     action.back()
     action.logout()
     action.login('*****@*****.**', 'a12345678')
     self.assertTrue(
         action.wait(
             type='id',
             el="com.deepblu.android.deepblu.internal:id/headerContainer"))
     android_signup_test.result = True
 def test_1951_2(self):
     email = action.signup()
     action.kill_app()
     action.sleep(2)
     action.open_app()
     self.assertTrue(
         action.wait(
             type='id',
             el=
             "com.deepblu.android.deepblu.internal:id/activity_toolbar_title"
         ))
     android_signup_test.result = True
 def test_1951(self):
     email = action.signup()
     action.signup_skip()
     action.logout()
     action.login(email, 'a12345678')
     self.assertTrue(
         action.wait(
             type='id',
             el=
             "com.deepblu.android.deepblu.internal:id/activity_toolbar_title"
         ))
     android_signup_test.result = True
Beispiel #10
0
def stateless(bot):
    '''
        Dumb temporary NPC controller function
        implementing a simple 8-directional desire system
    '''

    world = rog.world()
    desires = Desires(wander=7)
    sight = rog.getms(bot, "sight")
    pos = world.component_for_entity(bot, cmp.Position)
    botCreature = world.component_for_entity(bot, cmp.Creature)

    ##    botType=world.component_for_entity(bot, cmp.Draw).char #should not depend on draw component

    # Where should this go????
    ##    rog.run_fov_manager(bot) # moved to can_see

    # TODO: write this function
    def isFoe(myFaction, theirFaction):
        return True

    # TODO: re-implement listening
    # listen to events
    '''lis=rog.listen(bot)
    if lis:
        for ev in lis:
            if rog.can_see(bot,ev.x,ev.y):
                continue
            # hearing
            if not ev.volume: continue
            if rog.can_hear(bot, ev.x,ev.y, ev.volume):
                interest=5
                _add_desire_direction(
                    desires, bot.x,bot.y, ev.x,ev.y, interest)
        rog.clear_listen_events(bot)'''

    # iterate through each tile in sight and see what is there...
    # is there a better way to do this?
    # This code is a little slow.
    for x in range(pos.x - sight, pos.x + sight + 1):
        for y in range(pos.y - sight, pos.y + sight + 1):
            if (not rog.is_in_grid(x, y)  # out of bounds
                    or (x == pos.x and y == pos.y)):  # ignore self
                continue
            if not rog.can_see(bot, x, y, sight): continue  # can't see it

            here = rog.thingat(x, y)

            if here:
                isCreature = world.has_component(here, cmp.Creature)
                # decide what it is and what to do about it
                if isCreature:
                    creature = world.component_for_entity(here, cmp.Creature)
                    if rog.on(here, DEAD):
                        continue  # no interest in dead things

                    interest = 0

                    #desire to fight
                    if creature.faction == FACT_ROGUE:
                        interest = 1000
                    #grouping behavior
                    elif creature.faction == botCreature.faction:
                        interest = 5

                    if (interest > 0):
                        _add_desire_direction(desires, pos.x, pos.y, x, y,
                                              interest)
                    elif (interest < 0):
                        _add_fear_direction(desires, pos.x, pos.y, x, y,
                                            interest)
                #if thing is inanimate
                else:
                    #food desire if hungry
                    #treasure desire
                    pass

    # pick the direction it wants to move in the most
    highest = -999
    for i in range(3):
        for j in range(3):
            new = desires.get(j - 1, i - 1)
            if new > highest:
                highest = new
                coords = (
                    j - 1,
                    i - 1,
                )
    dx, dy = coords
    xto = pos.x + dx
    yto = pos.y + dy

    # out of bounds
    if not rog.is_in_grid(xto, yto):
        return

    # fight if there is a foe present
    mon = rog.monat(xto, yto)
    if (mon and mon is not bot):
        monFaction = world.component_for_entity(mon, cmp.Creature).faction
        if isFoe(botCreature.faction, monFaction):
            action.fight(bot, mon)
            return
    # or move
    elif not rog.solidat(xto, yto):
        if action.move(bot, dx, dy):
            return

    # if no action was done, just wait
    action.wait(bot)
 def test_1412(self):
     action.login_skip()
     self.assertTrue(action.wait(type='xpath', el=GlobalString.create_post))
     android_login_test.result = True
Beispiel #12
0
def stateless(bot):

    # desire to move in a particular coordinate
    desires = Desires(wander=7)

    # listen to events
    '''lis=rog.listen(bot)
    if lis:
        for ev in lis:
            if rog.can_see(bot,ev.x,ev.y):
                continue
            # hearing
            if not ev.volume: continue
            if rog.can_hear(bot, ev.x,ev.y, ev.volume):
                interest=5
                _add_desire_direction(
                    desires, bot.x,bot.y, ev.x,ev.y, interest)
        rog.clear_listen_events(bot)'''

    # iterate through each tile in sight and see what is there...
    # is there a better way to do this?
    # This code is a little slow.
    sight = bot.stats.sight

    for x in range(bot.x - sight, bot.x + sight + 1):
        for y in range(bot.y - sight, bot.y + sight + 1):
            if (not rog.is_in_grid(x, y)  #out of bounds
                    or (x == bot.x and y == bot.y)):  #ignore self
                continue
            if not rog.can_see(bot, x, y): continue  #bot can't see it

            here = rog.thingat(x, y)

            if here:

                # decide what it is and what to do about it
                if rog.is_creature(here):
                    if rog.on(here, DEAD):
                        continue  #no interest in dead things

                    interest = 0

                    #desire to fight
                    if here.faction == FACT_ROGUE:
                        interest = 1000
                    #desire to run away
                    #elif here.type == '@':
                    #   interest=-1000
                    #grouping behavior
                    elif here.type == bot.type:
                        interest = 5
                    if (interest > 0):
                        _add_desire_direction(desires, bot.x, bot.y, x, y,
                                              interest)
                    elif (interest < 0):
                        _add_fear_direction(desires, bot.x, bot.y, x, y,
                                            interest)
                #if thing is inanimate
                else:
                    #food desire if hungry
                    #treasure desire
                    pass

    # pick the direction it wants to move in the most
    highest = -999
    for i in range(3):
        for j in range(3):
            new = desires.get(j - 1, i - 1)
            if new > highest:
                highest = new
                coords = (
                    j - 1,
                    i - 1,
                )
    dx, dy = coords
    xto = bot.x + dx
    yto = bot.y + dy

    # out of bounds
    if not rog.is_in_grid(xto, yto):
        return

    # fight if there is a monster present
    mon = rog.monat(xto, yto)
    if (mon and mon is not bot):
        if not mon.type == bot.type:  ##TEMPORARY
            action.fight(bot, mon)
            return
    # or move
    elif not rog.solidat(xto, yto):
        if action.move(bot, dx, dy):
            return

    # if no action was done, just wait
    action.wait(bot)