def create_hero(self, name): if name == "timo": return Timo() elif name == "police": return Police() else: raise Exception(f"{name}英雄不在英雄工厂中")
def create_hero(self, name): if name == "Timo": return Timo() elif name == "Police": return Police() else: raise Exception("此英雄不在英雄工厂中!")
def create_hero(self, name): if name == "Timo": return Timo() elif name == "Police": return Police(); else: print(f"这个英雄:{name}不在英雄工厂")
def run_game(): ''' start the game and build an screen object ''' pygame.init() ai_settings = Settings() screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height)) pygame.display.set_caption("Rabbits in Tierpark") # create a player police = Police(ai_settings, screen) # create a group to store the bullets bullets = Group() rabbits = Group() # create a familiy of rabbits gf.create_fleet(ai_settings, screen, police, rabbits) # create stats data stats = GameStats(ai_settings) # start the inicial loop of the game while True: gf.check_events(ai_settings, screen, police, bullets) if stats.game_active: police.update() gf.update_bullets(rabbits, bullets) gf.update_rabbits(ai_settings, stats, screen, police, rabbits, bullets) gf.update_screen(ai_settings, screen, police, rabbits, bullets)
def police(): player = game.get_player() pol = Police() demand = pol.generate_requested_items(player.get_inventory()) return render_template('police.html', demand=json.dumps(demand), fskills=player.get_fighter_skills(), pskills=player.get_pilotskills())
def get_market_data(): global username if request.method == "GET": band1 = Bandit() trader1 = Trader() police1 = Police() cost1 = Cost() market_inventory = regions.child(currRegion).child('inventory').get() ship_inventory = users.child(username).child('ship').child( 'inventory').get() difficulty = users.child(username).child('difficulty').get() ship_cargo = users.child(username).child('ship').child('cargo').get() credit_val = users.child(username).child('credit').get() ship_health = users.child(username).child('ship').child('health').get() pilot_skill = users.child(username).child('skills').child( 'pilot').get() engineer = users.child(username).child('skills').child( 'engineer').get() fighter_skill = users.child(username).child('skills').child( 'fighter').get() merchant_skill = users.child(username).child('skills').child( 'merchant').get() fuel = users.child(username).child('ship').child('fuel').get() fuelcost = cost1.calculate_fuel(difficulty, credit_val) demand = band1.calculate_demand(difficulty, credit_val) repair = cost1.calculate_repair(difficulty, engineer, credit_val) price = trader1.item_to_sell(difficulty, credit_val) qty = trader1.qty item = trader1.item stolen = police1.stolen_item(ship_inventory) to_return = { 'username': username, 'currRegion': currRegion, 'market_inventory': market_inventory, 'ship_inventory': ship_inventory, 'cargo': ship_cargo, 'credit': credit_val, 'health': ship_health, 'demand': demand, 'qty': qty, 'item': item, 'price': price, 'eng': engineer, 'stolen': stolen, 'difficulty': difficulty, 'pilot': pilot_skill, 'fighter': fighter_skill, 'fuel': fuel, 'fuelcost': fuelcost, 'merch': merchant_skill, 'repair': repair } return to_return return None
def creatHero(self,name): if name == "ez": return if name == 'jinx': return Jinx() if name == 'police': return Police() if name == 'timo': return Timo() else: print('英雄不在英雄池中')
def create_hero(self,name): if name=="Jinx": return Jinx() elif name=="EZ": return EZ() elif name=="Timo": return Timo() elif name=="Police": return Police() else: raise Exception(f"没有此英雄,不在英雄工厂中")
def crate_hero(name): if name == "JINX": return JINX() elif name == "EZ": return EZ() elif name == "Timo": return Timo() elif name == "Police": return Police() else: raise Exception("英雄名称不存在")
def fight(): player = game.get_player() pol = Police() #if fight was successful if pol.get_result(player.get_fighter_skills(), True): #fight off police, get to travel to new region so update universe = game.get_universe() universe.set_currentregion(game.get_potential_region()) ship = game.get_player().get_ship() ship.set_fuel(game.get_potential_fuel()) return json.dumps({"result": "success"}) #change current region to random one regions = game.get_regions() universe = game.get_universe() rand = random.randint(0, len(regions) - 1) universe.set_currentregion(regions[rand]) #player loses 40 hit points on their ship ship = player.get_ship() hp_lost = 40 ship.set_health(ship.get_health() - hp_lost) #police confiscate items items = request.form["items"] items = json.loads(items) player.remove_from_inventory(items) return json.dumps({ "result": "fail", "health_penalty": hp_lost, "health": ship.get_health() })
def flee(): #whether or not player is successful, region remains same player = game.get_player() pol = Police() #False is for not using fighter skills if pol.get_result(player.get_pilotskills(), False): ship = game.get_player().get_ship() ship.set_fuel(game.get_potential_fuel()) return json.dumps({"result": "success"}) #credit penalty is 15-30% of player's credits credit_penalty = int(player.get_credits() * (random.randint(15, 30) / 100)) player.set_credits(player.get_credits() - credit_penalty) print(credit_penalty) print(player.get_credits()) #player loses 10 hit points on their ship ship = player.get_ship() hp_lost = 10 ship.set_health(ship.get_health() - hp_lost) #police confiscate items items = request.form["items"] items = json.loads(items) player.remove_from_inventory(items) return json.dumps({ "result": "fail", "health_penalty": hp_lost, "health": ship.get_health(), "credit_penalty": credit_penalty, "credits": player.get_credits() })
from police import Police from timo import Timo police = Police() timo = Timo() police.fight(timo.name, timo.hp, timo.power) police.speak_lines() timo.speak_lines()
def hook_process(self): police = Police() police_norm = police.get_police_norm()