def configure_project(self, document): folder = tools.get_document_folder(document) ods = tools.get_ods_fname(folder) db_name_base = db_name = ods[:-4] n = 0 # Look for an unused db name while True: try: self.register_db(os.path.join(folder, ods), os.path.join(folder, db_name + ".odb"), db_name) except ValueError: n += 1 db_name = db_name_base + "-" + str(n) else: break for tmpl in tools.get_odt_fnames(folder): already_opened = tools.get_document_fname(document) == tmpl odt = document if already_opened else self.open_document( os.path.join(folder, tmpl)) self.link_db(odt, db_name, tmpl[:-4]) self.update_sections_link(odt, folder) if not already_opened: odt.dispose() messages.message(document.CurrentController.Frame.ContainerWindow, str("Les modèles ont été configurés avec succès."), "Configuration terminée")
def allowedEmptyArguments(self, allowed = True): self.allowed_empty_arguments = allowed if not allowed and self.is_empty: msg.message(msg.ERROR, "You must set any arguments (for help -h)") return self
def __checkIncompatible(self): for a in self.used_arguments: if not a._checkIncompatible(): msg.message( msg.ERROR, "Incompatible arguments between: \n\t%s \n\t%s"%(str(a), str(a._getWhatIsIncompatible()) ) )
def doPlayerKilled(payload): player = payload["player"] main = player["main"] equipment = player["equipment"] currency = player["currency"] location = player["location"] status = player["status"] stats = player["stats"] battle = player["battle"] opponent = battle["opponent"] deathEvent = newEvent(DEATH_EVENT, battle["ring_in_use"], 0, 0, "") # check if player died from greed or fatigue if stats["quickness"] == 0: if battle["rounds"] >= stats["max_quickness"] * N_FATIGUE: deathEvent["arg3"] = K_FATIGUE else: deathEvent["arg3"] = K_GREED else: deathEvent["arg3"] = K_MONSTER deathEvent["arg4"] = opponent["real_name"] doCancelMonster(player) # TODO: Log the battle loss handleEvent() message(player, ["Your die a horrible death!\n", MESSAGE_MORE, MESSAGE_CLEAR])
def __checkDependencies(self): for a in self.used_arguments: if not a._checkDependencies(): msg.message( msg.ERROR, "Is not set all dependencies: %s\n\t is needed: %s"%(a, a._getWhatNeedArgument()) )
def addArgument(self, argument, is_shaddow_argument = False): if self.ready: msg.message( msg.SYSTEM_ERROR, "After calling method check is not possible call method addArgument", StandardError ) #raise StandardError, "After calling method check is not possible call method addArgument" if isinstance(argument, Argument): if len(argument._getShort()): self.arguments_for_checking[str(self.short_prefix) + argument._getShort()] = argument if len(argument._getLong()): self.arguments_for_checking[str(self.long_prefix) + argument._getLong()] = argument argument._setAllArguments(self.used_arguments) self.arguments.append(argument) if is_shaddow_argument: self.shadow_argument = argument return self else: msg.message( msg.SYSTEM_ERROR, "Type must be instance of Argument, not %s"%type(argument), TypeError )
def doSin(player, sin): event = {} stats = player["stats"] status = player["status"] equipment = player["equipment"] if equipment["ring_type"] == R_DLREG: stats["sin"] += sin * 2 else: stats["sin"] += sin if stats["sin"] < 0.0: stats["sin"] = 0.0 if equipment["blessing"] and stats["sin"] > ((1500.0 + stats["level"]) / (stats["level"] + 30)): message(player, ["Your blessing is consumed by the evil of your actions!\n", MESSAGE_MORE, MESSAGE_CLEAR]) equipment["blessing"] = False if stats["sin"] > 25.0 + random() * 25.0: aNewEvent = newEvent(DEATH_EVENT, 0, 0, K_SIN, "") # TODO: File event elif stats["sin"] > 20.0 and random() < .2: message(player, ["You cackle gleefully at the chaos you are causing!\n", MESSAGE_MORE, MESSAGE_CLEAR])
def act(self, rs): mes.currentMessage( "selecting action according to current beleived state") action = self.qAgent.policy(self.currentState, rs) self.actHistory = action mes.currentMessage("performing action: " + str(action)) (self.environment).performAction( action) # here actual state is updated self.updatePerceivedTime() mes.currentMessage("perceiving") newState = self.perceive(self.problemStateDefinition) # PARAMETRIZE mes.message("current problem state: " + str(newState)) newGState = self.perceive(self.goalStateDefinition) reward = self.R(newGState) self.rewardHistory = reward mes.currentMessage("Reward:" + str(reward)) mes.currentMessage("learning from previous transition: ") self.qAgent.learn(newState, reward) self.currentState = newState
def setDependencies(self, list_of_arguments): if not isinstance(list_of_arguments, list): msg.message( msg.SYSTEM_ERROR, "list_of_arguments must be list", TypeError ) self.dependencies = list_of_arguments return self
def doMonsterKilled(payload): player = payload["player"] main = player["main"] equipment = player["equipment"] currency = player["currency"] location = player["location"] status = player["status"] stats = player["stats"] battle = player["battle"] opponent = battle["opponent"] if opponent["experience"]: doExperience(player, opponent["experience"], False) # TODO: log the victory # sprintf(string_buffer, "%s killed size %.0lf %s\n", c->player.lcname, c->battle.opponent->size, c->battle.opponent->realName); # Do_log(BATTLE_LOG, &string_buffer); # monster flocks */ if random() < opponent["flock_percent"] / 100.0: aNewEvent = newEvent(MONSTER_EVENT, MONSTER_FLOCKED, opponent["size"], opponent["type"], 0, "") else: # last fight in sequence, remove timeout penalty battle["timeouts"] = 0 # monster has treasure if (opponent["treasure_type"] > 0.0 and (random() > 0.2 + pow(0.4, opponent["size"] / 3.0))) or \ opponent["special_type"] == SM_UNICORN: aNewEvent = newEvent(TREASURE_EVENT, opponent["size"], 0, 0, "") # unicorns will always drop trove or pick scrolls */ if opponent["special_type"] == SM_UNICORN: if stats["level"] <= 100 - currency["gems"]: aNewEvent["arg2"] = 1 else: aNewEvent["arg2"] = 5 aNewEvent["arg3"] = opponent["treasure_type"] stackEvent(payload, aNewEvent) if equipment["ring_duration"] <= 0: if equipment["ring_type"] == R_NAZREG: doRing(player, R_NONE, False); message(player, [MESSAGE_CLEAR, "Your ring vanishes!\n", MESSAGE_MORE]) elif equipment["ring_type"] == R_BAD: doRing(player, R_SPOILED, False) elif equipment["ring_type"] == R_SPOILED: aNewEvent = newEvent(DEATH_EVENT, 0, 0, K_RING) doPlayerKilled(payload) # remove player bonuses */ doEnergy(player, stats["energy"], stats["max_energy"], equipment["shield"], 0, False) doStrength(player, stats["max_strength"], equipment["sword"], 0, False) doSpeed(player, stats["max_quickness"], equipment["quicksilver"], 0, False) battle["force_field"] = 0 battle["strength_spell"] = 0 battle["speed_spell"] = 0
def setIncompatibleArguments(self, list_of_arguments): if not isinstance(list_of_arguments, list): msg.message( msg.SYSTEM_ERROR, "list_of_arguments must be list", TypeError ) self.incompatible = list_of_arguments return self
def _answerVirgin(payload): player = payload["player"] action = payload["action"] location = player["location"] if action["arg1"] == MESSAGE_NO: doVirgin(player, True, False) else: doExperience(player, 2500.0 * location["circle"], False) doSin(player, 1.0); message(player, ["", MESSAGE_CLEAR])
def _answerPickupRingOfPower(payload): player = payload["player"] action = payload["action"] if action["arg1"] == MESSAGE_NO: message(player, ["", MESSAGE_CLEAR]) return if random() < 0.8: # regular ring doRing(player, R_NAZREG, False) else: # bad ring doRing(player, R_BAD, False) message(player, ["", MESSAGE_CLEAR])
def sendMessage(text): ui.addStatus("Sending message") comms.sendMessage(text) mesg = message(text,sender=username) mesg.saveToFile() ui.addMessage(mesg) ui.updateMessageScreen()
def doTeleport(payload): print("doTeleport") event = payload["action"] player = payload["player"] location = player["location"] print(event["arg2"]) if event["arg2"] == True: print(event["message"]["x"]) print(event["message"]["y"]) location["x"] = event["message"]["x"] location["y"] = event["message"]["y"] setCircle(location) setLocation(location) message(player, ["", MESSAGE_CLEAR])
def doHitMonster(payload, inflict): player = payload["player"] main = player["main"] equipment = player["equipment"] currency = player["currency"] location = player["location"] status = player["status"] stats = player["stats"] battle = player["battle"] opponent = battle["opponent"] battle["messages"] = [] message(player, ["You hit %s for %.0f damage!\n" % (opponent["name"], inflict)]) opponent["shield"] -= inflict if opponent["shield"] < 0.0: opponent["energy"] += opponent["shield"] opponent["shield"] = 0.0 if opponent["special_type"] != SM_IT_COMBAT: if opponent["energy"] > 0.0: if opponent["special_type"] == SM_DARKLORD or opponent["special_type"] == SM_SHRIEKER: # special monster didn't die doMonsterHits(payload) else: # monster died. print message. if opponent["special_type"] == SM_DARKLORD: broadcast(player, "%s has just defeated the Dark Lord!\n" % main["modified_name"]) elif opponent["special_type"] == SM_MORGOTH: message(player, ["You have overthrown Morgoth! But beware, he will return...\n", MESSAGE_MORE, MESSAGE_CLEAR]) status["morgoth_count"] = 500 broadcast(player, "All hail %s for overthrowing Morgoth, Enemy of the Vala!\n" % main["modified_name"]) elif opponent["special_type"] == SM_SMURF and not status["blind"]: message(player, ["You finally manage to squish the Smurf. Good work, %s.\n" % main["modified_name"], MESSAGE_MORE, MESSAGE_CLEAR]) else: # all other types of monsters message(player, ["You killed it. Good work, %s.\n" % main["modified_name"], MESSAGE_MORE, MESSAGE_CLEAR]) if opponent["special_type"] == SM_MIMIC and opponent["name"] != "A Mimic" and not status["blind"]: message(player, ["%s's body slowly changes into the form of a mimic.\n" % opponent["name"], MESSAGE_MORE, MESSAGE_CLEAR]) doMonsterKilled(payload)
def _answerWayland(payload): print("_answerWayland") player = payload["player"] action = payload["action"] event = action["message"]["event"] stats = player["stats"] equipment = player["equipment"] if action["arg1"] == MESSAGE_NO: message(player, ["", MESSAGE_CLEAR]) return if action["arg2"] == 1: # upgrade shield # determine the shield bonus dtemp = .018 * equipment["shield"] if dtemp > 1 + 60 * event["arg1"]: dtemp = 1 + 60 * event["arg1"] if dtemp < 1: dtemp = 1 # award the bonus doEnergy(player, stats["energy"], stats["max_energy"], equipment["shield"] + dtemp, 0, False) if action["arg2"] == 2: # determine the sword bonus dtemp = .018 * equipment["sword"] if dtemp > 1 + 2 * event["arg1"]: dtemp = 1 + 2 * event["arg1"] if dtemp < 1: dtemp = 1 # award the bonus doStrength(player, stats["max_strength"], equipment["sword"] + dtemp, 0, False) if action["arg2"] == 3: # determine the quicksilver bonus dtemp = .018 * equipment["quicksilver"] if dtemp > 1 + .12 * event["arg1"]: dtemp = 1 + .12 * event["arg1"] if dtemp < 1: dtemp = 1 # award the bonus doSpeed(player, stats["max_quickness"], equipment["quicksilver"] + dtemp, 0, False) message(player, ["", MESSAGE_CLEAR])
def doGuru(payload): player = payload["player"] message(player, ["You've met a Guru. . .\n"]) if random() * player["stats"]["sin"] > 1.0: message(player, ["You disgusted him with your sins!\n", MESSAGE_MORE, MESSAGE_CLEAR]) elif player["stats"]["poison"] > 0.0: message(player, ["He looked kindly upon you, and cured you.\n", MESSAGE_MORE, MESSAGE_CLEAR]) doPoison(player, -player["stats"]["poison"]) elif random() / 10 > player["stats"]["sin"] and player["location"]["circle"] > 1: message(player, ["He slips something into your charm pouch as a reward for your saintly behavior!\n", MESSAGE_MORE, MESSAGE_CLEAR]) doMana(player, 40.0 + 15 * player["location"]["circle"], False) player["equipment"]["charms"] += 1 + player["location"]["circle"] / 20 else: message(player, ["He rewarded you for your virtue.\n", MESSAGE_MORE, MESSAGE_CLEAR]) doMana(player, 40.0 + 10 * player["location"]["circle"], False) doEnergy(player, player["stats"]["energy"] + 2 + player["location"]["circle"] / 5, \ player["stats"]["max_energy"], \ player["equipment"]["shield"] + 2 + player["location"]["circle"] / 5, 0, False)
def doTreasureMap(payload): print("doTreasureMap") player = payload["player"] location = player["location"] trove = Objects.query.filter(Objects.object_type == "TROVE").all() x_loc = trove[0].x y_loc = trove[0].y # determine the distance to the trove dtemp = doDistance(location["x"], x_loc, location["y"], y_loc) if dtemp > 1.0: # throw in a fudge factor of up to 12.5% if not near trove dtemp = floor(dtemp * (.875 + random() * .25) + .01) msg = "It says, 'To find me treasure trove, ye must move %.0lf squares to the " % dtemp msg = msg + doDirection(player, x_loc, y_loc) msg = msg + " and then look for me next map.\n" message(player, [msg, MESSAGE_MORE, MESSAGE_CLEAR]) elif dtemp == 1.0: msg = "Arr, you're almost there. The booty is 1 square " msg = msg + doDirection(player, x_loc, y_loc) message(player, [msg, MESSAGE_MORE, MESSAGE_CLEAR]) else: message(player, ["You've found the treasure! Dig matey, dig!\n", MESSAGE_MORE, MESSAGE_CLEAR])
def update_gantt(self, document): if not tools.has_database(document): messages.error(document.CurrentController.Frame.ContainerWindow, str("Merci de configurer l'étude."), "Etude non configurée") return folder = tools.get_document_folder(document) calc = self.open_document( os.path.join(folder, tools.get_ods_fname(folder))) try: gantt.update(document, calc) except Exception as e: # TODO messages.error(document.CurrentController.Frame.ContainerWindow, str(e), "Erreur Gantt") else: messages.message(document.CurrentController.Frame.ContainerWindow, str("Le Gantt a été mis à jour avec succès."), "Mise à jour du Gantt terminée") finally: calc.dispose()
def __init__(self, age=[], food=[], pos=[], speed=[], last_breed=[]): # These attributes vary on a per-fox basis self.age = age self.food = food self.pos = pos self.speed = speed self.last_breed = last_breed self.dead = False # Is this agent dead or alive? self.has_been_eaten = False # Has this agent been eaten? # Messages passed to this agent self.messages = message(self.pos, self.dead, self.has_been_eaten) # Incremenent number of alive foxes by one self.__class__.num_foxes = self.__class__.num_foxes + 1
def message(bot, update, args): bot.sendChatAction(chat_id=update['message']['chat']['id'], action=ChatAction.TYPING) msg = "" count = 0 if len(args) == 0: bot.send_message(chat_id=update['message']['chat']['id'], text=messages.alert_error( update['message']['chat']['first_name']), parse_mode=ParseMode.HTML) return for i in args: if count != 0: i = str(i).replace("\\n", '\n') msg += i + " " count += 1 try: if int(args[0]): session = Session() user = session.query( db.User).filter_by(telegram_id=int(args[0])).first() first_name = user.first_name bot.send_message(chat_id=args[0], text=messages.message( msg, update['message']['chat']['first_name'], user.first_name), parse_mode=ParseMode.HTML) admin = session.query(db.Admins).filter_by( user_id=update['message']['chat']['id']).first() session.add(db.Alert(admin.id, int(args[0]), str(msg))) user = session.query( db.User).filter_by(telegram_id=admin.user_id).first() bot.send_message(chat_id=update['message']['chat']['id'], text=messages.alert_success( user.first_name, first_name), parse_mode=ParseMode.HTML) session.commit() session.close() except ValueError: bot.send_message(chat_id=update['message']['chat']['id'], text=messages.alert_error( update['message']['chat']['first_name']), parse_mode=ParseMode.HTML) except Exception as error: main.error_callback(bot, update, error)
def __init__(self, short, long, description, contains_value = True, required = False): if isinstance(short, str) == False or isinstance(long, str) == False or isinstance(description, str) == False: msg.message( msg.SYSTEM_ERROR, "Parameters short, long and description must be string", TypeError ) if isinstance(contains_value, bool) == False: msg.message( msg.SYSTEM_ERROR, "Parameter contains_value must be bool", TypeError ) if isinstance(required, bool) == False: msg.message( msg.SYSTEM_ERROR, "Parameter required must be bool", TypeError ) if len(short) == 0 and len(long) == 0: msg.message( msg.SYSTEM_ERROR, "At least one of the parameters (short, long) must be filled", ValueError ) self.short = short self.long = long self.description = description self.contains_value = contains_value self.required = required self.function_name_check_value = "" self.function_name = "" self.params = [] self.value = "" self.is_correct = True self.is_selected = False self.is_all_dependencies = True self.nothing_incompatible = True self.dependencies = [] self.incompatible = [] self.all_arguments = [] self.what_is_incompatible = None
def _answerGems(payload): print("Calling _answerGems") player = payload["player"] action = payload["action"] event = action["message"]["event"] if action["arg1"] == MESSAGE_NO: message(player, ["", MESSAGE_CLEAR]) return if random() < event["arg3"] / 35.0 + 0.04: if action["message"]["gems"] == 1: message(player, ["It was cursed!\n", MESSAGE_MORE, MESSAGE_CLEAR]) doCursedTreasure(payload) else: message(player, ["They were cursed!\n", MESSAGE_MORE, MESSAGE_CLEAR]) doCursedTreasure(payload) else: doGems(payload["player"], action["message"]["gems"], False) message(player, ["", MESSAGE_CLEAR])
def __init__(self, age=[], food=[], pos=[], speed=[], last_breed=[]): # These attributes apply to individual rabbits self.age = age self.food = food self.pos = pos # cpos: round up position to nearest grid point self.cpos = np.round(pos).astype(np.int) - 1 self.speed = speed self.last_breed = last_breed self.dead = False # Is this agent dead or alive? self.has_been_eaten = False # Has this agent been eaten? # Messages passed to this agent self.messages = message(self.pos, self.dead, self.has_been_eaten) #Rabbit messages contain one extra element: cpos self.messages.cpos = self.cpos # We've created a new instance so increment the counter self.__class__.num_rabbits = self.__class__.num_rabbits + 1
def doCursedTreasure(payload): player = payload["player"] location = player["location"] equipment = player["equipment"] stats = player["stats"] status = player["status"] if equipment["amulets"] >= floor(sqrt(location["circle"])): message(player, ["But your amulets saved you!\n", MESSAGE_MORE]) equipment["amulets"] -= floor(sqrt(location["circle"])) elif equipment["charms"] > 0: message(player, ["But your charm saved you!\n", MESSAGE_MORE]) equipment["charms"] = equipment["charms"] - 1 else: message(player, ["", MESSAGE_MORE]) dtemp = stats["energy"] - random() * (stats["max_energy"] + equipment["shield"]) / 3.0 if dtemp < stats["max_energy"] / 10.0: dtemp = min(stats["energy"], stats["max_energy"] / 10.0) doEnergy(player, dtemp, stats["max_energy"], equipment["shield"], 0, False) doAdjustedPoison(player, 0.25) message(player, ["", MESSAGE_CLEAR])
def _answerGold(payload): print("_answerGold") player = payload["player"] action = payload["action"] event = action["message"]["event"] if action["arg1"] == MESSAGE_NO: message(player, ["", MESSAGE_CLEAR]) return if random() < event["arg3"] / 35.0 + 0.04: # Never a single gold piece message(player, ["They were cursed!\n", MESSAGE_MORE, MESSAGE_CLEAR]) doCursedTreasure(payload) else: doGold(payload["player"], action["message"]["gold"], False) message(player, ["", MESSAGE_CLEAR])
def _answerPickupOneRing(payload): player = payload["player"] action = payload["action"] equipment = player["equipment"] if action["arg1"] == MESSAGE_NO: message(player, ["", MESSAGE_CLEAR]) return if equipment["ring_type"] != R_NONE: message(player, ["Your old ring no longer feels very precious to you and you throw it away.\n", MESSAGE_MORE, MESSAGE_CLEAR]) doRing(player, R_NONE, False) # roll up a ring if random() < 0.8: #regular ring */ doRing(player, R_DLREG, False) else: # bad ring */ doRing(player, R_BAD, False) message(player, ["", MESSAGE_CLEAR])
def doSmith(payload): print("doSmith") player = payload["player"] action = payload["action"] event = action["message"]["event"] stats = player["stats"] equipment = player["equipment"] # make a mutable copy of the current event. We will need it back after client response cpEvent = copy.deepcopy(event) stats["sin"] = 0 equipment["shield"] = 10000 equipment["sword"] = 5000 equipment["quicksilver"] = 5000 if stats["sin"] < random() * 2.0: message(player, ["Wayland Smith offers to improve a piece of your equipment!\n", MESSAGE_MORE]) if equipment["shield"] == 0 and \ equipment["sword"] == 0 and \ equipment["quicksilver"] == 0: message(player, ["He then sees you have none, guffaws and leaves.\n", MESSAGE_MORE, MESSAGE_CLEAR]) else: # We need to stack the event here otherwise we lose the event waylandEvent = newEvent(event["type"], event["arg1"], event["arg2"], event["arg3"], "") waylandEvent["message"] = {"type":"wayland","callback":"_answerWayland","event":cpEvent} if equipment["shield"] > 0: waylandEvent["message"]["shield"] = equipment["shield"] if equipment["sword"] > 0: waylandEvent["message"]["sword"] = equipment["sword"] if equipment["quicksilver"] > 0: waylandEvent["message"]["quicksilver"] = equipment["quicksilver"] stackEvent(payload, waylandEvent) else: message(player, ["Wayland Smith appears! He glares at you for a moment, then walks away.\n", MESSAGE_MORE, MESSAGE_CLEAR])
def receiveMessage(data): ui.addStatus("Receiving message") mesg = message(data) mesg.saveToFile() ui.addMessage(mesg) ui.updateMessageScreen()
def doMonsterHits(payload): inflict = -1 player = payload["player"] main = player["main"] equipment = player["equipment"] currency = player["currency"] location = player["location"] status = player["status"] stats = player["stats"] battle = player["battle"] opponent = battle["opponent"] moronmesg = [ "A Moron queries, 'what do u need to do to b a apprentice? I play for two years'\n", "A Moron remembers, 'in the good old days I ruled the realm, I had a MANs sword'\n", "A Moron threatens, 'dont mess with me man, I a l33t haxxor you n00b!'\n", "A Moron complains, 'aargh the lag! can u reset the server?'\n", "A Moron complains, 'this game needs cheats!'\n", "A Moron begs, 'steward can i please have 5k? ill pay you back.'\n", "A Moron complains, 'this game is too hard!'\n", "A Moron complains, 'this game is too easy!'\n", "A Moron complains, 'this game sucks!'\n", "A Moron snarls, 'i hate the changes. why cant they bring back the old version?'\n", "A Moron grumbles, 'wizards never do anything. why dont they add some pics?'\n", "A Moron queries, 'where do i buy stuff?'\n", "A Moron whimpers, 'how do I get rid of plague?'\n", "A Moron boasts, 'i have a level 8k char, just you wait!'\n", "A Moron wonders, 'what do i do with a virgin?\n", "A Moron squeals, 'ooh a smurf how cute!\n", "A Moron howls, 'but i don't want to read the rules!'\n", "A Moron asks, 'how come morons never run out?\n", "A Moron snivels, 'why is everything cursed? this curse rate is too high!'\n", "A Moron whines, 'how come a Troll hit me 5 times in a row? it must be a bug!'\n", "A Moron yells, 'HEY ALL COME CHEK OUT MY KNEW GAME!'\n", "A Moron slobbers, 'please make me an apprentice please please please'\n", "A Moron grouches, 'all the apprentices are power-hungry maniacs'\n", "A Moron asserts, 'I'm not a liar, honest!'\n", "A Moron sings, 'i love you! you love me!'\n", "A Moron exclaims, 'But I didn't MEAN to kill you!'\n", "A Moron curses, 'smurfing smurf smurf! why can't i swear?'\n", "A Moron demands, 'i want a bank to store gold so i can get a bigger shield!'\n", "A Moron bawls, 'Waa! My mommy died! Hey, will u make me apprentice?'\n", "A Moron warns, 'my dad is a wizard, don't mess with me!'\n", "A Moron leers, 'hey baby what's your sign?'\n", "A Moron drools, 'If I had a pick scroll, I'd pick you! What's your number?'\n" ] if stats["quickness"] <= 0: # kill a player at speed 0 with no TODO: network - saves time # also kill a player at speed 0 once monster inflicts 3 rounds # of fatigue so that people won't have to sit forever if battle["rounds"] > N_FATIGUE * 3: inflict = stats["energy"] + battle["force_field"] + 1.0 opponent["special_type"] = SM_NONE if opponent["special_type"] == SM_DARKLORD: # hits just enough to kill player */ inflict = stats["energy"] + battle["force_field"] + 1.0 elif opponent["special_type"] == SM_SHRIEKER: aNewEvent = newEvent(MONSTER_EVENT, MONSTER_SHRIEKER, 0, 0, "") if equipment["shield"] / stats["degenerated"] > 100000.0: # Shield too big. Summon a Cerberus aNewEvent["arg3"] = 96 elif equipment["quicksilver"] / stats["degenerated"] > 500.0: # Too much quicksilver. Summon a Jabberwock aNewEvent["arg3"] = 94 else: # Else summon a large monster aNewEvent["arg3"] = roll(70.0, 30.0) stackEvent(payload, aNewEvent) message(player, ["Shrieeeek!! You scared it, and it called one of its friends.\n", MESSAGE_MORE, MESSAGE_CLEAR]) doCancelMonster(player); return elif opponent["special_type"] == SM_BALROG: # if there is no experience to take, do damage if (random() > .33 and stats["experience"] > 0 and status["special_type"] < SC_KING): # take experience away inflict = (.001 + random() * .003) * stats["experience"] inflict = min(stats["experience"], inflict) # add to strength opponent["strength"] += min(.05 * equipment["shield"], floor(sqrt(stats["experience"] / 1800.0))) message(player, ["%s lashes his whip and absorbs %.0f experience points from you!\n" % (opponent["name"], inflict)]) doExperience(player, inflict *- 1, False) return elif opponent["special_type"] == SM_FAERIES: # holy water kills when monster tries to hit if equipment["holywater"] >= floor(sqrt(opponent["size"])): message(player, ["Your holy water killed it!\n"]) equipment["holywater"] -= floor(sqrt(opponent["size"])) opponent["energy"] = 0.0 return elif opponent["special_type"] == SM_TITAN: equipment["shield"] = ceil(equipment["shield"] * .99) inflict = floor(1.0 + random() * opponent["strength"]) inflict = min(inflict, stats["energy"]) if battle["force_field"] > 0.0: # inflict damage through force field message(player, ["%s punches through your pitiful force field and hit you for %.0f damage!\n" % (opponent["name"], inflict)]) battle["force_field"] = 0.0 doEnergy(player, stats["energy"] - inflict, stats["max_energy"], equipment["shield"], \ battle["force_field"], False) return else: message(player, ["%s hit you for %.0f damage and damages your shield!\n" % (opponent["name"], inflict)]) elif opponent["special_type"] == SM_NONE: a = "none" # normal hit elif random() < 0.2 or ( \ ((opponent["special_type"] == SM_CERBERUS) and \ (equipment["shield"] / stats["degenerated"] > 50000.0)) or \ ((opponent["special_type"] == SM_JABBERWOCK) and \ (equipment["quicksilver"] / stats["degenerated"] > 500.0))): # check for magic resistance if ((opponent["special_type"] != SM_MODNAR) and \ (opponent["special_type"] != SM_MORGOTH) and \ (opponent["special_type"] != SM_MORON) and \ (opponent["special_type"] != SM_SMURF) and \ (opponent["special_type"] != SM_IDIOT) and \ (opponent["special_type"] != SM_MIMIC) and \ (opponent["special_type"] != SM_SMEAGOL) and \ (opponent["special_type"] != SM_TROLL) and \ ((opponent["special_type"] == C_HALFLING) and (random() < 0.25))): message(player, ["%s tries to do something special, but you resist the attack!\n" % opponent["name"]]) return if ((opponent["special_type"] != SM_MODNAR) and (opponent["special_type"] != SM_MORON) and (opponent["special_type"] != SM_SMURF) and (opponent["special_type"] != SM_TROLL) and (opponent["special_type"] != SM_SMEAGOL) and ((opponent["special_type"] != SM_SARUMAN) or (equipment["amulets"] >= equipment["charms"])) and (opponent["special_type"] != SM_MIMIC)): # dwarves/halflings/expers use fewer charms dtemp = opponent["treasure_type"] - (floor((status["type"] + 1) * 1.5)) if dtemp < 1: dtemp = 1 dtemp2 = ceil(random() * floor(sqrt(opponent["size"]) * dtemp)) if dtemp2 < dtemp: dtemp2 = dtemp if equipment["charms"] >= dtemp2: # TODO: Log "%s, %s, %.0lf charms blocked size %.0lf attack (%.0lf TT %d)\n" message(player, ["%s tries to do something special, but you used %.0lf of your charms to block it!\n" % (opponent["name"], dtemp2)]) equipment["charms"] -= dtemp2 return elif opponent["special_type"] == SM_LEANAN: # takes some of the player's strength inflict = roll(1.0, opponent["size"] * 4) inflict = min(stats["level"], inflict) inflict = max(.02 * stats["strength"], inflict) if inflict > stats["strength"]: message(player, ["%s sucks all of your strength away, destroying your soul!\n" % opponent["name"]]) inflict = stats["strength"] else: message(player, ["%s sapped %0.f of your strength!\n" % (opponent["name"], inflict)]) doStrength(player, stats["max_strength"] - inflict, equipment["sword"], battle["strength_spell"], False) return elif opponent["special_type"] == SM_THAUMATURG: # transport player */ message(player, ["%s transported you!\n" % opponent["name"]]) aNewEvent = newEvent(MOVE_EVENT, 0, 0, A_FAR, "") doCancelMonster(player) return elif opponent["special_type"] == SM_SARUMAN: if equipment["charms"] > equipment["amulets"]: message(player, ["%s turns your charms into amulets and vice versa!\n" % opponent["name"]]) dtemp = equipment["charms"] equipment["charms"] = equipment["amulets"] equipment["amulets"] = dtemp elif equipment["palantir"]: # take away palantir message(player, ["Wormtongue stole your palantir!\n"]) doPalantir(player, False, False); elif random() > 0.5: # gems turn to gold message(player, ["%s transformed your gems into gold!\n" % opponent["name"]]) doGold(player, currency["gems"], False) doGems(c, currency["gems"], False) else: # scramble some stats message(player, ["%s casts a spell and you feel different!\n" % opponent["name"]]) doScrambleStats(player) return elif opponent["special_type"] == SM_VORTEX: # suck up some mana inflict = roll(0, 50 * opponent["size"]) inflict = min(stats["mana"], floor(inflict)) message(player, ["%s sucked up %.0f of your mana!\n" % (opponent["name"], inflict)]) doMana(player, -inflict, False) return elif opponent["special_type"] == SM_SUCCUBUS: # take some brains message(player, ["%s caresses you and whispers sweet nothings in your ear. You feel foolish!\n" % opponent["name"]]) stats["brains"] *= 0.8 return elif opponent["special_type"] == SM_TIAMAT: # take some gold and gems message(player, ["%s took half your gold and gems and flew off.\n" % opponent["name"]]) doGold(player, -floor(currency["gold"] / 2.0), False) doGems(player, -floor(currency["gems"] / 2.0), False) doCancelMonster(player) return elif opponent["special_type"] == SM_KOBOLD: # steal a gold piece and run if currency["gold"] > 0: message(player, ["%s stole one gold piece and ran away.\n" % opponent["name"]]) doGold(c, -1.0, False); doCancelMonster(player) return elif opponent["special_type"] == SM_SHELOB: # bite and (medium) poison message(player, ["%s has bitten and poisoned you!\n" % opponent["name"]]) doAdjustedPoison(player, 1.0) return elif opponent["special_type"] == SM_LAMPREY: if (random() * 10 < (opponent["size"] / 2) - 1): # bite and (small) poison message(player, ["%s bit and poisoned you!\n" % opponent["name"]]) doAdjustedPoison(player, 0.25) return elif opponent["special_type"] == SM_BONNACON: # fart and run message(player, ["%s farted and scampered off.\n" % opponent["name"]]) # damage from fumes doEnergy(player, stats["energy"] / 2.0, stats["max_energy"], equipment["shield"], battle["force_field"], False) doCancelMonster(player) return elif opponent["special_type"] == SM_SMEAGOL: if equipment["ring_type"] != R_NONE: # try to steal ring if random() > 0.1: message(player, ["%s tried to steal your ring, but was unsuccessful.\n" % opponent["name"]]) else: message(player, ["%s tried to steal your ring and ran away with it!\n" % opponent["name"]]) doRing(player, R_NONE, False) doCancelMonster(player) return elif status["type"] == C_HALFLING: if stats["sin"] > 2.0: message(player, ["%s cries, 'Thief! Baggins! We hates it, we hates it, for ever and ever!'\n" % opponent["name"]]) else: message(player, ["%s wonders, 'What has it got in itsss pocketsss?'\n" % opponent["name"]]) elif opponent["special_type"] == SM_CERBERUS: # take all metal treasures message(player, ["%s took all your metal treasures and ran off!\n" % opponent["name"]]) # TODO: sprintf(string_buffer, "%s, %s, cerbed.\n", # Do_log(COMBAT_LOG, &string_buffer); doEnergy(player, stats["energy"], stats["max_energy"], 0.0, battle["force_field"], False) doStrength(player, stats["max_strength"], 0.0, battle["strength_spell"], False) if stats["level"] > MIN_KING: doCrowns(player, -equipment["crowns"], False) doGold(c, -currency["gold"], False); doCancelMonster(player) return elif opponent["special_type"] == SM_UNGOLIANT: # (large) poison and take a quickness message(player, ["%s stung you with a virulent poison. You begin to slow down!\n" % opponent["name"]]) doAdjustedPoison(player, 5.0); doSpeed(player, stats["max_quickness"] - 1.0, equipment["quicksilver"], battle["speed_spell"], False) return elif opponent["special_type"] == SM_JABBERWOCK: if random() > .75 or equipment["quicksilver"] == 0: # fly away, and leave either a Jubjub bird or Bandersnatch message(player, ["%s flew away, and left you to contend with one of its friends.\n" % opponent["name"]]) aNewEvent = newEvent(MONSTER_EVENT, MONSTER_JABBERWOCK, 0, 0, "") if random.choice([True, False]): # Jubjub Bird aNewEvent["arg3"] = 55 else: # Bandersnatch aNewEvent["arg3"] = 71 # TODO: Deal with monster event doCancelMonster(player) return else: # burble, causing the player to lose quicksilver message(player, ["%s burbles as it drinks half of your quicksilver!\n" % opponent["name"]]) doSpeed(player, stats["max_quickness"], floor(equipment["quicksilver"] * .5), battle["speed_spell"], False) return elif opponent["special_type"] == SM_TROLL: # partially regenerate monster message(player, ["%s partially regenerated his energy!\n" % opponent["name"]]) opponent["energy"] += floor((opponent["max_energy"] - opponent["energy"]) / 2.0) opponent["strength"] = opponent["max_strength"] opponent["speed"] = opponent["max_speed"] battle["melee_damage"] = battle["skirmish_damage"] = 0.0 return elif opponent["special_type"] == SM_WRAITH: if not status["blind"]: # make blind message(player, ["%s blinded you!\n" % opponent["name"]]) status["blind"] = True opponent["name"] = "A monster" return elif opponent["special_type"] == SM_IDIOT: message(player, ["%s drools.\n" % opponent["name"]]) elif opponent["special_type"] == SM_MORON: # don't subject males to pickup line */ if stats["gender"] == "Female": msg = moronmesg[int(roll(0.0, len(moronmesg)))] else: msg = moronmesg[int(roll(0.0, len(moronmesg)-2))] message(player, [msg]) elif opponent["special_type"] == SM_SMURF: if random() < .5: if random() < .5: if stats["gender"] == "Female": message(player, ["%s sneers, 'Smurfette is prettier than you!'\n" % opponent["name"]]) elif status["type"] == C_MAGIC: message(player, ["%s yells out, 'Aah! I'm being attacked by Gargamel!'\n" % opponent["name"]]) elif status["type"] == C_HALFLING: message(player, ["%s wonders, 'Are you Angry Smurf?'\n" % opponent["name"]]) elif status["type"] == C_DWARF: message(player, ["%s howls, 'A giant! Run!'\n" % opponent["name"]]) else: message(player, ["%s snarls, 'Smurf you, you smurfing smurf!'\n" % opponent["name"]]) else: message(player, ["%s shrieks, 'Help, Papa Smurf, Help!'\n" % opponent["name"]]) else: message(player, ["%s sings, 'Lah lah la lah la la!'\n" % opponent["name"]]) elif opponent["special_type"] == SM_NAZGUL: # try to take ring if player has one if equipment["ring_type"] != R_NONE: # player has a ring message(player, ["%s demands your ring. Do you hand it over?\n" % opponent["name"]]) #TODO #if (Do_yes_no(c, &theAnswer) == S_NORM && theAnswer == 0) { theAnswer = random.choice(["Yes", "No"]) if theAnswer == "Yes": # take ring away doRing(player, R_NONE, False) battle["ring_in_use"] = False doCancelMonster(battle["player"]) return else: opponent["strength"] *= 1.1 + .4 * random() opponent["max_speed"] += 1 opponent["speed"] = opponent["speed"] + ceil((opponent["max_speed"] - opponent["speed"]) / 2) message(player, ["Angered by your refusal, %s attacks harder and faster!.\n" % opponent["name"]]) # also fall through to the curse # curse the player if equipment["blessing"] == True: message(player, ["%s hurls an eldritch curse at you! But you were saved by your blessing!\n" % opponent["name"]]) doBlessing(player, False, False); else: message(player, ["%s hurls an eldritch curse at you! You feel weak and ill!\n" % opponent["name"]]) doEnergy(player, (stats["energy"] + battle["force_field"]) / 2, \ stats["max_energy"] * .99, equipment["shield"], \ battle["force_field"], False) doAdjustedPoison(player, 0.5) return # fall through to here if monster inflicts a normal hit if inflict == -1: inflict = floor(1.0 + random() * opponent["strength"]) message(player, ["%s hit you for %.0f damage!\n" % (opponent["name"], inflict)]) if battle["force_field"] < inflict: doEnergy(player, stats["energy"] + battle["force_field"] - inflict, \ stats["max_energy"], equipment["shield"], 0, False) else: doEnergy(player, stats["energy"], stats["max_energy"], equipment["shield"], \ battle["force_field"] - inflict, False) return
def doTreasure(payload): player = payload["player"] event = payload["reaction"] location = player["location"] # make a mutable copy of the current event. We will need it back after client response cpEvent = copy.deepcopy(event) # Gold and gems only in circles that aren't fully beyond if ((event["arg2"] == 10) or ((location["circle"] <= D_BEYOND / 88.388 and random() > 0.65) and not(event["arg2"] > 0))): if event["arg3"] > 7: # gems gems = floor(roll(1.0, pow(event["arg3"] - 7.0, 1.8) * (event["arg1"] - 1.0) / 4.0)) if gems == 1: message(player, ["You have discovered a gem!\n"]) message(player, ["Do you want to pick it up?\n", MESSAGE_YESNO]) else: message(player, ["You have discovered %.0lf gems!\n" % gems]) message(player, ["Do you want to pick them up?\n", MESSAGE_YESNO]) event["message"] = {"type":"gems","gems":gems,"callback":"_answerGems","event":cpEvent} else: # gold gold = floor(roll(event["arg3"] * 10.0, event["arg3"] * event["arg3"] * 8.0 * (event["arg1"] - 1.0))) if gold == 1: gold = 2 message(player, ["You have found %.0lf gold pieces.\n" % gold]) message(player, ["Do you want to pick them up?\n", MESSAGE_YESNO]) event["message"] = {"type":"gold","gold":gold,"callback":"_answerGold","event":cpEvent} else: # Other treasure message(player, ["You have found some treasure. Do you want to inspect it?\n", MESSAGE_YESNO_NOALL]) event["message"] = {"type":"other","callback":"_answerOther","event":cpEvent}
def _answerReadScroll(payload): print("_answerReadScroll") player = payload["player"] action = payload["action"] event = action["message"]["event"] stats = player["stats"] status = player["status"] currency = player["currency"] if action["arg1"] == MESSAGE_NO: message(player, ["", MESSAGE_CLEAR]) return if event["arg2"] > 0 and event["arg2"] < 7: dtemp = event["arg2"] else: # pick a scroll type dtemp = int(roll(1, 6)) if dtemp == 1: print(stats["level"]) if stats["level"] <= 100 - currency["gems"]: doTreasureMap(payload) else: # character is too high level, pick another scroll dtemp = int(roll(2, 5)) if dtemp == 2: message(player, ["It throws up a shield for your next monster.\n", MESSAGE_MORE, MESSAGE_CLEAR]) status["shield_nf"] += 1 if dtemp == 3: message(player, ["It makes you faster for your next monster.\n", MESSAGE_MORE, MESSAGE_CLEAR]) status["haste_nf"] += 1 if dtemp == 4: message(player, ["It increases your strength for your next monster.\n", MESSAGE_MORE, MESSAGE_CLEAR]) status["strong_nf"] += 1 if dtemp == 5: message(player, ["It tells you how to pick your next monster.\n", MESSAGE_MORE, MESSAGE_CLEAR]) pickEvent = newEvent(MONSTER_EVENT, MONSTER_SPECIFY, 0, 0, "") stackEvent(payload, pickEvent) if dtemp == 6: message(player, ["It was cursed!\n", MESSAGE_MORE, MESSAGE_CLEAR]) doCursedTreasure(payload)
n2o_rad = np.ones(e5.nfull) * n2o n2_rad = np.ones(e5.nfull) * n2 o2_rad = np.ones(e5.nfull) * o2 o3_rad = e5.o3_mean[0, :] # Profiles on LES grid h2o_atmo = e5_at_z['qt'][0, :] co2_atmo = np.ones(grid.kmax) * co2 ch4_atmo = np.ones(grid.kmax) * ch4 n2o_atmo = np.ones(grid.kmax) * n2o n2_atmo = np.ones(grid.kmax) * n2 o2_atmo = np.ones(grid.kmax) * o2 o3_atmo = e5_at_z['o3'][0, :] # Write MicroHH input message('Writing forcings as LES input') # Update namelist variables nl_file = '{}.ini'.format(settings['case_name']) nl_backup = '{}.ini.bak'.format(settings['case_name']) shutil.copyfile(nl_file, nl_backup) nl = mht.read_namelist(nl_file) nl['grid']['ktot'] = grid.kmax nl['grid']['zsize'] = grid.zsize nl['time']['endtime'] = e5.time_sec.max() nl['force']['fc'] = e5.fc nl['radiation']['lon'] = settings['central_lon'] nl['radiation']['lat'] = settings['central_lat']
def two_Player_Loop(): """Create the loop for the two player game, will run until both players are dead.""" # Knowing when the game is over and should close game_over = False game_close = False #Knowing when either players have died snake1Dead = False snake2Dead = False #Starting points for both players x1 = settings.display_width / 2 - 10 y1 = settings.display_height / 2 x2 = settings.display_width / 2 + 10 y2 = settings.display_height / 2 x1_change = 0 y1_change = 0 x2_change = 0 y2_change = 0 snake_list = [] snake2_list = [] snake_length = 1 snake2_length = 1 snakeProperties.snake_speed = 30 snakeProperties.snake2_speed = 30 # Creating the food diameters foodx = round( random.randrange( 0, settings.display_width - snakeProperties.snake_block) / 10) * 10 foody = round( random.randrange(0, settings.display_height - snakeProperties.snake_block) / 10) * 10 food2x = round( random.randrange( 0, settings.display_width - snakeProperties.snake_block) / 10) * 10 food2y = round( random.randrange(0, settings.display_height - snakeProperties.snake_block) / 10) * 10 winner = False while not game_over: # Will run until the game should close, when the winner will be announced while game_close: display.fill(settings.black) messages.message(display, "You lost! Press Q to Quit or C to play again", settings.white, 200) if winner == True: messages.message(display, "Player 1 is WINNER!", settings.white, 50) else: messages.message(display, "Player 2 is WINNER!", settings.white, 50) pygame.display.update() for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_q: game_over = True game_close = False if event.key == pygame.K_c: snakeProperties.snake_speed = 15 snakeProperties.snake2_speed = 15 two_Player_Loop() # Player movements for event in pygame.event.get(): if event.type == pygame.QUIT: game_over = True if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: x1_change = -10 y1_change = 0 if event.key == pygame.K_RIGHT: x1_change = 10 y1_change = 0 if event.key == pygame.K_UP: x1_change = 0 y1_change = -10 if event.key == pygame.K_DOWN: x1_change = 0 y1_change = 10 if event.key == pygame.K_a: x2_change = -10 y2_change = 0 if event.key == pygame.K_d: x2_change = 10 y2_change = 0 if event.key == pygame.K_w: x2_change = 0 y2_change = -10 if event.key == pygame.K_s: x2_change = 0 y2_change = 10 # Check if player 1 leaves the screen if x1 >= settings.display_width or x1 < 0 or y1 >= settings.display_height or y1 < 0: winner = True snake1Dead = True # Check if player 2 leaves the screen if x2 >= settings.display_width or x2 < 0 or y2 >= settings.display_height or y2 < 0: winner = False snake2Dead = True x1 += x1_change y1 += y1_change x2 += x2_change y2 += y2_change display.fill(settings.black) # Draw food for both snakes pygame.draw.rect(display, settings.yellow, [ foodx, foody, snakeProperties.snake_block, snakeProperties.snake_block ]) pygame.draw.rect(display, settings.white, [ food2x, food2y, snakeProperties.snake_block, snakeProperties.snake_block ]) snake_head = [x1, y1] snake2_head = [x2, y2] snake_list.append(snake_head) snake2_list.append(snake2_head) if len(snake_list) > snake_length: del snake_list[0] if len(snake2_list) > snake2_length: del snake2_list[0] for x in snake_list[:-1]: if x == snake_head: winner = True snake1Dead = True for x in snake2_list[:-1]: if x == snake2_head: winner = False snake2Dead = True # Determine who won based on points if snake1Dead and snake2Dead: if snake_length > snake2_length: winner = True else: winner = False game_close = True snakeProperties.current_snake(display, settings.green, snakeProperties.snake_block, snake_list) snakeProperties.current_snake(display, settings.blue, snakeProperties.snake2_block, snake2_list) messages.current_score(display, snake_length - 1, 0) messages.current_score(display, snake2_length - 1, 300) pygame.display.update() # Checks if a snake has ate food if x1 == foodx and y1 == foody: foodx = round( random.randrange( 0, settings.display_width - snakeProperties.snake_block) / 10) * 10 foody = round( random.randrange( 0, settings.display_height - snakeProperties.snake_block) / 10) * 10 snake_length += 1 snakeProperties.snake_speed += 1 if x2 == food2x and y2 == food2y: food2x = round( random.randrange( 0, settings.display_width - snakeProperties.snake2_block) / 10) * 10 food2y = round( random.randrange( 0, settings.display_height - snakeProperties.snake2_block) / 10) * 10 snake2_length += 1 snakeProperties.snake2_speed += 1 clock.tick(snakeProperties.snake_speed) clock.tick(snakeProperties.snake2_speed) pygame.quit() quit()
def _answerOther(payload): print("_answerOther") druidmesg = [ "\tA blessing works perfectly if the bearer is free of any sin.\n", "\tA palantir can even pierce a cloak.\n", "\tA smurf berry a day keeps the medic away.\n", "\tA thaumaturgist can really put you in hot water!\n", "\tAll or nothing is your best friend against higher-level players.\n", "\tAmulets protect you from cursed treasure.\n", "\tBe careful to keep your sin low, or you may find yourself having a smurfy time.\n", "\tBe sure to rest if your speed drops from fatigue.\n", "\tBeware the Cracks of Doom!\n", "\tBeware the Jabberwock, my friend! The jaws that bite, the claws that catch!\n", "\tBlindness wears off eventually... eventually.\n", "\tBuy amulets to protect your charms from being used on treasure.\n", "\tCatching a unicorn requires the virtue and control of a saint.\n", "\tDo not meddle in the affairs of the Game Wizards, for they are subtle and quick to anger.\n", "\tDo not ask to speak to a Game Wizard without giving your reason up front, or he will ignore you.\n", "\tDon't beg the Game Wizards for help with the game.\n", "\tDon't swear on channel 1. Acronyms count, too.\n", "\tDwarves regenerate energy faster than other characters.\n", "\tElves are immune to the plague!\n", "\tExperimentos have been known to come back from the dead!\n", "\tFighting the Dark Lord leads to certain death...unless it's a Mimic!\n", "\tHalflings are said to be extremely lucky.\n", "\tIf the game isn't acting the way it should, report it to an Apprentice.\n", "\tIf your speed drops a lot, get rid of some of the heavy gold you are carrying.\n", "\tIt doesn't matter if you buy books one at a time or all at once.\n", "\tIt is impossible to teleport into the Dead Marshes except via the eagle Gwaihir.\n", "\tIt is very hard to walk through the Dead Marshes.\n", "\tKeep moving farther out, or you'll die from old age.\n", "\tListen to the Apprentices, they speak with the voice of the Game Wizards.\n", "\tMedics don't like liars, and punish accordingly.\n", "\tMedics don't work for charity.\n", "\tMerchants don't like players sleeping on their posts.\n", "\tOnly a moron would fight morons for experience.\n", "\tOnly a fool would dally with a Succubus or Incubus.\n", "\tOnly the Steward can give gold, but beware their smurfs if you ask too many times!\n", "\tParalyze can be a slow character's best friend.\n", "\tPicking up treasure while poisoned is bad for your health.\n", "\tReading the rules is a very good idea, and is often rewarded.\n", "\tRings of power contain much power, but much peril as well.\n", "\tSaintly adventurers may not have as much fun, but they tend to live longer.\n", "\tSmurfs may look silly, but they are actually quite deadly.\n", "\tStockpile amulets to protect your charms.\n", "\tTeleports are more efficient over short distances.\n", "\tThe corpse of a councilmember or a valar has never been found.\n", "\tThe One Ring is most likely to be found in the Cracks of Doom.\n", "\tThere are only three certainties in Phantasia : death, taxes, and morons.\n", "\tThe Game Wizards are always right.\n", "\tThe gods will revoke their blessing if you sin too much.\n", "\tThe nastier your poison, the more gold a medic will want to cure it.\n", "\tThere is a post in the Plateau of Gorgoroth that sells blessings.\n", "\tWant to live dangerously? Nick a shrieker.\n", "\tWhen all else fails ... use all or nothing.\n", "\tWhen starting, do not spend too much money at once, or you may be branded a thief.\n", "\tWizards have been known to be nice if you are polite without being obsequious.\n", ] player = payload["player"] action = payload["action"] event = action["message"]["event"] equipment = player["equipment"] location = player["location"] stats = player["stats"] battle = player["battle"] status = player["status"] if action["arg1"] == MESSAGE_NO: message(player, ["", MESSAGE_CLEAR]) return # make a mutable copy of the current event. We will need it back after client response cpEvent = copy.deepcopy(event) if random() < 0.08 and event["arg3"] != 4: message(player, ["It was cursed!\n"]) doCursedTreasure(payload) else: if event["arg2"] > 0 and event["arg2"] < 4: whichtreasure = event["arg2"] else: # pick a treasure whichtreasure = int(roll(1.0, 3.0)) if event["arg3"] == 1: # Treasure Type 1 if whichtreasure == 1: message(player, ["You've found a vial of holy water!\n", MESSAGE_MORE, MESSAGE_CLEAR]) equipment["holy_water"] += 1 elif whichtreasure == 2: dtemp = floor(sqrt(event["arg1"])) if dtemp < 1: dtemp = 1 if dtemp == 1: message(player, ["You've found an amulet of protection.\n", MESSAGE_MORE, MESSAGE_CLEAR]) else: message(player, ["You've found %.0lf amulets of protection.\n" % dtemp, MESSAGE_MORE, MESSAGE_CLEAR]) equipment["amulets"] += dtemp elif whichtreasure == 3: message(player, ["You have found a holy orb. You feel less sinful.\n", MESSAGE_MORE, MESSAGE_CLEAR]) doSin(player, -0.1) elif event["arg3"] == 2: # Treasure Type 2 if whichtreasure == 1: if stats["sin"] < 9.5 * random() + 0.5: message(player, ["You have encountered a druid who teaches you the following words of wisdom:\n"]) message(player, [druidmesg[int(roll(0.0, len(druidmesg)))], MESSAGE_MORE, MESSAGE_CLEAR]) doExperience(player, roll(0.0, 2000.0 + event["arg1"] * 750.0), False) else: message(player, ["You have encountered a druid. He runs in fear for his life!\n", MESSAGE_MORE, MESSAGE_CLEAR]) elif whichtreasure == 2: dtemp = floor((.5 + random()) * 15 * event["arg1"]) message(player, ["You've found a +%.0lf buckler.\n" % dtemp]) if dtemp >= equipment["shield"]: message(player, ["", MESSAGE_MORE, MESSAGE_CLEAR]) doEnergy(player, stats["energy"] - equipment["shield"] + dtemp, stats["max_energy"], dtemp, 0, False) else: message(player, ["But you already have something better.\n"]) message(player, ["", MESSAGE_MORE, MESSAGE_CLEAR]) elif whichtreasure == 3: if stats["poison"] > 0.0: doAdjustedPoison(player, -0.25) if stats["poison"] < 0.0: stats["poison"] = 0.0 message(player, ["You've found some smurf berries! You feel cured!\n", MESSAGE_MORE, MESSAGE_CLEAR]) else: message(player, ["You've found some smurf berries! You feel slightly better.\n", MESSAGE_MORE, MESSAGE_CLEAR]) else: message(player, ["You've found some smurf berries! You feel smurfy!\n", MESSAGE_MORE, MESSAGE_CLEAR]) battle["rounds"] /= 2 doSpeed(player, stats["max_quickness"], equipment["quicksilver"], 0, False) doEnergy(player, stats["energy"] + (stats["max_energy"] + equipment["shield"]) / 15.0 + stats["level"] / 3.0 + 2.0, stats["max_energy"], equipment["shield"], battle["force_field"], False) elif event["arg3"] == 3: # Treasure type 3 if whichtreasure == 1: message(player, ["You've met a hermit! You heal, gain mana, and lose sin.\n", MESSAGE_MORE, MESSAGE_CLEAR]) if stats["sin"] > 6.66: doSin(player, -1.0) else: doSin(player, -0.15 * stats["sin"]) ptype = getPlayerType(status["type"])["stats"][0] doMana(player, ptype["mana"]["increase"] / 2 * event["arg1"], False) doEnergy(player, stats["energy"] + (stats["max_energy"] + equipment["shield"]) / 7.0 + stats["level"] / 3.0 + 2.0, stats["max_energy"], equipment["shield"], battle["force_field"], False) elif whichtreasure == 2: if stats["gender"] == "Male": message(player, ["You have rescued a virgin. Do you wish you succumb to your carnal desires?\n", MESSAGE_YESNO]) else: message(player, ["You have rescued a virgin. Do you wish to sacrifice her now?\n", MESSAGE_YESNO]) # We need to stack the event here otherwise we lose the event readEvent = newEvent(event["type"], event["arg1"], event["arg2"], event["arg3"], "") readEvent["message"] = {"type":"other","callback":"_answerVirgin", "event":cpEvent} stackEvent(payload, readEvent) elif whichtreasure == 3: dtemp = floor((.5 + random()) * event["arg1"]) if dtemp < 1: dtemp = 1 message(player, ["You've found a +%.0lf short sword!\n" % dtemp]) if dtemp >= equipment["sword"]: doStrength(player, stats["max_strength"], dtemp, 0, False) else: message(player, ["But you already have something better.\n"]) message(player, ["", MESSAGE_MORE, MESSAGE_CLEAR]) elif event["arg3"] == 4: # Treasure type 4 if status["blind"]: message(player, ["You've found a scroll. Too bad you are blind!\n", MESSAGE_MORE, MESSAGE_CLEAR]) else: message(player, ["You've found a scroll. Will you read it?\n", MESSAGE_YESNO]) # We need to stack the event here otherwise we lose the event readEvent = newEvent(event["type"], event["arg1"], event["arg2"], event["arg3"], "") readEvent["message"] = {"type":"other","callback":"_answerReadScroll", "event":cpEvent} stackEvent(payload, readEvent) elif event["arg3"] == 5: # Treasure type 5 if whichtreasure == 1: message(player, ["You've discovered a power booster! Your mana increases.\n", MESSAGE_MORE, MESSAGE_CLEAR]) ptype = getPlayerType(status["type"])["stats"][0] doMana(player, ptype["mana"]["increase"] / 2 * event["arg1"], False) elif whichtreasure == 2: dtemp = floor((.5 + random()) * 50.0 * event["arg1"]) message(player, ["You've found a +%.0lf shield!\n" % dtemp]) if (dtemp >= equipment["shield"]): message(player, ["", MESSAGE_MORE, MESSAGE_CLEAR]) doEnergy(player, stats["energy"] - equipment["shield"] + dtemp, stats["max_energy"], dtemp, 0, False) else: message(player, ["But you already have something better.\n", MESSAGE_MORE, MESSAGE_CLEAR]) elif whichtreasure == 3: if stats["poison"] > 0.0: doAdjustedPoison(player, -1.0); message(player, ["You've discovered some lembas! You feel much better!\n", MESSAGE_MORE, MESSAGE_CLEAR]) if stats["poison"] < 0.0: stats["poison"] = 0.0 else: message(player, ["You've discovered some lembas! You feel energetic!\n", MESSAGE_MORE, MESSAGE_CLEAR]) battle["rounds"] = 0 doSpeed(player, stats["max_quickness"], equipment["quicksilver"], 0, False) doEnergy(player, stats["energy"] + (stats["max_energy"] + equipment["shield"]) / 3.0 + stats["level"] / 3.0 + 2.0, stats["max_energy"], equipment["shield"], battle["force_field"], False) elif event["arg3"] == 6: # Treasure type 6 if whichtreasure == 1: if status["blind"]: message(player, ["You've discovered a tablet! But you can't read it while blind!\n", MESSAGE_MORE, MESSAGE_CLEAR]) else: message(player, ["You've discovered a tablet! You feel smarter.\n", MESSAGE_MORE, MESSAGE_CLEAR]) ptype = getPlayerType(status["type"])["stats"][0] stats["brains"] += ptype["brains"]["increase"] * (.75 + random() / 2) * (1 + event["arg1"] / 10) if whichtreasure == 2: if stats["sin"] * random() < 2.0: message(player, ["You have come upon Treebeard! He gives you some miruvor and you feel tougher!\n", MESSAGE_MORE, MESSAGE_CLEAR]) ptype = getPlayerType(status["type"])["stats"][0] dtemp = ptype["energy"]["increase"] * (.75 + random() / 2) * (1 + event["arg1"] / 5) doEnergy(player, stats["max_energy"] + dtemp + equipment["shield"], stats["max_energy"] + dtemp, equipment["shield"], 0, False) else: message(player, ["You have come upon Treebeard! 'Hoom, hom!' he growls, and leaves.\n", MESSAGE_MORE, MESSAGE_CLEAR]) if whichtreasure == 3: dtemp = floor((.5 + random()) * 2 * event["arg1"]) message(player, ["You've found a +%.0lf long sword!\n" % dtemp]) if dtemp >= equipment["sword"]: message(player, ["", MESSAGE_MORE, MESSAGE_CLEAR]) doStrength(player, stats["max_strength"], dtemp, 0, False) else: message(player, ["But you already have something better.\n", MESSAGE_MORE, MESSAGE_CLEAR]) elif event["arg3"] == 7: # treasure type 7 if whichtreasure == 1: if stats["sin"] < 3 * random() / 5: message(player, ["You've found an Aes Sedai. She bows and completely cleanses you of the taint.\n", MESSAGE_MORE, MESSAGE_CLEAR]) doSin(player, -stats["sin"]) else: message(player, ["You've found an Aes Sedai. She sniffs loudly and cleanses some of your taint.\n", MESSAGE_MORE, MESSAGE_CLEAR]) if stats["sin"] > 4.5: doSin(player, -1.5) else: doSin(player, -0.33 * stats["sin"]) elif whichtreasure == 2: if stats["sin"] * random() < 2.5: message(player, ["You release Gwaihir and he offers you a ride. Do you wish to go anywhere?\n", MESSAGE_YESNO]) # We need to stack the event here otherwise we lose the event readEvent = newEvent(event["type"], event["arg1"], event["arg2"], event["arg3"], "") readEvent["message"] = {"type":"other","callback":"_answerGwaihir", "event":cpEvent} stackEvent(payload, readEvent) else: message(player, ["You release Gwaihir! He thanks you for his freedom and flies off.\n", MESSAGE_MORE, MESSAGE_CLEAR]) elif whichtreasure == 3: if stats["sin"] * random() < 2.0: message(player, ["You have come upon Hercules! He improves your strength and experience!\n", MESSAGE_MORE, MESSAGE_CLEAR]) ptype = getPlayerType(status["type"])["stats"][0] doStrength(player, stats["max_strength"] + ptype["strength"]["increase"] * (.75 + random() / 2) * (1 + event["arg1"] / 5), equipment["sword"], 0, False) doExperience(player, 10000 * location["circle"], False) else: message(player, ["You have come upon Hercules! He kicks sand in your face and walks off.\n", MESSAGE_MORE, MESSAGE_CLEAR]) elif event["arg3"] == 8: # treasure type 7 if whichtreasure == 1: message(player, ["You've discovered some athelas! You inhale its fragrance and feel wonderful!\n", MESSAGE_MORE, MESSAGE_CLEAR]) # remove blindness status["blind"] = False # zero out poison doPoison(player, -stats["poison"]) # make player immune to next plague at this circle doAdjustedPoison(player, -1.0); # heal the player completely and remove fatigue doEnergy(player, stats["max_energy"] + equipment["shield"], stats["max_energy"], equipment["shield"], 0, False) battle["rounds"] = 0 doSpeed(player, stats["max_quickness"], equipment["quicksilver"], 0, False) if whichtreasure == 2: if stats["sin"] * random() < 1.0: message(player, ["You have encountered Merlyn! He teaches you magic.\n", MESSAGE_MORE, MESSAGE_CLEAR]) ptype = getPlayerType(status["type"])["stats"][0] stats["magic_level"] += ptype["magic_level"]["increase"] * (.75 + random() / 2) * (1 + event["arg1"] / 10) doMana(player, ptype["mana"]["increase"] * event["arg1"], False) else: message(player, ["You have encountered Merlyn! He frowns and teleports off.\n", MESSAGE_MORE, MESSAGE_CLEAR]) if whichtreasure == 3: dtemp = (.75 + random() / 2) * .8 * (event["arg1"] - 9) if dtemp < 1: dtemp = 1 message(player, ["You have discovered %.0lf quicksilver!\n" % dtemp]) if dtemp >= equipment["quicksilver"]: message(player, ["", MESSAGE_MORE, MESSAGE_CLEAR]) doSpeed(player, stats["max_quickness"], dtemp, 0, False) else: message(player, ["But you already have something better.\n", MESSAGE_MORE, MESSAGE_CLEAR]) elif event["arg3"] >= 10 or event["arg3"] <= 14: # treasure types 10 - 14 if random() < 0.93 or event["arg2"] == 4: if event["arg3"] == 12: # Ungoliant treasure message(player, ["You've found a Silmaril! Its light quickens your step!\n", MESSAGE_MORE, MESSAGE_CLEAR]) ptype = getPlayerType(status["type"])["stats"][0] if stats["max_quickness"] < ptype["quickness"]["base"] + ptype["quickness"]["interval"]: doSpeed(player, stats["max_quickness"] + 2.0, equipment["quicksilver"], 0, False) else: doSpeed(player, stats["max_quickness"] + 1.0, equipment["quicksilver"], 0, False) return elif event["arg3"] == 11: # Saruman treasure if not equipment["palantir"]: message(player, ["You've acquired Saruman's palantir.\n", MESSAGE_MORE, MESSAGE_CLEAR]) doPalantir(player, True, False) return else: message(player, ["You've rescued Gandalf! He heals you, and casts some spells on you for your next combat!\n", MESSAGE_MORE, MESSAGE_CLEAR]) doEnergy(player, stats["max_energy"] + equipment["shield"], stats["max_energy"], equipment["shield"], 0, False) status["blind"] = False battle["rounds"] = 0 doSpeed(player, stats["max_quickness"], equipment["quicksilver"], 0, False) if stats["sin"] < random(): status["strong_nf"] += 1 if stats["sin"] < random(): status["haste_nf"] += 1 if stats["sin"] < random(): status["shield_nf"] += 1 if stats["sin"] * 2 < random(): pickEvent = newEvent(MONSTER_EVENT, MONSTER_SPECIFY, 0, 0, "") stackEvent(payload, pickEvent) return elif equipment["ring_type"] == R_NONE \ and status["special_type"] < SC_COUNCIL \ and event["arg3"] == 10: # Nazgul treasure message(player, ["You've discovered a ring of power. Will you pick it up?\n", MESSAGE_YESNO]) # We need to stack the event here otherwise we lose the event readEvent = newEvent(event["type"], event["arg1"], event["arg2"], event["arg3"], "") readEvent["message"] = {"type":"other","callback":"_answerPickupRingOfPower", "event":cpEvent} stackEvent(payload, readEvent) return elif event["arg3"] == 14: # Dark Lord treasure # drop a ring if status["special_type"] < SC_KING \ and event["arg1"] > 200 \ and equipment["ring_type"] != R_DLREG: doSin(player, random()) message(player, ["You've discovered The One Ring, the Ring to Rule Them All. Will you pick it up?\n", MESSAGE_YESNO]) # We need to stack the event here otherwise we lose the event readEvent = newEvent(event["type"], event["arg1"], event["arg2"], event["arg3"], "") readEvent["message"] = {"type":"other","callback":"_answerPickupOneRing", "event":cpEvent} stackEvent(payload, readEvent) return elif not equipment["palantir"]: message(player, ["You've acquired The Dark Lord's palantir.\n", MESSAGE_MORE, MESSAGE_CLEAR]) doPalantir(player, True, False) return elif status["special_type"] < SC_KING and equipment["ring_type"] != R_DLREG: message(player, ["You've discovered a ring of power. Will you pick it up?\n", MESSAGE_YESNO]) readEvent = newEvent(event["type"], event["arg1"], event["arg2"], event["arg3"], "") readEvent["message"] = {"type":"other","callback":"_answerPickupRingOfPower", "event":cpEvent} stackEvent(payload, readEvent) return # fall through to treasure type 9 if no treasure from above event["arg3"] = 9 if event["arg3"] == 9: # Treasure type 9 if whichtreasure == 1: if stats["level"] < MAX_STEWARD and \ stats["level"] > 10 and \ equipment["crowns"] < 1 and \ status["special_type"] != SC_STEWARD: message(player, ["You have found a staff!\n", MESSAGE_MORE, MESSAGE_CLEAR]) doCrowns(player, 1, False) elif location["circle"] > 26 and location["circle"] < 29: doVolcano(payload) else: doSmith(payload) elif whichtreasure == 2: message(player, ["You've received the blessing of the Valar for your heroism!\n", MESSAGE_MORE, MESSAGE_CLEAR]) doAwardBlessing(payload); elif whichtreasure == 3: dtemp = floor(roll(floor(2 * sqrt(event["arg1"])), event["arg3"] * .5 * (sqrt(event["arg1"])))) if dtemp < 1: dtemp = 1 if (dtemp == 1): message(player, ["You've discovered a charm!\n", MESSAGE_MORE, MESSAGE_CLEAR]) else: message(player, ["You've discovered %.0lf charms!\n" % dtemp, MESSAGE_MORE, MESSAGE_CLEAR]) equipment["charms"] += dtemp
def game_loop(): """Loop that will take place until the game is over.""" # To determine if the game is over and if it should close game_over = False game_close = False # Starting point of the X and Y coord's x1 = settings.display_width / 2 y1 = settings.display_height / 2 x1_change = 0 y1_change = 0 # Every coord in the snake and the length snake_list = [] snake_length = 1 # Creating food diameters foodx = round( random.randrange( 0, settings.display_width - snakeProperties.snake_block) / 10) * 10 foody = round( random.randrange(0, settings.display_height - snakeProperties.snake_block) / 10) * 10 while not game_over: while game_close: # Setting the game over screen display.fill(settings.black) messages.message(display, "You lost! Press Q to Quit or C to play again", settings.white, 100) pygame.display.update() # Determine if the user wants to play again or close the application for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_q: game_over = True game_close = False if event.key == pygame.K_c: settings.snake_speed = 15 game_loop() # Detecting input from the user for event in pygame.event.get(): if event.type == pygame.QUIT: game_over = True if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: x1_change = -10 y1_change = 0 if event.key == pygame.K_RIGHT: x1_change = 10 y1_change = 0 if event.key == pygame.K_UP: x1_change = 0 y1_change = -10 if event.key == pygame.K_DOWN: x1_change = 0 y1_change = 10 # Determine if the user has left the screen if x1 >= settings.display_width or x1 < 0 or y1 >= settings.display_height or y1 < 0: game_close = True x1 += x1_change y1 += y1_change display.fill(settings.black) # Drawing food pygame.draw.rect(display, settings.yellow, [ foodx, foody, snakeProperties.snake_block, snakeProperties.snake_block ]) snake_head = [x1, y1] snake_list.append(snake_head) if len(snake_list) > snake_length: del snake_list[0] for x in snake_list[:-1]: if x == snake_head: game_close = True #Displaying current score snakeProperties.current_snake(display, settings.green, snakeProperties.snake_block, snake_list) messages.current_score(display, snake_length - 1, 0) pygame.display.update() # Determine if the food has been eaten if x1 == foodx and y1 == foody: foodx = round( random.randrange( 0, settings.display_width - snakeProperties.snake_block) / 10) * 10 foody = round( random.randrange( 0, settings.display_height - snakeProperties.snake_block) / 10) * 10 snake_length += 1 snakeProperties.snake_speed += 1 clock.tick(snakeProperties.snake_speed) pygame.quit() quit()
def check(self): if self.ready: msg.message( msg.SYSTEM_ERROR, "After calling method check is not possible call method check", StandardError ) self.ready = True if self.is_empty: if not self.allowed_empty_arguments: msg.message(msg.ERROR, "You must set any arguments (for help -h)") return self again_continue = False set_value = None last_argument = self.execution_arguments[-1] for a in self.execution_arguments: if again_continue: again_continue = False continue if set_value is not None: r = set_value._setValue(a) r_e = r # error r_m = "" # message if isinstance(r, tuple): r_e = bool(r[0]) r_m = "\nMessage: %s"%str(r[1]) if r_e is False: p = [] if len(set_value._getShort()): p.append(self.short_prefix + set_value._getShort()) if len(set_value._getLong()): p.append(self.long_prefix + set_value._getLong()) msg.message( msg.ERROR, "%s can't accept this value: %s%s"%(set_value, a, r_m) ) set_value = None continue if self.arguments_for_checking.has_key(a): a_obj = self.arguments_for_checking[a] if a_obj in self.used_arguments: if a_obj._containsValue(): again_continue = True continue a_obj._setSelected() self.used_arguments.append(a_obj) if a_obj._containsValue(): set_value = a_obj elif a == last_argument: self.shadow_argument._setValue(a) if self.help_argument in self.used_arguments: self.__help() self.__checkDependencies() self.__checkIncompatible() return self
def doExperience(player, experience, force): stats = player["stats"] status = player["status"] battle = player["battle"] knight = player["knight"] equipment = player["equipment"] force_field = 0.0 strength_spell = 0.0 if "battle" in player.keys(): force_field = player["battle"]["force_field"] strength_spell = player["battle"]["strength_spell"] # add the experience stats["experience"] += experience # determine the new level newLevel = calcLevel(stats["experience"]) inc = newLevel - stats["level"] # if we've gone up any levels if inc > 0: # make sure we send the level information force = True stats["level"] = newLevel if status["type"] == C_EXPER: # roll a type to use for increment */ ptype = getPlayerType(int(roll(C_MAGIC, (C_HALFLING-C_MAGIC + 1))))["stats"][0] else: ptype = getPlayerType(status["type"])["stats"][0] doEnergy(player, stats["energy"] + ptype["energy"]["increase"] * inc, stats["max_energy"] + ptype["energy"]["increase"] * inc, equipment["shield"], force_field, False) doStrength(player, stats["max_strength"] + ptype["strength"]["increase"] * inc, equipment["sword"], strength_spell, False) doMana(player, ptype["mana"]["increase"] * inc, False) stats["brains"] += ptype["brains"]["increase"] * inc stats["magic_level"] = stats["magic_level"] + ptype["magic_level"]["increase"] * inc if (status["special_type"] == SC_KNIGHT): # knights may get more energy doEnergy(player, stats["energy"] - knight["knight_energy"] + floor(stats["max_energy"] / 4), stats["max_energy"], equipment["shield"], force_field, False) knight["knight_energy"] = floor(stats["max_energy"] / 4) if stats["level"] == 1000.0: # send congratulations message message(player, ["Congratulations on reaching level 1000! The throne awaits...\n", MESSAGE_MORE, MESSAGE_CLEAR]) if stats["level"] >= MAX_STEWARD and status["special_type"] == SC_STEWARD: # no longer able to be steward -- dethrone message(player, ["After level 200, you can no longer be steward.\n"]) # Do_dethrone(c); if stats["level"] >= MAX_KING and status["special_type"] == SC_KING: # no longer able to be king -- dethrone */ message(player, ["After level 2000, you can no longer be king or queen.\n"]) # Do_dethrone(c); status["special_type"] = SC_NONE if equipment["crowns"] > 0: message(player, ["Your crowns were cashed in.\n", MESSAGE_MORE, MESSAGE_CLEAR]) doGold(player, equipment["crowns"] * 5000.0, False) doCrowns(player, equipment["crowns"] * -1, False) #if status["special_type"] == SC_KING: #TODO: Do_dethrone(c); elif stats["level"] >= MAX_STEWARD and stats["level"] < 1000.0: message(player, ["Your staves were cashed in.\n", MESSAGE_MORE, MESSAGE_CLEAR]) doGold(player, equipment["crowns"] * 1000.0, False) doCrowns(player, equipment["crowns"] * -1, False) #if status["special_type"]== SC_STEWARD: #TODO: Do_dethrone(c); if stats["level"] >= 3000.0 and status["special_type"] < SC_COUNCIL: # if by some chance this person is king or knight, dethrone him */ #if status["special_type"] == SC_KING or status["special_type"] == SC_KNIGHT: #TODO: Do_dethrone(c); broadcast("The Council of the Wise announces its newest member, %s.\n" % player["main"]["name"])