void Algorythm::createTable(bool tutorial_table) { //TODO: fix this if(!tutorial_table) { for(unsigned int i=0;i<2; ++i) { addLetter(); //addLetter(); } } else { _cells.setLetter(0,1,GameInfo::getInstance()->getLetter('B')); _cells.setLetter(1,1,GameInfo::getInstance()->getLetter('A')); _cells.setLetter(2,1,GameInfo::getInstance()->getLetter('A')); } _drawer->setTabelCells(_cells); logTable(); //set table in signal emit signalTableChanged(_cells); }
void Algorythm::swapCell(CellCordinates cell) { bool action_performed = false; if(_cells.hasCell(cell)) { Cell curr = _cells.getCell(cell); if(!curr.isEmpty()) { if(_swap_first_point_selected) { //second point selection if(cell == _swap_first_point) { ADStatistics::logEvent("[Game-Booster] Swap deselect cell"); //We pressed the same point _drawer->swapDeselectCell(cell); _swap_first_point_selected = false; action_performed = true; } else { ADStatistics::logEvent("[Game-Booster] Swap performed"); //Do swap points _drawer->swapCells(TwoCells(_swap_first_point, cell)); _cells.setCell(cell, _cells.getCell(_swap_first_point)); _cells.setCell(_swap_first_point, curr); _swap_first_point_selected = false; emit signalTableChanged(_cells); emit signalSwapBoosterEnded(); action_performed = true; } } else { ADStatistics::logEvent("[Game-Booster] Swap first selected"); //Select first cell _swap_first_point_selected = true; _swap_first_point = cell; _drawer->swapSelectCell(cell); action_performed = true; } } } if(!action_performed) this->previousActionFinished(); logTable(); }
Json::Value doLogLevel (RPC::Context& context) { // log_level if (!context.params.isMember (jss::severity)) { // get log severities Json::Value ret (Json::objectValue); Json::Value lev (Json::objectValue); lev[jss::base] = Logs::toString(Logs::fromSeverity(deprecatedLogs().severity())); std::vector< std::pair<std::string, std::string> > logTable ( deprecatedLogs().partition_severities()); typedef std::map<std::string, std::string>::value_type stringPair; for (auto const& it : logTable) lev[it.first] = it.second; ret[jss::levels] = lev; return ret; } LogSeverity const sv ( Logs::fromString (context.params[jss::severity].asString ())); if (sv == lsINVALID) return rpcError (rpcINVALID_PARAMS); auto severity = Logs::toSeverity(sv); // log_level severity if (!context.params.isMember (jss::partition)) { // set base log severity deprecatedLogs().severity(severity); return Json::objectValue; } // log_level partition severity base? if (context.params.isMember (jss::partition)) { // set partition severity std::string partition (context.params[jss::partition].asString ()); if (boost::iequals (partition, "base")) deprecatedLogs().severity (severity); else deprecatedLogs().get(partition).severity(severity); return Json::objectValue; } return rpcError (rpcINVALID_PARAMS); }
Json::Value doLogLevel (RPC::Context& context) { // log_level if (!context.params.isMember ("severity")) { // get log severities Json::Value ret (Json::objectValue); Json::Value lev (Json::objectValue); lev["base"] = Logs::toString(Logs::fromSeverity(deprecatedLogs().severity())); std::vector< std::pair<std::string, std::string> > logTable ( deprecatedLogs().partition_severities()); typedef std::map<std::string, std::string>::value_type stringPair; BOOST_FOREACH (const stringPair & it, logTable) lev[it.first] = it.second; ret["levels"] = lev; return ret; }
void Algorythm::setTableCells(TableCells cells) { for(int x=0; x<Cell::N; ++x) { for(int y=0; y<Cell::N; ++y) { if(!cells.getCell(x,y).isEmpty()) { Letter letter = GameInfo::getInstance()->getLetter( cells.getCell(x,y).getLetter().getLetter()); cells.setLetter(x,y,letter); } } } _cells = cells; if(_drawer) _drawer->setTabelCells(_cells); logTable(); //set table in signal emit signalTableChanged(_cells); }
static int ProfileShortestPathFunc( SPTF_CMD cmd, track_p trk, EPINX_T ep, EPINX_T ep0, DIST_T dist, void * data ) { track_p trkN; EPINX_T epN; int rc0=0; int pathMatch; switch (cmd) { case SPTC_TERMINATE: rc0 = 1; break; case SPTC_MATCH: if ( EndPtIsIgnoredElev(trk,ep) ) break; if ( PathListSingle() ) { if ( trk == pathStartTrk && ep == pathStartEp ) { pathMatch = 2; } else if ( trk == pathEndTrk && ep == pathEndEp ) { pathMatch = 3; } else { break; } } else if ( ( trkN = GetTrkEndTrk(trk,ep) ) == NULL ) { break; } else { epN = GetEndPtConnectedToMe( trkN, trk ); if ( trkN == pathStartTrk && epN == pathStartEp ) { pathMatch = 1; } else if ( trkN == pathEndTrk && epN == pathEndEp ) { pathMatch = 2; } else if ( trkN == pathStartTrk && trkN == pathEndTrk ) { pathMatch = 2; } else if ( trkN == pathStartTrk ) { pathMatch = 1; } else if ( trkN == pathEndTrk ) { pathMatch = 2; } else { break; } } if ( profileShortestPathMatch < 0 || profileShortestPathDist > dist ) { LOG( log_shortPath, 4, ( " Match=%d", pathMatch ) ) profileShortestPathMatch = pathMatch; profileShortestPathDist = dist; } rc0 = 1; break; case SPTC_MATCHANY: rc0 = -1; break; case SPTC_IGNNXTTRK: if ( EndPtIsIgnoredElev(trk,ep) ) rc0 = 1; else if ( (GetTrkBits(trk)&TB_PROFILEPATH)!=0 ) rc0 = 1; else if ( (!EndPtIsDefinedElev(trk,ep)) && GetTrkEndTrk(trk,ep)==NULL ) rc0 = 1; else rc0 = 0; break; case SPTC_ADD_TRK: if (log_shortPath<=0||logTable(log_shortPath).level<4) LOG( log_profile, 4, ( " ADD_TRK T%d:%d", GetTrkIndex(trk), ep ) ) SetTrkBits( trk, TB_PROFILEPATH ); DrawTrack( trk, &mainD, profilePathColor ); rc0 = 0; break; case SPTC_VALID: rc0 = 1; break; default: break; } return rc0; }
void Algorythm::makeMove(MoveDirection direction) { std::vector< std::vector <CellMovementInfo > > for_drawer; int64_t old_score = _score; //move _direction = direction; for(int y=0; y<Cell::N; ++y) { int empty = 0; _info.clear(); for(int x=0; x<Cell::N; ++x) { //replace coordinates in deppend on direction int x_cur = x; int y_cur = y; if(direction == MoveDirection::Right || direction == MoveDirection::Up) x_cur = Cell::N - x - 1; if(direction == MoveDirection::Down || direction == MoveDirection::Up) { std::swap(x_cur, y_cur); } Cell curr_cell = _cells.getCell(x_cur,y_cur); if(curr_cell.isEmpty()) ++ empty; else { processOneCell(x_cur, y_cur, empty); } } if(!_info.empty()) for_drawer.push_back(_info); } //if there is no changes after the move do not add new letter(do not continue the algorythm) if(for_drawer.empty()) { ADStatistics::logEvent("[Game] Move no change"); previousActionFinished(); return; } ADStatistics::logEvent("[Game] Move"); //add a new letter Cell new_letter = addLetter(); sendPackagetForDrawer(for_drawer, new_letter); //sendScores(for_drawer); //look - is there next move, if no - send signal to table - game end if(isGameEnd()) { emit signalGameEnd(); } //make unmerged all cells unMergeCells(); //for debug logTable(); //send scores if(old_score != _score) { emit signalScoreChanged(_score); } //send signal table is changed emit signalTableChanged(_cells); }