#include #include #include #include #include struct damage { int intensity; apstring component; }; class SpaceShip //make sure it is on the board { public: SpaceShip::SpaceShip (); SpaceShip::SpaceShip (apstring newName, float Xcor, float Ycor, apstring alignment); //name has to be unique SpaceShip::SpaceShip (apstring newName, float Xcor, float Ycor, apstring alignment, apstring type); SpaceShip::SpaceShip (apstring newName,float Xcor,float Ycor,apstring alignment,apstring type,float XDim,float YDim,int HullMax,int PSMax,int LSMax,int RSMax,int IDSMax,int HI,int PSI,int LSI,int RSI,int IDSI,int autoRepair,int crew,int STEX,float maxAcc); float SpaceShip::XDim(); //returns X dimension float SpaceShip::YDim(); float SpaceShip::X(); //returns X position of upper left hand corner float SpaceShip::Y(); float SpaceShip::XV(); //returns X velocity float SpaceShip::YV(); apstring SpaceShip::alignment(); int SpaceShip::laserPower(); int SpaceShip::numSTEX(); int SpaceShip::numCrew(); void SpaceShip::outputCoordinates(); void SpaceShip::outputInfo(); //void SpaceShip::setAcc(int XAcc, int YAcc); void SpaceShip::hit(apstring component, int intensity); bool SpaceShip::isSuccessfullyInvaded(SpaceShip A); void SpaceShip::killSTEX(int dead); void SpaceShip::changePersonnel(int numSTEX,int numCrew/*,int numAmmo*/); void SpaceShip::repairPS(); bool SpaceShip::surviveCount(); apstring name; int counter; private: int SpaceShip::flowLeftOverFromRepair(apstring component, int amount); apstring myAlignment; apstring myType; float myXDim; float myYDim; int myHullMax; //maximum integrity int myPSMax; //maximum power system int myLSMax; //maximum laser system int myRSMax; //maximum rail system int myIDSMax; //maximum internal defence system int myHI; //Hull integrity int myPSI; //Power system integrity int myLSI; //laser system integrity int myRSI; //rail system integrity int myIDSI;//internal defence system, counts like a STEX defending can be repaired int myAutoRepair; //maximum repair fluid flow/count apstack myDamages; //damages to be accounted for at count int myCrew; //crew can defend but not board other ships int mySTEX; //Can board or defend, counts as 10 crew float myX; // position float myY; float myXV; //velocity Positive right float myYV; //velocity Positive down float myMaxAcc; //MaxAcceleration float myXAcc; // myMAXAcc >= (myXAcc^2 + myYAcc^2)^.5 float myYAcc; }; SpaceShip::SpaceShip () { counter = 0; name = "Should not exist"; myX = 0; myY = 0; myAlignment = "none"; apstring myType = "unknown"; myXDim = 20;myYDim = 10; myHullMax = 100; //standard values for defult constructor myPSMax = 100; myLSMax = 10; myRSMax = 10; myIDSMax = 2;myHI = myHullMax; myPSI = myPSMax; myLSI = myLSMax; myRSI = myRSMax; myIDSI = myIDSMax; myAutoRepair = 4;myCrew = 20; mySTEX = 8;myMaxAcc = 4.04; } SpaceShip::SpaceShip (apstring newName, float Xcor, float Ycor, apstring alignment) { counter = 0; name = newName; myX = Xcor; myY = Ycor; myAlignment = alignment; apstring myType = "unknown"; myXDim = 20; myYDim = 10; myHullMax = 100; //standard values for defult constructor myPSMax = 100; myLSMax = 10;myRSMax = 10; myIDSMax = 2;myHI = myHullMax; myPSI = myPSMax; myLSI = myLSMax; myRSI = myRSMax; myIDSI = myIDSMax; myAutoRepair = 4;myCrew = 20; mySTEX = 8;myMaxAcc = 4.04; } SpaceShip::SpaceShip (apstring newName, float Xcor, float Ycor, apstring alignment, apstring type) { counter = 0; name = newName; myX = Xcor; myY = Ycor; myAlignment = alignment; apstring myType = type; if (type == "sss") { myXDim = 10; myYDim = 20; myHullMax = 100; //standard values for defult constructor myPSMax = 100; myLSMax = 10; myRSMax = 10; myIDSMax = 2; myHI = myHullMax; myPSI = myPSMax; myLSI = myLSMax; myRSI = myRSMax; myIDSI = myIDSMax; myAutoRepair = 4; myCrew = 20; mySTEX = 8; myMaxAcc = 4.02; } else { myXDim = 20; myYDim = 10; myHullMax = 100; //standard values for defult constructor myPSMax = 100; myLSMax = 10; myRSMax = 10; myIDSMax = 2; myHI = myHullMax; myPSI = myPSMax; myLSI = myLSMax; myRSI = myRSMax; myIDSI = myIDSMax; myAutoRepair = 4; myCrew = 20; mySTEX = 8; myMaxAcc = 4.04; } } SpaceShip::SpaceShip (apstring newName,float Xcor,float Ycor,apstring alignment,apstring type,float XDim,float YDim,int HullMax,int PSMax,int LSMax,int RSMax,int IDSMax,int HI,int PSI,int LSI,int RSI,int IDSI,int autoRepair,int crew,int STEX,float maxAcc) { counter = 0; name = newName; myX = Xcor; myY = Ycor; myAlignment = alignment; myType = type; myXDim = XDim; myYDim = YDim; myHullMax = HullMax; myPSMax = PSMax; myLSMax = LSMax; myRSMax = RSMax; myIDSMax = IDSMax; myHI = HI;myPSI = PSI; myLSI = LSI; myRSI = RSI; myIDSI = IDSI; myAutoRepair = autoRepair; myCrew = crew; mySTEX = STEX; myMaxAcc = maxAcc; } float SpaceShip::XDim() { return myXDim; } float SpaceShip::YDim() { return myYDim; } float SpaceShip::X() { return myX; } float SpaceShip::Y() { return myY; } float SpaceShip::XV() { return myXV; } float SpaceShip::YV() { return myYV; } apstring SpaceShip::alignment() { return myAlignment; } int SpaceShip::laserPower() { return myLSI; } int SpaceShip::numSTEX() { return mySTEX; } int SpaceShip::numCrew() { return myCrew; } void SpaceShip::outputCoordinates() { cout< 0) //do something about excessive flow to repaired component { apstring component; int amount; cout<<"Component: (L for laser system, H for hull, P for power, must be capitalized) type 0 to use no more"<>component; cout<<"Intensity: (type 0 to use no more)"<>amount; if (amount == 0) break; else if (amount > 0) if (amount == flow) { flow = flowLeftOverFromRepair(component, amount); if (flow == 0) cout<<"Repairing system, no flow left to allocate."<>magnitude; if (magnitude == 0) { myX += myXV; myY += myYV; counter++; return true; } } while (magnitude <= myMaxAcc); cout<<"Type in direction of acceleration in degrees starting from +X direction CCwise"<>direction; if (direction < 0) direction = -(direction); direction = direction % 360; myXAcc = myMaxAcc * cos (direction); myYAcc = - myMaxAcc * sin (direction); //calculating net movement, and final velocity myX = myXAcc/2 + myXV; myY = myYAcc/2 + myYV; myXV += myXAcc; myYV += myYAcc; counter++; return true; } int SpaceShip::flowLeftOverFromRepair(apstring component, int amount) { if (component == "H") { myHI += amount; if (myHI == myHullMax) { cout<<"System fully repaired."< myHullMax) { int overflow = myHI - myHullMax; myHI = myHullMax; cout<<"System fully repaired, overflow expected."< myPSMax) { int overflow = myPSI - myPSMax; myPSI = myPSMax; cout<<"System fully repaired, overflow expected."< myLSMax) { int overflow = myLSI - myLSMax; myLSI = myLSMax; cout<<"System fully repaired, overflow expected."< myRSMax) { int overflow = myRSI - myRSMax; myRSI = myRSMax; cout<<"System fully repaired, overflow expected."< myIDSMax) { int overflow = myIDSI - myIDSMax; myIDSI = myIDSMax; cout<<"System fully repaired, overflow expected."<