def examine(commands, available_actions, player, room): if commands[0] == "examine" and len(commands) < 2: print "\tUsage: examine [item]" return if commands[1] == "all": for item in room.inventory: print "\t{}: {}".format(item.shortnames[0], item.description) if room.npcs: for npc in room.npcs: print "\t{}: {}".format(npc.shortnames[0], npc.description) if npc.inventory: print "\t{} appears to be holding:".format(npc.name) for item in npc.inventory: print "\t{}".format(item.name) return if commands[1] in room.ordinary: print "\tIt is an ordinary {}.".format(commands[1]) return item, owner = get_item(room, player, commands[1])# owner = room, player, openable, npc, npc_item if not item: things = owner if commands[1] not in things: print "\tI do not know the word {}.".format(commands[1]) return if commands[1] in things: print "\tYou don't see the {} here.".format(commands[1]) return if owner == "npc_item": for npc in room.npcs: if npc.inventory: for item in npc.inventory: for sname in item.shortnames: if commands[1] == sname: print "\t{} declines to show you the {}".format(npc.name, commands[1]) return else: print item.description return
print( "\n*************************************ex1*************************************" ) # dataframe ? => 행렬을 저장 from get_item import get_item # get_item 클래스에 대한 인스턴스인 item 객체를 만든다 item = get_item() print(item.code_df_kospi) print( "\n*************************************ex2*************************************" ) print("type: ", type(item.code_df_kospi)) print( "\n*************************************ex3*************************************" ) print("len: ", len(item.code_df_kospi)) print( "\n*************************************ex4*************************************" ) # iloc : 행, 열 단위로 dafaframe 안에 있는 데이터에 접근 # 아래는 0행 0열과 0행 1열을 출력 print(item.code_df_kospi.iloc[0, 0], item.code_df_kospi.iloc[0, 1]) # 아래는 123행 0열과 123행 1열을 출력 print(item.code_df_kospi.iloc[123, 0], item.code_df_kospi.iloc[123, 1])
def take(commands, available_actions, player, room): if len(commands) < 2: print "\tUsage: take [item]" return if commands[1] in room.ordinary: print "\tYou cannot take the {}.".format(commands[1]) return if not room.inventory: print "\tThere is nothing to take!" return if commands[1] == "all": items_to_remove = [] for npc in room.npcs: print "\tYou cannot take the {}.".format(npc.shortnames[0]) for item in room.inventory: if hasattr(item, "opened") and item.opened and item.inventory: sub_items_to_remove=[] for sub_item in item.inventory: if sub_item.takeable: player.inventory.append(sub_item) sub_items_to_remove.append(sub_item) print "\t{} taken".format(sub_item.shortnames[0]) else: print "\tYou cannot take the {}.".format(sub_item.shortnames[0]) if sub_items_to_remove: for sub_item in sub_items_to_remove: item.inventory.remove(sub_item) if item.takeable: player.inventory.append(item) items_to_remove.append(item) print "\t{} taken".format(item.shortnames[0]) # room.inventory.remove(item) else: print "\tYou cannot take the {}.".format(item.shortnames[0]) if items_to_remove: for item in items_to_remove: room.inventory.remove(item) return item, owner = get_item(room, player, commands[1])# owner = room, player, openable, npc, npc_item if not item: things = owner if commands[1] not in things: print "\tI do not know the word {}.".format(commands[1]) return if commands[1] in things: print "\tYou don't see the {} here.".format(commands[1]) return if owner == "npc": print "You cannot take the {}!".format(commands[1]) return if owner == "npc_item": print "The {} declines to give you the {}!".format(item.name, commands[0]) return if owner == "player": print "\tYou already have the {}.".format(commands[1]) return if owner == "room": if item.takeable: player.inventory.append(item) print "\t{} taken".format(item.shortnames[0]) room.inventory.remove(item) return else: print "\tThe {} is too heavy to move.".format(commands[1]) return if owner == "openable": for sub_item in item.inventory: if commands[1] in sub_item.shortnames : if sub_item.takeable: player.inventory.append(sub_item) print "\t{} taken".format(sub_item.shortnames[0]) item.inventory.remove(sub_item) return else: print "\tYou cannot take the {}.".format(commands[1]) return
def eat(commands, available_actions, player, room): if len(commands) < 2: print "\tUsage: eat [item]" return if commands[1] in room.ordinary: print "\tYou cannot eat the {}.".format(commands[1]) return item, owner = get_item(room, player, commands[1])# owner = room, player, openable, npc, npc_item if not item: things = owner if commands[1] not in things: print "\tYou cannot eat the {}, if there is even really a {} here.".format(commands[1], commands[1]) return else: print "\tYou don't see the {} here.".format(commands[1]) return if owner == "player": if hasattr(item, "eatable"): print "\tYou have eaten the {}. It was so-so".format(commands[1]) player.inventory.remove(item) item.eaten = True player.eaten.append(item) return else: print "\tThe {} is not edible.".format(commands[1]) return if owner == "room": if hasattr(item, "eatable"): print "\tYou have eaten the {}. It was so-so".format(commands[1]) room.inventory.remove(item) item.eaten = True player.eaten.append(item) return else: print "\tThe {} is not edible.".format(commands[1]) return if owner == "openable": for sub_item in item.inventory: if commands[1] in sub_item.shortnames : if hasattr(sub_item, "eatable"): item.inventory.remove(sub_item) print "\t{} eaten".format(sub_item.shortnames[0]) sub_item.eaten = True player.eaten.append(sub_item) return else: print "\tYou cannot eat the {}.".format(commands[1]) return if owner == "npc_item": print "\tThe {} decliens to let you eat the {}.".format(item.shortnames[0], commands[1]) return if owner == "npc": print "\tYou cannot eat the {}!".format(commands[1]) return