F2- gt; amount lt; 10) exit (0);
} if (PF1- gt; amount lt; 10) exit (0); sres=QMessageBox :: warning (this, Увага! raquo ;, tr ( Зберегти гру перед виходом? raquo ;), QMessageBox :: Yes, QMessageBox :: No); (sres == QMessageBox :: Yes)
{(PF1- gt; K lt; 20)
{(); (0);
} exit (0); (gMode!=1) (PF2- gt; K lt; 20)
{(); (0);
} if (EF- gt; K lt; 20)
{(); (0);
} exit (0);
} (sres == QMessageBox :: No) exit (0);
}
}
MainWindow :: about ()
{str; = Laquo; Гра Морський бій nВерсія 1.0 nІгра розроблена студенткою групи З - 8 001 Поспєлова І.В. raquo ;;
QMessageBox :: information (NULL, tr ( Про програму ), str);
}
MainWindow :: help ()
{hFile; str, path;=QApplication :: applicationDirPath () + /help.txtraquo ;;
. setFileName (path) ;. open (QIODevice :: ReadOnly); (! hFileEnd ())=hFile.readAll () ;. close ();
:: information (NULL, tr ( Як грати ), str);
} :: ~ MainWindow ()
{
}
Файл playerfield.h
# ifndef PLAYERFIELD_H
# define PLAYERFIELD_H
# include lt; QApplication gt;
# include field.h
# include battleship.h
# include cruiser.h
# include destroyer.h
# include boat.h
PlayerField: public Field
{_ OBJECT: ();
~ PlayerField (); blackout (QColor bColor, QColor lColor, QColor hitColor);// закриває вороже поле
void calcPos (int x, int y);// зіставляє позицію натискання ЛФМ з player [] []
void mousePressEvent (QMouseEvent * event);// мишьdeleteDeck ();// видаляє виділену палубу
: comp (); slots: four (); three (); two (); one (); compFire (); randCalc ();
: checkAround (int x, int y);
};
# endif//PLAYERFIELD_H
Файл playerfield.cpp
# include playerfield.h
:: PlayerField ()
{ gt; setScene ( amp; scene);
}
PlayerField :: blackout (QColor bColor, QColor lColor, QColor hitColor)
{i, j; (bColor, lColor);
(i=0; i lt; sizeField; i ++) (j=0; j lt; sizeField; j ++)
{(player [i] [j] == 0 amp; amp; player [i] [j] == - 1) .addRect ((j + 1) * sizeDeck, (i + 1 ) * sizeDeck, sizeDeck, sizeDeck, QPen (lColor), QBrush (bColor)); if (player [i] [j] == 2) past (lColor, i + 1, j + 1); if (player [i ] [j] == 1) wound (i + 1, j + 1, lColor, hitColor);
}
}
PlayerField :: mousePressEvent (QMouseEvent * event)
{x, y;=event- gt; pos (). x () - 30;=event- gt; pos (). y () - 20; (x, y);
(event- gt; button () == Qt :: LeftButton)
{
(x gt;=30 amp; amp; x lt;=330 amp; amp; y gt;=30 amp; amp; y lt;=330)
{(size gt; 0) selectShip (flag, t, size); if (amount!=10) :: warning (NULL, Warring raquo ;, tr ( Виберіть тип корабля! raquo ;)); emit startFight ();
}
} if (event- gt; button () == Qt :: RightButton)
{();
}
}
PlayerField :: calcPos (int x, int y)
{(x gt;=30 amp; amp; x lt;=330 amp; amp; y gt;=30 amp; amp; y lt;=330)
{= x/30;=y/30;
}
}
PlayerField :: randCalc ()
{= (rand ()% 10 + 0) +1;=(rand ()% 10 + 0) +1;
}
PlayerField :: deleteDeck ()
{i, j, f;=0;=iShip - 1;=jShip - 1;
(player [i] [j] == size)
{(player [i - 1] [j] == size)
{((player [i] [j - 1] == size) || (player [i] [j + 1] == size) || (player [i + 1] [ j]) == size)
{= 1;...