本文整理汇总了C++中getStats函数的典型用法代码示例。如果您正苦于以下问题:C++ getStats函数的具体用法?C++ getStats怎么用?C++ getStats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getStats函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getStats
void PlayerTroop::ResolveBattle(PlayerTroop* enemy){
if (getStats()->getAttack() > enemy->getStats()->getDefence()){
float damage = getStats()->getAttack();
damage /= enemy->getStats()->getArmour() + 1;
enemy->DealDamage(damage * Game->TIME.delta);
}
}
示例2: getStringField
/*
* Example obtainting client stats from an E_CONNECT or E_STOP event
*/
void FmsAuthAdaptor::processStats(IFmsAuthEvent* pAev)
{
I64 statsHandle;
FmsClientStats baseStats;
if (!getI64Field(pAev, IFmsAuthEvent::F_CLIENT_STATS_HANDLE, statsHandle))
return;
char* pAppName = getStringField(pAev, IFmsAuthEvent::F_APP_NAME);
if (pAev->getType() == IFmsAuthEvent::E_CONNECT)
{
getStats(statsHandle, baseStats);
// log data
char buf[1024];
char hashKey[9];
memset(hashKey, 0, 9);
memcpy(hashKey, &statsHandle, sizeof(statsHandle));
sprintf(buf, "client Stats Handle= %s, bytes_in= %f, bytes_out= %f\n", hashKey,
static_cast<double>(baseStats.bytes_in), static_cast<double>(baseStats.bytes_out));
m_pFmsAuthServerContext->log(buf, IFmsServerContext::kInformation, false);
}
else if (pAev->getType() == IFmsAuthEvent::E_STOP)
{
getStats(statsHandle, baseStats);
}
}
示例3: Object
PlayerTroop::PlayerTroop(int health, int attack, int armour, int defence, int range, float speed, std::string name) : Object(name){
getStats()->setHealth(health);
getStats()->setAttack(attack);
getStats()->setArmour(armour);
getStats()->setDefence(defence);
getStats()->setRange(range);
getStats()->setSpeed(speed);
getStats()->setMaxHealth(health);
getStats()->setMaxAttack(attack);
getStats()->setMaxArmour(armour);
getStats()->setMaxDefence(defence);
m_target = NULL;
}
示例4: getFiringAccuracy
/**
* Calculate firing accuracy.
* Formula = accuracyStat * weaponAccuracy * kneelingbonus(1.15) * one-handPenalty(0.8) * woundsPenalty(% health) * critWoundsPenalty (-10%/wound)
* @param actionType
* @param item
* @return firing Accuracy
*/
double BattleUnit::getFiringAccuracy(BattleActionType actionType, BattleItem *item)
{
double result = (double)(getStats()->firing / 100.0);
double weaponAcc = item->getRules()->getAccuracySnap();
if (actionType == BA_AIMEDSHOT || actionType == BA_LAUNCH)
weaponAcc = item->getRules()->getAccuracyAimed();
else if (actionType == BA_AUTOSHOT)
weaponAcc = item->getRules()->getAccuracyAuto();
else if (actionType == BA_HIT)
weaponAcc = item->getRules()->getAccuracyMelee();
result *= (double)(weaponAcc/100.0);
if (_kneeled)
result *= 1.15;
if (item->getRules()->isTwoHanded())
{
// two handed weapon, means one hand should be empty
if (getItem("STR_RIGHT_HAND") != 0 && getItem("STR_LEFT_HAND") != 0)
{
result *= 0.80;
}
}
return result * getAccuracyModifier();
}
示例5: getStats
bool Entity::humanCanWieldItem(const Item& item) const
{
Stat* myStats = getStats();
if ( !myStats )
{
return false;
}
if ( monsterAllyIndex >= 0 && (monsterAllyClass != ALLY_CLASS_MIXED || item.interactNPCUid == getUID()) )
{
return monsterAllyEquipmentInClass(item);
}
switch ( itemCategory(&item) )
{
case WEAPON:
return true;
case ARMOR:
return true;
case MAGICSTAFF:
return false;
case THROWN:
return false;
default:
return false;
}
return false;
}
示例6: TEST_F
TEST_F(PacksTests, test_discovery_zero_state) {
auto pack = Pack("foobar", getPackWithDiscovery());
auto stats = pack.getStats();
EXPECT_EQ(stats.total, 0);
EXPECT_EQ(stats.hits, 0);
EXPECT_EQ(stats.misses, 0);
}
示例7: query13
int query13() {
char filename[40];
char *linha=NULL;
Stats stats=NULL;
int ano, npublics,publics;
double percentagem=0.0;
CatalogoPtr c=NULL;
ano = npublics = publics=0;
printf("Nome do autor: ");
if (fgets(filename, 40, stdin) != NULL) {
linha = newline(filename);
}
ano = 0;
printf("Ano: ");
if(scanf("%d", &ano)>0) {
c=getCatalogo();
stats=getStats();
npublics = npublicsem(c,linha, ano);
publics=getPublics(ano,stats);
percentagem=(double)npublics/publics;
percentagem=percentagem*100;
printf("Percentagem relativa ao nr publicações de %d: %f\n",ano,percentagem);
}
return 1;
}
示例8: query10
int query10() {
int year = 0;
FILE *fp;
char filename[40];
Stats stats=NULL;
int i;
printf("Ano: ");
if(scanf("%d", &year)>0) {
getchar();
printf("Nome do ficheiro em qual quer gravar: ");
if (fgets(filename, 40, stdin) != NULL) {
fp = NULL;
fp = fopen(filename, "w");
fprintf(fp, "#Ano;#Autores;#Publicações\n");
stats = getStats();
while (stats->ano != year) {
if (year < stats->ano) {
stats = stats->left;
} else {
stats = stats->right;
}
}
printf("#Ano;#Autores;#Publicações\n");
for (i = 0; i <= 2; i++) {
printf("%d;%d;%d\n", stats->ano, i + 1, stats->coautores[i]);
fprintf(fp, "%d;%d;%d\n", stats->ano, i + 1, stats->coautores[i]);
}
fclose(fp);
}
}
return 1;
}
示例9: LogRelFlow
STDMETHODIMP MachineDebuggerWrap::GetStats(IN_BSTR aPattern,
BOOL aWithDescriptions,
BSTR *aStats)
{
LogRelFlow(("{%p} %s:enter aPattern=%ls aWithDescriptions=%RTbool aStats=%p\n", this, "MachineDebugger::getStats", aPattern, aWithDescriptions, aStats));
VirtualBoxBase::clearError();
HRESULT hrc;
try
{
CheckComArgOutPointerValidThrow(aStats);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc()))
throw autoCaller.rc();
hrc = getStats(BSTRInConverter(aPattern).str(),
aWithDescriptions,
BSTROutConverter(aStats).str());
}
catch (HRESULT hrc2)
{
hrc = hrc2;
}
catch (...)
{
hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
}
LogRelFlow(("{%p} %s: leave aStats=%ls hrc=%Rhrc\n", this, "MachineDebugger::getStats", *aStats, hrc));
return hrc;
}
示例10: run
void run() {
//Instance inst1 = InstanceGenerator::generate("./src/instances/test", 25, 3, 0, 0);
//generateInstances();
int numAnts = 100;
std::string path = "./src/instances/weakly_correlated/10k25i.dat";
//Instance inst = InstanceGenerator::generate(path, 25, 10, 1, 1);
Instance inst(path);
Colony col(inst, numAnts, 0.95, 2.0, 1.0);
getStats(col, 10, inst.getOptimal());
//ColonyTuner cT(inst1, numAnts);
//Colony col = cT.test();
//Solution best = col.run();
//printResults(col.getSolutionValues());
//std::cout << "Best solution found: " << best.getValue() << "\n";
//std::cout << "Optimal value: " << inst.getOptimal() << "\n";
//std::cout << best.toString() << "\n";
}
示例11: tr_statsFileCreated
void
tr_statsFileCreated (tr_session * session)
{
struct tr_stats_handle * s;
if ((s = getStats (session)))
s->single.filesAdded++;
}
示例12: switch
/**
* Get the number of time units a certain action takes.
* @param actionType
* @param item
* @return TUs
*/
int BattleUnit::getActionTUs(BattleActionType actionType, BattleItem *item)
{
if (item == 0)
{
return 0;
}
switch (actionType)
{
case BA_PRIME:
return (int)floor(getStats()->tu * 0.50);
case BA_THROW:
return (int)floor(getStats()->tu * 0.25);
case BA_AUTOSHOT:
return (int)(getStats()->tu * item->getRules()->getTUAuto() / 100);
case BA_SNAPSHOT:
return (int)(getStats()->tu * item->getRules()->getTUSnap() / 100);
case BA_HIT:
return (int)(getStats()->tu * item->getRules()->getTUMelee() / 100);
case BA_LAUNCH:
case BA_AIMEDSHOT:
return (int)(getStats()->tu * item->getRules()->getTUAimed() / 100);
case BA_USE:
return (int)(getStats()->tu * item->getRules()->getTUUse() / 100);
case BA_MINDCONTROL:
case BA_PANIC:
return item->getRules()->getTUUse();
default:
return 0;
}
}
示例13: die
void CInimigo::die()
{
if(getStats()->getPV() <= 0)
{
divisorxp->giveXP();
estado = E_MORTO;
respawn = ENEMYRESPAWNTIME;
}
}
示例14: tr_statsAddDownloaded
void tr_statsAddDownloaded(tr_session* session, uint32_t bytes)
{
struct tr_stats_handle* s;
if ((s = getStats(session)) != NULL)
{
s->single.downloadedBytes += bytes;
s->isDirty = true;
}
}
示例15: getFittest
Individual<N> * Population<N>::iterate (int iterations) {
for (int i = 0; i < iterations; i++) {
Individual<N> * fittest = getFittest ();
if (fittest) {
return fittest;
}
else {
// print ();
if (OUTPUT) {
std::cout << std::endl
<< "WHOLE POPULATION:" << std::endl;
}
getStats (individuals, size);
// if (OUTPUT) print ();
if (OUTPUT) std::cout << "WINNERS:" << std::endl;
Individual<N> * winners = tournament ();
getStats (winners, size/2);
// if (OUTPUT) print (winners);
mutation (winners);
if (OUTPUT) std::cout << "WINNERS AFTER MUTATION:" << std::endl;
getStats (winners, size/2);
// if (OUTPUT) print (winners);
if (OUTPUT) std::cout << "CHILDREN:" << std::endl;
Individual<N> * children = crossOver (winners);
getStats (children, size/2);
// if (OUTPUT) print (children);
merge (winners, children);
return fittest;
}
}
return nullptr;
}