Skip to content

Commit

Permalink
Leadership inherited by fittest follower, instead of oldest. Part of #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonrohrer committed May 15, 2020
1 parent 561cd2d commit 2771d59
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
3 changes: 3 additions & 0 deletions documentation/changeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ Server Fixes
--Property inherited by fittest close relative, instead of oldest close
relative. Part of #610

--Leadership inherited by fittest follower, instead of oldest. Part of #610





Expand Down
33 changes: 14 additions & 19 deletions server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,8 +1101,7 @@ char getFemale( LiveObject *inPlayer ) {



// find most fit offspring over 14 years old
// (old enough to manage ownership of property)
// find most fit offspring
static LiveObject *findFittestOffspring( int inPlayerID, int inSkipID ) {
LiveObject *fittestOffspring = NULL;
double fittestOffspringFitness = 0;
Expand All @@ -1113,10 +1112,7 @@ static LiveObject *findFittestOffspring( int inPlayerID, int inSkipID ) {
if( otherPlayer->id != inPlayerID &&
otherPlayer->id != inSkipID ) {

double age = computeAge( otherPlayer );

if( age > 14.0 &&
otherPlayer->fitnessScore > fittestOffspringFitness ) {
if( otherPlayer->fitnessScore > fittestOffspringFitness ) {

if( otherPlayer->lineage->getElementIndex( inPlayerID )
!= -1 ) {
Expand Down Expand Up @@ -15076,34 +15072,33 @@ static void leaderDied( LiveObject *inLeader ) {


// if leader is following no one (they haven't picked an heir to take over)
// have them follow their oldest direct follower now automatically
// have them follow their fittest direct follower now automatically

if( inLeader->followingID == -1 &&
directFollowers.size() > 0 ) {

LiveObject *oldestFollower = NULL;
double oldestAge = 0;
LiveObject *fittestFollower = NULL;
double fittestFitness = 0;

for( int i=0; i<directFollowers.size(); i++ ) {
LiveObject *otherPlayer = directFollowers.getElementDirect( i );

double age = computeAge( otherPlayer );

if( age > oldestAge ) {
oldestAge = age;
oldestFollower = otherPlayer;
if( otherPlayer->fitnessScore > fittestFitness ) {

fittestFitness = otherPlayer->fitnessScore;
fittestFollower = otherPlayer;
}
}

inLeader->followingID = oldestFollower->id;
inLeader->followingID = fittestFollower->id;

// they become top of tree, following no one
oldestFollower->followingID = -1;
oldestFollower->followingUpdate = true;
fittestFollower->followingID = -1;
fittestFollower->followingUpdate = true;

// inform them differently, instead of as part of
// group of followers below
oldFollowers.deleteElementEqualTo( oldestFollower );
oldFollowers.deleteElementEqualTo( fittestFollower );

const char *pronoun = "HIS";

Expand All @@ -15116,7 +15111,7 @@ static void leaderDied( LiveObject *inLeader ) {
"YOU HAVE INHERITED %s POSITION.",
leaderName, pronoun );

sendGlobalMessage( message, oldestFollower );
sendGlobalMessage( message, fittestFollower );
delete [] message;
}

Expand Down

0 comments on commit 2771d59

Please sign in to comment.