src/book2/book2-ship.cpp

00001 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
00002 /*
00003  * frpuniverse
00004  * Copyright (C) Peter L. Berghold 2008 <Peter@Berghold.net>
00005  * 
00006  * frpuniverse is free software.
00007  * 
00008  * You may redistribute it and/or modify it under the terms of the
00009  * GNU General Public License, as published by the Free Software
00010  * Foundation; either version 2 of the License, or (at your option)
00011  * any later version.
00012  * 
00013  * frpuniverse is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License
00019  * along with frpuniverse.  If not, write to:
00020  *      The Free Software Foundation, Inc.,
00021  *      51 Franklin Street, Fifth Floor
00022  *      Boston, MA  02110-1301, USA.
00023  */
00024 
00025 #include "book2/book2-ship.hpp"
00026 
00027 
00028 
00029 
00030 book2Ship::book2Ship() : shipObj(){
00031 
00032         hull = new book2ShipHull();
00033         
00034 }
00035 
00036 book2Ship::book2Ship(int ix) : shipObj() {
00037         hull = new book2ShipHull(ix);
00038 }
00039 
00040 
00041 void book2Ship::addHull(book2ShipHull *h){
00042         hull = h;
00043 }
00044 
00045 void book2Ship::addHull (int ix){
00046         hull = new book2ShipHull(ix);
00047 }
00048 
00049 void book2Ship::addHull (double m,double d){
00050         hull = new book2ShipHull(m,d);
00051 }
00052 
00053 void book2Ship::addDrives(char p,char m, char j){
00054         drives = new book2DriveCompartment (p,m,j);
00055         double totalDriveMass = drives->totalMass();
00056         
00057         if (hull->getDriveCompartment() < totalDriveMass ){
00058                 double diff = totalDriveMass - hull->getDriveCompartment();
00059                 double newDriveCompartment = hull->getDriveCompartment() + diff;
00060                 double newMainCompartment = hull->getMainCompartment() - diff;
00061                 
00062                 hull->setMainCompartment(newMainCompartment);
00063                 hull->setDriveCompartment(newDriveCompartment);
00064         }
00065         
00066 }

Generated on Fri Mar 7 16:40:53 2008 for frpuniverse by  doxygen 1.4.7