view atc_plane_specs.py @ 45:c93c3c910c85

Updated headers/copyrights ATC is now licensed under GPLv2 only
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Fri, 01 Jun 2007 02:04:37 -0400
parents b2ed1770081f
children
line wrap: on
line source

#/*
# * ATC - Air Traffic Controller simulation game
# *
# * Copyright (C) 2004-2007 Josef "Jeff" Sipek <jeffpc@josefsipek.net>
# *
# * This program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License version 2 as
# * published by the Free Software Foundation.
# *
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# * GNU General Public License for more details.
# */

import os
import sys
import atc_config

# all measurements in meters/sec or meters
plane_SPECS	= []

plane_dir = os.listdir(atc_config.plane_spec_dir)

for f in plane_dir:
	plane = {"fullname": str(None),
		 "name": str(None),
		 "heavy": False,
		 "jet": False,
		 "stall_speed": 0.0,
		 "climb_normal": 0.0,
		 "max_altitude": 0.0}
	
	fd = open(atc_config.plane_spec_dir + "/" + f, 'r')
	s = fd.read()
	fd.close()
	
	s = s.split("\n")
	for line in s:
		if (line.__len__()==0):
			continue
		
		cmd = line[:line.find(' ')-1]
		param = line[line.find(' ')+1:]
		
		if	cmd=="FullName":
			plane["fullname"] = param
		elif	cmd=="Name":
			plane["name"] = param
		elif	cmd=="Heavy":
			if (param.upper() == "YES"):
				plane["heavy"] = True
			else:
				plane["heavy"] = False
		elif	cmd=="Jet":
			if (param.upper() == "YES"):
				plane["jet"] = True
			else:
				plane["jet"] = False
		elif	cmd=="StallSpeed":
			plane["stall_speed"] = float(param)
		elif	cmd=="ClimbNormal":
			plane["climb_normal"] = float(param)
		elif	cmd=="MaxAltitude":
			plane["max_altitude"] = float(param)
		else:
			print "Error parsing " + f + ": Unknown statement"
			sys.exit(1)
	
	plane_SPECS.append(plane)
	print "Parsed and added " + plane["fullname"] + " aka. " + plane["name"]

print "Added " + str(plane_SPECS.__len__()) + " plane types"