#include <star.hpp>
Inheritance diagram for star:
As such a star can be part of an orbit plane and also contain it's own orbit plane.
The "Scouts" volume of Traveller was used as a baseline guide for the methodology used generate star information. This will be revisited over time and is subject to change.
Definition at line 66 of file star.hpp.
Public Member Functions | |
star () | |
star (star *s) | |
void | setOrbit (int ix) |
int | getOrbit () |
void | generateStarInfo () |
void | generateStarInfo (star *) |
char * | toXML () |
void | setSize (int s) |
int | getSize () |
void | setType (int t) |
int | getType () |
void | setSpectralClass (int c) |
int | getSpectralClass () |
void | setMinOrbitNumber (int m) |
int | getMinOrbitNumber () |
void | setHabitableOrbit (int h) |
int | getHabitableorbit () |
void | setMaxOrbits (int m) |
int | getMaxOrbits () |
void | setGasGiants (int g) |
int | getGasGiants () |
void | setPlanetoid (int p) |
int | getPlanetoid () |
void | placeCompanion (star *s, int x) |
int | hasCloseCompanion () |
void | setOrbits (orbitPlane *) |
orbitPlane * | getOrbits () |
char * | nodeSignature () |
star::star | ( | ) |
If no parameters are passed, then this is likely supposed to be the primary star....
Definition at line 55 of file star.cpp.
References generateStarInfo().
00055 :orbitPlace(){ 00056 orbits= new orbitPlane(); 00057 this->generateStarInfo(); 00058 closeCompanionPresent=0; 00059 }
Here is the call graph for this function:
star::star | ( | star * | s | ) |
For a subordinate star, we pass the parent star to the constructor to allow the appropriate dms to be calculated from the attributes of the parent star
s | is of type star and is the star the object is subordinate to |
Definition at line 61 of file star.cpp.
References generateStarInfo().
00061 : orbitPlace() { 00062 orbits=new orbitPlane(); 00063 this->generateStarInfo(s); 00064 closeCompanionPresent=0; 00065 00066 }
Here is the call graph for this function:
void star::generateStarInfo | ( | star * | ) |
Generate a subordinate star's information.
Definition at line 605 of file star.cpp.
References size_roll, and type_roll.
00605 { 00606 size_roll = s->size_roll + d2d6(); 00607 type_roll = s->type_roll + d2d6(); 00608 int dm; 00609 00610 size = primarySizeLookup(size_roll); 00611 type = primaryTypeLookup(type_roll); 00612 00613 spectral = ( d1d6() > 3 ? 5 : 0 ); 00614 min_orbit_number = this->calculateMinOrbit(); 00615 habitable_orbit = this->calculateHabitableOrbit(); 00616 00617 // Calculate a DM based on star size. 00618 dm = ( size == STAR_SIZE_III ? 4 : 00619 ( ((STAR_SIZE_Ia <= size ) && ( size <= STAR_SIZE_II)) ? 00620 8:0 ) ); 00621 // Add to or subtract from that DM based on type. 00622 dm = dm + ( type == STAR_TYPE_M ? -4 : 00623 ( type == STAR_TYPE_K ? -2 : 0 ) ); 00624 max_orbits = d2d6() + dm; 00625 // Eliminate negative values if present. 00626 max_orbits = ( max_orbits >= 0 ? max_orbits : 0 ); 00627 00628 // Determine if gas giants are present and how many 00629 if ( d2d6() < 10 ) { 00630 int roll = d2d6(); 00631 gas_giants = 00632 ( roll < 4 ? 1 : 00633 ( (( roll == 4) || (roll == 5 )) ? 2 : 00634 ( ( roll == 6) || (roll == 7) ? 3 : 4 ) ) ); 00635 00636 00637 } else { 00638 gas_giants=0; 00639 } 00640 00641 gas_giants = ( gas_giants > max_orbits ? max_orbits : gas_giants); 00642 00643 // Determine if planetoid belts are present and how many 00644 00645 dm = gas_giants; 00646 00647 if ( (d2d6() + dm ) > 6 ) { 00648 planetoid = 0; 00649 } else { 00650 int roll= d2d6() + roll; 00651 planetoid = ( roll > 6 ? 1 : 2 ) ; 00652 } 00653 00654 planetoid = ( (gas_giants + planetoid) > max_orbits? (max_orbits-gas_giants) : 00655 planetoid); 00656 00657 00658 00659 }
void star::generateStarInfo | ( | ) |
Generate a primary star's information.
Definition at line 551 of file star.cpp.
Referenced by star().
00551 { 00552 int dm; 00553 size_roll = d2d6(); 00554 type_roll = d2d6(); 00555 size = primarySizeLookup(size_roll); 00556 type = primaryTypeLookup(type_roll); 00557 00558 spectral = ( d1d6() > 3 ? 5 : 0 ); 00559 min_orbit_number = this->calculateMinOrbit(); 00560 habitable_orbit = this->calculateHabitableOrbit(); 00561 00562 // Calculate a DM based on star size. 00563 dm = ( size == STAR_SIZE_III ? 4 : 00564 ( ((STAR_SIZE_Ia <= size ) && ( size <= STAR_SIZE_II)) ? 00565 8:0 ) ); 00566 // Add to or subtract from that DM based on type. 00567 dm = dm + ( type == STAR_TYPE_M ? -4 : 00568 ( type == STAR_TYPE_K ? -2 : 0 ) ); 00569 max_orbits = d2d6() + dm; 00570 // Eliminate negative values if present. 00571 max_orbits = ( max_orbits >= 0 ? max_orbits : 0 ); 00572 00573 // Determine if gas giants are present and how many 00574 if ( d2d6() < 10 ) { 00575 int roll = d2d6(); 00576 gas_giants = 00577 ( roll < 4 ? 1 : 00578 ( (( roll == 4) || (roll == 5 )) ? 2 : 00579 ( ( roll == 6) || (roll == 7) ? 3 : 4 ) ) ); 00580 00581 00582 } else { 00583 gas_giants=0; 00584 } 00585 00586 gas_giants = ( gas_giants > max_orbits ? max_orbits : gas_giants); 00587 00588 // Determine if planetoid belts are present and how many 00589 00590 dm = gas_giants; 00591 00592 if ( (d2d6() + dm ) > 6 ) { 00593 planetoid = 0; 00594 } else { 00595 int roll= d2d6() + roll; 00596 planetoid = ( roll > 6 ? 1 : 2 ) ; 00597 } 00598 00599 planetoid = ( (gas_giants + planetoid) > max_orbits? (max_orbits-gas_giants) : 00600 planetoid); 00601 00602 00603 }
Here is the caller graph for this function:
int star::getGasGiants | ( | ) | [inline] |
int star::getHabitableorbit | ( | ) | [inline] |
Get the habitable orbit value See caveats with respect to setHabitableOrbit().
Definition at line 220 of file star.hpp.
int star::getMaxOrbits | ( | ) | [inline] |
int star::getMinOrbitNumber | ( | ) | [inline] |
int star::getOrbit | ( | ) | [inline] |
Get the star's orbit. This is not valid for a primary star.
Reimplemented from orbitPlace.
Definition at line 102 of file star.hpp.
References sparseVectorNode::getIndex().
00102 { 00103 return this->getIndex(); 00104 };
Here is the call graph for this function:
orbitPlane * star::getOrbits | ( | ) |
Get the orbit plane.
Definition at line 763 of file star.cpp.
int star::getPlanetoid | ( | ) | [inline] |
int star::getSize | ( | ) | [inline] |
int star::getSpectralClass | ( | ) | [inline] |
int star::getType | ( | ) | [inline] |
int star::hasCloseCompanion | ( | ) |
char * star::nodeSignature | ( | ) |
Overloaded method to return the "signature" for this object. In this case the string "star"
Reimplemented from orbitPlace.
Definition at line 772 of file star.cpp.
void star::placeCompanion | ( | star * | s, | |
int | x | |||
) |
Place a companion star around this this star.
s | Pointer to the companion star being placed. | |
x | either a 2 or a 3 depending on which companion this is... |
Definition at line 661 of file star.cpp.
References sparseVector::addAt(), gas_giants, habitable_orbit, max_orbits, and planetoid.
00661 { 00662 int dm = ( x == 3 ? 4:0); 00663 int dist; 00664 00665 switch (d2d6()+dm){ 00666 case 0: 00667 case 1: 00668 case 2: 00669 case 3: 00670 closeCompanionPresent=1; 00671 closeCompanion=s; 00672 break; 00673 case 4: 00674 if ( min_orbit_number > 1 ) { 00675 closeCompanionPresent=1; 00676 closeCompanion=s; 00677 } else { 00678 orbits->addAt(1,s); 00679 min_orbit_number = 2; 00680 } 00681 break; 00682 case 5: 00683 if ( min_orbit_number > 2 ) { 00684 closeCompanionPresent=1; 00685 closeCompanion=s; 00686 } else { 00687 orbits->addAt(2,s); 00688 min_orbit_number=3; 00689 } 00690 break; 00691 case 6: 00692 if ( min_orbit_number > 3 ) { 00693 closeCompanionPresent=1; 00694 closeCompanion=s; 00695 } else { 00696 orbits->addAt(3,s); 00697 min_orbit_number=4; 00698 } 00699 break; 00700 case 7: 00701 dist = 4 + d1d6(); 00702 if ( min_orbit_number > dist ) { 00703 closeCompanionPresent=1; 00704 closeCompanion=s; 00705 } else { 00706 orbits->addAt(dist,s); 00707 } 00708 break; 00709 case 8: 00710 dist= 5 + d1d6(); 00711 if ( min_orbit_number > dist ) { 00712 closeCompanionPresent=1; 00713 closeCompanion=s; 00714 } else { 00715 orbits->addAt(dist,s); 00716 } 00717 break; 00718 case 9: 00719 dist = 6 + d1d6(); 00720 if ( min_orbit_number > dist ) { 00721 closeCompanionPresent=1; 00722 closeCompanion=s; 00723 } else { 00724 orbits->addAt(dist,s); 00725 } 00726 break; 00727 case 10: 00728 dist = 7 + d1d6(); 00729 if ( min_orbit_number > dist ) { 00730 closeCompanionPresent=1; 00731 closeCompanion=s; 00732 } else { 00733 orbits->addAt(dist,s); 00734 } 00735 break; 00736 case 11: 00737 dist = 8+ d1d6(); 00738 if ( min_orbit_number > dist ) { 00739 closeCompanionPresent=1; 00740 closeCompanion=s; 00741 } else { 00742 orbits->addAt(dist,s); 00743 } 00744 break; 00745 default: 00746 dist = 20+d2d6(); 00747 orbits->addAt(dist,s); 00748 break; 00749 }; 00750 00751 // Let's prevent some cosmological imposibilities... 00752 // 00753 if ( closeCompanionPresent == 1 ) { 00754 closeCompanion->habitable_orbit=-1; // Take away the habitable orbit if it existed. 00755 closeCompanion->gas_giants=0; 00756 closeCompanion->planetoid=0; 00757 closeCompanion->max_orbits=0; 00758 } 00759 00760 00761 }
Here is the call graph for this function:
void star::setGasGiants | ( | int | g | ) | [inline] |
void star::setHabitableOrbit | ( | int | h | ) | [inline] |
Set what the habitiable orbit number is for this star. In reality this is actually a band of "orbits" that can be part of the habitable zone.
This will need to be revisited later.
h | Integer value to set the habitable orbit to. |
remove inlining
Definition at line 210 of file star.hpp.
void star::setMaxOrbits | ( | int | m | ) | [inline] |
void star::setMinOrbitNumber | ( | int | m | ) | [inline] |
void star::setOrbit | ( | int | ix | ) | [inline] |
Set this star's orbit. Note: this is invalid for a primary star.
ix | integer value to set the orbit to. |
Reimplemented from orbitPlace.
Definition at line 92 of file star.hpp.
References sparseVectorNode::setIndex().
00092 { 00093 this->setIndex(ix); 00094 }
Here is the call graph for this function:
void star::setOrbits | ( | orbitPlane * | ) |
Set the orbit plane member
pointer | to an orbitPlane |
Definition at line 767 of file star.cpp.
void star::setPlanetoid | ( | int | p | ) | [inline] |
void star::setSize | ( | int | s | ) | [inline] |
void star::setSpectralClass | ( | int | c | ) | [inline] |
Set the spectral class for this star
c | the integer value for the spectral class of this star |
add support of spectral classifications of other than 0 and 5
change the spectral classifications from integer values to decimal values
remove inlining.
Definition at line 172 of file star.hpp.
void star::setType | ( | int | t | ) | [inline] |
char * star::toXML | ( | ) |
Extract the star's information and output a very long XML file for it.
Definition at line 540 of file star.cpp.
00540 { 00541 char *buffer; 00542 00543 buffer=createStartElement("star"); 00544 buffer=addXMLElement(buffer,"size",starSize(size)); 00545 buffer=addXMLElement(buffer,"type",starType(type)); 00546 00547 return buffer; 00548 00549 }