def load_game(self, file_name): self.players = [] current_team_name = None current_team_obj = None with open(file_name, "r") as f: first_line = f.readline() if first_line[0] == "M": self.map_name = first_line.split(":")[1].rstrip() self.world = World(self.map_name) print("creating map from " + self.map_name) self.set_color_prefs(Game.default_prefs) for line in f: # print(line[0]) if line[0] == "t": current_team_name = line.split("-")[1].split("@")[0] host, port = line.split("-")[1].split("@")[1].split(":") port = int(port) print("creating new team: " + current_team_name) current_team_obj = Team(self.world, current_team_name) self.add_player(Server_Facing_Networked_Player(self, current_team_obj, host, port)) elif line[0] == "m": loc = location(line.split("@")[1][:-1]) current_team_obj.create_mech(line[2:6], loc) elif line[0] == "s": loc = location(line.split("@")[1][:-1]) self.world.create_station_at(loc, current_team_obj)
from Game import Game from Player import Player from Server_Facing_Networked_Player import Server_Facing_Networked_Player from Hot_Seat_Player import Hot_Seat_Player from Team import Team import os os.system("printf '\e[8;32;100t'") g = Game("map1long.png") local = Team(g.world, "Local") g.add_player(Hot_Seat_Player(g, local)) remote = Team(g.world, "Remote") g.add_player(Server_Facing_Networked_Player(g, remote, "localhost", 42069)) remote.create_mech("RRGG", "A3") remote.create_mech("RRGG", "C5") local.create_mech("RRBB", "v7") local.create_mech("RRGG", "x5") local.create_mech("RRGG", "z18") third = Team(g.world, "Third") g.add_player(Server_Facing_Networked_Player(g, third, "localhost", 42070)) third.create_mech("RRGG", "w20") third.create_mech("RRGG", "A22") third.create_mech("RRGG", "s18") g.set_color_prefs(Game.default_prefs) g.start()
from Game import Game from Player import Player from Stupid_AI import Stupid_AI from Hot_Seat_Player import Hot_Seat_Player from Team import Team import os os.system("printf '\e[8;32;100t'") g = Game("map1long.png") human = Team(g.world, "Humans") g.add_player(Hot_Seat_Player(g, human)) robots = Team(g.world, "Robots") g.add_player(Stupid_AI(g, robots)) robots.create_mech("RRGG", "A3") robots.create_mech("RRGG", "C5") human.create_mech("RRBB", "v7") human.create_mech("RRGG", "x5") human.create_mech("RRGG", "z18") g.set_color_prefs(Game.default_prefs) g.start()