コード例 #1
0
ファイル: tae.cpp プロジェクト: AfrazHussain/tpserver-cpp
// Create properties for use with components.  This function is based off the
// function of the same name implemented in RFTS.
void taeRuleset::createProperties() {
    Property* prop = new Property();
    DesignStore* ds = Game::getGame()->getDesignStore();

    // Passengers
    prop = new Property();
    prop->addCategoryId(ds->getCategoryByName("Ships"));
    prop->setRank(0);
    prop->setName("Passengers");
    prop->setDisplayName("Passengers");
    prop->setDescription("The passengers aboard the ship");
    // Value of property -> String to display:
    // 1 -> Merchants
    // 2 -> Scientists
    // 3 -> Settlers
    // 4 -> Mining Robots
    // 5 -> Merchant Leader
    // 6 -> Lead Scientist
    // 7 -> Government Official
    // 8 -> Mining Foreman
    prop->setTpclDisplayFunction("(lambda (design bits) (let ((n (apply + bits)))"
        "(cons n (cond "
            "((= n 1) \"Merchants\") "
            "((= n 2) \"Scientists\") "
            "((= n 3) \"Settlers\") "
            "((= n 4) \"Mining Robots\") "
            "((= n 5) \"Merchant Leader\") "
            "((= n 6) \"Lead Scientist\") "
            "((= n 7) \"Government Official\") "
            "((= n 8) \"Mining Foreman\") "
            "((< n 1) (cons n \"ERROR: value too low!\")) "
            "((> n 8) (cons n \"ERROR: value too high!\"))))))");
    prop->setTpclRequirementsFunction("(lambda (design) (cons #t \"\"))");
    ds->addProperty(prop);

    prop = new Property();
    prop->addCategoryId(ds->getCategoryByName("Ships"));
    prop->setRank(0);
    prop->setName("Bombs");
    prop->setDisplayName("Supernova Bombs");
    prop->setDescription("The number of supernova bombs aboard the ship");
    prop->setTpclDisplayFunction("(lambda (design bits) (let ((n (apply + bits))) (cons n (string-append (number->string n) \" bombs\")) ) )");
    prop->setTpclRequirementsFunction("(lambda (design) (cons #t \"\"))");
    ds->addProperty(prop);

}
コード例 #2
0
void PropertyFactory::initWeaponWinProperty() {
  Property* prop = new Property();
  DesignStore *ds = Game::getGame()->getDesignStore();

  prop->setCategoryId(ds->getCategoryByName("Ships"));
  prop->setRank(0);
  prop->setName("WeaponWin");
  prop->setDisplayName("Weapon Strength at Win");
  prop->setDescription("The amount of damage done on a win.");
  prop->setTpclDisplayFunction("(lambda (design bits) (let ((n (apply + bits))) (cons n (string-append (number->string n) \" HP\")) ) )");
  prop->setTpclRequirementsFunction("(lambda (design) (cons #t \"\"))");
  ds->addProperty(prop);
  return;
}
コード例 #3
0
void PropertyFactory::initSpeedProperty() {
  Property* prop = new Property();
  DesignStore *ds = Game::getGame()->getDesignStore();

  prop->setCategoryId(ds->getCategoryByName("Ships"));
  prop->setRank(0);
  prop->setName("Speed");
  prop->setDisplayName("Speed");
  prop->setDescription("How fast a ship moves. ");
  prop->setTpclDisplayFunction("(lambda (design bits) (let ((n (apply + bits))) (cons n (string-append (number->string (/ n 1000000)) \" mega-units\")) ) )");
  prop->setTpclRequirementsFunction("(lambda (design) (cons #t \"\"))");
  ds->addProperty(prop);
  return;
}
コード例 #4
0
void PropertyFactory::initColoniseProperty() {
  Property* prop = new Property();
  DesignStore *ds = Game::getGame()->getDesignStore();

  prop->setCategoryId(ds->getCategoryByName("Ships"));
  prop->setRank(0);
  prop->setName("Colonise");
  prop->setDisplayName("Colonise");
  prop->setDescription("Whether a ship can colonise or not.");
  prop->setTpclDisplayFunction("(lambda (design bits) (let ((n (apply + bits))) (cons n (if (= n 1) \"Yes\" \"No\")) ) )");
  prop->setTpclRequirementsFunction("(lambda (design) (cons #t \"\"))");
  ds->addProperty(prop);
  return;
}
コード例 #5
0
void PropertyFactory::initBuildTimeProperty() {
  Property* prop = new Property();
  DesignStore *ds = Game::getGame()->getDesignStore();

  prop->setCategoryId(ds->getCategoryByName("Ships"));
  prop->setRank(0);
  prop->setName("BuildTime");
  prop->setDisplayName("Build Time");
  prop->setDescription("The number of turns to build a ship");
  prop->setTpclDisplayFunction("(lambda (design bits) (let ((n (apply + bits))) (cons n (string-append (number->string n) \" turns\")) ) )");
  prop->setTpclRequirementsFunction("(lambda (design) (cons #t \"\"))");
  ds->addProperty(prop);
  return;
}
コード例 #6
0
void PropertyFactory::init_num_componentsProperty() {
  Property* prop = new Property();
  DesignStore *ds = Game::getGame()->getDesignStore();

  prop->setCategoryId(ds->getCategoryByName("Ships"));
  prop->setRank(0);
  prop->setName("_num-components");
  prop->setDisplayName("Number of Components");
  prop->setDescription("The number of components in a design");
  prop->setTpclDisplayFunction("(lambda (design bits) (let ((n (apply + bits))) (cons n (string-append (number->string n) \" components\"))))");
  prop->setTpclRequirementsFunction("(lambda (design) (cons #t \"\"))");
  ds->addProperty(prop);
  return;
}