Beispiel #1
0
int faction::response_time(game *g)
{
 int base = abs(mapx - g->levx);
 if (abs(mapy - g->levy) > base)
  base = abs(mapy - g->levy);
 if (base > size)	// Out of our sphere of influence
  base *= 2.5;
 base *= 24;	// 24 turns to move one overmap square
 int maxdiv = 10;
 if (goal == FACGOAL_DOMINANCE)
  maxdiv += 2;
 if (has_job(FACJOB_CARAVANS))
  maxdiv += 2;
 if (has_job(FACJOB_SCAVENGE))
  maxdiv++;
 if (has_job(FACJOB_MERCENARIES))
  maxdiv += 2;
 if (has_job(FACJOB_FARMERS))
  maxdiv -= 2;
 if (has_value(FACVAL_EXPLORATION))
  maxdiv += 2;
 if (has_value(FACVAL_LONERS))
  maxdiv -= 3;
 if (has_value(FACVAL_TREACHERY))
  maxdiv -= rng(0, 3);
 int mindiv = (maxdiv > 9 ? maxdiv - 9 : 1);
 base /= rng(mindiv, maxdiv);// We might be in the field
 base -= likes_u;	// We'll hurry, if we like you
 if (base < 100)
  base = 100;
 return base;
}
Beispiel #2
0
END_TEST

START_TEST(has_job_test)
  {
  all_jobs alljobs;
  struct job *test_job = job_alloc();
  int result;


  result = has_job(NULL,test_job);
  fail_unless(result != PBSE_NONE, "null input array fail");

  result = has_job(&alljobs,NULL);
  fail_unless(result != PBSE_NONE, "NULL input job fail");

  insert_job(&alljobs, test_job);
  result = has_job(&alljobs, test_job);
  fail_unless(result == TRUE, "has_job fail");
  }
bool faction::matches_us(faction_value v)
{
    int numvals = 2;
    if (job2 != FACJOB_NULL) {
        numvals++;
    }
    for (int i = 0; i < NUM_FACVALS; i++) {
        if (has_value(faction_value(i))) {
            numvals++;
        }
    }
    if (has_job(FACJOB_DRUGS) && v == FACVAL_STRAIGHTEDGE) { // Mutually exclusive
        return false;
    }
    int avggood = (good / numvals + good) / 2;
    int avgstrength = (strength / numvals + strength) / 2;
    int avgsneak = (sneak / numvals + sneak / 2);
    int avgcrime = (crime / numvals + crime / 2);
    int avgcult = (cult / numvals + cult / 2);
    /*
     debugmsg("AVG: GOO %d STR %d SNK %d CRM %d CLT %d\n\
           VAL: GOO %d STR %d SNK %d CRM %d CLT %d (%s)", avggood, avgstrength,
    avgsneak, avgcrime, avgcult, facval_data[v].good, facval_data[v].strength,
    facval_data[v].sneak, facval_data[v].crime, facval_data[v].cult,
    facval_data[v].name.c_str());
    */
    if ((abs(facval_data[v].good     - avggood)  <= 3 ||
         (avggood >=  5 && facval_data[v].good >=  1) ||
         (avggood <= -5 && facval_data[v].good <=  0))  &&
        (abs(facval_data[v].strength - avgstrength)   <= 5 ||
         (avgstrength >=  5 && facval_data[v].strength >=  3) ||
         (avgstrength <= -5 && facval_data[v].strength <= -1))  &&
        (abs(facval_data[v].sneak    - avgsneak) <= 4 ||
         (avgsneak >=  5 && facval_data[v].sneak >=  1) ||
         (avgsneak <= -5 && facval_data[v].sneak <= -1))  &&
        (abs(facval_data[v].crime    - avgcrime) <= 4 ||
         (avgcrime >=  5 && facval_data[v].crime >=  0) ||
         (avgcrime <= -5 && facval_data[v].crime <= -1))  &&
        (abs(facval_data[v].cult     - avgcult)  <= 3 ||
         (avgcult >=  5 && facval_data[v].cult >=  1) ||
         (avgcult <= -5 && facval_data[v].cult <= -1))) {
        return true;
    }
    return false;
}