/*Wrapper function, adds legal Pawn Moves from Location to Linked List*/ int getPawnMoves(Game *game, Location *loc, ListNode *temp){ int flag = 0; if (canMoveUK(game->board, loc, 1) && isEmpty(game->board[loc->column][loc->row + shiftUp(game->board, loc)])){ Move *move = setMove(loc, setLocation(loc->column, loc->row + shiftUp(game->board, loc)), NONETYPE); if (isValidMove(game, move)){ getPawnSingleMove(game->board, loc, temp, move); flag = 1; } else{ freeMove(move); } } if (canMoveULK(game->board, loc, 1) && isOpposite(game->board[loc->column + shiftLeft(game->board, loc)][loc->row + shiftUp(game->board, loc)], game->board, loc)){ Move *move = setMove(loc, setLocation(loc->column + shiftLeft(game->board, loc), loc->row + shiftUp(game->board, loc)), NONETYPE); if (isValidMove(game, move)){ getPawnSingleMove(game->board, loc, temp, move); flag = 1; } else{ freeMove(move); } } if (canMoveURK(game->board, loc, 1) && isOpposite(game->board[loc->column + shiftRight(game->board, loc)][loc->row + shiftUp(game->board, loc)], game->board, loc)){ Move *move = setMove(loc, setLocation(loc->column + shiftRight(game->board, loc), loc->row + shiftUp(game->board, loc)), NONETYPE); if (isValidMove(game, move)){ getPawnSingleMove(game->board, loc, temp, move); flag = 1; } else{ freeMove(move); } } return flag; }
void PokeEdit::changeMove() { int slot = sender()->property("move").toInt(); int move = MoveInfo::Number(m_moves[slot]->text()); setMove(slot, move); }
/*Add legal Moves for Bishop/Rook/Queen/King at Location to Linked List*/ int getBRQKMoves(Game *game, Location *loc, ListNode *temp){ int killflag, blockedflag, i, j, dist, len; int flag = 0; MoveType type; MoveType *list = getMoveTypeList(game->board, loc); len = getMoveTypeListLength(game->board, loc); for (i = 0; i < len; i++){ killflag = 0; blockedflag = 0; type = list[i]; dist = distFrom(game->board, loc, type); if (isKing(game->board, loc) && dist>0){ dist = 1; } for (j = 1; j <= dist&&!killflag&&!blockedflag; j++){ Location *tLoc = setLocation(loc->column + shiftCol(game->board, loc, type)*j, loc->row + shiftRow(game->board, loc, type)*j); if (legalMoveToKing(game, loc, tLoc)){ Move *move = setMove(loc, tLoc, NONETYPE); if (isValidMove(game, move)){ addMoveToList(temp, move); flag = 1; } else{ freeMove(move); } } else{ free(tLoc); } } } return flag; }
void NonPlayerCharacter::update(float dt) { Character::update(dt); int priority = 0; int bestPattern = -1; for (int i = 0; i < aiPatternsCount; i++) { int p = game->getAiPattern( aiPatterns[i] )->calculatePriority(this); if ( p > priority ) { priority = p; bestPattern = i; } } if (bestPattern > -1) { switch ( game->getAiPattern( aiPatterns[bestPattern] )->calculateOperation(this) ) { case NPC_OPERATION_TRAVERSE: targetPosition = game->getAiPattern( aiPatterns[bestPattern] )->calculateTargetPosition(this); if ( (targetPosition.x > position.x && !turnedRight) || (targetPosition.x < position.x && turnedRight) ) { turn(); } setMove(traverseMove); break; case NPC_OPERATION_DOMOVE: break; } } }
void fButtonSF(struttura *str) /*Funzione associata al tasto 'sf' */ { setMove(str,window); gtk_widget_show(window); gtk_widget_hide(str->window); }
// Open the dialog type 't' void FileHandling::openDialog(QString t) { if(verbose) std::clog << "fhd: Open widget:" << t.toStdString() << std::endl; if(currentfile != "") { // Make sure all widgets are hidden by default renameWidget->hide(); deleteWidget->hide(); moveWidget->hide(); copyWidget->hide(); // Save current state dialogType = t; // Set right widget if(t == "rename") setRename(); if(t == "delete") setDelete(); if(t == "copy") setCopy(); if(t == "move") setMove(); // And animate makeShow(); } }
Textual::Textual(QWidget *parent) : KHTMLPart(parent, parent, KHTMLPart::BrowserViewGUI) , m_curr_selected(-1) , m_layout_style(0) { m_loader.setSize(12); connect(browserExtension(), SIGNAL(openUrlRequest(const KUrl&,const KParts::URLArgs&)), this, SLOT(onURL(const KUrl&))); setJScriptEnabled(false); setJavaEnabled(false); setMetaRefreshEnabled(false); setPluginsEnabled(false); QString fpath = KStandardDirs::locate("appdata", "scripts/movelist_textual.html"); //kDebug() << "HTML file is:"<< fpath; QFile file(fpath); file.open(QIODevice::ReadOnly); QTextStream stream(&file); QString html = stream.readAll(); //kDebug() << "Using HTML:"<<html; begin(); write(html); end(); setMove(0, -1, "Mainline:"); }
void tray_icon_on_click(GtkStatusIcon *status_icon,struttura *str) { // printf("Clicked on tray icon\n"); gtk_widget_show(str->window); gtk_status_icon_set_visible(str->tray_icon, FALSE); setMove(str,str->window); }
void movetodown(struttura *str,GtkWidget *win) { //se (str->move.position_height==str->move.delay_verticale*2) è verificato =0 altrimenti + delay_verticale //delay verticale è lo spostamento verticale getMaxScreen(str); str->move.position_height=(str->move.position_height+str->move.delay_verticale+WINDOW_HEIGHT>str->move.s_height)?0:str->move.position_height+str->move.delay_verticale; setMove(str,win); }
void window_insert(struttura *str) { GtkWidget *winDialog,*button1,*button2,*label; GtkDialog *dialog; char slabel[LEN_WORD_DB+16]; gtk_widget_hide(str->window); winDialog = gtk_dialog_new(); dialog=GTK_DIALOG(winDialog); gtk_window_set_title(GTK_WINDOW(winDialog), "new word?"); button1=gtk_dialog_add_button(dialog,"cancel",0); button2=gtk_dialog_add_button(dialog,"insert",1); snprintf(slabel,LEN_WORD_DB+16,"insert '%s' in db?",intToChar(str->ins.new_word)); label = gtk_label_new (slabel); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(dialog)),label, TRUE, TRUE, 0); gtk_widget_show (label); g_signal_connect(G_OBJECT(button1), "clicked",G_CALLBACK (gtk_widget_destroy), winDialog); g_signal_connect(G_OBJECT(button2), "clicked",G_CALLBACK(button_pressed_insert), str); g_signal_connect_swapped (winDialog, "destroy", G_CALLBACK (gtk_widget_destroy), winDialog); gtk_dialog_run(dialog); setMove(str,str->window); gtk_widget_show(str->window); gtk_widget_destroy(winDialog); ins(str); }
void KMovingConfig::load( void ) { QString key; KConfigGroup cg(config, "Windows"); key = cg.readEntry(KWIN_MOVE, "Opaque"); if( key == "Transparent") setMove(TRANSPARENT); else if( key == "Opaque") setMove(OPAQUE); // DF: please keep the default consistent with kwin (options.cpp line 145) key = cg.readEntry(KWIN_RESIZE_OPAQUE, "Opaque"); if( key == "Opaque") setResizeOpaque(RESIZE_OPAQUE); else if ( key == "Transparent") setResizeOpaque(RESIZE_TRANSPARENT); //KS 10Jan2003 - Geometry Tip during window move/resize bool showGeomTip = cg.readEntry(KWIN_GEOMETRY, false); setGeometryTip( showGeomTip ); setMoveResizeMaximized(cg.readEntry(KWIN_MOVE_RESIZE_MAXIMIZED, false)); int v; v = cg.readEntry(KWM_BRDR_SNAP_ZONE, KWM_BRDR_SNAP_ZONE_DEFAULT); if (v > MAX_BRDR_SNAP) setBorderSnapZone(MAX_BRDR_SNAP); else if (v < 0) setBorderSnapZone (0); else setBorderSnapZone(v); v = cg.readEntry(KWM_WNDW_SNAP_ZONE, KWM_WNDW_SNAP_ZONE_DEFAULT); if (v > MAX_WNDW_SNAP) setWindowSnapZone(MAX_WNDW_SNAP); else if (v < 0) setWindowSnapZone (0); else setWindowSnapZone(v); v = cg.readEntry(KWM_CNTR_SNAP_ZONE, KWM_CNTR_SNAP_ZONE_DEFAULT); if (v > MAX_CNTR_SNAP) setCenterSnapZone(MAX_CNTR_SNAP); else if (v < 0) setCenterSnapZone (0); else setCenterSnapZone(v); OverlapSnap->setChecked(cg.readEntry("SnapOnlyWhenOverlapping", false)); emit KCModule::changed(false); }
void PokePersonal::removeMove(int movenum) { for (int i = 0; i < 4; i++) { if (move(i) == movenum) { setMove(0, i); } } }
void movetoright(struttura *str) { if (str->move.position_width<str->move.delay_orizzontale*2)//se non sei a fine schermo { str->move.position_width+=str->move.delay_orizzontale; setMove(str); } }
void movetoleft(struttura *str) { if (str->move.position_width>0)//se non sei a inizio schermo { str->move.position_width-=str->move.delay_orizzontale; setMove(str); } }
int PokePersonal::addMove(int moveNum, bool check) throw(QString) { for (int i = 0; i < 4; i++) if (move(i) == 0) { setMove(moveNum, i, check); return i; } throw QObject::tr("No free move available!"); }
/*Add legal Moves for Knight at Location to Linked List*/ int getKnightSingleMove(Game *game, Location *loc, ListNode *temp, MoveType type){ MoveType col; MoveType row; char c; int flag = 0; switch (type) { case UR:col = R; row = U; break; case UL:col = L; row = U; break; case DL:col = L; row = D; break; case DR:col = R; row = D; break; case U:row = U; case D:row = D; case L:col = L; case R:row = R; } if (canMoveK(game->board, loc, 1, col) && canMoveK(game->board, loc, 2, row)){ c = game->board[loc->column + shiftCol(game->board, loc, col)][loc->row + shiftRow(game->board, loc, row) * 2]; if (isEmpty(c) || isOpposite(c, game->board, loc)){ Move *move = setMove(loc, setLocation(loc->column + shiftCol(game->board, loc, col), loc->row + shiftRow(game->board, loc, row) * 2), NONETYPE); if (isValidMove(game, move)){ addMoveToList(temp, move); flag = 1; } else{ freeMove(move); } } } if (canMoveK(game->board, loc, 2, col) && canMoveK(game->board, loc, 1, row)){ c = game->board[loc->column + shiftCol(game->board, loc, col) * 2][loc->row + shiftRow(game->board, loc, row)]; if (isEmpty(c) || isOpposite(c, game->board, loc)){ Move *move = setMove(loc, setLocation(loc->column + shiftCol(game->board, loc, col) * 2, loc->row + shiftRow(game->board, loc, row)), NONETYPE); if (isValidMove(game, move)){ addMoveToList(temp, move); flag = 1; } else{ freeMove(move); } } } return flag; }
void Alien::move(int time) { if (down_) { position_.second+=5*speed_; down_ = false; } if (time - lastMoved_ > moveHorizontal_time_) { lastMoved_ = time; switch(direction_) { case right: position_.first+= speed_; break; case left: position_.first-=speed_; break; case down: position_.second+=5; break; } } if (time - lastChangedDir_ > switchDirection_time_ ) { lastChangedDir_ = time; switch(direction_) { case right: setMove(left); break; case left: setMove(right); break; } } if (time - lastMovedDown_ >moveVertical_time_ ) { lastMovedDown_ = time; down_ = true; } sprite_.setPosition(position_); // TODO: add going down }
void KMovingConfig::defaults() { setMove(OPAQUE); setResizeOpaque(RESIZE_TRANSPARENT); setGeometryTip(false); setMoveResizeMaximized(false); //copied from kcontrol/konq/kwindesktop, aleXXX setWindowSnapZone(KWM_WNDW_SNAP_ZONE_DEFAULT); setBorderSnapZone(KWM_BRDR_SNAP_ZONE_DEFAULT); setCenterSnapZone(KWM_CNTR_SNAP_ZONE_DEFAULT); OverlapSnap->setChecked(false); emit KCModule::changed(true); }
void multiPlayer() { do { system("CLS"); gameName(); draw(); setMove(getMove()); checkWin(); checkBoard(); }while(gameFinished!=true); printBoard(); system("PAUSE"); resetBoard(); }
bool PowerPlantTower::init() { if (!Sprite::init()) //如果忘记了这句话则会在runApplication报错 { return false; } setTowerType(5); setIsSelected(false); setGrade(0);//开始没有等级 setPower(0);//塔消耗电力 setMove(false);//开始不处于移动状态 setIsPowerEnough(true);//开始状态电力足够 setIsPowerConsumption(false);//该塔不耗电 setTowerSize(Size(3, 3));//占地面积3*3 towerSprite = Sprite::create("towerItem/Item6.png"); towerSprite->setScale(0.4); addChild(towerSprite, 5); //血量条背景图片 towerHpSprite = Sprite::create("manaBarBg.png"); towerHpSprite->setPosition(towerSprite->getPosition()+Point(0,50)); towerHpSprite->setScale(0.3); addChild(towerHpSprite, 10); //炮塔血量 hp = 4; //炮塔血量进度条 towerHp = ProgressTimer::create(Sprite::create("soldierProduceTimeBar.png")); //参数是一个图片sprite towerHp->setScaleX(2); towerHp->setScaleY(5.2); towerHp->setType(ProgressTimer::Type::BAR); towerHp->setMidpoint(Point(0, 0.5f)); towerHp->setBarChangeRate(Point(1, 0)); towerHp->setPercentage(100); towerHp->setPosition(Point(towerHpSprite->getContentSize().width / 2, towerHpSprite->getContentSize().height / 3 * 2 - 10)); towerHpSprite->addChild(towerHp, 5); //初始化不可见 towerHp->setVisible(false); towerHpSprite->setVisible(false); addTouch();//添加触摸事件 return true; }
void PokeEdit::moveEntered(const QModelIndex &index) { int num = index.data(CustomModel::MovenumRole).toInt(); if (num == Move::SecretSword && poke().num() == Pokemon::Keldeo && PokemonInfo::Released(Pokemon::Keldeo_R, poke().gen())) { setNum(Pokemon::Keldeo_R); return; } for (int i = 0; i < 4; i++) { if (poke().move(i) == Move::NoMove) { setMove(i, num); return; } } QMessageBox::information(NULL, tr("Impossible to add move"), tr("No more free moves!")); }
void singlePlayer() { do { system("CLS"); gameName(); draw(); if(player==1) {setRmove(getRmove());} else {setMove(getMove());} checkWin(); checkBoard(); }while(gameFinished!=true); printBoard(); system("PAUSE"); resetBoard(); }
void xQGanttBarViewPort::setMode(int mode) ///////////////////////////// { if(_mode == (Mode) mode) { return; } switch(_mode) { case Select: setSelect(); break; case Zoom: setZoom(); break; case Move: setMove(); break; default: setCursor(arrowCursor); setMouseTracking(false); break; } emit modeChanged(_mode); }
bool ForetellingTower::init() { if (!Sprite::init()) //如果忘记了这句话则会在runApplication报错 { return false; } setTowerType(6); setIsSelected(false); setGrade(0);//开始没有等级 setPower(60);//塔消耗电力 setMove(false);//开始不处于移动状态 setIsPowerEnough(true);//开始状态电力足够 setIsPowerConsumption(false);//该塔不耗电 setTowerSize(Size(3, 3));//占地面积3*3 towerSprite = Sprite::create("towerItem/Item7.png"); towerSprite->setScale(0.4); addChild(towerSprite, 5); addTouch();//添加触摸事件 return true; }
bool ArtilleryTower::init() { if (!Sprite::init()) //如果忘记了这句话则会在runApplication报错 { return false; } setScope(300); setAttack(2); setRate(2); setIsSelected(false); setTowerType(1); setGrade(0);//开始没有等级 setPower(0);//塔消耗电力 setMove(false);//开始不处于移动状态 setIsPowerEnough(true);//开始状态电力足够 setIsPowerConsumption(false);//该塔耗电 basePlate = Sprite::createWithSpriteFrameName("fort1.png"); //塔的基座 addChild(basePlate,2); //log("111111111111111"); rotateArtillery = Sprite::createWithSpriteFrameName("fort2.png"); //塔的弓箭 rotateArtillery->setPosition(0, 0); rotateArtillery->setRotation(270); addChild(rotateArtillery,3); //这个不能少,虽然不显示,这是因为这个炮塔比较特殊,是由2个sprite拼接而成的 towerSprite = Sprite::create("towerItem/Item2.png"); addChild(towerSprite); towerSprite->setVisible(false); gradeSprite = Sprite::create("level1.png"); gradeSprite->setScale(2); gradeSprite->setAnchorPoint(Point(0, 0)); gradeSprite->setPosition(this->getPosition().x + 60, -towerSprite->getBoundingBox().size.height / 2-10); gradeSprite->setOpacity(0);//开始让其不可见 addChild(gradeSprite, 6); //沉默图片 noAttackSprite = Sprite::create("noSpeak.png"); noAttackSprite->setScale(0.9); noAttackSprite->setAnchorPoint(Point(0.5, 0)); noAttackSprite->setPosition(towerSprite->getBoundingBox().size.width / 2 - 70, towerSprite->getBoundingBox().size.height - 60); addChild(noAttackSprite, 8); noAttackSprite->setVisible(false); //血量条背景图片 towerHpSprite = Sprite::create("manaBarBg.png"); towerHpSprite->setPosition(towerSprite->getPosition() + Point(0, 100)); towerHpSprite->setScale(0.8); addChild(towerHpSprite, 10); //炮塔血量 hp = 2; maxHp = 2; //炮塔血量进度条 towerHp = ProgressTimer::create(Sprite::create("soldierProduceTimeBar.png")); //参数是一个图片sprite towerHp->setScaleX(2); towerHp->setScaleY(5.2); towerHp->setType(ProgressTimer::Type::BAR); towerHp->setMidpoint(Point(0, 0.5f)); towerHp->setBarChangeRate(Point(1, 0)); towerHp->setPercentage(100); towerHp->setPosition(Point(towerHpSprite->getContentSize().width / 2, towerHpSprite->getContentSize().height / 3 * 2 - 10)); towerHpSprite->addChild(towerHp, 5); //初始化不可见 towerHp->setVisible(false); towerHpSprite->setVisible(false); schedule(schedule_selector(ArtilleryTower::rotateAndShoot), 0.5f); //别忘了调用函数,时间间隔越小,炮塔旋转越平滑 schedule(schedule_selector(ArtilleryTower::shoot), 2.5f); addTouch(); return true; }
void button_clicked2(GtkWidget *widget, struttura *str) { const gchar* buttonow=gtk_button_get_label(GTK_BUTTON(widget)); int keycode; if(strcmp(buttonow,"z")==0) { keycode = XK_z; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Control_R){ system("xdotool key ctrl+z"); } } } if(strcmp(buttonow,"r")==0) { keycode = XK_r; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Control_R){ system("xdotool key ctrl+r"); } } } if(strcmp(buttonow,"x")==0) { keycode = XK_x; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Control_R){ system("xdotool key ctrl+x"); } } } if(strcmp(buttonow,"c")==0) { keycode = XK_c; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Control_R){ system("xdotool key ctrl+c"); } } } if(strcmp(buttonow,"v")==0) { keycode = XK_v; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Control_R){ system("xdotool key ctrl+v"); } } } if(strcmp(buttonow,"+")==0) { keycode = XK_plus; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Control_R){ system("xdotool key ctrl+plus"); } } } if(strcmp(buttonow,"-")==0) { keycode = XK_minus; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Control_R){ system("xdotool key ctrl+minus"); } } } if(strcmp(buttonow,"f")==0) { keycode = XK_f; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Control_R){ system("xdotool key ctrl+f"); } if(modifier==XK_Alt_L){ system("xdotool key alt+f"); } } } if(strcmp(buttonow,"a")==0) { keycode = XK_a; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Control_R){ system("xdotool key ctrl+a"); } } } if(strcmp(buttonow,"m")==0) { keycode = XK_m; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Alt_L){ system("xdotool key alt+m"); } } } if(strcmp(buttonow,"f1")==0) { keycode = XK_F1; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Alt_L){ system("xdotool key alt+F1"); } } } if(strcmp(buttonow,"f2")==0) { keycode = XK_F2; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Alt_L){ system("xdotool key alt+F2"); } } } if(strcmp(buttonow,"f3")==0) { keycode = XK_F3; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Alt_L){ system("xdotool key alt+F3"); } } } if(strcmp(buttonow,"f4")==0) { keycode = XK_F4; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Alt_L){ system("xdotool key alt+F4"); } } } if(strcmp(buttonow,"f5")==0) { keycode = XK_F5; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Alt_L){ system("xdotool key alt+F5"); } } } if(strcmp(buttonow,"f9")==0) { keycode = XK_F9; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Alt_L){ system("xdotool key alt+F9"); } } } if(strcmp(buttonow,"f10")==0) { keycode = XK_F10; if(modifier==0){ printOnFocus(str,keycode,0); } else{ if(modifier==XK_Alt_L){ system("xdotool key alt+F10"); } } } if(strcmp(buttonow,"ctrl")==0) { if(modifier==XK_Control_R){ modifier=0; gtk_container_remove(GTK_CONTAINER(box), mylabel); mylabel = gtk_label_new ("Ctrl and Alt off"); gtk_container_add(GTK_CONTAINER(box), mylabel); gtk_widget_show (mylabel); } else{ modifier=XK_Control_R; gtk_container_remove(GTK_CONTAINER(box), mylabel); mylabel = gtk_label_new (NULL); gtk_label_set_text (GTK_LABEL (mylabel),"activated Ctrl"); gtk_container_add(GTK_CONTAINER(box), mylabel); gtk_widget_show (mylabel); } gdk_window_process_all_updates(); } if(strcmp(buttonow,"alt")==0) { if(modifier==XK_Alt_L){ modifier=0; gtk_container_remove(GTK_CONTAINER(box), mylabel); mylabel = gtk_label_new ("Ctrl and Alt off"); gtk_container_add(GTK_CONTAINER(box), mylabel); gtk_widget_show (mylabel); } else{ modifier=XK_Alt_L; gtk_container_remove(GTK_CONTAINER(box), mylabel); mylabel = gtk_label_new (NULL); gtk_label_set_text (GTK_LABEL (mylabel),"activated Alt"); gtk_container_add(GTK_CONTAINER(box), mylabel); gtk_widget_show (mylabel); } gdk_window_process_all_updates(); } else if(strcmp(buttonow,"close")==0) gtk_main_quit(); else if(strcmp(buttonow,".")==0) { gtk_status_icon_set_visible(str->tray_icon, TRUE); gtk_widget_hide(window); } else if(strcmp(buttonow,"→")==0) movetoright(str,window); else if(strcmp(buttonow,"↓")==0) movetodown(str,window); else if(strcmp(buttonow,"nf")==0) { setMove(str,str->window); gtk_widget_show(str->window); gtk_widget_hide(window); } }
void movetoright(struttura *str,GtkWidget *win) { getMaxScreen(str); str->move.position_width=(str->move.position_width+str->move.delay_orizzontale+WINDOW_WIDTH>str->move.s_width)?0:str->move.position_width+str->move.delay_orizzontale; setMove(str,win); }
// --- void QGAMES::Background::initialize () { // The initial values... int fadeGrade = 255; bool autMove = false; QGAMES::Vector movDirection (__BD 1, __BD 0, __BD 0); int speed = 0, pixels = 0; QGAMES::Background* linkedBackground = NULL; int linkedSpeed = 0; bool roll = false; bool fix = false; // Has the fasdegrade property been defined? if (existObjProperty (_FADEGRADEPROPERTY)) fadeGrade = std::stoi (objectProperty (_FADEGRADEPROPERTY)); // Has the automatic movement property been defined? if (existObjProperty (_AUTOMATICMOVEPROPERTY)) autMove = (objectProperty (_AUTOMATICMOVEPROPERTY) == std::string (__YES_STRING__)) ? true : false ; // Has the movement direction property been defined? if (existObjProperty (_MOVDIRECTIONPROPERTY)) { std::vector <int> cV; std::string m = objectProperty (_MOVDIRECTIONPROPERTY); while (m != std::string (__NULL_STRING__)) { int cP = m.find_first_of (','); // The vector dta is separated by comma! if (cP != -1) { cV.push_back (std::stoi (m.substr (0, cP))); m = (cP != m.length () - 1) ? m.substr (cP + 1) : std::string (__NULL_STRING__); } else { cV.push_back (std::stoi (m)); m = std::string (__NULL_STRING__); } } movDirection = QGAMES::Vector ((cV.size () > 0) ? __BD cV [0] : __BD 0, (cV.size () > 1) ? __BD cV [1] : __BD 0, (cV.size () > 2) ? __BD cV [2] : __BD 0); } // Has the speed property been defined? if (existObjProperty (_SPEEDPROPERTY)) speed = std::stoi (objectProperty (_SPEEDPROPERTY)); // Has the pixels property been defined? if (existObjProperty (_PIXELSPROPERTY)) pixels = std::stoi (objectProperty (_PIXELSPROPERTY)); // Has the background linked been defined? if (existObjProperty (_LINKEDBKPROPERTY)) { assert (game ()); // The game has to have been defined... linkedBackground = (QGAMES::Background*) game () -> objectBuilder () -> object (std::stoi (objectProperty (_LINKEDBKPROPERTY))); linkedBackground -> initialize (); } // Has the speed of the background linked been defined? if (existObjProperty (_SPEEDLINKEDBKPROPERTY)) linkedSpeed = std::stoi (objectProperty (_SPEEDLINKEDBKPROPERTY)); // Has to roll? if (existObjProperty (_ROLLPROPERTY)) roll = (objectProperty (_ROLLPROPERTY) == std::string (__YES_STRING__)) ? true : false ; // The position is fixed? if (existObjProperty (_FIXPOSITIONPROPERTY)) fix = (objectProperty (_FIXPOSITIONPROPERTY) == std::string (__YES_STRING__)) ? true : false ; // The background is a mandatory attribute... // Sets the fadegrade setFade (fadeGrade); // Sets the movement setMove (autMove, movDirection); // Sets the movement data setMovementData (speed, pixels); // Sets the linked background if any... setLinkedBackground (linkedSpeed, linkedBackground); // Sets whether it rolls or not! setRoll (roll); // Sets whether the position is or not fix... setFixPosition (fix); // Restats the counters... reStartAllCounters (); // Initially the position of the background is to 0... setPosition (QGAMES::Position::_cero); }
void PokePersonal::runCheck() { if (!PokemonInfo::Exists(num(), gen())) { reset(); return; } if (!PokemonInfo::AFormesShown(num())) { num() = num().original(); } if (gen() <= 2) { ability() = 0; nature() = 0; } else { AbilityGroup ab = PokemonInfo::Abilities(num(), gen()); if (ability() == 0 || (ability() != ab.ab(2) && ability() != ab.ab(1))) ability() = ab.ab(0); } if (gen().num == 2) controlGender(); if (!ItemInfo::Exists(item(), gen())) { item() = 0; } for (int i = 0; i < 6; i++) controlEVs(i); if (gen() <= 2) { for (int i = 0; i < 6; i++) { if (DV(i) >= 15) setDV(i, 15); } } if (gen().num == 2) { setEV(SpDefense, EV(SpAttack)); setDV(SpDefense, DV(SpAttack)); } int avail = PokemonInfo::Gender(num()); if (avail != Pokemon::MaleAndFemaleAvail) { gender() = avail; } else if (gender() == Pokemon::Neutral){ gender() = Pokemon::Male; } int minLevel = PokemonInfo::AbsoluteMinLevel(num(), gen()); if (MoveSetChecker::enforceMinLevels && level() < minLevel) { level() = minLevel; } QSet<int> invalidMoves; MoveSetChecker::isValid(num(), gen(), move(0), move(1), move(2), move(3), ability(), gender(), level(), false, &invalidMoves); while (invalidMoves.size() > 0) { for (int i = 0; i < 4; i++) { if (invalidMoves.contains(move(i))) { setMove(0, i, false); } } invalidMoves.clear(); MoveSetChecker::isValid(num(), gen(), move(0), move(1), move(2), move(3), ability(), gender(), level(), false, &invalidMoves); } if (num().pokenum == Pokemon::Keldeo) { if (move(0) == Move::SecretSword || move(1) == Move::SecretSword || move(2) == Move::SecretSword || move(3) == Move::SecretSword) { num() = Pokemon::Keldeo_R; } else { num() = num().original(); } } }
void PokeTeam::loadFromXml(const QDomElement &poke, int version) { if (poke.hasAttribute("Gen")) { setGen(Pokemon::gen(poke.attribute("Gen", QString::number(GenInfo::GenMax())).toInt(), poke.attribute("SubGen", QString::number(GenInfo::NumberOfSubgens(poke.attribute("Gen", QString::number(GenInfo::GenMax())).toInt())-1)).toInt())); } reset(); /* Code to import old teams which had different formes registered as different pokemon numbers */ int num = poke.attribute("Num").toInt(); int forme = poke.attribute("Forme").toInt(); if (gen().num == 4 && num > 493 && forme == 0 && !PokemonInfo::Exists(Pokemon::uniqueId(num, 0), 4)) { //Old way int indexes[] = { 479,479,479,479,479,386,386,386,413,413,492,487 }; int formes[] = { 1,2,3,4,5,1,2,3,1,2,1,1 }; int i = num - 494; setNum(Pokemon::uniqueId(indexes[i], formes[i])); } else { setNum(Pokemon::uniqueId(num, forme)); } bool outdated = gen() < 5 && version < 1; load(); nickname() = poke.attribute("Nickname"); item() = poke.attribute("Item").toInt(); ability() = poke.attribute("Ability").toInt(); if (outdated) { ability() = AbilityInfo::ConvertFromOldAbility(ability()); } nature() = poke.attribute("Nature").toInt(); gender() = poke.attribute("Gender").toInt(); shiny() = QVariant(poke.attribute("Shiny")).toBool(); happiness() = poke.attribute("Happiness").toInt(); level() = poke.attribute("Lvl").toInt(); int cptMove=0; QDomElement moveElement = poke.firstChildElement("Move"); while(!moveElement.isNull()) { int movenum = moveElement.text().toInt(); if (outdated) { movenum = MoveInfo::ConvertFromOldMove(movenum); } setMove(movenum,cptMove,false); cptMove++; moveElement = moveElement.nextSiblingElement("Move"); } int cptDV=0; QDomElement DVElement = poke.firstChildElement("DV"); while(!DVElement.isNull()) { setDV(outdated ? NatureInfo::ConvertToStat(cptDV) : cptDV,DVElement.text().toInt()); cptDV++; DVElement = DVElement.nextSiblingElement("DV"); } int cptEV=0; QDomElement EVElement = poke.firstChildElement("EV"); while(!EVElement.isNull()) { setEV(outdated ? NatureInfo::ConvertToStat(cptEV) : cptEV,EVElement.text().toInt()); cptEV++; EVElement = EVElement.nextSiblingElement("EV"); } }