Example #1
0
DWORD IBuff::GetRemain()
{
	if( GetInst() == 0 )
		return 0;
	
	DWORD dwElapsedTime = ::timeGetTime() - GetInst();
	if( dwElapsedTime > GetTotal() )	// 남은 시간은 총 버프 시간보다 클 수 없다.
		return 0;						// 실제로 버프 제거는 시간 만료 후 다음 프로세스에서 하기 때문에 발생 가능하다.

	return GetTotal() - dwElapsedTime;
}
Example #2
0
SDst
AMUnitList::AdjustOffsetForHeight(SDst h, bool is_top)
{
	if(GetFullViewHeight() > h)
	{
		const SDst item_h(GetItemHeight());

		if(YB_UNLIKELY(item_h == 0))
			return 0;
		vwList.RestrictSelected();
		if(is_top)
			return AdjustBottomForHeight(item_h, h);
		else
		{
			const auto d((h + uTopOffset) % item_h);

			if(d != 0)
			{
				const auto tmp(uTopOffset + item_h - d);

				uTopOffset = tmp % item_h;
				AdjustViewLengthForHeight(item_h, h);
			// XXX: Conversion to 'ptrdiff_t' might be implementation-defined.
				vwList.IncreaseHead(ptrdiff_t(tmp / item_h), GetTotal());
			}
			return d;
		}
	}
	return 0;
}
Example #3
0
size_t
AMUnitList::GetLastLabelIndexClipped(SPos v_off, SDst height) const
{
	// XXX: Conversion to 'SPos' might be implementation-defined.
	return vwList.GetHeadIndex() + min(size_t((SPos(height + uTopOffset)
		- v_off - 1) / SPos(GetItemHeight()) + 1), vwList.GetValid(GetTotal()));
}
Example #4
0
BOOL IBuff::IsAddable( CMover* pMover )
{
	int nTotal	= static_cast<int>( GetTotal() );
	ASSERT( nTotal >= 0 );
	if( nTotal < 0 )
		return FALSE;
	return TRUE;
}
Example #5
0
void SuffixTree<Symb,NSymb>::Move(Symb* str, int& len, Range& rng, Count& total)
{
	Edge e;
	FindEdge(e, str, len);
	len = GetLen(e);
	GetRange(state, e, rng);
	total = GetTotal(state);
	BHASSERT_WITH_NO_PERFORMANCE_IMPACT(rng.high <= total);
	Move(e);
}
Example #6
0
void
AMUnitList::ResetView()
{
	bool b(vwList.IsSelected());

	vwList.Reset();
	if(b)
		vwList.SetSelectedIndex(0, GetTotal());
	yunseq(uTopOffset = 0, idxShared = size_t(-1));
}
Example #7
0
int main()
{
	int num, ret;
	scanf("%d", &num);
	ret = GetTotal(num);
	if (ret != 1)
		printf(") ");
	printf("= %d \n", ret);

	
	return 0;
}
Example #8
0
int GetTotal(int n)
{
	if (n == 1)
	{
		int ret = GetSum(1);
		return ret;
	}
	int res = GetTotal(n - 1);
	if (res != 1)
		printf(") ");
	printf("+");
	return res + GetSum(n);
}
Example #9
0
void
AMUnitList::AdjustViewForContent(SDst h)
{
	if(vwList.AdjustForContent(GetTotal()) && vwList.IsSelected())
	{
		AdjustOffsetForHeight(h,
			vwList.GetSelectedIndex() == vwList.GetHeadIndex());
		return;
	}
	if(GetFullViewHeight() < GetViewPosition() + h)
		uTopOffset = 0;
	AdjustViewLengthForHeight(GetItemHeight(), h);
}
Example #10
0
void Window_ShopNumber::Refresh() {
	contents->Clear();

	int y = 34;
	DrawItemName(&Data::items[item_id - 1], 0, y);

	std::stringstream ss;
	ss << number;

	contents->TextDraw(132, y, Font::ColorDefault, "x");
	contents->TextDraw(132 + 30, y, Font::ColorDefault, ss.str(), Surface::TextAlignRight);
	SetCursorRect(Rect(132 + 14, y - 2, 20, 16));
	
	DrawCurrencyValue(GetTotal(), contents->GetWidth(), y + 32);
}
Example #11
0
    //
    // Returns for radius "r" values of integrand for evaluation of terms of total energy
    //
    double FunEner::Get(double r) const
    {
        double v;

        assert(r > 0);
        switch (m_type)
        {
        case 0: v = GetTotal(r);	break;
        case 1: v = GetNucleus(r);	break;
        case 2: v = GetHartree(r);	break;
        case 3: v = GetExch(r);		break;
        case 4: v = GetCorr(r);		break;
        case 5: v = GetKinetic(r);	break;
        default: assert(0); v = 0;	break;
        }
        return v;
    }
Example #12
0
	void UserFiltersModel::AddMultiFilters (QStringList lines)
	{
		lines = Util::Map (lines, Util::QStringTrimmed {});

		beginResetModel ();
		auto p = std::for_each (lines.begin (), lines.end (),
				LineParser (&Filter_));
		endResetModel ();

		if (p.GetSuccess () <= 0)
			return;

		Proxy_->GetEntityManager ()->HandleEntity (Util::MakeNotification ("Poshuku CleanWeb",
				tr ("Imported %1 user filters (%2 parsed successfully).")
					.arg (p.GetSuccess ())
					.arg (p.GetTotal ()),
				PInfo_));
	}
void CFrameTimer::addFrame()
{
    Stop();
    dt = GetInterval();

    _nframes++;
    _print_nframes++;

    if (_print_interval != 0 && _nframes != 0 && (GetTotal() > _print_interval))
    {
        float _print_fps = (float)(_print_nframes) / (_print_interval);
        CLog::getInstance()->addInfo(printStr + std::to_string((int)_print_fps));
        if (needToCollectFps) fpsList->push_back(_print_fps);

        _print_nframes = 0;
        Reset();
    }
    Continue();
}
	void UserFiltersModel::AddMultiFilters (QStringList lines)
	{
		std::for_each (lines.begin (), lines.end (),
				[] (QString& str) { str = str.trimmed (); });

		beginResetModel ();
		auto p = std::for_each (lines.begin (), lines.end (),
				LineParser (&Filter_));
		endResetModel ();

		if (p.GetSuccess () <= 0)
			return;

		WriteSettings ();

		emit gotEntity (Util::MakeNotification ("Poshuku CleanWeb",
				tr ("Imported %1 user filters (%2 parsed successfully).")
					.arg (p.GetSuccess ())
					.arg (p.GetTotal ()),
				PInfo_));
	}
void ribi::gtst::ParticipantDialogStateGroupReAssign::ShowPage(ParticipantDialog * const dialog)
{
  assert(dialog);
  assert(GetDialog()->CanGetParticipant()
    && "A Participant must be logged in in this state");

  const boost::shared_ptr<const Participant>& participant = dialog->GetParticipant();
  assert(GetDialog()->GetParticipant()->CanGetId()
    && "A Participant must be assigned an ID before entering this state");

  const auto payoffs = participant->GetPayoffs();

  const Group * const group = m_server->GetGroups()->FindMyGroup(participant);
  assert(group);

  //Create the widget(s)
  ui.m_label_status = new Wt::WLabel;
  ui.m_label_time_left = new Wt::WLabel;

  //Check the widget(s)
  assert(ui.m_label_status);
  assert(ui.m_label_time_left);

  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WLabel("Group re-assign"));
  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(ui.m_label_time_left);
  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WLabel("This is the end of this period"));
  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WLabel(
    (std::string("You are in group #")
    + std::to_string(group->GetId())).c_str()));
  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WLabel(
    (std::string("Your earnings in this period are ")
      + CurrencyToStr(payoffs->GetLast()->m_payoff)
      + std::string(" points")).c_str()));
  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WLabel(
    (std::string("Your total earnings are ")
      + CurrencyToStr(payoffs->GetTotal())
      + std::string(" points")).c_str()));
  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WLabel("Group average earnings:"));
  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WBreak);

  Wt::WTable * table = new Wt::WTable(dialog);
  const auto groups = m_server->GetGroups()->CollectGroups(false,false,true,false);
  std::for_each(groups.begin(),groups.end(),
    [&dialog,&table,this,group](const Group* const any_group)
    {
      assert(!any_group->GetAveragePayoffs().empty());
      table->insertRow(0);

      table->elementAt(0,0)->addWidget(new Wt::WText(
        Wt::WString("Group {1}").arg(any_group->GetId())));

      table->elementAt(0,1)->addWidget(new Wt::WText(
        Wt::WString("{1} points").arg(
          this->CurrencyToStr(any_group->GetAveragePayoffs().back()))));

      if (any_group == group)
      {
        table->elementAt(0,2)->addWidget(new Wt::WText("your group"));
      }
    }
  );


  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WBreak);

  ServerStateGroupReAssign * const server_state
    = dynamic_cast<ServerStateGroupReAssign*>(m_server->GetStates()->GetCurrentState());
  if (!server_state)
  {
    std::clog << __func__ << ": warning: no ServerStateGroupReAssign\n";
    return;
  }

  const auto p = server_state->GetWorstAndBestGroup();
  if (group == p.first)
  {
    //Worst
    if (p.second->GetSize() == 5)
    {
      dialog->addWidget(new Wt::WText("Your group has the lowest average earnings in this period"));
      dialog->addWidget(new Wt::WBreak);
      dialog->addWidget(new Wt::WText("and has been selected to <b>be eliminated from the experiment</b>"));
    }
    else
    {
      dialog->addWidget(new Wt::WText(Wt::WString("Group {1} has the highest average earnings in this period and has been selected to grow").arg(p.first->GetId())));
      dialog->addWidget(new Wt::WBreak);
      dialog->addWidget(new Wt::WText(Wt::WString("This group grows from 3 to 5 members.")));
      dialog->addWidget(new Wt::WBreak);
      dialog->addWidget(new Wt::WText(Wt::WString("Your group <b>remains the same</b>")));
    }
  }
  else if (group == p.second)
  {
    if (group->GetSize() == 5)
    {
      dialog->addWidget(new Wt::WText("Your group has the highest average earnings in this period"));
      dialog->addWidget(new Wt::WBreak);
      dialog->addWidget(new Wt::WText("and has been selected to <b>grow and split</b> into two groups."));
      dialog->addWidget(new Wt::WBreak);
      dialog->addWidget(new Wt::WText("Your group first grows from 5 to 6 members, and then splits into two groups of three members."));
      dialog->addWidget(new Wt::WBreak);
      dialog->addWidget(new Wt::WText("Your group in the next period will be one of those two groups"));
    }
    else
    {
      dialog->addWidget(new Wt::WText("Your group has the highest average earnings in this period and has been selected to <b>grow</b>"));
      dialog->addWidget(new Wt::WBreak);
      dialog->addWidget(new Wt::WText("Your group grows from 3 to 5 members"));
    }
  }
  else
  {
    if (p.second->GetSize() == 3)
    {
      //Best group grows
      dialog->addWidget(new Wt::WText(Wt::WString("Group {1} has the highest average earnings in this period and has been selected to grow").arg(p.first->GetId())));
      dialog->addWidget(new Wt::WBreak);
      dialog->addWidget(new Wt::WText(Wt::WString("This group grows from 3 to 5 members.")));
      dialog->addWidget(new Wt::WBreak);
      dialog->addWidget(new Wt::WText(Wt::WString("Your group <b>remains the same</b>")));
    }
    else
    {
      //Best group splits, worst dies
      dialog->addWidget(new Wt::WText(Wt::WString("Group {1} has the highest average earnings in this period").arg(p.second->GetId())));
      dialog->addWidget(new Wt::WBreak);
      dialog->addWidget(new Wt::WText("and has been selected to grow and split into two groups."));
      dialog->addWidget(new Wt::WBreak);
      dialog->addWidget(new Wt::WText(Wt::WString("Group {1} has the lowest average earnings in this period").arg(p.first->GetId())));
      dialog->addWidget(new Wt::WBreak);
      dialog->addWidget(new Wt::WText("and has been selected to be eliminated from the experiment."));
      dialog->addWidget(new Wt::WBreak);
      dialog->addWidget(new Wt::WText(Wt::WString("Your group <b>remains the same</b>")));
    }
  }

  dialog->addWidget(new Wt::WBreak);
  dialog->addWidget(new Wt::WBreak);

  if (group == p.first && p.second->GetSize() == 5)
  {
    //A dead Participant :3
    dialog->addWidget(new Wt::WLabel("For you, this experiment ends now"));
  }
  else
  {
    //A survivor
    #define TEMP_DEBUG_215487632492487527652376428
    #ifdef TEMP_DEBUG_215487632492487527652376428
    if(!dynamic_cast<const PayoffReAssign*>(payoffs->GetLast().get()))
    {
      TRACE(group->GetId());
      TRACE(participant->GetId());
    }
    #endif
    assert(dynamic_cast<const PayoffReAssign*>(payoffs->GetLast().get()));
    dialog->addWidget(new Wt::WLabel(
      Wt::WString("You earn {1} points for reaching the next period").arg(
        CurrencyToStr(payoffs->GetLast()->m_payoff))));
  }

}
Example #16
0
double Conteneur::GetMoyenne() const
{
	int ScoMoyen_ = 0;
	ScoMoyen_ = GetTotal() / NbDonnees_;
   return ScoMoyen_;
}
Example #17
0
SDst
AMUnitList::GetFullViewHeight() const
{
	return SDst(GetItemHeight() * GetTotal());
}
bool GenericPlayer::IsBusted( ) const
{
	return (GetTotal( ) > 21);
}