Esempio n. 1
0
void Field::NewTetromino() {
	downKeyReleased_ = false;

	ResetCounter();
	score_ += level_;
	if (tetromino_) {
		tetromino_->AttachToField();
		CheckLines();
	}
	tetromino_ = nextTetromino_;
	nextTetromino_.reset(new Tetromino(std::uniform_int_distribution<int>(0, 6)(random), *this));

	if (tetromino_) {
		const int xPositions[] = { 5, 6, 4, 7, 3, 8, 2, 9, 1, 10, 0 };
		for(int i = 0; i < 11; ++i)
		{
			tetromino_->SetX(xPositions[i]);
			if(!tetromino_->Collided())
			{
				return;
			}
		}
		tetromino_->SetX(xPositions[0]);
		gameOver_ = true;
		nextTetromino_ = tetromino_;
		counter_ = 10;
	}
}
Esempio n. 2
0
/**
 * Moves down the current piece.
 */
void TetraminoesManager::InnerData::MoveDown() {
    int aux = pieceY;
    pieceY++;

    if (CheckCollision()) {
        pieceY = aux;
        PutPieceIntoWorld();
        CheckLines();
        GetNextPiece();
    }
}
Esempio n. 3
0
/**
 * Moves the current piece to the bottom.
 */
void TetraminoesManager::InnerData::FallDown() {
    int aux;
    do {
        aux = pieceY;
        pieceY++;
    } while (!CheckCollision());

    pieceY = aux;
    PutPieceIntoWorld();
    CheckLines();
    GetNextPiece();
}
Esempio n. 4
0
void LocalUser::FullConnect()
{
	ServerInstance->stats.Connects++;
	this->idle_lastmsg = ServerInstance->Time();

	/*
	 * You may be thinking "wtf, we checked this in User::AddClient!" - and yes, we did, BUT.
	 * At the time AddClient is called, we don't have a resolved host, by here we probably do - which
	 * may put the user into a totally seperate class with different restrictions! so we *must* check again.
	 * Don't remove this! -- w00t
	 */
	MyClass = NULL;
	SetClass();
	CheckClass();
	CheckLines();

	if (quitting)
		return;

	this->WriteNumeric(RPL_WELCOME, ":Welcome to the %s IRC Network %s", ServerInstance->Config->Network.c_str(), GetFullRealHost().c_str());
	this->WriteNumeric(RPL_YOURHOSTIS, ":Your host is %s, running version %s", ServerInstance->Config->ServerName.c_str(), INSPIRCD_BRANCH);
	this->WriteNumeric(RPL_SERVERCREATED, ":This server was created %s %s", __TIME__, __DATE__);

	const std::string& modelist = ServerInstance->Modes->GetModeListFor004Numeric();
	this->WriteNumeric(RPL_SERVERVERSION, "%s %s %s", ServerInstance->Config->ServerName.c_str(), INSPIRCD_BRANCH, modelist.c_str());

	ServerInstance->ISupport.SendTo(this);

	/* Now registered */
	if (ServerInstance->Users->unregistered_count)
		ServerInstance->Users->unregistered_count--;

	/* Trigger MOTD and LUSERS output, give modules a chance too */
	ModResult MOD_RESULT;
	std::string command("LUSERS");
	std::vector<std::string> parameters;
	FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true, command));
	if (!MOD_RESULT)
		ServerInstance->Parser.CallHandler(command, parameters, this);

	MOD_RESULT = MOD_RES_PASSTHRU;
	command = "MOTD";
	FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true, command));
	if (!MOD_RESULT)
		ServerInstance->Parser.CallHandler(command, parameters, this);

	if (ServerInstance->Config->RawLog)
		WriteServ("PRIVMSG %s :*** Raw I/O logging is enabled on this server. All messages, passwords, and commands are being recorded.", nick.c_str());

	/*
	 * We don't set REG_ALL until triggering OnUserConnect, so some module events don't spew out stuff
	 * for a user that doesn't exist yet.
	 */
	FOREACH_MOD(OnUserConnect, (this));

	this->registered = REG_ALL;

	FOREACH_MOD(OnPostConnect, (this));

	ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d (class %s): %s (%s) [%s]",
		this->GetServerPort(), this->MyClass->name.c_str(), GetFullRealHost().c_str(), this->GetIPString().c_str(), this->fullname.c_str());
	ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Adding NEGATIVE hit for " + this->GetIPString());
	ServerInstance->BanCache.AddHit(this->GetIPString(), "", "");
	// reset the flood penalty (which could have been raised due to things like auto +x)
	CommandFloodPenalty = 0;
}
bool ColoredPolygon::PixelCheck(const FPoint &point) {
    if (Math::Inside(point, _dots) || CheckLines(point)) {
        return true;
    }
    return SearchNearest(point.x, point.y) >= 0;
}
Esempio n. 6
0
void Board::Update(float timeStep)
{
    if (gameOver_)
    {
        if (score_ > record_)
        {
            record_ = score_;
            SaveRecord();
        }
        Restart();
        return;
    }

    selectionNode_->Rotate(Quaternion(0.0f, timeStep * 50, 0.0f));
    if (Path::GetTotalCount() > 0)
        return;
    if (needCheckLines_)
    {
        if (CheckLines())
        {
            needSpawnBalls_ = false;
        }
        needCheckLines_ = false;
        // может быть что поле полностью занято, новых шаров спанить не надо и ходить некуда
        // не работает чот
        gameOver_ = true;
        for (int i = 0; i < height_; i++)
        {
            for (int j = 0; j < width_; j++)
            {
                if (!board_[i][j] || board_[i][j]->GetBallState() == BS_GHOST)
                {
                    gameOver_ = false;
                    break;
                }

            }
        }
        if (gameOver_)
            return;

    }
    if (needSpawnBalls_)
    {
        for (int i = 0; i < numAddBalls_; i++)
        {
            if (!SpawnBall())
            {
                gameOver_ = true;
                return;
            }
        }
        if (difficulty_ <= D_NORMAL)
        {
            for (int i = 0; i < numAddBalls_; i++)
                CreateBall(true);
        }
        needSpawnBalls_ = false;
    }

    UIElement* uiRoot = GetSubsystem<UI>()->GetRoot();
    Text* t = static_cast<Text*>(uiRoot->GetChild("Score", true));
    t->SetText("Score: " + String(score_));
    t = static_cast<Text*>(uiRoot->GetChild("Colors", true));
    t->SetText("Colors: " + String(numColors_));
    t = static_cast<Text*>(uiRoot->GetChild("LineLength", true));
    t->SetText("Line length: " + String(lineLength_));
    t = static_cast<Text*>(uiRoot->GetChild("Record", true));
    t->SetText("Record: " + String(record_));
    // нужно выбрасывать шары если после уделаения линий поле пустое
}
//@doc SECEditView
//@mfunc Internal handler. If a line is deleted from another view, we need to
//              make sure our m_pCurLine and m_pTopLine are still
//              valid.
//
//@rdesc void 
//@parm CView* pSender
//@parm  LPARAM lHint
//@parm  CObject* pHint
void SECEditView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) //ADMacroDone
{
	pSender; //UNUSED
	SECEditHint* hint;

	if ((lHint == IDS_OE_DELETELINE) && pHint->IsKindOf(RUNTIME_CLASS(SECEditHint)))
		{
		hint = (SECEditHint*)pHint;
		CheckLines(hint->m_pLine);
		}

	// If we are embedded in a dynamic splitter,
	// make sure we are properly synched with our other views
	if((lHint == OE_SYNCH_SPLITTERS) &&  m_pSplitterParent)
	{
		BOOL bNeedUpdate = FALSE;

		ASSERT_VALID(m_pSplitterParent);
		ASSERT(m_pSplitterParent->IsKindOf(RUNTIME_CLASS(CSplitterWnd)));

		if(pSender == NULL)
			pSender = (CView*)m_pSplitterParent->GetActivePane();

		// Need to synch up the appropriate views to the
		// active view
		if(pSender->IsKindOf(RUNTIME_CLASS(SECEditView)) && (pSender != this))
		{
			SECEditView* pView = (SECEditView*)pSender;
			int nRow = pView->m_nSplitRow;
			int nCol = pView->m_nSplitCol;

			if(nCol == m_nSplitCol)
			{
				// Align the left edges
				if(m_iLeftEdge != pView->m_iLeftEdge)
				{
					m_iLeftEdge = pView->m_iLeftEdge;
					bNeedUpdate = TRUE;
					MySetScrollPos(SB_HORZ,m_iLeftEdge,m_bUpdate);
				}
			}

			if(nRow == m_nSplitRow)
			{
				// Align the tops
				if(m_iFirstLineNo != pView->m_iFirstLineNo)
				{
					m_pTopLine = pView->m_pTopLine;
					m_pCurLine = pView->m_pCurLine;
					m_iFirstLineNo = pView->m_iFirstLineNo;
					MySetScrollPos(SB_VERT,m_iFirstLineNo-1,TRUE);
					bNeedUpdate = TRUE;
				}
			}
		}
		if(bNeedUpdate)
			InvalidateRect(NULL,FALSE);

		return;
	}

	if (m_bUpdate)
		InvalidateRect(NULL,FALSE);
}