src/book2/book2-ship-hull.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-hull.hpp"
00026 #include "traveller-constants.hpp"
00027 
00028 
00029 typedef struct standardHullRecord {
00030         double tonnage;
00031         double mainTonnage;
00032         double driveTonnage;
00033         double cost;
00034         int    time;
00035 } standardHullRecord;
00036 
00037 static standardHullRecord standardHulls[6]={
00038         {100,85,15,MCR 2,9},
00039         {200,185,15,MCR 8,11},
00040         {400,350,50,MCR 16,14},
00041         {600,515,85,MCR 48,22},
00042         {800,635,165,MCR 80,25},
00043         {1000,835,165,MCR 100,27}
00044         
00045 };
00046 
00047 
00048 book2ShipHull::book2ShipHull(){
00049 }
00050 
00051 book2ShipHull::book2ShipHull(int ix){
00052         if ( ix < 0 ) ix=0;
00053         if ( ix > 5 ) ix=5;
00054         
00055         standardHullRecord standardHull = standardHulls[ix];
00056         
00057         this->setSize(standardHull.tonnage);
00058         this->setMainCompartment(standardHull.mainTonnage);
00059         this->setDriveCompartment(standardHull.driveTonnage);
00060         this->setCost(standardHull.cost);
00061         this->setHullType(standard);
00062         
00063 }
00064 
00065 book2ShipHull::book2ShipHull(double m,double d){
00066         double total = m + d; 
00067         double hullCost =0;
00068         
00069         int    check; 
00070         
00071         check = (int)( total/100 );
00072         check = ( check > 5000 ? 5000 : check);
00078         if ( (check * 100) != (int) total) {
00079                 total = (double) check; 
00080                 m = total - d;
00081         }
00082 
00083         this->setSize(total);
00084         this->setMainCompartment(m);
00085         this->setDriveCompartment(d);
00086         
00087         hullCost = MCR 0.1 * total;
00088         this->setCost(hullCost);
00089         this->setHullType(custom);
00090         
00091 }
00092 
00093 void book2ShipHull::setSize(double s){
00094         size=s;
00095 }
00096 
00097 double book2ShipHull::getSize(){
00098         return size;
00099 }
00100 
00101 void book2ShipHull::setMainCompartment(double s){
00102         mainCompartment =s;
00103 }
00104 
00105 double book2ShipHull::getMainCompartment(){
00106         return mainCompartment;
00107 }
00108 
00109 void book2ShipHull::setDriveCompartment(double s){
00110         driveCompartment=s;
00111 }
00112 
00113 double book2ShipHull::getDriveCompartment(){
00114         return driveCompartment;
00115 }
00116 
00117 void book2ShipHull::setCost(double c){
00118         cost =c;
00119 }
00120 
00121 double book2ShipHull::getCost(){
00122         return cost;
00123 }
00124 
00125 void book2ShipHull::setHullType (typeHull t){
00126         hullType=t;
00127 }
00128 
00129 typeHull book2ShipHull::getHullType (){
00130         return hullType;
00131 }
00132 
00133 void book2ShipHull::isStreamlined (int s){
00134         streamlined = ( s==0? 0: 1);
00135 }
00136 
00137 int book2ShipHull :: isStreamlined (){
00138         return streamlined;
00139 }

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