def updateVersions(force = True): initTitles() initFiles() i = 0 for k,t in Titles.items(): if force or t.version == None: if (t.isDLC or t.isUpdate or Config.download.base) and (not t.isDLC or Config.download.DLC) and (not t.isDemo or Config.download.demo) and (not t.isUpdate or Config.download.update) and (t.key or Config.download.sansTitleKey) and (len(titleWhitelist) == 0 or t.id in titleWhitelist) and t.id not in titleBlacklist: v = t.lastestVersion(True) Print.info("%s[%s] v = %s" % (str(t.name), str(t.id), str(v)) ) i = i + 1 if i % 20 == 0: Titles.save() for t in list(Titles.data().values()): if not t.isUpdate and not t.isDLC and t.updateId and t.updateId and not Titles.contains(t.updateId): u = Title() u.setId(t.updateId) if u.lastestVersion(): Titles.set(t.updateId, u) Print.info("%s[%s] FOUND" % (str(t.name), str(u.id)) ) i = i + 1 if i % 20 == 0: Titles.save() Titles.save()
def download(id): bits = id.split(',') version = None key = None if len(bits) == 1: id = bits[0].upper() elif len(bits) == 2: id = bits[0].upper() key = bits[1].strip() elif len(bits) == 3: id = bits[0].upper() key = bits[1].strip() version = bits[2].strip() else: Print.info('invalid args: ' + download) return False if key == '': key = None if version == '': version = None if len(id) != 16: raise IOError('Invalid title id format') if Titles.contains(id): title = Titles.get(id) CDNSP.download_game(title.id.lower(), version or title.lastestVersion(), key or title.key, True, '', True) else: CDNSP.download_game(id.lower(), version or Title.getCdnVersion(id.lower()), key, True, '', True) return True
def title(): title_inst = Title() while True: title_inst.title_aesthetics() title_inst.input() if title_inst.button_logic() is not None: flags = title_inst.button_logic() if title_inst.game_started: return True, flags
def sellHotel(player, titleDeedsNames, titleDeedsOwned, bank): #Print all title deeds owned that have hotel for titleDeedRecord in titleDeedsOwned: if (titleDeedRecord["Hotels"] != None and titleDeedRecord["Hotels"] == 1): print(titleDeedRecord["Title Deed"].getName()) print("You may need to scroll if you have many title deeds with hotels.") #User types in title deed to buy a hotel titleDeedToSellHotel = input( "Enter name of title deed you wish to sell a hotel: " ) #This needs validation #Search for the title deed, and get the card information titleDeedRecord = None for titleDeed in titleDeedsOwned: if (titleDeedToSellHotel == titleDeed["Title Deed"].getName()): titleDeedRecord = titleDeed #If there is no title deed of such name, stop processing. if (titleDeedRecord == None): print( "There is no title deed card with that name. Returning to previous menu." ) return #Go to the previous caller function #Check if that property is in the monopoly colorGroup = titleDeedRecord["Title Deed"].getColorGroup() propertiesList = Title.getColorGroup(colorGroup) propertyInGroup = False if (titleDeedRecord["Title Deed"].getName() in propertiesList): propertyInGroup = True if (not propertyInGroup): print( "This property is not part of a monopoly. Returning to the previous menu." ) return #Go to the previous caller function #Check if other properties have the exactly same number as homes/hotels available for this property before selling. getCurrentHotels = titleDeedRecord["Hotels"] #Check if current property has no homes to sell if (getCurrentHotels == 0): print("You do not have any hotels to sell.") return #Go to the previous caller function. #Since a player would already have at most one hotel (and thus that property part of monopoly), and other functions have already handled the checking process of number of houses before selling (meaning any other properties must have at least four homes), checking the number of hotels is not necessary. #If other requirements are passed, sell the hotel. sellBuildingAmount = titleDeedRecord["Title Deed"].getBuildingCosts( Property.HOTELS_COST) * 0.50 #Purchase the home by purchasing from bank and then get the home player.sellHotel(titleDeedToSellHotel, sellBuildingAmount, bank) print(player.getName() + ", has sold a hotel for " + titleDeedRecord["Title Deed"].getName() + "Returning to the previous menu.")
def __init__(self): super().__init__() pygame.init() self.logger = logging.getLogger("Game") logging.basicConfig( format='%(asctime)s - %(name)s: %(levelname)s - %(message)s', level=logging.INFO) self.logger.info("Initializing Game") self.logger.info("Winding the clock") # clock - for FPS self.clock = pygame.time.Clock() self.background = pygame.Color('black') self.screen_width = 900 self.screen_height = 900 self.screen = pygame.display.set_mode( (self.screen_width, self.screen_height)) self.logger.info("Moving to Title Scene") self.active_scene = Title() self.running = True
def scanDLC(id, showErr=True, dlcStatus=None): id = id.upper() title = Titles.get(id) baseDlc = Title.baseDlcId(id) for i in range(0x1FF): scanId = format(baseDlc + i, 'X').zfill(16) if Titles.contains(scanId): continue ver = CDNSP.get_version(scanId.lower()) if ver != None: t = Title() t.setId(scanId) Titles.set(scanId, t) Titles.save() Print.info('Found new DLC ' + str(title.name) + ' : ' + scanId) elif showErr: Print.info('nothing found at ' + scanId + ', ' + str(ver)) if dlcStatus: dlcStatus.add()
def scanBaseThread(baseStatus): while Config.isRunning: try: id = getRandomTitleId() if Titles.contains(id): continue ver = CDNSP.get_version(id.lower()) if ver != None: Print.info('Found new base ' + id) t = Title() t.setId(id) Titles.set(id, t) Titles.save() baseStatus.add() except BaseException as e: print('exception: ' + str(e))
def initialize(self): pygame.init() Globals.WIDTH = 1000 Globals.HEIGHT = 600 Globals.SCREEN = pygame.display.set_mode( (Globals.WIDTH, Globals.HEIGHT)) SettingsManager.load() Globals.set_brightness(SettingsManager.BRIGHTNESS, save=False) Globals.set_volume(SettingsManager.VOLUME, save=False) pygame.display.set_caption('The Crazy Six - Field Day') Globals.STATE = Title() Globals.EVENT_MANAGER = EventManager()
def scanLatestTitleUpdates(): initTitles() initFiles() for k, i in CDNSP.get_versionUpdates().items(): id = str(k).upper() version = str(i) if not Titles.contains(id): if len(id) != 16: Print.info('invalid title id: ' + id) continue continue t = Title() t.setId(id) Titles.set(id, t) Print.info('Found new title id: ' + str(id)) t = Titles.get(id) if str(t.version) != str(version): Print.info('new version detected for %s[%s] v%s' % (t.name or '', t.id or ('0' * 16), str(version))) t.setVersion(version, True) Titles.save()
def startScraping(): print(datetime.datetime.now()) persons = [] titles = [] personi = 0 titlei = 0 #Number of ids to retrieve numIds = 10 while (True): if len(persons) == 0: persons = getTopPersons(numIds) if len(titles) == 0: titles = getTopTitles(numIds) for personID in persons: print(personID) start = time.time() person = Person(personID) if not person.checkInDB(False, False, False): print("checked DB") personi += 1 person.scrapeData() person.commitDB() end = time.time() print("{} scraping person {} : {}".format( personi, person.name, (end - start))) persons = [] for titleID in titles: print(titleID) #start = time.time() title = Title(titleID) if not title.checkInDB(False): titlei += 1 title.scrapeData() title.commitDB() end = time.time() print("{} scraping title {} : {}".format( titlei, title.name, (end - start))) titles = []
def init(self): #initialize images self.shield = pygame.image.load('img/shield.png').convert_alpha() self.tentImage = pygame.image.load('img/tentacles.png').convert_alpha() self.heartEmpty = pygame.image.load( 'img/heart_empty.png').convert_alpha() self.heartFilled = pygame.image.load( 'img/heart_filled.png').convert_alpha() self.heartFilledRed = pygame.image.load( 'img/heart_filled_large.png').convert_alpha() self.keyboard = pygame.image.load('img/keyboard.png').convert_alpha() self.keyW = pygame.image.load('img/key_w.png').convert_alpha() self.keyS = pygame.image.load('img/key_s.png').convert_alpha() self.key1 = pygame.image.load('img/key_1.png').convert_alpha() self.key2 = pygame.image.load('img/key_2.png').convert_alpha() self.keyArrows = pygame.image.load( 'img/key_arrows.png').convert_alpha() #for game self.planetGroup = pygame.sprite.Group() self.parasite = pygame.sprite.Group() self.inhabitedGroup = pygame.sprite.Group() self.formedInhabitedGroup = pygame.sprite.Group() self.eatMeInvGroup = pygame.sprite.Group() self.eatMeStopGroup = pygame.sprite.Group() self.eatMeTenGroup = pygame.sprite.Group() self.eatMeLifeGroup = pygame.sprite.Group() parasiteNew = Parasite(self.parasiteSize) self.parasite.add(parasiteNew) #add static stars self.starList = [] for star in range(125): starCoordsX = random.randrange(0, self.width) starCoordsY = random.randrange(0, self.height) self.starList.append((starCoordsX, starCoordsY)) #for splash screen self.parasiteTitle = pygame.sprite.Group() self.instructionsInhabited = pygame.sprite.Group() self.titleGroup = pygame.sprite.Group() parasiteTitleNew = Parasite(self.parasiteSize) self.parasiteTitle.add(parasiteTitleNew) titleNew = Title() self.titleGroup.add(titleNew) inhabitedTitleNew = Inhabited((self.width // 20) * 27, (self.height // 10) * 15) self.instructionsInhabited.add(inhabitedTitleNew) self.formed = False
def __init__(self, parent, **kwargs): Window.__init__(self, parent) # data self.__dict__["title"] = None self.__dict__["items"] = None self.__dict__["looseFocusClose"] = 1 self.__dict__["columns"] = 1 self.__dict__["decorated"] = 0 self.__dict__["layoutManager"] = SimpleGridLM() self.__dict__["width"] = 10 self.__dict__["_labels"] = [] self.processKWArguments(kwargs) # subscribe action # add title Title(self, id="_menuTitle")
def list_contents(self): contents = {} for title in available_books_by_title: if title not in contents: contents[title] = {} contents[title]['available'] = available_books_by_title[ title].copy() for title in available_books_by_title: if title not in contents: contents[title] = {} contents[title]['available'] = available_books_by_title[ title].copy() for title in contents: contents[title]['object'] = Title.find_title(title)
def process_title(title, article): title_set = clean_text(title) id = frozenset_to_filename(frozenset(title_set)) if len(id) >= 254 or len(pathname2url(id)) >= 254: return "error" else: try: title_entry = titles_dict.get(id, Title(id=id, words=title_set)) if article.id not in set(title_entry.articles): title_entry.add_article(article.id) titles_dict[id] = title_entry add_title_to_words(title_entry) return title_entry except: return "error"
class Game(object): """ The Game - Based on the pygame framework """ def __init__(self): super().__init__() pygame.init() self.logger = logging.getLogger("Game") logging.basicConfig( format='%(asctime)s - %(name)s: %(levelname)s - %(message)s', level=logging.INFO) self.logger.info("Initializing Game") self.logger.info("Winding the clock") # clock - for FPS self.clock = pygame.time.Clock() self.background = pygame.Color('black') self.screen_width = 900 self.screen_height = 900 self.screen = pygame.display.set_mode( (self.screen_width, self.screen_height)) self.logger.info("Moving to Title Scene") self.active_scene = Title() self.running = True def run(self): """ Run loop - Show the game board """ while self.running: events = pygame.event.get() for event in events: if event.type == pygame.QUIT: self.running = False if event.type == pygame.KEYUP: if event.key == pygame.K_ESCAPE: self.running = False self.active_scene.process_input(events) self.active_scene.update() self.active_scene.render(self.screen) self.active_scene = self.active_scene.next pygame.display.update() self.clock.tick(60) pygame.quit()
def removeTitle(self, name): title=Title(name=name) for i in title.getAllUsers(): title.safeRemoveUser(i.uid) self.store.delete(title.getNode())
def search(self, keyword): results = {} title_ids = Title.keyword_search(keyword) for title_id in title_ids: results[title_id] = Kiosk.get_available_book_counts(title_id) return results
def __init__(self, leaf): self.file = File(leaf) self.legend = Legend(leaf) self.contour = Contour(leaf) self.title = Title(leaf) self.uv = UV(leaf)
if version == '': version = None if len(id) != 16: raise IOError('Invalid title id format') if Titles.contains(id): title = Titles.get(id) CDNSP.download_game(title.id.lower(), version or title.lastestVersion(), key or title.key, True, '', True) else: CDNSP.download_game( id.lower(), version or Title.getCdnVersion(id.lower()), key, True, '', True) if args.scan: initTitles() initFiles() scan() if args.refresh: refresh() if args.organize: organize() if args.set_masterkey1: f = Fs.Nsp(args.set_masterkey1, 'r+b')
def run_game(): settings = Settings() # initialise the game pygame.init() # returns a pyGame surface music = pygame.mixer.Sound("music.wav") screen = pygame.display.set_mode( (settings.screen_width, settings.screen_height), 0, 32) clock = pygame.time.Clock() scoreboard = Scoreboard(screen) play_button = Button( screen, settings.screen_width / 2 - settings.button_width / 2, settings.screen_height / 2 - settings.button_height / 2, settings, "Play Food Fetcher") instructions = Instructions(screen, settings) draw_title = Title(screen) foods = [] poisons = [] basket = Basket(screen) engine = Engine(screen, settings, scoreboard, foods, poisons, basket) # play music music.play(loops=-1) # main event loop # while True: while True: time_passed = clock.tick(50) mouse_x = pygame.mouse.get_pos()[0] mouse_y = pygame.mouse.get_pos()[1] engine.check_events(play_button, mouse_x, mouse_y) screen.fill(settings.bg_color) if settings.game_active: engine.update_basket(mouse_x) engine.check_foods(time_passed) engine.check_poisons(time_passed) if len(foods) == 0: if scoreboard.food_caught > 0: # Increase the balloon speed for each new batch of balloons. settings.food_speed *= settings.speed_increase_factor settings.poison_ratio *= settings.speed_increase_factor scoreboard.batches_finished += 1 # If player has completed required batches, increase batch_size if scoreboard.batches_finished % settings.batches_needed == 0 and scoreboard.batches_finished > 0: settings.batch_size += 1 engine.release_batch() else: play_button.blitme() draw_title.blitme( settings.screen_width / 2 - settings.button_width / 2, settings.screen_height / 2 - settings.button_height * 4) # If a game has just ended, show Game Over button if settings.games_played > 0: score = scoreboard.get_score() pizza_caught = scoreboard.get_caught_pizza() poison_caught = scoreboard.get_caught_poison() displayScore = DisplayScore(screen, settings, score, pizza_caught, poison_caught) displayScore.blitme() if settings.games_played < 1: instructions.blitme() # Display scoreboard scoreboard.blitme() pygame.display.flip()
if key == '': key = None if version == '': version = None if len(id) != 16: raise IOError('Invalid title id format') if Titles.contains(id): title = Titles.get(id) CDNSP.download_game(title.id.lower(), version or title.lastestVersion(), key or title.key, True, '', True) else: CDNSP.download_game(id.lower(), version or Title.getCdnVersion(id.lower()), key, True, '', True) if args.scan: initTitles() initFiles() scan() if args.refresh: refresh() if args.organize: organize() if args.set_masterkey1: f = Fs.Nsp(args.set_masterkey1, 'r+b') f.setMasterKeyRev(0)
def getMortgage(self, player, titleDeedsNames, titleDeedsOwned, bank=None): #Print all title deeds owned for titleDeed in titleDeedsNames: print(titleDeed) print("You may need to scroll if you own a large number of title deeds.") #User types in title deed to mortgage titleDeedToMortgage = input( "Enter name of title deed you wish to mortgage: " ) #This needs validation #Search for the title deed, and get the card information titleDeedRecord = None for titleDeed in titleDeedsOwned: if (titleDeedToMortgage == titleDeed["Title Deed"].getName()): titleDeedRecord = titleDeed #If there is no title deed of such name, stop processing. if (titleDeedRecord == None): print( "There is no title deed card with that name. Returning to previous menu." ) return #Go to the previous caller function #Check if there is any buildings on that title deed and other title deeds of that color group. #If there are any buildings, player must sell all properties first. if (titleDeedRecord["Title Deed"].getTitleType() == "Property"): #Get the color group information from card and player's current monopolies colorGroup = titleDeedRecord["Title Deed"].getColorGroup() playerColorMonopoly = player.getColorMonopoly() colorGroupStats = None #Get the stats information on that monopoly for colorMonopoly in playerColorMonopoly: if (colorMonopoly["Color Group"] == colorGroup): colorGroupStats = colorMonopoly #Check if there is any property, and if so inform player the property cannot be mortgaged if (colorGroupStats["Number Buildings Built"] > 0): print( "You cannot mortgage this property because there are buildings in at least one of properties in the color group " + colorGroup) #List the title deeds in the color group with buildings propertiesList = Title.getColorGroup(colorGroup) for propertyItem in propertiesList: for titleDeed in titleDeedsOwned: if (titleDeed["Title Deed"].getName() == propertyItem): print("Property Name: " + propertyItem + "\nNumber of Houses: " + titleDeed["Houses"] + "\nNumber of Hotels: " + titleDeed["Hotels"] + "\n") print("If you wish to add a mortgage to " + titleDeedToMortgage + "please sell all buildings first in this color group first.") return #Go to the previous caller function #Get the mortgage value mortgageValue = titleDeedRecord["Title Deed"].getMortgageValue() #Make the mortgage player.addMortgage(titleDeedRecord["Title Deed"], mortgageValue, bank) print(player.getName() + ", your mortgage request for " + titleDeedRecord["Title Deed"].getName() + " was successful.\n" + "Returning to the previous menu.")
def sellProperty(playerOwner, playerReceiver, titleDeedsNames, titleDeedsOwned, bank): #Print all title deeds owned by the owner for titleDeed in titleDeedsNames: print(titleDeed) print("You may need to scroll if you own a large number of title deeds.") #User types in title deed to sell titleDeedToSellProperty = input( "Enter name of property title deed you wish to sell: " ) #This needs validation #Search for the title deed, and get the card information titleDeedRecord = None for titleDeed in titleDeedsOwned: if (titleDeedToSellProperty == titleDeed["Title Deed"].getName()): titleDeedRecord = titleDeed #If there is no title deed of such name, stop processing. if (titleDeedRecord == None): print( "There is no title deed card with that name. Aborting sell. Returning to previous menu." ) return #Go to the previous caller function #Check if this title deed is a property if (titleDeedRecord["Title Deed"].getTitleType() != "Property"): print( "This title deed is not a property. Aborting sell. Returning to previous menu." ) return #Go to the previous caller function #Check if there is any buildings on that title deed and other title deeds of that color group. #If there are any buildings, player must sell all properties first. if (titleDeedRecord["Title Deed"].getTitleType() == "Property" and titleDeedRecord["Mortgaged"] == False): #Get the color group information from card and player's current monopolies colorGroup = titleDeedRecord["Title Deed"].getColorGroup() playerColorMonopoly = playerOwner.getColorMonopoly() colorGroupStats = None #Get the stats information on that monopoly for colorMonopoly in playerColorMonopoly: if (colorMonopoly["Color Group"] == colorGroup): colorGroupStats = colorMonopoly #Check if there is any buildings, and if so inform player the property cannot be sold until all buildings ar esold if (colorGroupStats["Number Buildings Built"] > 0): print( "You cannot sell this property because there are buildings in at least one of properties in the color group " + colorGroup) #List the title deeds in the color group with buildings propertiesList = Title.getColorGroup(colorGroup) for propertyItem in propertiesList: for titleDeed in titleDeedsOwned: if (titleDeed["Title Deed"].getName() == propertyItem): print("Property Name: " + propertyItem + "\nNumber of Houses: " + titleDeed["Houses"] + "\nNumber of Hotels: " + titleDeed["Hotels"] + "\n") print("If you wish to sell this property, " + titleDeedRecord["Title Deed"].getName() + "please sell all buildings in this color group first.") return #Go to the previous caller function #Check if the property is mortgaged mortgaged = titleDeedRecord["Mortgaged"] #Make the selling price agreementReached = False amountWishToSell = 0 titleDeedName = titleDeedRecord["Title Deed"].getName() while (not agreementReached): amountWishToSell = makeSellTitleDeedDeal(playerOwner, playerReceiver, titleDeedName) if (amountWishToSell > 0): agreementReached = True #If agreement reached, make the sell - owner begins the selling titleDeedInTransit = playerOwner.sellTitle(titleDeedName, amountWishToSell) playerReceiver.inheritTitle(titleDeedInTransit, amountWishToSell, mortgaged, bank) #Clear any debt to the receiver reduceDebtAfterSell(playerOwner, playerReceiver) print(playerOwner.getName() + ", has sold the property " + titleDeedRecord["Title Deed"].getName() + " to " + playerReceiver.getName() + "\n" + "Returning to the previous menu.")
def main(): # load the system state db = yaml.load(open("inventory.yaml").read()) inventory_import(db['inventory']) #pprint.pprint(obj) # (System) Creates inventory inv = Inventory() # (System) Creates admin admin = Admin("Joe") # (System) Creates kiosk .. and adds it to the inventory kiosk = Kiosk('aacpl') Kiosk.add_kiosk(kiosk) # (Admin) Creates a title .. and adds it to the inventory title1 = Title(1234, "title1", "author1") Title.add_title(title1) # (Admin) Creates a book .. and associates it with a title and bearer Book.add_book(Book(4321, title1, admin)) # *Admin sends book to kiosk for insertion* # (Employee) Inserts book into kiosk (via qr_code) kiosk.insert_book(4321) print "\nKiosk Title Availability: (Employee just inserted a book)" pprint.pprint(kiosk.available_books_by_title) pprint.pprint(kiosk.reserved_books_by_title) # (User) Searches for book userweb1 = UserWebService("user1") results = userweb1.search("title1") print "\nSearch Results: (User just searched for a title.)" pprint.pprint(results) # (User) Reserves A Book title_choice = results.items()[0][0] kiosk_choice = results.items()[0][1].keys()[0] userweb1.reserve_title(title_choice, kiosk_choice) print "\nKiosks Title Availability: (User just reserved a title)" pprint.pprint(kiosk.available_books_by_title) pprint.pprint(kiosk.reserved_books_by_title) # Another user tries for the same title, but must request userweb2 = UserWebService("user2") results = userweb2.search("title1") print "\nSearch Results: (User Searched For Unavailable Title)" pprint.pprint(results) # 2nd User Requests Title title_choice = results.items()[0][0] kiosk_choice = results.items()[0][1].keys()[0] userweb2.request_title(title_choice, kiosk_choice) print "\nKiosk Requests: (User just requested unavailable title.)" pprint.pprint(kiosk.requests) # First user picks up a book. kiosk.eject_reserved_book("user1", 4321) print "\nBook Bearer: ", Book.find_book(4321).bearer_uuid print "Kiosks Title Availability: (User just picked up a book)" pprint.pprint(kiosk.available_books_by_title) pprint.pprint(kiosk.reserved_books_by_title) # User returns book kiosk.insert_book(4321) print "\nBook Bearer: ", Book.find_book(4321).bearer_uuid print "Kiosks Title Availability: (User just returned a book)" pprint.pprint(kiosk.available_books_by_title) pprint.pprint(kiosk.reserved_books_by_title) # Second user picks up a book. kiosk.eject_reserved_book("user2", 4321) print "\nBook Bearer: ", Book.find_book(4321).bearer_uuid print "Kiosks Title Availability: (User just picked up a book)" pprint.pprint(kiosk.available_books_by_title) pprint.pprint(kiosk.reserved_books_by_title) # Second user returns book kiosk.insert_book(4321) print "\nBook Bearer: ", Book.find_book(4321).bearer_uuid print "Kiosks Title Availability: (User just returned a book)" pprint.pprint(kiosk.available_books_by_title) pprint.pprint(kiosk.reserved_books_by_title)
def sellHome(player, titleDeedsNames, titleDeedsOwned, bank): #Print all title deeds owned that have houses for titleDeedRecord in titleDeedsOwned: if (titleDeedRecord["Houses"] != None and titleDeedRecord["Houses"] >= 1): print(titleDeedRecord["Title Deed"].getName()) print("You may need to scroll if you have many title deeds with houses.") #User types in title deed to sell the home titleDeedToSellHouse = input( "Enter name of title deed you wish to sell a home: " ) #This needs validation #Search for the title deed, and get the card information titleDeedRecord = None for titleDeed in titleDeedsOwned: if (titleDeedToSellHouse == titleDeed["Title Deed"].getName()): titleDeedRecord = titleDeed #If there is no title deed of such name, stop processing. if (titleDeedRecord == None): print( "There is no title deed card with that name. Returning to previous menu." ) return #Go to the previous caller function #Check if other properties have the exactly same number as homes/hotels available for this property before selling. First current number of buildings of title deed player wishes to sell another building getCurrentHouses = titleDeedRecord["Houses"] #Check if current property has no homes to sell if (getCurrentHouses == 0): print("You do not have any houses to sell.") return #Go to the previous caller function. #Check other properties of the color group colorGroup = titleDeedRecord["Title Deed"].getColorGroup() propertiesList = Title.getColorGroup(colorGroup) notEvenHouses = False for propertyItem in propertiesList: for titleDeed in titleDeedsOwned: if (titleDeed["Title Deed"].getName() == propertyItem): getCurrentBuildingsOther = 0 #Get current number of buildings of that title deed getCurrentHousesOther = titleDeed["Houses"] #Get the number of hotels of that title deed getCurrentHotelsOther = titleDeed["Hotel"] if (getCurrentHotelsOther): getCurrentBuildingsOther = getCurrentHousesOther + getCurrentHotelsOther else: getCurrentBuildingsOther = getCurrentHousesOther print("Property Name: " + titleDeed["Title Deed"].getName() + "\tNumber of Houses: " + getCurrentHousesOther + "\tNumber of Hotels: " + getCurrentHotelsOther) if (getCurrentBuildingsOther > getCurrentHouses): notEvenHouses = True if (notEvenHouses): print( "You cannot sell a house on this property " + titleDeedRecord["Title Deed"].getName() + " right now.\nPlease ensure all other properties of the color group " + colorGroup + " have exactly " + getCurrentHouses + " each before proceeding.") return #Go to the previous caller function. #If other requirements are passed, sell the home sellBuildingAmount = titleDeedRecord["Title Deed"].getBuildingCosts( Property.HOMES_COST) * 0.50 #Purchase the home by purchasing from bank and then get the home player.sellHome(titleDeedToSellHouse, sellBuildingAmount, bank) print(player.getName() + ", has sold a house for " + titleDeedRecord["Title Deed"].getName() + "Returning to the previous menu.")
""" With thanks to https://realpython.com/python-gui-tkinter/#building-a-temperature-converter-example-app """ # Import the library import tkinter as tk # Import our custom components from Title import Title from SpeedForm import SpeedForm # Create our application root = tk.Tk() # Create our custom components main = Title(root) form = SpeedForm(root) # Add our components to the root main.pack(fill="both", expand=True) form.pack() """ User Interfaces (and games) usually setup their rules and then enter into an 'infinite loop'. During each run through the loop the state of the program is advanced and any user events are handled """ root.mainloop()
def title(self, text): from Title import Title title = Title(text) self.contents.append(title) return title
def __init__(self, master=None): # set up the main frame tk.Frame.__init__(self, width=1230, height=800) Title(self, master) self.setUpMAESTRO(master)
def purchaseHotel(player, titleDeedsNames, titleDeedsOwned, bank): #Print all title deeds owned for titleDeed in titleDeedsNames: print(titleDeed) print("You may need to scroll if you own a large number of title deeds.") #User types in title deed to buy a hotel titleDeedToPurchaseHotel = input( "Enter name of title deed you wish to buy a hotel: " ) #This needs validation #Search for the title deed, and get the card information titleDeedRecord = None for titleDeed in titleDeedsOwned: if (titleDeedToPurchaseHotel == titleDeed["Title Deed"].getName()): titleDeedRecord = titleDeed #If there is no title deed of such name, stop processing. if (titleDeedRecord == None): print( "There is no title deed card with that name. Returning to previous menu." ) return #Go to the previous caller function #Check if the property's color group is a monopoly. colorGroup = titleDeedRecord["Title Deed"].getColorGroup() monopolyList = player.getColorMonopoly() colorMonopoly = False if (colorGroup in monopolyList): colorMonopoly = True if (not colorMonopoly): print( "You cannot purchase a hotel at this time; you must own all properties of color group " + colorGroup + "first before you can purchase a hotel, which requires building four houses first." ) return #Go to the previous caller function #Check if the current property is mortgaged if (titleDeedRecord["Mortgaged"]): print( "This property is currently mortgaged. You cannot purchase any buildings." ) return #Go to the previous caller function #Check if other properties of that color group are mortgaged if (colorMonopoly): propertiesList = Title.getColorGroup(colorGroup) otherPropertiesMortgaged = False for propertyItem in propertiesList: for titleDeed in titleDeedsOwned: if (titleDeed["Title Deed"].getName() == propertyItem): if (titleDeed["Mortgaged"]): print("This property " + titleDeed["Title Deed"].getName() + " is mortgaged.") otherPropertiesMortgaged = True if (otherPropertiesMortgaged): print( "Please repay the mortgages of the other properties first before purchasing buildings." ) return #Go to the previous caller function #Check if this building has already reached the limit for hotels if (titleDeedRecord["Hotels"] == 1): print( "You cannot purchase any more hotels on this property. You have reached the limit." ) #Check if other properties have the exactly same number as homes as this property, in this case four if (colorMonopoly): #Check other properties of the color group propertiesList = Title.getColorGroup(colorGroup) notEvenHouses = False for propertyItem in propertiesList: for titleDeed in titleDeedsOwned: if (titleDeed["Title Deed"].getName() == propertyItem): #Get current number of buildings of that title deed getCurrentHousesOther = titleDeed["Houses"] print("Property Name: " + titleDeed["Title Deed"].getName() + "\tNumber of Houses: " + getCurrentHousesOther) if (getCurrentHousesOther != 4): notEvenHouses = True if (notEvenHouses): print( "You cannot build a hotel on this property " + titleDeedRecord["Title Deed"].getName() + " right now.\nPlease ensure all other properties of the color group " + colorGroup + " each have exactly 4 houses before proceeding.") return #Go to the previous caller function. #If other requirements are passed, purchase the hotel buildingCost = titleDeedRecord["Title Deed"].getBuildingCosts( Property.HOTELS_COST) #Purchase the hotel by purchasing from bank and then get the home player.purchaseHotel(titleDeedToPurchaseHotel, buildingCost, bank) print(player.getName() + ", has purchase a hotel for " + titleDeedRecord["Title Deed"].getName() + "Returning to the previous menu.")
return stats.spearmanr(self.standard, glb), stats.spearmanr(self.standard, avg), stats.spearmanr(self.standard, simmax) if __name__ == '__main__': word_vector_file = '/data/m1/cyx/etc/output/exp3/vectors_word10.dat' title_vector_file = '/data/m1/cyx/etc/output/exp10/vectors_title10.dat' mention_name_file = '/data/m1/cyx/etc/enwiki/mention_names' word_sim_file = '/data/m1/cyx/etc/expdata/wordsim_similarity_goldstandard.txt' output_file = '/data/m1/cyx/etc/expdata/log_wordsim353' wiki_id_file = '/data/m1/cyx/etc/enwiki/wiki_title_cl' has_title = False wiki_word = Word() wiki_word.loadVector(word_vector_file) print len(wiki_word.vectors) if has_title: wiki_title = Title() wiki_title.loadVector(title_vector_file) print len(wiki_title.vectors) mention_map = Map() mention_map.loadWikiID(wiki_id_file) mention_map.load(mention_name_file) print len(mention_map.names) eval = Evaluator() eval.loadData(word_sim_file) if has_title: eval.loadEmbeddings(wiki_word, wiki_title) eval.loadMentionMap(mention_map) else: eval.loadWordEmbeddings(wiki_word)