def move(self, player): param = player.action.action_parameter if type(param) == int: road = player.truck.active_contract.game_map.current_node.roads[ param] elif type(param) == Road: road = param else: raise ValueError( "Attribute passed to move action was not an index or a road!") self.current_location = player.truck.active_contract.game_map.current_node time_taken = 0 fuel_efficiency = GameStats.getMPG( player.truck.speed) * GameStats.costs_and_effectiveness[ ObjectType.tires]['fuel_efficiency'][player.truck.tires] for route in self.current_location.roads: if route == road: # May need to be redone player.truck.active_contract.game_map.get_next_node() event = self.event_controller.event_chance( road, player, player.truck) time_taken = (road.length / player.truck.get_current_speed()) gas_used = (road.length / fuel_efficiency) / ( player.truck.body.max_gas * 100) player.truck.body.current_gas -= gas_used player.time -= time_taken return [road.road_type, event[0], event[1]]
def __init__(self, class_type): super().__init__() self.object_type = ObjectType.character stats = GameStats() self.health = stats.health[class_type] self.class_type = class_type self.initiative = 0 self.effects = list()
def __init__(self): super().__init__() self.gs = GameStats()
def init(self, team_name, color=[255, 255, 255], is_npc=False, position=None): GameObject.init(self, ObjectType.ship) # used by engine to track ships self.id = str(uuid4()) # used to match NPC client instances to npc ships self.is_npc = is_npc # allows players to track ships by random id # could be changed to be more readable. self.public_id = str(uuid4()) self.team_name = team_name if self.is_npc: self.color = None else: self.color = color self.max_hull = GameStats.get_ship_stat(ShipStat.hull, ModuleLevel.base) self.current_hull = self.max_hull self.engine_speed = GameStats.get_ship_stat(ShipStat.engine_speed, ModuleLevel.base) self.weapon_damage = GameStats.get_ship_stat(ShipStat.weapon_damage, ModuleLevel.base) self.weapon_range = GameStats.get_ship_stat(ShipStat.weapon_range, ModuleLevel.base) self.cargo_space = GameStats.get_ship_stat(ShipStat.cargo_space, ModuleLevel.base) self.mining_yield = GameStats.get_ship_stat(ShipStat.mining_yield, ModuleLevel.base) self.sensor_range = GameStats.get_ship_stat(ShipStat.sensor_range, ModuleLevel.base) self.module_0 = ModuleType.empty self.module_1 = ModuleType.locked self.module_2 = ModuleType.locked self.module_3 = ModuleType.locked self.module_0_level = ModuleLevel.base self.module_1_level = ModuleLevel.base self.module_2_level = ModuleLevel.base self.module_3_level = ModuleLevel.base self.action = PlayerAction.none self.action_param_1 = None self.action_param_2 = None self.action_param_3 = None self.move_action = None # ideally a dictionary of ItemType enums mapped to a count of the number of that item self.inventory = {} self.position = position self.notoriety = 0 self.legal_standing = LegalStanding.citizen self.bounty = 0 self.bounty_list = [] self.respawn_counter = -1 self.credits = 2000 self.passive_repair_counter = GameStats.passive_repair_counter
def init(self, level=1, position=None): if level == 1: name = "Police" elif level == 2: name = "Police Elite" elif level == 3: name = "Enforcer" super().init(team_name=name, is_npc=True, position=position) if level == 3: self.object_type = ObjectType.enforcer else: self.object_type = ObjectType.police # explicitly set ship stats if level >= 1: self.max_hull = GameStats.get_ship_stat(ShipStat.hull, ModuleLevel.base) self.current_hull = self.max_hull self.engine_speed = math.floor(GameStats.get_ship_stat(ShipStat.engine_speed, ModuleLevel.base) * 0.8) self.weapon_damage = math.floor(GameStats.get_ship_stat(ShipStat.weapon_damage, ModuleLevel.base) * 0.5) self.weapon_range = math.floor(GameStats.get_ship_stat(ShipStat.weapon_range, ModuleLevel.base) * 1.25) self.cargo_space = math.floor(GameStats.get_ship_stat(ShipStat.cargo_space, ModuleLevel.base) * 0.9) self.mining_yield = 0 self.sensor_range = math.floor(GameStats.get_ship_stat(ShipStat.sensor_range, ModuleLevel.base) * 1.25) if level >= 2: self.max_hull = GameStats.get_ship_stat(ShipStat.hull, ModuleLevel.one) self.current_hull = self.max_hull self.engine_speed = GameStats.get_ship_stat(ShipStat.engine_speed, ModuleLevel.one) self.weapon_damage = GameStats.get_ship_stat(ShipStat.weapon_damage, ModuleLevel.one) self.weapon_range = GameStats.get_ship_stat(ShipStat.weapon_range, ModuleLevel.one) self.sensor_range = GameStats.get_ship_stat(ShipStat.sensor_range, ModuleLevel.one) if level >= 3: self.max_hull = GameStats.get_ship_stat(ShipStat.hull, ModuleLevel.one) self.current_hull = self.max_hull self.engine_speed = GameStats.get_ship_stat(ShipStat.engine_speed, ModuleLevel.one) self.weapon_damage = GameStats.get_ship_stat(ShipStat.weapon_damage, ModuleLevel.one) self.weapon_range = GameStats.get_ship_stat(ShipStat.weapon_range, ModuleLevel.one) self.sensor_range = GameStats.get_ship_stat(ShipStat.sensor_range, ModuleLevel.one)
def __init__(self): super().__init__() self.gs = GameStats() self.all_effects = list()