Example #1
0
def myhook(dict):
    if 'name' in dict:
        if 'genre' in dict:
            return shop.Shop(dict['name'], dict['address'],
                             dict['phone_number'], dict['coordinate'],
                             dict['genre'])
        return shop.Shop(dict['name'], dict['address'], dict['phone_number'],
                         dict['coordinate'], '')

    return dict  # 他の型はdefaultのデコード方式を使用
Example #2
0
    def test_empty_false(self):
        machine_shop = shop.Shop()
        machine_shop.open_(sample_users.USER_POD)
        machine_shop.add_user_s_to_slot([sample_users.USER_CERTIFIED],
                                        FIRST_SLOT)

        assert not machine_shop._empty()
Example #3
0
 def __init__(self, state=STATE_IN):
     self._event_q = queue.Queue()
     self._message_q = queue.Queue()
     self._shop = shop.Shop()
     self._start_state = state
     self._handler = error_handler.ErrorHandler(self._event_q,
                                                self._message_q, self._shop)
Example #4
0
def parseShop(raw):
    contents = raw.contents
    p = shop.Shop()
    p.city = contents[real(1)].string
    p.name = contents[real(2)].string
    p.address = contents[real(3)].string
    return p
Example #5
0
    def __init__(self, event_q, message_q, shop_user_db):
        self._state = CLOSED
        self._shop = shop.Shop()
        self._shop_user_database = shop_user_db
        self._event_q = event_q
        self._message_q = message_q
        self._error_handler = error_handler.ErrorHandler(
            event_q, message_q, self._shop, shop_user_db)

        self._state_data = {
            CLOSED: ("\0SHOP CLOSED.\n\rPROCTOR SWIPE", {
                event.CARD_SWIPE: self._closed_process_card_swipe
            }),
            OPENING: ("\0STARTING UP!\n\rFLIP SWITCH", {
                event.BUTTON_CANCEL: self._go_to_closed_state,
                event.SWITCH_FLIP_ON: self._opening_process_switch_flip
            }),
            STANDBY: ("\0BOARD LOCKED.\n\rPOD SWIPE", {
                event.CARD_SWIPE: self._standby_process_card_swipe
            }),
            UNLOCKED: ("\0BOARD UNLOCKED.\n\rTAKE ANY ACTION", {
                event.BUTTON_CANCEL:
                self._go_to_standby_state,
                event.CARD_SWIPE:
                self._unlocked_process_card_swipe,
                event.CARD_REMOVE:
                self._go_to_remove_user_state,
                event.BUTTON_MONEY:
                self._go_to_clear_money_state,
                event.BUTTON_CHANGE_POD:
                self._go_to_change_pod_state,
                event.SWITCH_FLIP_OFF:
                self._unlocked_process_closing_shop
            }),
            ADDING_USER: ("\0ADDING USER.\n\rSWIPE/INSRT CARD", {
                event.CARD_SWIPE: self._adding_user_process_card_swipe,
                event.CARD_INSERT: self._adding_user_s_process_slot,
                event.BUTTON_CANCEL: self._go_to_standby_state
            }),
            ADDING_USERS: ("\0ADDING USERS.\n\rINSERT CARDS", {
                event.CARD_INSERT: self._adding_user_s_process_slot,
                event.BUTTON_CANCEL: self._go_to_standby_state
            }),
            REMOVING_USER: ("\0REMOVING USER_S\n\r(R)NSRT/CLR/CHRG", {
                event.CARD_INSERT:
                self._removing_user_process_slot,
                event.BUTTON_DISCHARGE_USER:
                self._removing_user_process_discharge,
                event.BUTTON_MONEY:
                self._removing_user_process_charge
            }),
            CLEARING_DEBT: ("\0CLEARING DEBT.\n\rSWIPE CARD", {
                event.CARD_SWIPE: self._clearing_debt_process_card_swipe,
                event.BUTTON_CANCEL: self._go_to_standby_state
            }),
            CHANGING_POD: ("\0CHANGING POD.\n\rSWIPE CARD", {
                event.CARD_SWIPE: self._changing_pod_process_card_swipe,
                event.BUTTON_CANCEL: self._go_to_standby_state
            })
        }
Example #6
0
    def test_close_success(self):
        machine_shop = shop.Shop()
        machine_shop.open_(sample_users.USER_POD)
        machine_shop.close_(sample_users.USER_POD)

        assert not machine_shop._open
        assert machine_shop._pods == []
        assert machine_shop._empty()
Example #7
0
    def test_change_pod_success_remove_pod(self):
        machine_shop = shop.Shop()
        machine_shop.open_(sample_users.USER_POD)
        machine_shop.change_pod(sample_users.USER_PROCTOR)
        machine_shop.change_pod(sample_users.USER_POD)

        assert not machine_shop.is_pod(sample_users.USER_POD)
        assert machine_shop.is_pod(sample_users.USER_PROCTOR)
Example #8
0
    def test_add_user_s_to_slot__success_single_user(self):
        machine_shop = shop.Shop()
        machine_shop.open_(sample_users.USER_POD)
        machine_shop.add_user_s_to_slot([sample_users.USER_CERTIFIED],
                                        FIRST_SLOT)

        assert machine_shop._occupants[FIRST_SLOT] == [
            sample_users.USER_CERTIFIED
        ]
Example #9
0
	def __init__(self, st=False, ktc=1):
		self.ktc = ktc
		self.version = 13.0
		self.pathuser = filept.split('\ '[0])[2]
		self.platform_number = 0
		self.ff_time = False
		self.golevels = []
		print("Downloading image content...")
		self.set_asset()
		print("Done")
		self.tk = Tk(className="lavaplatformer")
		self.tk.title("lavaPlatformer start-up")
	#	self.tk.geometry("500x500+10+200")
		x = Label(self.tk, text="Welcome on lavaPlatformer!")
		x.pack()
		self.p = PhotoImage(file="C:/Users/{0}/.lavaPlatformer/Data/showupimage.gif".format(self.pathuser))
		self.l = Label(self.tk, image=self.p)
		self.l.pack()
		self.name = s.askstring("Player name", "Enter player name:") if self.ff_time or st else None
		control = self.check_name()
		if not control and not os.path.exists("C:/Users/{0}/.lavaPlatformer/user.txt".format(self.pathuser)):
			messagebox.showerror("Error", "Invalid name, You can only use characters from a-z, A-Z, numbers and underscore. Your name can not exist two times")
			shutil.rmtree("C:/Users/{0}/.lavaPlatformer".format(self.pathuser))
			sys.exit()
		x.destroy()
		self.l.destroy()
		self.tk.resizable(0,0)
		self.tk.protocol("WM_DELETE_WINDOW", lambda: self.gameover(closing=True))
		self.tk.title("LavaPlatformer v{0}".format(self.version))
		self.canvas = Canvas(self.tk, width=500, height=500, bg="lightblue")
		self.canvas.pack()
		self.platforms = [] #List of platforms
		self.gameIsRunning = False
		self.color = "black"
		self.selected = self.color
		self.coins = 0
		self.diamonds = 0
		self.keys = 0
		self.lava_dist = 450.0
		self.timetxt = self.canvas.create_text(0,0, anchor="nw", text="Time: {0}".format(round(0-0, 2)), font="Purisa 14 bold", fill="blue")
		self.cointxt = self.canvas.create_text(0,35, anchor="nw", text="Coins: {0}".format(self.coins), font="Purisa 14 bold", fill="yellow")
		self.lavadisttxt = self.canvas.create_text(500,0, anchor="ne", text="Lava Distance: {0}".format(self.lava_dist), font="Purisa 14 bold", fill="red")
		self.diamondstxt = self.canvas.create_text(500,35, anchor="ne", text="Diamonds: {0}".format(self.diamonds), font="Purisa 14 bold", fill="purple")
		self.keystxt = self.canvas.create_text(500, 70, anchor="ne", text="Keys: {0}".format(self.keys), font="Purisa 14 bold", fill="green")
		self.shop = shop.Shop(self, pt="C:/Users/{0}/.lavaPlatformer/".format(self.pathuser))
		self.shop.show_button()
		self.statistics_menu = statistics.Statistics(self)
		self.statistics_menu.show_button()
		self.statistics = {
			"best_time" : 0,
			"platforms_jumped" : 0,
			"times_played" : 0,
			"best_job_level" : 0,
			"best_game_level" : 0,
			"skins_owned" : 1
		}
		self.maxtime = 0.0
Example #10
0
    def test_change_pod_failure_not_proctor(self):
        machine_shop = shop.Shop()
        machine_shop.open_(sample_users.USER_POD)

        try:
            machine_shop.change_pod(sample_users.USER_CERTIFIED)
        except shop_check_in_exceptions.NonProctorError:
            assert not machine_shop.is_pod(sample_users.USER_CERTIFIED)
        else:
            assert False
Example #11
0
    def test_change_pod_failure_only_pod(self):
        machine_shop = shop.Shop()
        machine_shop.open_(sample_users.USER_POD)

        try:
            machine_shop.change_pod(sample_users.USER_POD)
        except shop_check_in_exceptions.PodRequiredError:
            assert machine_shop.is_pod(sample_users.USER_POD)
        else:
            assert False
Example #12
0
    def test_discharge_user_s_single_user(self):
        machine_shop = shop.Shop()
        machine_shop.open_(sample_users.USER_POD)
        machine_shop.add_user_s_to_slot([sample_users.USER_CERTIFIED],
                                        FIRST_SLOT)

        discharged_user = machine_shop.discharge_user_s(FIRST_SLOT)

        assert machine_shop._empty()
        assert discharged_user == [sample_users.USER_CERTIFIED]
Example #13
0
    def test_replace_or_transfer_user_replace(self):
        machine_shop = shop.Shop()
        machine_shop.open_(sample_users.USER_POD)
        machine_shop.add_user_s_to_slot([sample_users.USER_CERTIFIED],
                                        FIRST_SLOT)
        machine_shop.replace_or_transfer_user(FIRST_SLOT, FIRST_SLOT)

        assert machine_shop._occupants[FIRST_SLOT] == [
            sample_users.USER_CERTIFIED
        ]
Example #14
0
    def __init__(self):

        self.dollars = 400 + random.randint(-150, 200)
        self.bitcoins = 0
        self.debug = 0
        self.income = 0  #In BTC
        self.btc_rate = 300  # exchange rate in dollars
        self.equipment = np.zeros(shape=(1, 9))
        self.shop = shop.Shop()
        self.time_last_tick = time.time()
Example #15
0
    def test_open_failure_already_open(self):
        machine_shop = shop.Shop()
        machine_shop.open_(sample_users.USER_POD)

        try:
            machine_shop.open_(sample_users.USER_POD)
        except shop_check_in_exceptions.ShopAlreadyOpenError:
            assert machine_shop._open
            assert machine_shop.is_pod(sample_users.USER_POD)
        else:
            assert False
Example #16
0
    def test_add_user_s_to_slot_failure_one_invalid(self):
        machine_shop = shop.Shop()
        machine_shop.open_(sample_users.USER_POD)

        try:
            machine_shop.add_user_s_to_slot([sample_users.USER_INVALID],
                                            FIRST_SLOT)
        except shop_check_in_exceptions.InvalidUserError:
            assert machine_shop._empty
        else:
            assert False
Example #17
0
    def test_empty_init(self):
        "Test the default Shop creation"

        # 1. Create default Shop object
        myobj = shop.Shop()

        # 2. Make sure it has the default values
        self.assertEqual(len(myobj.items), 19)

        # 3. Check methods
        self.assertEqual(len(list(myobj.combinations())), 1680)
Example #18
0
    def __init__(self, text=None, part2=False):

        # 1. Set the initial values
        self.part2 = part2
        self.text = text
        self.shop = shop.Shop()
        self.boss = None

        # 2. Process text (if any)
        if text is not None and len(text) > 0:
            self.boss = player.Player(text)
Example #19
0
    def test_close_failure_not_pod(self):
        machine_shop = shop.Shop()
        machine_shop.open_(sample_users.USER_POD)
        machine_shop.add_user_s_to_slot([sample_users.USER_CERTIFIED],
                                        FIRST_SLOT)

        try:
            machine_shop.close_(sample_users.USER_PROCTOR)
        except shop_check_in_exceptions.UnauthorizedUserError:
            assert machine_shop._open
            assert machine_shop.is_pod(sample_users.USER_POD)
            assert not machine_shop._empty()
Example #20
0
 def parse_elements(self, html):
     result = []
     soup = BeautifulSoup(html, 'lxml')
     shops = soup.find_all('div', class_='b-teaser')
     for shop in shops:
         name = self.__get_name(shop)
         discount = self.__get_discount(shop)
         label = self.__get_label(shop)
         url = self.__get_url(shop)
         image = self.__get_image(shop)
         item = s.Shop(name, discount, label, url, image)
         result.append(item)
     return result
Example #21
0
def enter():
    global Shop
    global Data, map, stage, shop_button_image, font,small_font, arrow_image,stage_button_image,click_sound,bgm
    map = load_image('image\\ui\\map.png')
    stage = load_image('image\\ui\\stage.png')
    shop_button_image = load_image('image\\ui\\shop_button.png')
    stage_button_image = load_image('image\\ui\\stage_button.png')
    arrow_image = load_image('image\\ui\\arrow.png')
    bgm = load_music('sound\\main_bgm.mp3')
    click_sound = load_wav('sound\\button.wav')
    font = load_font('font\\neodgm.ttf',60)
    small_font = load_font('font\\neodgm.ttf', 40)
    Data = game_data.Data()
    Shop = shop.Shop()
def shop_list(area, id_number, limit=None):
    try:
        options = Options()
        options.add_argument('--headless')
        driver = webdriver.Chrome(options=options)

        url = 'https://saitama-goto-eat.com/store.html#result_content'

        wait = WebDriverWait(driver, 10)

        driver.get(url)

        wait.until(
            EC.presence_of_element_located((By.NAME, 'seach_municipality')))

        select_element = driver.find_element(By.ID, 'round')
        select_object = Select(select_element)
        select_object.select_by_visible_text(text=area)

        # 店舗リストの表示を待機する
        wait.until(EC.presence_of_element_located((By.ID, 't01_content')))

        # 店舗リストを抽出する
        html = driver.page_source
        soup = BeautifulSoup(html, 'lxml')

        id_text = 't' + id_number + '_content'
        storebox_elms = soup.find('div', {'id': id_text})
        storebox_elms_1 = storebox_elms.find_all('div', {'class': 'storebox'},
                                                 limit=limit)
        list = []

        for storebox_elm in storebox_elms_1:
            store_contents = storebox_elm.contents
            store_name = store_contents[1].string
            store_address = store_contents[4].string
            store_phone = store_contents[5].string
            store_genre = genre_text(id_number)

            shop_obj = shop.Shop(store_name, store_address, store_phone, [],
                                 store_genre)
            list.append(shop_obj)

        return list

    finally:
        driver.quit()
Example #23
0
    def __init__(self, host, port):
        self.host = host
        self.port = port
        self.app = Bottle()
        self.setupRouting()

        self.dbname = "tamapro_database.db"

        self.simulations = {}
        self.shop = shop.Shop()
        
        self.createNewTamaJSON("debuguid", "debugpw")
        self.simulations["debuguid"].addItemJSON("tire")
        self.simulations["debuguid"].addItemJSON("child")
        self.simulations["debuguid"].addItemJSON("banana")
        self.createNewTamaJSON("debuguid2", "debugpw2")
        self.simulations["debuguid"].addFriend("debuguid2")
        
        self.saveToDatabase(verbose=2)
        
        self.loadFromDatabase(verbose=True)
Example #24
0
import wx
import shop
import json
import os
from sys import argv
import datetime

# load a file or just create a simple shop
if len(argv) == 1:
    items = [
        shop.Item("Item 1", 10, 1),
        shop.Item("Item 2", 10, 1),
        shop.Item('Item 3', 10, 1)
    ]
    main = shop.Shop("", items, 0.0)
else:
    file = open(str(argv[1]), 'r')
    file.seek(0)
    jsonitems = json.loads(file.read())['items']
    file.seek(0)
    name = json.loads(file.read())['name']
    file.seek(0)
    profit = json.loads(file.read())['profit']
    items = []
    for i in jsonitems:
        items.append(shop.Item(i['name'], i['amount'], i['min_cost']))
    main = shop.Shop(name, items, profit)


class MyFrame(wx.Frame):
    """
Example #25
0
import random
import string
import shop

listings = range(1,50000)
random.shuffle(listings)

users = range(1,10000)
random.shuffle(users)


for i in range(50000):
    if len(listings) == 0:
        break
    id = i+1
    name_size = random.randrange(10, 180)
    name = ''.join(random.choice(string.ascii_uppercase + "   ") for x in range(name_size))

    user = users.pop()

    s = shop.Shop(id, name, user)
    num_listings = int(round(random.lognormvariate(0, 5))) + 1 

    for j in range(num_listings):
        if len(listings) > 0:
            listing = listings.pop()
            count = int(round(random.lognormvariate(0, 5))) + 1

            s.addListing(listing, count)
    print s.toJson()
#
#   The Shops server
#

from __future__ import print_function
import Pyro4
import shop

ns = Pyro4.naming.locateNS()
daemon = Pyro4.core.Daemon()

uri = daemon.register(shop.Shop())
ns.register("example.shop.Shop", uri)

print(list(ns.list(prefix="example.shop.").keys()))

# enter the service loop.

daemon.requestLoop()
Example #27
0
# When in eternal lines to time jenn grow’st:
#    So long as men can breathe or eyes can see,
#    So long lives this, and this gives life to jenn.""")
@bot.command(name="daniel",help="gently persuade Daniel to return to us")
async def daniel(ctx):
    await ctx.send("""@panDANIELlo:rainbow: whence shall we hear your joyful voice again
as the flowers sweetly bloom in the meadow
and children frolic to and fro
lest we forget that gay summer's day
perched on a porcelain throne""")
@bot.command(name="mute",help="server mute yourself")
@commands.has_permissions(administrator=True)
async def mute(ctx):
    await ctx.author.edit(mute=True)
@bot.command(name="begone",help="Stop the bot")
@commands.has_permissions(administrator=True)
async def begone(ctx):
    for c in bot.cogs:
        cog=bot.get_cog(c)
        if isinstance(cog,jukebox.Jukebox):
            await cog.graceful_stop()
    await ctx.send("bye!")
    await bot.logout()
bot.add_cog(slots.Slots(bot))
bot.add_cog(economy.Economy(bot))
bot.add_cog(countdown.Countdown(bot))
bot.add_cog(hangman.Hangman(bot))
bot.add_cog(dib.Games(bot))
bot.add_cog(jukebox.Jukebox(bot))
bot.add_cog(shop.Shop(bot))
bot.run(token)
Example #28
0
    screen = pygame.display.set_mode(WINDOW_SIZE)
    main_menu = Menu()
    running = True

    #часть кода Андрея
    board = Board(25, 25)
    screen.fill((0, 0, 0))
    board.render()

    # создадим группу, содержащую все спрайты
    all_sprites = pygame.sprite.Group()
    # получим картинку(surface)
    shop_image = load_image("shop.png")
    # добавляем спрайты
    for _ in range(1):
        shop.Shop(all_sprites)
    # рисуем все спрайты на screen
    all_sprites.draw(screen)

    pygame.display.flip()

    while running:

        screen.fill((0, 0, 0))
        board.render()

        all_sprites.draw(screen)
        all_sprites.update()
        pygame.display.flip()

        for event in pygame.event.get():
Example #29
0
def main():
    pygame.init()

    # メイン画面の初期化,rectでサイズを指定
    screen = pygame.display.set_mode(SCREEN_RECT.size)

    # メイン画面のタイトル
    pygame.display.set_caption("exit: press esc")

    clock = pygame.time.Clock()

    title = tl.Title(screen)

    item = it.Item()

    menu_display = False

    #主人公の画像読み込み
    player = pl.Player("assets/pipo-charachip029c.png", title, item)
    group = pygame.sprite.RenderUpdates()
    group.add(player)

    field_map = mp.Map(screen, "assets/maps/field-map.txt", player)

    player.mapSet(field_map)

    town_map = mp.Map(screen, "assets/maps/town-map.txt", player)
    town = tw.Town(player, field_map, 5)

    cave_map = mp.Map(screen, "assets/maps/cave-map.txt", player)
    cave = tw.Town(player, field_map, 4)

    monster = ms.Monster()
    battle = bt.Battle(player, monster)

    menu = mn.Menu(screen, player)

    shop = sp.Shop(menu, player, screen, item)
    inn = nn.Inn(menu, player, screen, item)

    global_count = 0

    def dataSave():
        player.saved_player_data += (str(player.hp) + "," + str(player.mp) +
                                     "," + str(player.exp) + "," +
                                     str(player.gold) + "," + str(player.wx) +
                                     "," + str(player.wy) + ",")
        if field_map.map_display:
            player.saved_player_data += "0"
        elif town.map_display:
            player.saved_player_data += "1"
        elif cave.map_display:
            player.saved_player_data += "2"
        for i in range(len(player.item_list)):
            player.saved_player_data += ("," + str(player.item_list[i][0]))
        if len(player.item_list) < 5:
            for i in range(5 - len(player.item_list)):
                player.saved_player_data += "," + str(0)
        with open("assets/saved-player-data.txt", mode="w") as fi:
            fi.write(player.saved_player_data)

    if player.where == 0:
        field_map.map_display = True
        town.map_display = False
        cave.map_display = False
    elif player.where == 1:
        field_map.map_display = False
        town.map_display = True
        cave.map_display = False
    if player.where == 2:
        field_map.map_display = False
        town.map_display = False
        cave.map_display = True

    while (True):
        menu_display = menu.menu_display

        pygame.event.clear()

        global_count += 1

        if title.title_display:
            title.update()
            title.drawTri(240, 317 + 50 * title.title_select_num, global_count)

        elif shop.shop_display:
            shop.shopAnim()

        elif inn.inn_display:
            inn.innAnim()

        else:
            if not town.map_display:
                battle.update()

            if (not battle.battle_now):

                if (field_map.map_display):
                    player.mapSet(field_map)
                    field_map.draw(0)
                    if player.wx <= 15 and player.wy <= 11:
                        monster.decideMonster(
                            "assets/monster-list/field-monsters.txt")
                    elif player.wx <= 15 and player.wy > 11:
                        monster.decideMonster(
                            "assets/monster-list/field-monsters2.txt")
                    elif player.wx > 15 and player.wy <= 11:
                        monster.decideMonster(
                            "assets/monster-list/field-monsters3.txt")
                    elif player.wx > 15 and player.wy > 11:
                        monster.decideMonster(
                            "assets/monster-list/field-monsters4.txt")
                    town.visited(8, 5)
                    cave.visited(18, 28)

                elif (town.map_display):
                    player.mapSet(town_map)
                    town_map.draw(1)
                    shop.update(3, 2)
                    inn.update(6, 2)
                    town.exit(6)

                elif (cave.map_display):
                    player.mapSet(cave_map)
                    monster.decideMonster(
                        "assets/monster-list/cave-monsters.txt")
                    cave_map.draw(8)
                    cave.exit(29)

                group.update(menu_display)
                group.draw(screen)

            else:

                battle.battleAnim(screen)

        if menu.menu_display and not title.title_display:

            menu.update()
            # menu.drawTri(60,39+menu.menu_select_num*40,global_count)

        # フレームレートの設定
        clock.tick(60)

        #イベント
        #keyはまとめてここに書かないと思った挙動にならない、正直めんどくさすぎる
        for event in pygame.event.get():

            # 終了イベント
            if event.type == QUIT:
                dataSave()
                pygame.quit()
                sys.exit()

            if event.type == pygame.KEYDOWN:
                if event.key == K_ESCAPE:
                    dataSave()
                    pygame.quit()
                    sys.exit()

                if not battle.battle_now:
                    if not menu.menu_display:
                        if event.key == pygame.K_RETURN:
                            menu.menu_display = True
                    else:
                        if event.key == pygame.K_RETURN:
                            menu.menu_display = False
                            menu.show_statas = False
                            menu.show_items = False
                            menu.show_magics = False
                            menu.item_select_tri = False
                            menu.use_item_anim = False

                shop.KeyEvent(event)
                # if shop.shop_display:
                #     player.moving_wait = False

                #     if event.key==pygame.K_DOWN:
                #         if(shop.shop_select_num == 2):
                #             shop.shop_select_num = 0
                #         else:
                #             shop.shop_select_num += 1

                #     if event.key==pygame.K_UP:
                #         if(shop.shop_select_num == 0):
                #             shop.shop_select_num = 2
                #         else:
                #             shop.shop_select_num -= 1

                # if event.key==pygame.K_RIGHT :
                #     if len(player.item_list) < 5:
                #         if shop.shop_select_num == 0 and player.gold >= int(item.all_item_list[0][3]):
                #             player.item_list.append(item.all_item_list[0])
                #             player.gold -= int(item.all_item_list[0][3])
                #         elif shop.shop_select_num == 1 and player.gold >= int(item.all_item_list[1][3]):
                #             player.item_list.append(item.all_item_list[1])
                #             player.gold -= int(item.all_item_list[1][3])
                #     if shop.shop_select_num == 2:
                #         shop.shop_display = False
                #         player.wy += 1

                if inn.inn_display:
                    player.moving_wait = False

                    if event.key == pygame.K_DOWN:
                        if (inn.inn_select_num == 1):
                            inn.inn_select_num = 0
                        else:
                            inn.inn_select_num += 1

                    if event.key == pygame.K_UP:
                        if (inn.inn_select_num == 0):
                            inn.inn_select_num = 1
                        else:
                            inn.inn_select_num -= 1

                    if event.key == pygame.K_RIGHT:
                        if inn.inn_select_num == 0 and player.gold >= 10:
                            player.gold -= 10
                            player.hp, player.mp = player.max_hp, player.max_mp
                        elif inn.inn_select_num == 1:
                            inn.inn_display = False
                            player.wy += 1

                if menu.menu_display:
                    if event.key == pygame.K_DOWN:
                        if (menu.menu_select_num == 2):
                            menu.menu_select_num = 0
                        else:
                            menu.menu_select_num += 1

                    if event.key == pygame.K_UP:
                        if (menu.menu_select_num == 0):
                            menu.menu_select_num = 2
                        else:
                            menu.menu_select_num -= 1

                    if event.key == pygame.K_LEFT:
                        menu.show_statas = False
                        menu.show_items = False
                        menu.show_magics = False
                        menu.item_select_tri = False
                        menu.magic_select_tri = False

                    if event.key == pygame.K_RIGHT and not menu.item_select_tri and not menu.magic_select_tri:
                        if menu.menu_select_num == 0:
                            menu.show_statas = True
                        elif menu.menu_select_num == 1:
                            menu.show_items = True
                            menu.item_select_tri = True
                            wait_count_item_show = global_count
                        elif menu.menu_select_num == 2:
                            menu.show_magics = True
                            menu.magic_select_tri = True
                            wait_count_magic_show = global_count

                if menu.item_select_tri == True and wait_count_item_show + 3 < global_count:
                    if event.key == pygame.K_DOWN:
                        if (menu.item_select_num == len(player.item_list) - 1):
                            menu.item_select_num = 0
                        else:
                            menu.item_select_num += 1

                    if event.key == pygame.K_UP:
                        if (menu.item_select_num == 0):
                            menu.item_select_num = len(player.item_list) - 1
                        else:
                            menu.item_select_num -= 1
                    if event.key == pygame.K_RIGHT:
                        menu.show_items = False
                        menu.item_select_tri = False
                        menu.use_item_anim = True
                        wait_count_item_anim = global_count
                        menu.use_item = player.item_list.pop(
                            menu.item_select_num)
                        player.hp += int(menu.use_item[2])
                        if player.hp > player.max_hp:
                            player.hp = player.max_hp

                if menu.use_item_anim == True and wait_count_item_anim + 3 < global_count:
                    menu.use_item_anim = False

                if menu.magic_select_tri == True and wait_count_magic_show + 3 < global_count:
                    if event.key == pygame.K_DOWN:
                        if menu.magic_arrow_num == menu.magic_arrow_max_num:
                            menu.magic_arrow_num = 0
                        else:
                            menu.magic_arrow_num += 1

                    if event.key == pygame.K_UP:
                        if (menu.magic_arrow_num == 0):
                            menu.magic_arrow_num = menu.magic_arrow_max_num
                        else:
                            menu.magic_arrow_num -= 1
                    if event.key == pygame.K_RIGHT and player.mp > player.selected_magic_mp and player.selected_magic_heal == 1:
                        menu.show_magics = False
                        menu.magic_select_tri = False
                        menu.use_magic_anim = True
                        player.mp -= player.selected_magic_mp
                        player.hp += player.selected_magic_damage
                        if player.hp > player.max_hp:
                            player.hp = player.max_hp
                        wait_count_magic_anim = global_count

                if menu.use_magic_anim == True and wait_count_magic_anim + 3 < global_count:
                    menu.use_magic_anim = False

                if title.title_display:
                    if event.key == pygame.K_DOWN:
                        if (title.title_select_num == 1):
                            title.title_select_num = 0
                        else:
                            title.title_select_num += 1

                    if event.key == pygame.K_UP:
                        if (title.title_select_num == 0):
                            title.title_select_num = 1
                        else:
                            title.title_select_num -= 1

                    if event.key == pygame.K_RIGHT:
                        title.title_display = False
                        player.moving_wait = False
                        player.parameterSet()
                        if player.where == 0:
                            field_map.map_display = True
                            town.map_display = False
                            cave.map_display = False
                        elif player.where == 1:
                            field_map.map_display = False
                            town.map_display = True
                            cave.map_display = False
                        elif player.where == 2:
                            field_map.map_display = False
                            town.map_display = False
                            cave.map_display = True
                        player.itemSet(item)
                        for i in range(len(player.magic_list_num)):
                            player.magic_list.append(
                                player.all_magic_list[player.magic_list_num[i]
                                                      - 1])

                if battle.command_select_tri:
                    if event.key == pygame.K_DOWN:
                        if (battle.command_arrow_num ==
                                battle.command_arrow_max_num):
                            battle.command_arrow_num = 0
                        else:
                            battle.command_arrow_num += 1

                    if event.key == pygame.K_UP:
                        if (battle.command_arrow_num == 0):
                            battle.command_arrow_num = battle.command_arrow_max_num
                        else:
                            battle.command_arrow_num -= 1

                    if event.key == pygame.K_RIGHT:
                        battle.command_select_tri = False
                        if (battle.command_arrow_num == 0):
                            battle.monster_selecting = True
                            wait_count_select_monster = battle.battle_anim_count
                        elif (battle.command_arrow_num == 1):
                            battle.magic_selecting = True
                            battle.magic_attack = True
                            wait_count_select_magic = battle.battle_anim_count
                        elif (battle.command_arrow_num == 2):
                            battle.guard_anim = True
                            battle.command_selecting = False
                            wait_count_guard_anim = battle.battle_anim_count
                        elif battle.command_arrow_num == 3:
                            wait_count_escape_anim = battle.battle_anim_count
                            battle.command_selecting = False
                            battle.random_walk = 5 + battle.battle_anim_count % 10
                            if (global_count % 100 + player.lv * 3) >= 100:
                                battle.escape_success = 1
                            else:
                                battle.escape_success = 2
                        elif battle.command_arrow_num == 4:
                            battle.item_select_tri = True
                            battle.item_selecting = True
                            wait_count_item_show_battle = battle.battle_anim_count

                if battle.item_select_tri:
                    if wait_count_item_show_battle + 3 < battle.battle_anim_count:
                        if event.key == pygame.K_DOWN:
                            if (battle.item_select_num == len(player.item_list)
                                    - 1):
                                battle.item_select_num = 0
                            else:
                                battle.item_select_num += 1

                        if event.key == pygame.K_UP:
                            if (battle.item_select_num == 0):
                                battle.item_select_num = len(
                                    player.item_list) - 1
                            else:
                                battle.item_select_num -= 1
                        if event.key == pygame.K_RIGHT:
                            battle.item_selecting = False
                            battle.item_select_tri = False
                            battle.command_selecting = False
                            battle.use_item_anim = True
                            wait_count_item_anim = global_count
                            battle.use_item = player.item_list.pop(
                                battle.item_select_num)
                            player.hp += int(battle.use_item[2])
                            if player.hp > player.max_hp:
                                player.hp = player.max_hp

                if battle.use_item_anim == True and wait_count_item_anim + 3 < global_count:
                    battle.use_item_anim = False
                    battle.attack_monster_anim = True
                    wait_count_restart = battle.battle_anim_count

                if battle.magic_selecting:

                    if event.key == pygame.K_DOWN and (
                            wait_count_select_magic +
                            3) < battle.battle_anim_count:
                        if (battle.magic_arrow_num ==
                                battle.magic_arrow_max_num):
                            battle.magic_arrow_num = 0
                        else:
                            battle.magic_arrow_num += 1

                    if event.key == pygame.K_UP and (
                            wait_count_select_magic +
                            3) < battle.battle_anim_count:
                        if (battle.magic_arrow_num == 0):
                            battle.magic_arrow_num = battle.magic_arrow_max_num
                        else:
                            battle.magic_arrow_num -= 1

                    if event.key == pygame.K_RIGHT and (
                            wait_count_select_magic + 3
                    ) < battle.battle_anim_count and player.mp > player.selected_magic_mp:
                        battle.monster_selecting = True
                        battle.magic_selecting = False
                        wait_count_select_monster = battle.battle_anim_count
                        player.selected_magic = battle.magic_arrow_num

                    if event.key == pygame.K_LEFT and (
                            wait_count_select_magic +
                            3) < battle.battle_anim_count:
                        battle.magic_selecting = False
                        battle.magic_attack = False
                        battle.command_select_tri = True

                if (battle.monster_selecting):
                    if not battle.magic_attack:
                        if event.key == pygame.K_RIGHT and (
                                wait_count_select_monster +
                                3) < battle.battle_anim_count:
                            battle.monster_selecting = False
                            battle.command_selecting = False
                            battle.attack_player_anim = True
                            wait_count_attack_monster = battle.battle_anim_count
                            if (monster.defence >= player.attack):
                                battle.damage = 1
                            else:
                                battle.damage = player.attack - monster.defence
                        if event.key == pygame.K_LEFT and (
                                wait_count_select_monster +
                                3) < battle.battle_anim_count:
                            battle.monster_selecting = False
                            battle.command_select_tri = True
                    else:
                        if event.key == pygame.K_RIGHT and (
                                wait_count_select_monster +
                                3) < battle.battle_anim_count:
                            battle.monster_selecting = False
                            battle.command_selecting = False
                            battle.magic_player_anim = True
                            wait_count_attack_monster = battle.battle_anim_count

                        if event.key == pygame.K_LEFT and (
                                wait_count_select_monster +
                                3) < battle.battle_anim_count:
                            battle.monster_selecting = False
                            battle.magic_selecting = True
                            wait_count_select_magic = battle.battle_anim_count

                if (battle.escape_success == 2):
                    if event.key == pygame.K_RIGHT and (
                            wait_count_escape_anim +
                            3) < battle.battle_anim_count:
                        battle.attack_monster_anim = True
                        battle.escape_success = 0
                        wait_count_restart = battle.battle_anim_count
                        if (player.defence >= monster.attack):
                            battle.damage = 1
                        else:
                            battle.damage = monster.attack - player.defence

                if (battle.escape_success == 1):
                    if event.key == pygame.K_RIGHT and (
                            wait_count_escape_anim +
                            3) < battle.battle_anim_count:
                        battle.escape_success = 0
                        battle.battle_now = False
                        battle.battle_anim_count = 0
                        player.move_count = 0
                        battle.random_walk = 5 + battle.battle_anim_count % 10
                        monster.random_monster_num = global_count % 100

                if (battle.attack_player_anim):
                    if event.key == pygame.K_RIGHT and (
                            wait_count_attack_monster +
                            3) < battle.battle_anim_count:
                        battle.attack_player_anim = False
                        wait_count_restart = battle.battle_anim_count
                        monster.hp -= battle.damage
                        battle.random_walk = 5 + battle.battle_anim_count % 6
                        monster.random_monster_num = global_count % 100
                        if (monster.hp <= 0):
                            battle.you_defeate = True
                        else:
                            battle.attack_monster_anim = True
                            if (player.defence >= monster.attack):
                                battle.damage = 1
                            else:
                                battle.damage = monster.attack - player.defence

                if (battle.magic_player_anim):
                    battle.magic_select_tri = False
                    battle.magic_attack = False
                    if event.key == pygame.K_RIGHT and (
                            wait_count_attack_monster +
                            3) < battle.battle_anim_count:
                        battle.magic_player_anim = False
                        wait_count_restart = battle.battle_anim_count
                        if player.selected_magic_heal == 1:
                            player.hp += player.selected_magic_damage
                            if player.hp > player.max_hp:
                                player.hp = player.max_hp
                        else:
                            monster.hp -= player.selected_magic_damage
                        player.mp -= player.selected_magic_mp
                        battle.random_walk = 5 + battle.battle_anim_count % 6
                        monster.random_monster_num = global_count % 100
                        if (monster.hp <= 0):
                            battle.you_defeate = True
                        else:
                            battle.attack_monster_anim = True
                            if (player.defence >= monster.attack):
                                battle.damage = 1
                            else:
                                battle.damage = monster.attack - player.defence

                if (battle.guard_anim):
                    if event.key == pygame.K_RIGHT and (
                            wait_count_guard_anim +
                            3) < battle.battle_anim_count:
                        battle.guard_anim = False
                        battle.attack_monster_anim = True
                        wait_count_restart = battle.battle_anim_count
                        if (player.defence * 2 >= monster.attack):
                            battle.damage = 1
                        else:
                            battle.damage = monster.attack - player.defence * 2

                if (battle.attack_monster_anim):
                    if event.key == pygame.K_RIGHT and (
                            wait_count_restart + 3) < battle.battle_anim_count:
                        if player.hp > battle.damage:
                            player.hp -= battle.damage
                            battle.battle_anim_count = 79
                            battle.attack_monster_anim = False
                        else:
                            battle.random_walk = 5 + battle.battle_anim_count % 10
                            monster.random_monster_num = global_count % 100
                            battle.attack_monster_anim = False
                            battle.you_lose = True
                            wait_count_you_lose = battle.battle_anim_count

                if (battle.you_defeate and
                    (wait_count_restart + 3) < battle.battle_anim_count):
                    player.exp += monster.exp
                    player.gold += monster.gold
                    if player.lv == len(player.lv_tables):
                        battle.you_defeate = False
                        battle.battle_now = False
                        player.moving_wait = False
                        battle.battle_anim_count = 0
                        player.move_count = 0
                    elif player.lv_tables[player.lv][5] <= player.exp:
                        battle.you_defeate = False
                        battle.lv_up_anim = True
                        player.parameterSet()
                        wait_count_lv_anim = battle.battle_anim_count
                    else:
                        battle.you_defeate = False
                        battle.battle_now = False
                        player.moving_wait = False
                        battle.battle_anim_count = 0
                        player.move_count = 0

                if (battle.lv_up_anim and
                    (wait_count_lv_anim + 3) < battle.battle_anim_count):
                    battle.lv_up_anim = False
                    battle.lv_up_anim_2 = True
                    wait_count_lv_anim_2 = battle.battle_anim_count

                if battle.lv_up_anim_2 and (wait_count_lv_anim_2 +
                                            3) < battle.battle_anim_count:
                    battle.lv_up_anim_2 = False
                    battle.battle_now = False
                    player.moving_wait = False
                    battle.battle_anim_count = 0
                    player.move_count = 0

                if (battle.you_lose and
                    (wait_count_you_lose + 3) < battle.battle_anim_count):

                    battle.you_lose = False
                    battle.battle_now = False
                    field_map.map_display = True
                    town.map_display = False
                    cave.map_display = False
                    player.hp = player.max_hp
                    player.mp = player.max_mp
                    player.gold = player.gold // 2
                    battle.battle_anim_count = 0
                    player.move_count = 0
                    player.wx, player.wy = 4, 3

            if event.type == pygame.KEYUP:
                if not player.moving_wait:
                    if event.key == pygame.K_DOWN or event.key == pygame.K_UP or event.key == pygame.K_RIGHT or event.key == pygame.K_LEFT:
                        player.moving_wait = True

        # print(player.lv_tables[player.lv][5])

        # メイン画面の更新
        pygame.display.update()
Example #30
0
# and that it sets a codeValidator for our Pyro object.

# NOTE that there is no ShoppingAgent module available here!!!
#      It will be downloaded from the client.

import sys, os
import Pyro.core

sys.path.insert(0, os.path.join(os.pardir, os.pardir))  # to find testserver.py

import testserver
import shop

Pyro.config.PYRO_MOBILE_CODE = 1  # Enable mobile code

s1 = shop.Shop("Fry's")
s1.setStock({'tv': 2000, 'computer': 3000, 'mouse': 10, 'cd': 19})
s2 = shop.Shop("Fred's groceries")
s2.setStock({'apples': 5, 'tomatoes': 9, 'bananas': 4, 'spices': 3})
s3 = shop.Shop("Rockport store")
s3.setStock({'shoes': 150, 'boots': 190})
s4 = shop.Shop("Snow world")
s4.setStock({'snowboard': 400, 'bindings': 150, 'goggles': 80, 'wax': 12})

# start the mall. We cannot start the testserver in delegation mode
# directly because we have to call setCodeValidator from the core.ObjBase!
# So create a subclass from ObjBase and our Mall.


class MallObj(Pyro.core.ObjBase, shop.Mall):
    def __init__(self):