Beispiel #1
0
    def on_press(self, *args, **kwargs):
        _screen = self._current_screen()
        menu_screen = ValidObject.menu_screen(_screen.manager.get_screen('menu'))
        bikes_screen = ValidObject.bikes_screen(_screen.manager.get_screen('bikes'))
        maps_screen = ValidObject.maps_screen(_screen.manager.get_screen('maps'))
        shop_screen = ValidObject.shop_screen(_screen.manager.get_screen('shop'))
        screens = [menu_screen, bikes_screen, maps_screen, shop_screen]

        if 'BikesScreen' == _screen.__class__.__name__:
            if not app_config('bike', 'title'):
                bike_model = get_bike_by_title(bikes_screen.ids['title'].text)
                rest_rm = calc_rest_rm(bike_model.price)

                if Bike.buy(bike_model):
                    RightPanelBtn.change_rm(screens, rest_rm)
                    RightPanelBtn.change_character_wrap(bikes_screen.ids['character_wrap_price'], bike_model.price)
                    RightPanelBtn.change_character_wrap(bikes_screen.ids['character_wrap_power'], bike_model.power)
                    RightPanelBtn.change_character_wrap(bikes_screen.ids['character_wrap_speed'], bike_model.speed)
                    RightPanelBtn.change_character_wrap(bikes_screen.ids['character_wrap_acceleration'], bike_model.acceleration)
                    RightPanelBtn.change_character_wrap(bikes_screen.ids['character_wrap_agility'], bike_model.agility)
                    RightPanelBtn.cancel_animation_button(screens, 'left_panel_menu_bikes')

                    self.init_item(menu_screen.init_bike)
                    RightPanelBtn.change_bottom_right_btn(menu_screen)
                    bikes_screen.ids['title'].color = UColor.hex(UColor.WHITE)
                else:
                    Clock.schedule_once(self._create_animation_fail, 0)
                    Clock.schedule_once(self._clear_animation, .5)

        elif 'MapsScreen' == _screen.__class__.__name__:
            if not app_config('map', 'title'):
                map_model = get_map_by_title(maps_screen.ids['title'].text)
                rest_rm = calc_rest_rm(map_model.price)

                if BaseLevel.buy(map_model):
                    RightPanelBtn.change_rm(screens, rest_rm)
                    RightPanelBtn.change_character_wrap(maps_screen.ids['character_wrap_price'], map_model.price)
                    RightPanelBtn.change_character_wrap(maps_screen.ids['character_wrap_record'], '/dev/')
                    RightPanelBtn.change_character_wrap(maps_screen.ids['character_wrap_level'], map_model.level)
                    RightPanelBtn.change_character_wrap(maps_screen.ids['character_wrap_map'], map_model.map)
                    RightPanelBtn.change_character_wrap(maps_screen.ids['character_wrap_total_way'], map_model.total_way)
                    RightPanelBtn.cancel_animation_button(screens, 'left_panel_menu_maps')

                    self.init_item(menu_screen.init_map)
                    RightPanelBtn.change_bottom_right_btn(menu_screen)
                    maps_screen.ids['title'].color = UColor.hex(UColor.WHITE)
                else:
                    Clock.schedule_once(self._create_animation_fail, 0)
                    Clock.schedule_once(self._clear_animation, .5)
Beispiel #2
0
    def test_map_buy_success(self):
        self.set_app()
        _map = get_map_by_title('Default')

        menu_screen = ValidObject.menu_screen(self.sm.get_screen('menu'))
        self.assertEqual(
            menu_screen.get_label_by_text('No map').text, 'No map')

        self.assertEqual(_map.title, 'Default')
        self.assertTrue(LevelOne.buy(_map))
        self.assertEqual(_map.title, Cache.get('map', 'title'))
        self.assertEqual(_map.level, Cache.get('map', 'level'))
        self.assertEqual(_map.map, Cache.get('map', 'map'))
        self.assertEqual(_map.total_way, Cache.get('map', 'total_way'))
        self.assertEqual(RM - int(_map.price), Cache.get('bike', 'rm'))
Beispiel #3
0
    def test_bike_buy_success(self):
        self.set_app()
        _bike = get_bike_by_title('Default')

        menu_screen = ValidObject.menu_screen(self.sm.get_screen('menu'))
        self.assertEqual(
            menu_screen.get_label_by_text('No bike').text, 'No bike')

        self.assertEqual(_bike.title, 'Default')
        self.assertTrue(Bike.buy(_bike))

        self.assertEqual(_bike.title, Cache.get('bike', 'title'))
        self.assertEqual(_bike.power, Cache.get('bike', 'power'))
        self.assertEqual(_bike.speed, Cache.get('bike', 'speed'))
        self.assertEqual(_bike.acceleration, Cache.get('bike', 'acceleration'))
        self.assertEqual(_bike.agility, Cache.get('bike', 'agility'))
        self.assertEqual(RM - int(_bike.price), Cache.get('bike', 'rm'))